[Bf-blender-cvs] [ab95cdaba97] master: GPUTexture: Change texture creation API
Clément Foucault
noreply at git.blender.org
Sat Sep 5 17:50:09 CEST 2020
Commit: ab95cdaba970a30127d804bd1e66ad25ab021ec1
Author: Clément Foucault
Date: Sat Sep 5 17:33:56 2020 +0200
Branches: master
https://developer.blender.org/rBab95cdaba970a30127d804bd1e66ad25ab021ec1
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
===================================================================
M intern/opencolorio/ocio_impl_glsl.cc
M source/blender/blenfont/intern/blf_glyph.c
M source/blender/blenkernel/intern/image_gpu.c
M source/blender/blenkernel/intern/movieclip.c
M source/blender/blenkernel/intern/studiolight.c
M source/blender/draw/engines/eevee/eevee_lightcache.c
M source/blender/draw/engines/eevee/eevee_motion_blur.c
M source/blender/draw/engines/gpencil/gpencil_antialiasing.c
M source/blender/draw/engines/select/select_engine.c
M source/blender/draw/engines/workbench/workbench_effect_antialiasing.c
M source/blender/draw/engines/workbench/workbench_render.c
M source/blender/draw/engines/workbench/workbench_volume.c
M source/blender/draw/intern/draw_cache_impl_hair.c
M source/blender/draw/intern/draw_cache_impl_particles.c
M source/blender/draw/intern/draw_cache_impl_volume.c
M source/blender/draw/intern/draw_common.c
M source/blender/draw/intern/draw_fluid.c
M source/blender/draw/intern/draw_hair.c
M source/blender/draw/intern/draw_manager.c
M source/blender/draw/intern/draw_manager_texture.c
M source/blender/editors/interface/interface_icons.c
M source/blender/editors/screen/glutil.c
M source/blender/editors/sculpt_paint/paint_cursor.c
M source/blender/editors/space_clip/clip_draw.c
M source/blender/editors/space_sequencer/sequencer_draw.c
M source/blender/gpu/GPU_texture.h
M source/blender/gpu/intern/gpu_extensions.cc
M source/blender/gpu/intern/gpu_framebuffer.cc
M source/blender/gpu/intern/gpu_material.c
M source/blender/gpu/intern/gpu_texture.cc
M source/blender/gpu/intern/gpu_texture_private.hh
M source/blender/gpu/intern/gpu_viewport.c
M source/blender/imbuf/IMB_imbuf.h
M source/blender/imbuf/intern/util_gpu.c
M source/blender/windowmanager/intern/wm_operators.c
===================================================================
diff --git a/intern/opencolorio/ocio_impl_glsl.cc b/intern/opencolorio/ocio_impl_glsl.cc
index 6765d569d2f..1461be42578 100644
--- a/intern/opencolorio/ocio_impl_glsl.cc
+++ b/intern/opencolorio/ocio_impl_glsl.cc
@@ -282,18 +282,20 @@ static void ensureGLSLLut3d(OCIO_GLSLLut3d **lut3d_ptr,
OCIO_GLSLLut3d *lut3d = OBJECT_GUARDED_NEW(OCIO_GLSLLut3d);
- for (int i = 0; i < 2; i++) {
- int extent[3] = {LUT3D_EDGE_SIZE, LUT3D_EDGE_SIZE, LUT3D_EDGE_SIZE};
- GPUTexture *tex = GPU_texture_create_3d(UNPACK3(extent), GPU_RGB16F, NULL, NULL);
- GPU_texture_filter_mode(tex, true);
- GPU_texture_wrap_mode(tex, false, true);
+ int extent[3] = {LUT3D_EDGE_SIZE, LUT3D_EDGE_SIZE, LUT3D_EDGE_SIZE};
- (&lut3d->texture)[i] = tex;
- }
+ lut3d->texture = GPU_texture_create_3d("OCIOLut", UNPACK3(extent), 1, GPU_RGB16F, NULL);
+ GPU_texture_filter_mode(lut3d->texture, true);
+ GPU_texture_wrap_mode(lut3d->texture, false, true);
+
+ lut3d->texture_display = GPU_texture_create_3d(
+ "OCIOLutDisplay", UNPACK3(extent), 1, GPU_RGB16F, NULL);
+ GPU_texture_filter_mode(lut3d->texture_display, true);
+ GPU_texture_wrap_mode(lut3d->texture_display, false, true);
updateGLSLLut3d(lut3d, processor_scene_to_ui, processpr_ui_to_display, shaderDesc, cache_id);
- lut3d->valid = (lut3d->texture != 0);
+ lut3d->valid = (lut3d->texture && lut3d->texture_display);
*lut3d_ptr = lut3d;
}
@@ -316,7 +318,7 @@ static void allocateCurveMappingTexture(OCIO_GLSLCurveMappping *curvemap,
{
int lut_size = curve_mapping_settings ? curve_mapping_settings->lut_size : 1;
/* Do not initialize. Only if used. */
- curvemap->texture = GPU_texture_create_1d(lut_size, GPU_RGBA16F, NULL, NULL);
+ curvemap->texture = GPU_texture_create_1d("OCIOCurveMap", lut_size, 1, GPU_RGBA16F, NULL);
GPU_texture_filter_mode(curvemap->texture, false);
GPU_texture_wrap_mode(curvemap->texture, false, true);
}
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index b06037cf6ec..773d3409905 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -508,7 +508,7 @@ void blf_glyph_render(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, float x, fl
if (gc->texture) {
GPU_texture_free(gc->texture);
}
- gc->texture = GPU_texture_create_1d_array(w, h, GPU_R8, false, NULL);
+ gc->texture = GPU_texture_create_1d_array(__func__, w, h, 1, GPU_R8, NULL);
gc->bitmap_len_landed = 0;
}
diff --git a/source/blender/blenkernel/intern/image_gpu.c b/source/blender/blenkernel/intern/image_gpu.c
index 0a6015a3933..183129bf9b6 100644
--- a/source/blender/blenkernel/intern/image_gpu.c
+++ b/source/blender/blenkernel/intern/image_gpu.c
@@ -95,7 +95,7 @@ static GPUTexture *gpu_texture_create_tile_mapping(Image *ima, const int multivi
tile_info[3] = tile->runtime.tilearray_size[1] / array_h;
}
- GPUTexture *tex = GPU_texture_create_1d_array(width, 2, GPU_RGBA32F, data, NULL);
+ GPUTexture *tex = GPU_texture_create_1d_array(ima->id.name + 2, width, 2, 1, GPU_RGBA32F, data);
GPU_texture_mipmap_mode(tex, false, false);
MEM_freeN(data);
@@ -180,7 +180,7 @@ static GPUTexture *gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf)
const bool use_high_bitdepth = (ima->flag & IMA_HIGH_BITDEPTH);
/* Create Texture without content. */
GPUTexture *tex = IMB_touch_gpu_texture(
- main_ibuf, arraywidth, arrayheight, arraylayers, use_high_bitdepth);
+ ima->id.name + 2, main_ibuf, arraywidth, arrayheight, arraylayers, use_high_bitdepth);
/* Upload each tile one by one. */
LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
@@ -316,7 +316,8 @@ static GPUTexture *image_get_gpu_texture(Image *ima,
(ima ? (ima->alpha_mode != IMA_ALPHA_STRAIGHT) : false) :
(ima ? (ima->alpha_mode == IMA_ALPHA_PREMUL) : true);
- *tex = IMB_create_gpu_texture(ibuf_intern, use_high_bitdepth, store_premultiplied);
+ *tex = IMB_create_gpu_texture(
+ ima->id.name + 2, ibuf_intern, use_high_bitdepth, store_premultiplied);
if (GPU_mipmap_enabled()) {
GPU_texture_generate_mipmap(*tex);
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 55e43a2b8ed..3865407b0a7 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -1924,7 +1924,7 @@ GPUTexture *BKE_movieclip_get_gpu_texture(MovieClip *clip, MovieClipUser *cuser)
/* This only means RGBA16F instead of RGBA32F. */
const bool high_bitdepth = false;
const bool store_premultiplied = ibuf->rect_float ? false : true;
- *tex = IMB_create_gpu_texture(ibuf, high_bitdepth, store_premultiplied);
+ *tex = IMB_create_gpu_texture(clip->id.name + 2, ibuf, high_bitdepth, store_premultiplied);
/* Do not generate mips for movieclips... too slow. */
GPU_texture_mipmap_mode(*tex, false, true);
diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c
index e08d301e5a6..95186d2311a 100644
--- a/source/blender/blenkernel/intern/studiolight.c
+++ b/source/blender/blenkernel/intern/studiolight.c
@@ -500,7 +500,7 @@ static void studiolight_create_equirect_radiance_gputexture(StudioLight *sl)
ImBuf *ibuf = sl->equirect_radiance_buffer;
sl->equirect_radiance_gputexture = GPU_texture_create_2d(
- ibuf->x, ibuf->y, GPU_RGBA16F, ibuf->rect_float, NULL);
+ "studiolight_radiance", ibuf->x, ibuf->y, 1, GPU_RGBA16F, ibuf->rect_float);
GPUTexture *tex = sl->equirect_radiance_gputexture;
GPU_texture_filter_mode(tex, true);
GPU_texture_wrap_mode(tex, true, true);
@@ -520,7 +520,7 @@ static void studiolight_create_matcap_gputexture(StudioLightImage *sli)
copy_v3_v3(*offset3, *offset4);
}
- sli->gputexture = GPU_texture_create_2d(ibuf->x, ibuf->y, GPU_R11F_G11F_B10F, NULL, NULL);
+ sli->gputexture = GPU_texture_create_2d("matcap", ibuf->x, ibuf->y, 1, GPU_R11F_G11F_B10F, NULL);
GPU_texture_update(sli->gputexture, GPU_DATA_FLOAT, gpu_matcap_3components);
MEM_SAFE_FREE(gpu_matcap_3components);
@@ -555,7 +555,7 @@ static void studiolight_create_equirect_irradiance_gputexture(StudioLight *sl)
BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECT_IRRADIANCE_IMAGE_CALCULATED);
ImBuf *ibuf = sl->equirect_irradiance_buffer;
sl->equirect_irradiance_gputexture = GPU_texture_create_2d(
- ibuf->x, ibuf->y, GPU_RGBA16F, ibuf->rect_float, NULL);
+ "studiolight_irradiance", ibuf->x, ibuf->y, 1, GPU_RGBA16F, ibuf->rect_float);
GPUTexture *tex = sl->equirect_irradiance_gputexture;
GPU_texture_filter_mode(tex, true);
GPU_texture_wrap_mode(tex, true, true);
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c
index 2d846ccd1d6..49d68481045 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -402,7 +402,7 @@ static bool eevee_lightcache_static_load(LightCache *lcache)
if (lcache->grid_tx.tex == NULL) {
lcache->grid_tx.tex = GPU_texture_create_2d_array(
- UNPACK3(lcache->grid_tx.tex_size), IRRADIANCE_FORMAT, NULL, NULL);
+ "lightcache_irradiance", UNPACK3(lcache->grid_tx.tex_size), 1, IRRADIANCE_FORMAT, NULL);
GPU_texture_update(lcache->grid_tx.tex, GPU_DATA_UNSIGNED_BYTE, lcache->grid_tx.data);
if (lcache->grid_tx.tex == NULL) {
@@ -415,17 +415,19 @@ static bool eevee_lightcache_static_load(LightCache *lcache)
if (lcache->cube_tx.tex == NULL) {
if (GPU_arb_texture_cube_map_array_is_supported()) {
- lcache->cube_tx.tex = GPU_texture_create_cube_array(lcache->cube_tx.tex_size[0],
+ lcache->cube_tx.tex = GPU_texture_create_cube_array("lightcache_cubemaps",
+ lcache->cube_tx.tex_size[0],
lcache->cube_tx.tex_size[2] / 6,
+ lcache->mips_len + 1,
GPU_R11F_G11F_B10F,
- NULL,
NULL);
- GPU_texture_update(lcache->cube_tx.tex, GPU_DATA_10_11_11_REV, lcache->cube_tx.data);
}
else {
- lcache->cube_tx.tex = GPU_texture_create_2d_array(
- UNPACK3(lcache->cube_tx.tex_size), GPU_R11F_G11F_B10F, NULL, NULL);
- GPU_texture_update(lcache->cube_tx.tex, GPU_DATA_10_11_11_REV, lcache->cube_tx.data);
+ lcache->cube_tx.tex = GPU_texture_create_2d_array("lightcache_cubemaps_fallback",
+ UNPACK3(lcache->cube_tx.tex_size),
+ lcache->mips_len + 1,
+ GPU_R11F_G11F_B10F,
+ NULL);
}
if (lcache->cube_tx.tex == NULL) {
@@ -433,9 +435,9 @@ static bool eevee_lightcache_static_load(LightCache *lcache)
return false;
}
- for (int mip = 0; mip < lcache->mips_len; mip++) {
- GPU_texture_add_mipmap(
- lcache->cube_tx.tex, GPU_DATA_10_11_11_REV, mip + 1, lcache->cube_mips[mip].data);
+ for (int mip = 0; mip <= lcache->mips_len; mip++) {
+ const void *data = (mip == 0) ? lcache->cube_tx.data : lcache->cube_mips[mip - 1].data;
+ GPU_texture_update_mipmap(lcache->cube_tx.tex, mip, GPU_DATA_10_11_11_REV, data);
}
GPU_texture_mipmap_mode(lcache->cube_tx.tex, true, true);
}
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index f10a3f42077..e10c627494a 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -468,7 +468,7 @@ void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata)
GPU_v
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list