diff options
Diffstat (limited to 'source/blender/gpu/intern/gpu_shader.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 8a141eaa2b2..31a85800754 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -563,6 +563,24 @@ int GPU_shader_get_uniform(GPUShader *shader, const char *name) { BLI_assert(shader && shader->program); const GPUShaderInput *uniform = GPU_shaderinterface_uniform(shader->interface, name); +#if 1 /* Remove this when we have transitionned all uniforms. */ + if (uniform == NULL) { +# ifndef NDEBUG + printf("Uniform \"%s\" needs to be added to shader interface after shader creation.\n", name); +# endif + /* Fallback to avoid issues. */ + return GPU_shader_get_uniform_ensure(shader, name); + } +#else + BLI_assert(uniform); +#endif + return uniform->location; +} + +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; } @@ -576,7 +594,6 @@ int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin) int GPU_shader_get_uniform_block(GPUShader *shader, const char *name) { BLI_assert(shader && shader->program); - const GPUShaderInput *ubo = GPU_shaderinterface_ubo(shader->interface, name); return ubo ? ubo->location : -1; } |