From ab95cdaba970a30127d804bd1e66ad25ab021ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Sat, 5 Sep 2020 17:33:56 +0200 Subject: GPUTexture: Change texture creation API This is to modernize the API: - Add meaningful name to all textures (except DRW textures). - Remove unused err_out argument: only used for offscreen python. - Add mipmap count to creation functions for future changes. - Clarify the data usage in creation functions. This is a cleanup commit, there is no functional change. # Conflicts: # source/blender/gpu/GPU_texture.h --- source/blender/imbuf/intern/util_gpu.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'source/blender/imbuf/intern/util_gpu.c') diff --git a/source/blender/imbuf/intern/util_gpu.c b/source/blender/imbuf/intern/util_gpu.c index e538e8e1659..73532a1825e 100644 --- a/source/blender/imbuf/intern/util_gpu.c +++ b/source/blender/imbuf/intern/util_gpu.c @@ -159,7 +159,8 @@ static void *imb_gpu_get_data(const ImBuf *ibuf, /* The ibuf is only here to detect the storage type. The produced texture will have undefined * content. It will need to be populated by using IMB_update_gpu_texture_sub(). */ -GPUTexture *IMB_touch_gpu_texture(ImBuf *ibuf, int w, int h, int layers, bool use_high_bitdepth) +GPUTexture *IMB_touch_gpu_texture( + const char *name, ImBuf *ibuf, int w, int h, int layers, bool use_high_bitdepth) { eGPUDataFormat data_format; eGPUTextureFormat tex_format; @@ -167,10 +168,10 @@ GPUTexture *IMB_touch_gpu_texture(ImBuf *ibuf, int w, int h, int layers, bool us GPUTexture *tex; if (layers > 0) { - tex = GPU_texture_create_2d_array(w, h, layers, tex_format, NULL, NULL); + tex = GPU_texture_create_2d_array(name, w, h, layers, 1, tex_format, NULL); } else { - tex = GPU_texture_create_2d(w, h, tex_format, NULL, NULL); + tex = GPU_texture_create_2d(name, w, h, 9999, tex_format, NULL); } GPU_texture_anisotropic_filter(tex, true); @@ -210,7 +211,10 @@ void IMB_update_gpu_texture_sub(GPUTexture *tex, } } -GPUTexture *IMB_create_gpu_texture(ImBuf *ibuf, bool use_high_bitdepth, bool use_premult) +GPUTexture *IMB_create_gpu_texture(const char *name, + ImBuf *ibuf, + bool use_high_bitdepth, + bool use_premult) { GPUTexture *tex = NULL; const int size[2] = {GPU_texture_size_with_limit(ibuf->x), GPU_texture_size_with_limit(ibuf->y)}; @@ -229,8 +233,12 @@ GPUTexture *IMB_create_gpu_texture(ImBuf *ibuf, bool use_high_bitdepth, bool use fprintf(stderr, "Unable to load non-power-of-two DXT image resolution,"); } else { - tex = GPU_texture_create_compressed( - ibuf->x, ibuf->y, ibuf->dds_data.nummipmaps, compressed_format, ibuf->dds_data.data); + tex = GPU_texture_create_compressed_2d(name, + ibuf->x, + ibuf->y, + ibuf->dds_data.nummipmaps, + compressed_format, + ibuf->dds_data.data); if (tex != NULL) { return tex; @@ -253,7 +261,7 @@ GPUTexture *IMB_create_gpu_texture(ImBuf *ibuf, bool use_high_bitdepth, bool use void *data = imb_gpu_get_data(ibuf, do_rescale, size, compress_as_srgb, use_premult, &freebuf); /* Create Texture. */ - tex = GPU_texture_create_2d(UNPACK2(size), tex_format, NULL, NULL); + tex = GPU_texture_create_2d(name, UNPACK2(size), 9999, tex_format, NULL); GPU_texture_update(tex, data_format, data); GPU_texture_anisotropic_filter(tex, true); -- cgit v1.2.3