From b82cb0ad3241ead3faee699847bc3e0065e304cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 2 Jun 2020 12:29:20 +0200 Subject: Cleanup: GPU: Remove GPU_shaderinterface_uniform_ensure --- source/blender/draw/intern/draw_manager_data.c | 4 ++-- source/blender/editors/interface/interface_icons.c | 10 +++++----- source/blender/editors/mask/mask_draw.c | 2 +- source/blender/editors/screen/glutil.c | 4 ++-- source/blender/editors/space_image/image_draw.c | 6 +++--- source/blender/editors/space_node/drawnode.c | 2 +- source/blender/gpu/GPU_shader.h | 1 - source/blender/gpu/GPU_shader_interface.h | 2 -- source/blender/gpu/intern/gpu_batch.c | 4 ++-- source/blender/gpu/intern/gpu_codegen.c | 2 +- source/blender/gpu/intern/gpu_immediate.c | 9 +++------ source/blender/gpu/intern/gpu_shader.c | 7 ------- source/blender/gpu/intern/gpu_shader_interface.c | 13 ------------- source/blender/makesrna/intern/rna_render.c | 2 +- source/blender/python/gpu/gpu_py_shader.c | 2 +- source/blender/windowmanager/intern/wm_draw.c | 6 +++--- source/blender/windowmanager/intern/wm_gesture.c | 2 +- 17 files changed, 26 insertions(+), 52 deletions(-) (limited to 'source/blender') diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index e7a74734f19..a5df60d66ce 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -232,7 +232,7 @@ static void drw_shgroup_uniform(DRWShadingGroup *shgroup, location = GPU_shader_get_uniform_block(shgroup->shader, name); } else { - location = GPU_shader_get_uniform_ensure(shgroup->shader, name); + location = GPU_shader_get_uniform(shgroup->shader, name); } if (location == -1) { @@ -420,7 +420,7 @@ void DRW_shgroup_uniform_vec4_array_copy(DRWShadingGroup *shgroup, const float (*value)[4], int arraysize) { - int location = GPU_shader_get_uniform_ensure(shgroup->shader, name); + int location = GPU_shader_get_uniform(shgroup->shader, name); if (location == -1) { /* Nice to enable eventually, for now eevee uses uniforms that might not exist. */ diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 0f22c83d945..deea3028354 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -1603,8 +1603,8 @@ static void icon_draw_cache_texture_flush_ex(GLuint texture, GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR); GPU_shader_bind(shader); - int img_loc = GPU_shader_get_uniform_ensure(shader, "image"); - int data_loc = GPU_shader_get_uniform_ensure(shader, "calls_data"); + int img_loc = GPU_shader_get_uniform(shader, "image"); + int data_loc = GPU_shader_get_uniform(shader, "calls_data"); glUniform1i(img_loc, 0); glUniform4fv(data_loc, ICON_DRAW_CACHE_SIZE * 3, (float *)texture_draw_calls->drawcall_cache); @@ -1750,9 +1750,9 @@ static void icon_draw_texture(float x, GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), alpha, alpha, alpha, alpha); } - glUniform1i(GPU_shader_get_uniform_ensure(shader, "image"), 0); - glUniform4f(GPU_shader_get_uniform_ensure(shader, "rect_icon"), x1, y1, x2, y2); - glUniform4f(GPU_shader_get_uniform_ensure(shader, "rect_geom"), x, y, x + w, y + h); + glUniform1i(GPU_shader_get_uniform(shader, "image"), 0); + glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), x1, y1, x2, y2); + glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), x, y, x + w, y + h); GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4); diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index bea44ee89f8..3786ed2789c 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -752,7 +752,7 @@ void ED_mask_draw_region( } IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); GPU_shader_uniform_vector( - state.shader, GPU_shader_get_uniform_ensure(state.shader, "shuffle"), 4, 1, red); + state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red); immDrawPixelsTex( &state, 0.0f, 0.0f, width, height, GL_RED, GL_FLOAT, GL_NEAREST, buffer, 1.0f, 1.0f, NULL); diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index ddb345ab65e..a9380debbdc 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -83,7 +83,7 @@ static void immDrawPixelsTexSetupAttributes(IMMDrawPixelsTexState *state) /* To be used before calling immDrawPixelsTex * Default shader is GPU_SHADER_2D_IMAGE_COLOR * You can still set uniforms with : - * GPU_shader_uniform_int(shader, GPU_shader_get_uniform_ensure(shader, "name"), 0); + * GPU_shader_uniform_int(shader, GPU_shader_get_uniform(shader, "name"), 0); * */ IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin) { @@ -191,7 +191,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state, /* NOTE: Shader could be null for GLSL OCIO drawing, it is fine, since * it does not need color. */ - if (state->shader != NULL && GPU_shader_get_uniform_ensure(state->shader, "color") != -1) { + if (state->shader != NULL && GPU_shader_get_uniform(state->shader, "color") != -1) { immUniformColor4fv((color) ? color : white); } diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 6037c1d2ec8..9040ca5e79c 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -476,7 +476,7 @@ static void sima_draw_zbuf_pixels( IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); GPU_shader_uniform_vector( - state.shader, GPU_shader_get_uniform_ensure(state.shader, "shuffle"), 4, 1, red); + state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red); immDrawPixelsTex( &state, x1, y1, rectx, recty, GL_RED, GL_INT, GL_NEAREST, recti, zoomx, zoomy, NULL); @@ -524,7 +524,7 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); GPU_shader_uniform_vector( - state.shader, GPU_shader_get_uniform_ensure(state.shader, "shuffle"), 4, 1, red); + state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red); immDrawPixelsTex( &state, x1, y1, rectx, recty, GL_RED, GL_FLOAT, GL_NEAREST, rectf, zoomx, zoomy, NULL); @@ -637,7 +637,7 @@ static void draw_image_buffer(const bContext *C, IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); GPU_shader_uniform_vector( - state.shader, GPU_shader_get_uniform_ensure(state.shader, "shuffle"), 4, 1, shuffle); + state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, shuffle); IMB_colormanagement_display_settings_from_ctx(C, &view_settings, &display_settings); display_buffer = IMB_display_buffer_acquire( diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 44003a5b9bc..01ac3a80871 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3638,7 +3638,7 @@ void draw_nodespace_back_pix(const bContext *C, IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); GPU_shader_uniform_vector( - state.shader, GPU_shader_get_uniform_ensure(state.shader, "shuffle"), 4, 1, shuffle); + state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, shuffle); immDrawPixelsTex(&state, x, diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index 0e382f2225f..baf3fb99974 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -92,7 +92,6 @@ void *GPU_shader_get_interface(GPUShader *shader); void GPU_shader_set_srgb_uniform(const struct GPUShaderInterface *interface); int GPU_shader_get_uniform(GPUShader *shader, const char *name); -int GPU_shader_get_uniform_ensure(GPUShader *shader, const char *name); int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin); int GPU_shader_get_uniform_block(GPUShader *shader, const char *name); void GPU_shader_uniform_vector( diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h index 91064719995..319a79a9e42 100644 --- a/source/blender/gpu/GPU_shader_interface.h +++ b/source/blender/gpu/GPU_shader_interface.h @@ -98,8 +98,6 @@ GPUShaderInterface *GPU_shaderinterface_create(int32_t program_id); void GPU_shaderinterface_discard(GPUShaderInterface *); const GPUShaderInput *GPU_shaderinterface_uniform(const GPUShaderInterface *, const char *name); -const GPUShaderInput *GPU_shaderinterface_uniform_ensure(const GPUShaderInterface *, - const char *name); const GPUShaderInput *GPU_shaderinterface_uniform_builtin(const GPUShaderInterface *, GPUUniformBuiltin); const GPUShaderInput *GPU_shaderinterface_ubo(const GPUShaderInterface *, const char *name); diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index 3dd43431393..5f77f13c135 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -551,11 +551,11 @@ void GPU_batch_program_use_end(GPUBatch *batch) #if TRUST_NO_ONE # define GET_UNIFORM \ - const GPUShaderInput *uniform = GPU_shaderinterface_uniform_ensure(batch->interface, name); \ + const GPUShaderInput *uniform = GPU_shaderinterface_uniform(batch->interface, name); \ assert(uniform); #else # define GET_UNIFORM \ - const GPUShaderInput *uniform = GPU_shaderinterface_uniform_ensure(batch->interface, name); + const GPUShaderInput *uniform = GPU_shaderinterface_uniform(batch->interface, name); #endif void GPU_batch_uniform_1ui(GPUBatch *batch, const char *name, uint value) diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 8a46e24d459..c1e7933d7ba 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -1160,7 +1160,7 @@ static int count_active_texture_sampler(GPUShader *shader, char *source) if (*code != '\0') { char sampler_name[64]; code = gpu_str_skip_token(code, sampler_name, sizeof(sampler_name)); - int id = GPU_shader_get_uniform_ensure(shader, sampler_name); + int id = GPU_shader_get_uniform(shader, sampler_name); if (id == -1) { continue; diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c index d95904c0007..a26b315e7e5 100644 --- a/source/blender/gpu/intern/gpu_immediate.c +++ b/source/blender/gpu/intern/gpu_immediate.c @@ -759,13 +759,11 @@ void immVertex2iv(uint attr_id, const int data[2]) #if 0 # if TRUST_NO_ONE # define GET_UNIFORM \ - const GPUShaderInput *uniform = GPU_shaderinterface_uniform_ensure(imm.shader_interface, \ - name); \ + const GPUShaderInput *uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); \ assert(uniform); # else # define GET_UNIFORM \ - const GPUShaderInput *uniform = GPU_shaderinterface_uniform_ensure(imm.shader_interface, \ - name); + const GPUShaderInput *uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); # endif #else /* NOTE: It is possible to have uniform fully optimized out from the shader. @@ -773,8 +771,7 @@ void immVertex2iv(uint attr_id, const int data[2]) * TODO(sergey): How can we detect existing-but-optimized-out uniform but still * catch typos in uniform names passed to immUniform*() functions? */ # define GET_UNIFORM \ - const GPUShaderInput *uniform = GPU_shaderinterface_uniform_ensure(imm.shader_interface, \ - name); \ + const GPUShaderInput *uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); \ if (uniform == NULL) \ return; #endif diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 8dfc992ae9f..d40b2307ea7 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -726,13 +726,6 @@ int GPU_shader_get_uniform(GPUShader *shader, const char *name) { BLI_assert(shader && shader->program); const GPUShaderInput *uniform = GPU_shaderinterface_uniform(shader->interface, name); - return uniform ? uniform->location : -2; -} - -int GPU_shader_get_uniform_ensure(GPUShader *shader, const char *name) -{ - BLI_assert(shader && shader->program); - const GPUShaderInput *uniform = GPU_shaderinterface_uniform_ensure(shader->interface, name); return uniform ? uniform->location : -1; } diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c index 5471333a4c8..2590d738917 100644 --- a/source/blender/gpu/intern/gpu_shader_interface.c +++ b/source/blender/gpu/intern/gpu_shader_interface.c @@ -454,19 +454,6 @@ const GPUShaderInput *GPU_shaderinterface_uniform(const GPUShaderInterface *shad return input_lookup(shaderface, shaderface->inputs + ofs, shaderface->uniform_len, name); } -const GPUShaderInput *GPU_shaderinterface_uniform_ensure(const GPUShaderInterface *shaderface, - const char *name) -{ - const GPUShaderInput *input = GPU_shaderinterface_uniform(shaderface, name); - /* If input is not found add it so it's found next time. */ - if (input == NULL) { - if ((G.debug & G_DEBUG_GPU) && (input->location == -1)) { - fprintf(stderr, "GPUShaderInterface: Warning: Uniform '%s' not found!\n", name); - } - } - return input; -} - const GPUShaderInput *GPU_shaderinterface_uniform_builtin(const GPUShaderInterface *shaderface, GPUUniformBuiltin builtin) { diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 6c21e4ad01b..6af031eb7b0 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -131,7 +131,7 @@ static void engine_bind_display_space_shader(RenderEngine *UNUSED(engine), Scene GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE); GPU_shader_bind(shader); - int img_loc = GPU_shader_get_uniform_ensure(shader, "image"); + int img_loc = GPU_shader_get_uniform(shader, "image"); GPU_shader_uniform_int(shader, img_loc, 0); } diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c index 7f894c6f816..165286c3661 100644 --- a/source/blender/python/gpu/gpu_py_shader.c +++ b/source/blender/python/gpu/gpu_py_shader.c @@ -78,7 +78,7 @@ static int bpygpu_uniform_location_get(GPUShader *shader, const char *name, const char *error_prefix) { - int uniform = GPU_shader_get_uniform_ensure(shader, name); + int uniform = GPU_shader_get_uniform(shader, name); if (uniform == -1) { PyErr_Format(PyExc_ValueError, "%s: uniform %.32s not found", error_prefix, name); diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 4cc9f4ee7d1..fa12d6cf974 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -574,13 +574,13 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend) alpha = 1.0f; } - glUniform1i(GPU_shader_get_uniform_ensure(shader, "image"), 0); - glUniform4f(GPU_shader_get_uniform_ensure(shader, "rect_icon"), + glUniform1i(GPU_shader_get_uniform(shader, "image"), 0); + glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), rect_tex.xmin, rect_tex.ymin, rect_tex.xmax, rect_tex.ymax); - glUniform4f(GPU_shader_get_uniform_ensure(shader, "rect_geom"), + glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), rect_geo.xmin, rect_geo.ymin, rect_geo.xmax, diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 9aa401722b7..6b2a74138c9 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -365,7 +365,7 @@ static void draw_filled_lasso(wmGesture *gt) IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); GPU_shader_bind(state.shader); GPU_shader_uniform_vector( - state.shader, GPU_shader_get_uniform_ensure(state.shader, "shuffle"), 4, 1, red); + state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red); immDrawPixelsTex(&state, rect.xmin, -- cgit v1.2.3