Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2020-09-05 18:33:56 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-09-05 18:49:14 +0300
commitab95cdaba970a30127d804bd1e66ad25ab021ec1 (patch)
treed0da883e11f81253cb7b3e5a75288ca69598e437 /source/blender/imbuf/intern/util_gpu.c
parentbac4606937514405641659d91a30bf3e6832cdf7 (diff)
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
Diffstat (limited to 'source/blender/imbuf/intern/util_gpu.c')
-rw-r--r--source/blender/imbuf/intern/util_gpu.c22
1 files changed, 15 insertions, 7 deletions
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);