Cleanup: GPUTexture header / API #105197
|
@ -241,7 +241,7 @@ static GPUTexture *gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf)
|
|||
}
|
||||
|
||||
if (GPU_mipmap_enabled()) {
|
||||
GPU_texture_generate_mipmap(tex);
|
||||
GPU_texture_update_mipmap_chain(tex);
|
||||
GPU_texture_mipmap_mode(tex, true, true);
|
||||
if (ima) {
|
||||
ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
|
||||
|
@ -423,7 +423,7 @@ static GPUTexture *image_get_gpu_texture(Image *ima,
|
|||
GPU_texture_wrap_mode(*tex, true, false);
|
||||
|
||||
if (GPU_mipmap_enabled()) {
|
||||
GPU_texture_generate_mipmap(*tex);
|
||||
GPU_texture_update_mipmap_chain(*tex);
|
||||
if (ima) {
|
||||
ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ static GPUTexture *image_get_gpu_texture(Image *ima,
|
|||
}
|
||||
|
||||
if (*tex) {
|
||||
GPU_texture_orig_size_set(*tex, ibuf_intern->x, ibuf_intern->y);
|
||||
GPU_texture_original_size_set(*tex, ibuf_intern->x, ibuf_intern->y);
|
||||
}
|
||||
|
||||
if (ibuf != ibuf_intern) {
|
||||
|
@ -820,7 +820,7 @@ static void gpu_texture_update_from_ibuf(
|
|||
}
|
||||
|
||||
if (GPU_mipmap_enabled()) {
|
||||
GPU_texture_generate_mipmap(tex);
|
||||
GPU_texture_update_mipmap_chain(tex);
|
||||
}
|
||||
else {
|
||||
ima->gpuflag &= ~IMA_GPU_MIPMAP_COMPLETE;
|
||||
|
|
|
@ -382,8 +382,8 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob)
|
|||
camera_background_images_stereo_setup(draw_ctx->scene, draw_ctx->v3d, ima, &iuser);
|
||||
tex = BKE_image_get_gpu_texture(ima, &iuser, nullptr);
|
||||
if (tex) {
|
||||
size[0] = GPU_texture_orig_width(tex);
|
||||
size[1] = GPU_texture_orig_height(tex);
|
||||
size[0] = GPU_texture_original_width(tex);
|
||||
size[1] = GPU_texture_original_height(tex);
|
||||
}
|
||||
}
|
||||
CLAMP_MIN(size[0], 1);
|
||||
|
|
|
@ -775,27 +775,27 @@ class Texture : NonCopyable {
|
|||
|
||||
bool depth() const
|
||||
{
|
||||
return GPU_texture_depth(tx_);
|
||||
return GPU_texture_has_depth_format(tx_);
|
||||
}
|
||||
|
||||
bool is_stencil() const
|
||||
{
|
||||
return GPU_texture_stencil(tx_);
|
||||
return GPU_texture_has_stencil_format(tx_);
|
||||
}
|
||||
|
||||
bool is_integer() const
|
||||
{
|
||||
return GPU_texture_integer(tx_);
|
||||
return GPU_texture_has_integer_format(tx_);
|
||||
}
|
||||
|
||||
bool is_cube() const
|
||||
{
|
||||
return GPU_texture_cube(tx_);
|
||||
return GPU_texture_is_cube(tx_);
|
||||
}
|
||||
|
||||
bool is_array() const
|
||||
{
|
||||
return GPU_texture_array(tx_);
|
||||
return GPU_texture_is_array(tx_);
|
||||
}
|
||||
|
||||
int3 size(int miplvl = 0) const
|
||||
|
@ -886,7 +886,7 @@ class Texture : NonCopyable {
|
|||
int3 size(0);
|
||||
GPU_texture_get_mipmap_size(tx_, 0, size);
|
||||
if (size != int3(w, h, d) || GPU_texture_format(tx_) != format ||
|
||||
GPU_texture_cube(tx_) != cubemap || GPU_texture_array(tx_) != layered) {
|
||||
GPU_texture_is_cube(tx_) != cubemap || GPU_texture_is_array(tx_) != layered) {
|
||||
free();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ void drw_texture_set_parameters(GPUTexture *tex, DRWTextureFlag flags)
|
|||
|
||||
if (flags & DRW_TEX_MIPMAP) {
|
||||
GPU_texture_mipmap_mode(tex, true, flags & DRW_TEX_FILTER);
|
||||
GPU_texture_generate_mipmap(tex);
|
||||
GPU_texture_update_mipmap_chain(tex);
|
||||
}
|
||||
else {
|
||||
GPU_texture_filter_mode(tex, flags & DRW_TEX_FILTER);
|
||||
|
@ -260,7 +260,7 @@ void DRW_texture_ensure_2d(
|
|||
|
||||
void DRW_texture_generate_mipmaps(GPUTexture *tex)
|
||||
{
|
||||
GPU_texture_generate_mipmap(tex);
|
||||
GPU_texture_update_mipmap_chain(tex);
|
||||
}
|
||||
|
||||
void DRW_texture_free(GPUTexture *tex)
|
||||
|
|
|
@ -102,7 +102,8 @@ GPUTexture *DRW_texture_pool_query(DRWTexturePool *pool,
|
|||
pool->handles.append(handle);
|
||||
/* Doing filtering for depth does not make sense when not doing shadow mapping,
|
||||
* and enabling texture filtering on integer texture make them unreadable. */
|
||||
bool do_filter = !GPU_texture_depth(handle.texture) && !GPU_texture_integer(handle.texture);
|
||||
bool do_filter = !GPU_texture_has_depth_format(handle.texture) &&
|
||||
!GPU_texture_has_integer_format(handle.texture);
|
||||
GPU_texture_filter_mode(handle.texture, do_filter);
|
||||
|
||||
return handle.texture;
|
||||
|
|
|
@ -89,7 +89,7 @@ void immDrawPixelsTexScaledFullSize(const IMMDrawPixelsTexState *state,
|
|||
|
||||
GPU_texture_filter_mode(tex, use_filter);
|
||||
if (use_mipmap) {
|
||||
GPU_texture_generate_mipmap(tex);
|
||||
GPU_texture_update_mipmap_chain(tex);
|
||||
GPU_texture_mipmap_mode(tex, true, true);
|
||||
}
|
||||
GPU_texture_wrap_mode(tex, false, true);
|
||||
|
|
|
@ -1223,7 +1223,7 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i
|
|||
|
||||
eGPUTextureFormat texture_format = IMB_gpu_get_texture_format(
|
||||
ibuf, ima->flag & IMA_HIGH_BITDEPTH, ibuf->planes >= 8);
|
||||
const char *texture_format_description = GPU_texture_format_description(texture_format);
|
||||
const char *texture_format_description = GPU_texture_format_name(texture_format);
|
||||
ofs += BLI_snprintf_rlen(str + ofs, len - ofs, TIP_(", %s"), texture_format_description);
|
||||
|
||||
uiItemL(col, str, ICON_NONE);
|
||||
|
|
|
@ -479,7 +479,7 @@ void GPU_unpack_row_length_set(uint len);
|
|||
* texture storage.
|
||||
* The \a data should be be the size of the entire mip 0 level.
|
||||
* \note This function only update the content of mip 0. Either specify other mips or use
|
||||
* `GPU_texture_generate_mipmap` to generate them if needed.
|
||||
* `GPU_texture_update_mipmap_chain` to generate them if needed.
|
||||
*/
|
||||
void GPU_texture_update(GPUTexture *texture, eGPUDataFormat data_format, const void *data);
|
||||
|
||||
|
@ -489,7 +489,7 @@ void GPU_texture_update(GPUTexture *texture, eGPUDataFormat data_format, const v
|
|||
* texture storage.
|
||||
* The \a data should be be the size of the mip 0 level region.
|
||||
* \note This function only update the content of mip 0. Either specify other mips or use
|
||||
* `GPU_texture_generate_mipmap` to generate them if needed.
|
||||
* `GPU_texture_update_mipmap_chain` to generate them if needed.
|
||||
*
|
||||
* \a offset_x , \a offset_y , \a offset_z specify the bottom left corner of the updated region.
|
||||
* \a width , \a height , \a depth specify the extent of the updated region.
|
||||
|
@ -535,7 +535,7 @@ void GPU_texture_copy(GPUTexture *dst, GPUTexture *src);
|
|||
* Update the mip-map levels using the mip 0 data.
|
||||
* \note this doesn't work on depth or compressed textures.
|
||||
*/
|
||||
void GPU_texture_generate_mipmap(GPUTexture *texture);
|
||||
void GPU_texture_update_mipmap_chain(GPUTexture *texture);
|
||||
|
||||
/**
|
||||
* Read the content of a \a mip_level from a \a tex and returns a copy of its data.
|
||||
|
@ -703,27 +703,27 @@ eGPUTextureUsage GPU_texture_usage(const GPUTexture *texture);
|
|||
/**
|
||||
* Return true if the texture is an array texture type (has layers).
|
||||
*/
|
||||
bool GPU_texture_array(const GPUTexture *texture);
|
||||
bool GPU_texture_is_array(const GPUTexture *texture);
|
||||
|
||||
/**
|
||||
* Return true if the texture is an cube-map texture type.
|
||||
*/
|
||||
bool GPU_texture_cube(const GPUTexture *texture);
|
||||
bool GPU_texture_is_cube(const GPUTexture *texture);
|
||||
|
||||
/**
|
||||
* Return true if the texture format has a depth component.
|
||||
*/
|
||||
bool GPU_texture_depth(const GPUTexture *texture);
|
||||
bool GPU_texture_has_depth_format(const GPUTexture *texture);
|
||||
|
||||
/**
|
||||
* Return true if the texture format has a stencil component.
|
||||
*/
|
||||
bool GPU_texture_stencil(const GPUTexture *texture);
|
||||
bool GPU_texture_has_stencil_format(const GPUTexture *texture);
|
||||
|
||||
/**
|
||||
* Return true if the texture format is an integer type (non-normalized integers).
|
||||
*/
|
||||
bool GPU_texture_integer(const GPUTexture *texture);
|
||||
bool GPU_texture_has_integer_format(const GPUTexture *texture);
|
||||
|
||||
/**
|
||||
* Returns the pixel dimensions of a texture's mip-map level.
|
||||
|
@ -746,9 +746,9 @@ void GPU_texture_get_mipmap_size(GPUTexture *texture, int mip_level, int *size);
|
|||
* WORKAROUND: Calling 'BKE_image_get_size' may free the texture. Store the source image size
|
||||
* (before down-scaling) inside the #GPUTexture to retrieve the original size later (Ref #59347).
|
||||
*/
|
||||
int GPU_texture_orig_width(const GPUTexture *texture);
|
||||
int GPU_texture_orig_height(const GPUTexture *texture);
|
||||
void GPU_texture_orig_size_set(GPUTexture *texture, int width, int height);
|
||||
int GPU_texture_original_width(const GPUTexture *texture);
|
||||
int GPU_texture_original_height(const GPUTexture *texture);
|
||||
void GPU_texture_original_size_set(GPUTexture *texture, int width, int height);
|
||||
|
||||
/**
|
||||
* Reference of a pointer that needs to be cleaned when deallocating the texture.
|
||||
|
@ -786,7 +786,7 @@ size_t GPU_texture_dataformat_size(eGPUDataFormat data_format);
|
|||
* Return the texture format as a string for display purpose.
|
||||
* Example: `GPU_RGBA8` returns as `"RGBA8"`.
|
||||
*/
|
||||
const char *GPU_texture_format_description(eGPUTextureFormat format);
|
||||
const char *GPU_texture_format_name(eGPUTextureFormat format);
|
||||
|
||||
/**
|
||||
* Returns the memory usage of all currently allocated textures in bytes.
|
||||
|
|
|
@ -83,12 +83,13 @@ void FrameBuffer::attachment_set(GPUAttachmentType type, const GPUAttachment &ne
|
|||
|
||||
if (new_attachment.tex) {
|
||||
if (new_attachment.layer > 0) {
|
||||
BLI_assert(GPU_texture_cube(new_attachment.tex) || GPU_texture_array(new_attachment.tex));
|
||||
BLI_assert(GPU_texture_is_cube(new_attachment.tex) ||
|
||||
GPU_texture_is_array(new_attachment.tex));
|
||||
}
|
||||
if (GPU_texture_stencil(new_attachment.tex)) {
|
||||
if (GPU_texture_has_stencil_format(new_attachment.tex)) {
|
||||
BLI_assert(ELEM(type, GPU_FB_DEPTH_STENCIL_ATTACHMENT));
|
||||
}
|
||||
else if (GPU_texture_depth(new_attachment.tex)) {
|
||||
else if (GPU_texture_has_depth_format(new_attachment.tex)) {
|
||||
BLI_assert(ELEM(type, GPU_FB_DEPTH_ATTACHMENT));
|
||||
}
|
||||
}
|
||||
|
@ -360,7 +361,7 @@ void GPU_framebuffer_config_array(GPUFrameBuffer *gpu_fb,
|
|||
fb->attachment_set(GPU_FB_DEPTH_ATTACHMENT, depth_attachment);
|
||||
}
|
||||
else {
|
||||
GPUAttachmentType type = GPU_texture_stencil(depth_attachment.tex) ?
|
||||
GPUAttachmentType type = GPU_texture_has_stencil_format(depth_attachment.tex) ?
|
||||
GPU_FB_DEPTH_STENCIL_ATTACHMENT :
|
||||
GPU_FB_DEPTH_ATTACHMENT;
|
||||
fb->attachment_set(type, depth_attachment);
|
||||
|
@ -478,11 +479,12 @@ void GPU_framebuffer_blit(GPUFrameBuffer *gpufb_read,
|
|||
}
|
||||
|
||||
if (blit_buffers & GPU_DEPTH_BIT) {
|
||||
BLI_assert(GPU_texture_depth(read_tex) && GPU_texture_depth(write_tex));
|
||||
BLI_assert(GPU_texture_has_depth_format(read_tex) && GPU_texture_has_depth_format(write_tex));
|
||||
BLI_assert(GPU_texture_format(read_tex) == GPU_texture_format(write_tex));
|
||||
}
|
||||
if (blit_buffers & GPU_STENCIL_BIT) {
|
||||
BLI_assert(GPU_texture_stencil(read_tex) && GPU_texture_stencil(write_tex));
|
||||
BLI_assert(GPU_texture_has_stencil_format(read_tex) &&
|
||||
GPU_texture_has_stencil_format(write_tex));
|
||||
BLI_assert(GPU_texture_format(read_tex) == GPU_texture_format(write_tex));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -654,7 +654,7 @@ void GPU_texture_image_unbind_all()
|
|||
Context::get()->state_manager->image_unbind_all();
|
||||
}
|
||||
|
||||
void GPU_texture_generate_mipmap(GPUTexture *tex)
|
||||
void GPU_texture_update_mipmap_chain(GPUTexture *tex)
|
||||
{
|
||||
reinterpret_cast<Texture *>(tex)->generate_mipmap();
|
||||
}
|
||||
|
@ -716,7 +716,7 @@ void GPU_texture_swizzle_set(GPUTexture *tex, const char swizzle[4])
|
|||
|
||||
void GPU_texture_stencil_texture_mode_set(GPUTexture *tex, bool use_stencil)
|
||||
{
|
||||
BLI_assert(GPU_texture_stencil(tex) || !use_stencil);
|
||||
BLI_assert(GPU_texture_has_stencil_format(tex) || !use_stencil);
|
||||
reinterpret_cast<Texture *>(tex)->stencil_texture_mode_set(use_stencil);
|
||||
}
|
||||
|
||||
|
@ -778,17 +778,17 @@ int GPU_texture_mip_count(const GPUTexture *tex)
|
|||
return reinterpret_cast<const Texture *>(tex)->mip_count();
|
||||
}
|
||||
|
||||
int GPU_texture_orig_width(const GPUTexture *tex)
|
||||
int GPU_texture_original_width(const GPUTexture *tex)
|
||||
{
|
||||
return reinterpret_cast<const Texture *>(tex)->src_w;
|
||||
}
|
||||
|
||||
int GPU_texture_orig_height(const GPUTexture *tex)
|
||||
int GPU_texture_original_height(const GPUTexture *tex)
|
||||
{
|
||||
return reinterpret_cast<const Texture *>(tex)->src_h;
|
||||
}
|
||||
|
||||
void GPU_texture_orig_size_set(GPUTexture *tex_, int w, int h)
|
||||
void GPU_texture_original_size_set(GPUTexture *tex_, int w, int h)
|
||||
{
|
||||
Texture *tex = reinterpret_cast<Texture *>(tex_);
|
||||
tex->src_w = w;
|
||||
|
@ -800,7 +800,7 @@ eGPUTextureFormat GPU_texture_format(const GPUTexture *tex)
|
|||
return reinterpret_cast<const Texture *>(tex)->format_get();
|
||||
}
|
||||
|
||||
const char *GPU_texture_format_description(eGPUTextureFormat texture_format)
|
||||
const char *GPU_texture_format_name(eGPUTextureFormat texture_format)
|
||||
{
|
||||
switch (texture_format) {
|
||||
case GPU_RGBA8UI:
|
||||
|
@ -906,27 +906,27 @@ const char *GPU_texture_format_description(eGPUTextureFormat texture_format)
|
|||
return "";
|
||||
}
|
||||
|
||||
bool GPU_texture_depth(const GPUTexture *tex)
|
||||
bool GPU_texture_has_depth_format(const GPUTexture *tex)
|
||||
{
|
||||
return (reinterpret_cast<const Texture *>(tex)->format_flag_get() & GPU_FORMAT_DEPTH) != 0;
|
||||
}
|
||||
|
||||
bool GPU_texture_stencil(const GPUTexture *tex)
|
||||
bool GPU_texture_has_stencil_format(const GPUTexture *tex)
|
||||
{
|
||||
return (reinterpret_cast<const Texture *>(tex)->format_flag_get() & GPU_FORMAT_STENCIL) != 0;
|
||||
}
|
||||
|
||||
bool GPU_texture_integer(const GPUTexture *tex)
|
||||
bool GPU_texture_has_integer_format(const GPUTexture *tex)
|
||||
{
|
||||
return (reinterpret_cast<const Texture *>(tex)->format_flag_get() & GPU_FORMAT_INTEGER) != 0;
|
||||
}
|
||||
|
||||
bool GPU_texture_cube(const GPUTexture *tex)
|
||||
bool GPU_texture_is_cube(const GPUTexture *tex)
|
||||
{
|
||||
return (reinterpret_cast<const Texture *>(tex)->type_get() & GPU_TEXTURE_CUBE) != 0;
|
||||
}
|
||||
|
||||
bool GPU_texture_array(const GPUTexture *tex)
|
||||
bool GPU_texture_is_array(const GPUTexture *tex)
|
||||
{
|
||||
return (reinterpret_cast<const Texture *>(tex)->type_get() & GPU_TEXTURE_ARRAY) != 0;
|
||||
}
|
||||
|
|
|
@ -162,7 +162,8 @@ void GLFrameBuffer::update_attachments()
|
|||
continue;
|
||||
}
|
||||
GLuint gl_tex = static_cast<GLTexture *>(unwrap(attach.tex))->tex_id_;
|
||||
if (attach.layer > -1 && GPU_texture_cube(attach.tex) && !GPU_texture_array(attach.tex)) {
|
||||
if (attach.layer > -1 && GPU_texture_is_cube(attach.tex) &&
|
||||
!GPU_texture_is_array(attach.tex)) {
|
||||
/* Could be avoided if ARB_direct_state_access is required. In this case
|
||||
* #glFramebufferTextureLayer would bind the correct face. */
|
||||
GLenum gl_target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + attach.layer;
|
||||
|
|
|
@ -297,7 +297,7 @@ static PyObject *pygpu_framebuffer__tp_new(PyTypeObject *UNUSED(self),
|
|||
if (!pygpu_framebuffer_new_parse_arg(depth_attachment, &config[0])) {
|
||||
return NULL;
|
||||
}
|
||||
if (config[0].tex && !GPU_texture_depth(config[0].tex)) {
|
||||
if (config[0].tex && !GPU_texture_has_depth_format(config[0].tex)) {
|
||||
PyErr_SetString(PyExc_ValueError, "Depth texture with incompatible format");
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue