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/draw/engines
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/draw/engines')
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.c22
-rw-r--r--source/blender/draw/engines/eevee/eevee_motion_blur.c2
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_antialiasing.c5
-rw-r--r--source/blender/draw/engines/select/select_engine.c3
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_antialiasing.c4
-rw-r--r--source/blender/draw/engines/workbench/workbench_render.c4
-rw-r--r--source/blender/draw/engines/workbench/workbench_volume.c6
7 files changed, 25 insertions, 21 deletions
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_vertbuf_use(mb_hair->psys[i].hair_pos[mb_step]);
mb_hair->psys[i].hair_pos_tx[mb_step] = GPU_texture_create_from_vertbuf(
- mb_hair->psys[i].hair_pos[mb_step]);
+ "hair_pos_motion_blur", mb_hair->psys[i].hair_pos[mb_step]);
}
}
break;
diff --git a/source/blender/draw/engines/gpencil/gpencil_antialiasing.c b/source/blender/draw/engines/gpencil/gpencil_antialiasing.c
index ac96a599eb6..511f09db247 100644
--- a/source/blender/draw/engines/gpencil/gpencil_antialiasing.c
+++ b/source/blender/draw/engines/gpencil/gpencil_antialiasing.c
@@ -57,10 +57,11 @@ void GPENCIL_antialiasing_init(struct GPENCIL_Data *vedata)
if (txl->smaa_search_tx == NULL) {
txl->smaa_search_tx = GPU_texture_create_2d(
- SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, GPU_R8, NULL, NULL);
+ "smaa_search", SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, 1, GPU_R8, NULL);
GPU_texture_update(txl->smaa_search_tx, GPU_DATA_UNSIGNED_BYTE, searchTexBytes);
- txl->smaa_area_tx = GPU_texture_create_2d(AREATEX_WIDTH, AREATEX_HEIGHT, GPU_RG8, NULL, NULL);
+ txl->smaa_area_tx = GPU_texture_create_2d(
+ "smaa_area", AREATEX_WIDTH, AREATEX_HEIGHT, 1, GPU_RG8, NULL);
GPU_texture_update(txl->smaa_area_tx, GPU_DATA_UNSIGNED_BYTE, areaTexBytes);
GPU_texture_filter_mode(txl->smaa_search_tx, true);
diff --git a/source/blender/draw/engines/select/select_engine.c b/source/blender/draw/engines/select/select_engine.c
index 0ce8937687a..ec6e4c73043 100644
--- a/source/blender/draw/engines/select/select_engine.c
+++ b/source/blender/draw/engines/select/select_engine.c
@@ -79,7 +79,8 @@ static void select_engine_framebuffer_setup(void)
GPU_framebuffer_texture_attach(e_data.framebuffer_select_id, dtxl->depth, 0, 0);
if (e_data.texture_u32 == NULL) {
- e_data.texture_u32 = GPU_texture_create_2d(size[0], size[1], GPU_R32UI, NULL, NULL);
+ e_data.texture_u32 = GPU_texture_create_2d(
+ "select_buf_ids", size[0], size[1], 1, GPU_R32UI, NULL);
GPU_framebuffer_texture_attach(e_data.framebuffer_select_id, e_data.texture_u32, 0, 0);
GPU_framebuffer_check_valid(e_data.framebuffer_select_id, NULL);
diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c
index 9d5ff47fc82..20c30d9ce68 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c
@@ -243,11 +243,11 @@ void workbench_antialiasing_engine_init(WORKBENCH_Data *vedata)
/* TODO could be shared for all viewports. */
if (txl->smaa_search_tx == NULL) {
txl->smaa_search_tx = GPU_texture_create_2d(
- SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, GPU_R8, NULL, NULL);
+ "smaa_search", SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, 1, GPU_R8, NULL);
GPU_texture_update(txl->smaa_search_tx, GPU_DATA_UNSIGNED_BYTE, searchTexBytes);
txl->smaa_area_tx = GPU_texture_create_2d(
- AREATEX_WIDTH, AREATEX_HEIGHT, GPU_RG8, NULL, NULL);
+ "smaa_area", AREATEX_WIDTH, AREATEX_HEIGHT, 1, GPU_RG8, NULL);
GPU_texture_update(txl->smaa_area_tx, GPU_DATA_UNSIGNED_BYTE, areaTexBytes);
GPU_texture_filter_mode(txl->smaa_search_tx, true);
diff --git a/source/blender/draw/engines/workbench/workbench_render.c b/source/blender/draw/engines/workbench/workbench_render.c
index 77e16327a43..8760f2651ee 100644
--- a/source/blender/draw/engines/workbench/workbench_render.c
+++ b/source/blender/draw/engines/workbench/workbench_render.c
@@ -79,8 +79,8 @@ static bool workbench_render_framebuffers_init(void)
* the other views will reuse these buffers */
if (dtxl->color == NULL) {
BLI_assert(dtxl->depth == NULL);
- dtxl->color = GPU_texture_create_2d(size[0], size[1], GPU_RGBA16F, NULL, NULL);
- dtxl->depth = GPU_texture_create_2d(size[0], size[1], GPU_DEPTH24_STENCIL8, NULL, NULL);
+ dtxl->color = GPU_texture_create_2d("txl.color", UNPACK2(size), 1, GPU_RGBA16F, NULL);
+ dtxl->depth = GPU_texture_create_2d("txl.depth", UNPACK2(size), 1, GPU_DEPTH24_STENCIL8, NULL);
}
if (!(dtxl->depth && dtxl->color)) {
diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c
index f71e77d5da5..7aa089d440f 100644
--- a/source/blender/draw/engines/workbench/workbench_volume.c
+++ b/source/blender/draw/engines/workbench/workbench_volume.c
@@ -45,9 +45,9 @@ void workbench_volume_engine_init(WORKBENCH_Data *vedata)
if (txl->dummy_volume_tx == NULL) {
const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
const float one[4] = {1.0f, 1.0f, 1.0f, 1.0f};
- txl->dummy_volume_tx = GPU_texture_create_3d(1, 1, 1, GPU_RGBA8, zero, NULL);
- txl->dummy_shadow_tx = GPU_texture_create_3d(1, 1, 1, GPU_RGBA8, one, NULL);
- txl->dummy_coba_tx = GPU_texture_create_1d(1, GPU_RGBA8, zero, NULL);
+ txl->dummy_volume_tx = GPU_texture_create_3d("dummy_volume", 1, 1, 1, 1, GPU_RGBA8, zero);
+ txl->dummy_shadow_tx = GPU_texture_create_3d("dummy_shadow", 1, 1, 1, 1, GPU_RGBA8, one);
+ txl->dummy_coba_tx = GPU_texture_create_1d("dummy_coba", 1, 1, GPU_RGBA8, zero);
}
}