From bac4606937514405641659d91a30bf3e6832cdf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 4 Sep 2020 22:56:30 +0200 Subject: Cleanup: GPUTexture: Remove use of GPU_texture_create_nD Use creation + update function instead. --- source/blender/blenfont/intern/blf_glyph.c | 3 +- source/blender/blenkernel/intern/studiolight.c | 13 ++------ .../blender/draw/engines/eevee/eevee_lightcache.c | 38 +++++++--------------- .../draw/engines/gpencil/gpencil_antialiasing.c | 27 ++++----------- .../workbench/workbench_effect_antialiasing.c | 28 ++++------------ source/blender/draw/intern/draw_fluid.c | 3 +- source/blender/editors/interface/interface_icons.c | 25 +++----------- source/blender/editors/sculpt_paint/paint_cursor.c | 8 ++--- source/blender/editors/space_clip/clip_draw.c | 12 ++----- .../editors/space_sequencer/sequencer_draw.c | 4 +-- source/blender/imbuf/intern/util_gpu.c | 12 +++++-- source/blender/windowmanager/intern/wm_operators.c | 4 +-- 12 files changed, 54 insertions(+), 123 deletions(-) (limited to 'source') diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index f46a74a739a..b06037cf6ec 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -508,8 +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_nD( - w, h, 0, 1, NULL, GPU_R8, GPU_DATA_UNSIGNED_BYTE, 0, false, NULL); + gc->texture = GPU_texture_create_1d_array(w, h, GPU_R8, false, NULL); gc->bitmap_len_landed = 0; } diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index 10830a3d4ba..e08d301e5a6 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -520,16 +520,9 @@ static void studiolight_create_matcap_gputexture(StudioLightImage *sli) copy_v3_v3(*offset3, *offset4); } - sli->gputexture = GPU_texture_create_nD(ibuf->x, - ibuf->y, - 0, - 2, - gpu_matcap_3components, - GPU_R11F_G11F_B10F, - GPU_DATA_FLOAT, - 0, - false, - NULL); + sli->gputexture = GPU_texture_create_2d(ibuf->x, ibuf->y, GPU_R11F_G11F_B10F, NULL, NULL); + GPU_texture_update(sli->gputexture, GPU_DATA_FLOAT, gpu_matcap_3components); + MEM_SAFE_FREE(gpu_matcap_3components); } diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c index 088a08fb51a..2d846ccd1d6 100644 --- a/source/blender/draw/engines/eevee/eevee_lightcache.c +++ b/source/blender/draw/engines/eevee/eevee_lightcache.c @@ -401,16 +401,9 @@ static bool eevee_lightcache_static_load(LightCache *lcache) } if (lcache->grid_tx.tex == NULL) { - lcache->grid_tx.tex = GPU_texture_create_nD(lcache->grid_tx.tex_size[0], - lcache->grid_tx.tex_size[1], - lcache->grid_tx.tex_size[2], - 2, - lcache->grid_tx.data, - IRRADIANCE_FORMAT, - GPU_DATA_UNSIGNED_BYTE, - 0, - false, - NULL); + lcache->grid_tx.tex = GPU_texture_create_2d_array( + UNPACK3(lcache->grid_tx.tex_size), IRRADIANCE_FORMAT, NULL, NULL); + GPU_texture_update(lcache->grid_tx.tex, GPU_DATA_UNSIGNED_BYTE, lcache->grid_tx.data); if (lcache->grid_tx.tex == NULL) { lcache->flag |= LIGHTCACHE_NOT_USABLE; @@ -422,24 +415,17 @@ 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_cube_create(lcache->cube_tx.tex_size[0], - lcache->cube_tx.tex_size[2] / 6, - lcache->cube_tx.data, - GPU_R11F_G11F_B10F, - GPU_DATA_10_11_11_REV, - NULL); + lcache->cube_tx.tex = GPU_texture_create_cube_array(lcache->cube_tx.tex_size[0], + lcache->cube_tx.tex_size[2] / 6, + 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_nD(lcache->cube_tx.tex_size[0], - lcache->cube_tx.tex_size[1], - lcache->cube_tx.tex_size[2], - 2, - lcache->cube_tx.data, - GPU_R11F_G11F_B10F, - GPU_DATA_10_11_11_REV, - 0, - false, - NULL); + 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); } if (lcache->cube_tx.tex == NULL) { diff --git a/source/blender/draw/engines/gpencil/gpencil_antialiasing.c b/source/blender/draw/engines/gpencil/gpencil_antialiasing.c index b9600ad8caf..ac96a599eb6 100644 --- a/source/blender/draw/engines/gpencil/gpencil_antialiasing.c +++ b/source/blender/draw/engines/gpencil/gpencil_antialiasing.c @@ -56,27 +56,12 @@ void GPENCIL_antialiasing_init(struct GPENCIL_Data *vedata) } if (txl->smaa_search_tx == NULL) { - txl->smaa_search_tx = GPU_texture_create_nD(SEARCHTEX_WIDTH, - SEARCHTEX_HEIGHT, - 0, - 2, - searchTexBytes, - GPU_R8, - GPU_DATA_UNSIGNED_BYTE, - 0, - false, - NULL); - - txl->smaa_area_tx = GPU_texture_create_nD(AREATEX_WIDTH, - AREATEX_HEIGHT, - 0, - 2, - areaTexBytes, - GPU_RG8, - GPU_DATA_UNSIGNED_BYTE, - 0, - false, - NULL); + txl->smaa_search_tx = GPU_texture_create_2d( + SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, GPU_R8, NULL, 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); + GPU_texture_update(txl->smaa_area_tx, GPU_DATA_UNSIGNED_BYTE, areaTexBytes); GPU_texture_filter_mode(txl->smaa_search_tx, true); GPU_texture_filter_mode(txl->smaa_area_tx, true); diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c index 47a03073839..9d5ff47fc82 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c +++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c @@ -242,27 +242,13 @@ 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_nD(SEARCHTEX_WIDTH, - SEARCHTEX_HEIGHT, - 0, - 2, - searchTexBytes, - GPU_R8, - GPU_DATA_UNSIGNED_BYTE, - 0, - false, - NULL); - - txl->smaa_area_tx = GPU_texture_create_nD(AREATEX_WIDTH, - AREATEX_HEIGHT, - 0, - 2, - areaTexBytes, - GPU_RG8, - GPU_DATA_UNSIGNED_BYTE, - 0, - false, - NULL); + txl->smaa_search_tx = GPU_texture_create_2d( + SEARCHTEX_WIDTH, SEARCHTEX_HEIGHT, GPU_R8, NULL, 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); + GPU_texture_update(txl->smaa_area_tx, GPU_DATA_UNSIGNED_BYTE, areaTexBytes); GPU_texture_filter_mode(txl->smaa_search_tx, true); GPU_texture_filter_mode(txl->smaa_area_tx, true); diff --git a/source/blender/draw/intern/draw_fluid.c b/source/blender/draw/intern/draw_fluid.c index c9f181f53db..9b63b50db61 100644 --- a/source/blender/draw/intern/draw_fluid.c +++ b/source/blender/draw/intern/draw_fluid.c @@ -184,8 +184,7 @@ static GPUTexture *create_volume_texture(const int dim[3], int final_dim[3] = {UNPACK3(dim)}; while (1) { - tex = GPU_texture_create_nD( - UNPACK3(final_dim), 3, NULL, format, GPU_DATA_FLOAT, 0, false, NULL); + tex = GPU_texture_create_3d(UNPACK3(final_dim), format, NULL, NULL); if (tex != NULL) { break; diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 70061427c33..8801d2956bb 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -866,30 +866,15 @@ void UI_icons_reload_internal_textures(void) icongltex.invw = 1.0f / b32buf->x; icongltex.invh = 1.0f / b32buf->y; - icongltex.tex[0] = GPU_texture_create_nD(b32buf->x, - b32buf->y, - 0, - 2, - b32buf->rect, - GPU_RGBA8, - GPU_DATA_UNSIGNED_BYTE, - 0, - false, - NULL); + icongltex.tex[0] = GPU_texture_create_2d(b32buf->x, b32buf->y, GPU_RGBA8, NULL, NULL); + GPU_texture_add_mipmap(icongltex.tex[0], GPU_DATA_UNSIGNED_BYTE, 0, b32buf->rect); GPU_texture_add_mipmap(icongltex.tex[0], GPU_DATA_UNSIGNED_BYTE, 1, b16buf->rect); } if (need_icons_with_border && icongltex.tex[1] == NULL) { - icongltex.tex[1] = GPU_texture_create_nD(b32buf_border->x, - b32buf_border->y, - 0, - 2, - b32buf_border->rect, - GPU_RGBA8, - GPU_DATA_UNSIGNED_BYTE, - 0, - false, - NULL); + icongltex.tex[1] = GPU_texture_create_2d( + b32buf_border->x, b32buf_border->y, GPU_RGBA8, NULL, NULL); + GPU_texture_add_mipmap(icongltex.tex[1], GPU_DATA_UNSIGNED_BYTE, 0, b32buf_border->rect); GPU_texture_add_mipmap(icongltex.tex[1], GPU_DATA_UNSIGNED_BYTE, 1, b16buf_border->rect); } } diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 0486fc9fe0f..4d885364440 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -348,8 +348,8 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima if (!target->overlay_texture) { eGPUTextureFormat format = col ? GPU_RGBA8 : GPU_R8; - target->overlay_texture = GPU_texture_create_nD( - size, size, 0, 2, buffer, format, GPU_DATA_UNSIGNED_BYTE, 0, false, NULL); + target->overlay_texture = GPU_texture_create_2d(size, size, format, NULL, NULL); + GPU_texture_update(target->overlay_texture, GPU_DATA_UNSIGNED_BYTE, buffer); if (!col) { GPU_texture_swizzle_set(target->overlay_texture, "rrrr"); @@ -466,8 +466,8 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) BLI_task_parallel_range(0, size, &data, load_tex_cursor_task_cb, &settings); if (!cursor_snap.overlay_texture) { - cursor_snap.overlay_texture = GPU_texture_create_nD( - size, size, 0, 2, buffer, GPU_R8, GPU_DATA_UNSIGNED_BYTE, 0, false, NULL); + cursor_snap.overlay_texture = GPU_texture_create_2d(size, size, GPU_R8, NULL, NULL); + GPU_texture_update(cursor_snap.overlay_texture, GPU_DATA_UNSIGNED_BYTE, buffer); GPU_texture_swizzle_set(cursor_snap.overlay_texture, "rrrr"); } diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 17539b2c423..8fbf9fa2144 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -1211,16 +1211,8 @@ static void draw_plane_marker_image(Scene *scene, GPU_blend(GPU_BLEND_ALPHA); } - GPUTexture *texture = GPU_texture_create_nD(ibuf->x, - ibuf->y, - 0, - 2, - display_buffer, - GPU_RGBA8, - GPU_DATA_UNSIGNED_BYTE, - 0, - false, - NULL); + GPUTexture *texture = GPU_texture_create_2d(ibuf->x, ibuf->y, GPU_RGBA8, NULL, NULL); + GPU_texture_update(texture, GPU_DATA_UNSIGNED_BYTE, display_buffer); GPU_texture_filter_mode(texture, false); GPU_matrix_push(); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 2f094661863..9504ed88bb1 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1639,8 +1639,8 @@ static void sequencer_draw_display_buffer(const bContext *C, GPU_matrix_identity_projection_set(); } - GPUTexture *texture = GPU_texture_create_nD( - ibuf->x, ibuf->y, 0, 2, display_buffer, format, data, 0, false, NULL); + GPUTexture *texture = GPU_texture_create_2d(ibuf->x, ibuf->y, format, NULL, NULL); + GPU_texture_update(texture, data, display_buffer); GPU_texture_filter_mode(texture, false); GPU_texture_bind(texture, 0); diff --git a/source/blender/imbuf/intern/util_gpu.c b/source/blender/imbuf/intern/util_gpu.c index 58ff8473a85..e538e8e1659 100644 --- a/source/blender/imbuf/intern/util_gpu.c +++ b/source/blender/imbuf/intern/util_gpu.c @@ -165,8 +165,13 @@ GPUTexture *IMB_touch_gpu_texture(ImBuf *ibuf, int w, int h, int layers, bool us eGPUTextureFormat tex_format; imb_gpu_get_format(ibuf, use_high_bitdepth, &data_format, &tex_format); - GPUTexture *tex = GPU_texture_create_nD( - w, h, layers, 2, NULL, tex_format, data_format, 0, false, NULL); + GPUTexture *tex; + if (layers > 0) { + tex = GPU_texture_create_2d_array(w, h, layers, tex_format, NULL, NULL); + } + else { + tex = GPU_texture_create_2d(w, h, tex_format, NULL, NULL); + } GPU_texture_anisotropic_filter(tex, true); return tex; @@ -248,7 +253,8 @@ 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_nD(UNPACK2(size), 0, 2, data, tex_format, data_format, 0, false, NULL); + tex = GPU_texture_create_2d(UNPACK2(size), tex_format, NULL, NULL); + GPU_texture_update(tex, data_format, data); GPU_texture_anisotropic_filter(tex, true); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 67511d2b433..de4dffd6d07 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2217,8 +2217,8 @@ static void radial_control_set_tex(RadialControl *rc) rc->use_secondary_tex, !ELEM(rc->subtype, PROP_NONE, PROP_PIXEL, PROP_DISTANCE)))) { - rc->texture = GPU_texture_create_nD( - ibuf->x, ibuf->y, 0, 2, ibuf->rect_float, GPU_R8, GPU_DATA_FLOAT, 0, false, NULL); + rc->texture = GPU_texture_create_2d(ibuf->x, ibuf->y, GPU_R8, ibuf->rect_float, NULL); + GPU_texture_filter_mode(rc->texture, true); GPU_texture_swizzle_set(rc->texture, "111r"); -- cgit v1.2.3