GPU: Rename GPU_shader_get_uniform to GPU_shader_get_uniform_ensure
[blender.git] / source / blender / gpu / intern / gpu_shader.c
index 8a141eaa2b240db2bc6be7fa4cdf67d156d406d3..31a85800754742820b137af3d5f8092ef3299ab1 100644 (file)
@@ -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;
 }