From c61b7b02635f90529b8c08a6914e87dda5f77df0 Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Wed, 12 Apr 2017 18:03:18 -0400 Subject: [PATCH] Gawain: add (temp) legacy GLSL support to ShaderInterface A temporary measure needed by GPU_basic_shader. Part of T51164 --- intern/gawain/src/shader_interface.c | 41 ++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/intern/gawain/src/shader_interface.c b/intern/gawain/src/shader_interface.c index 85fa1d0b676..d3c9ad0240c 100644 --- a/intern/gawain/src/shader_interface.c +++ b/intern/gawain/src/shader_interface.c @@ -14,6 +14,7 @@ #include #include +#define SUPPORT_LEGACY_GLSL 1 #define DEBUG_SHADER_INTERFACE 0 #if DEBUG_SHADER_INTERFACE @@ -92,17 +93,23 @@ ShaderInterface* ShaderInterface_create(GLint program) input->location = glGetUniformLocation(program, name); -#if TRUST_NO_ONE - assert(input->location != -1); +#if SUPPORT_LEGACY_GLSL + if (input->location != -1) + { +#elif TRUST_NO_ONE + assert(input->location != -1); #endif - if (setup_builtin_uniform(input, name)) - ; // reclaim space from name buffer (don't advance offset) - else - { - input->name = name; - name_buffer_offset += name_len + 1; // include NULL terminator + if (setup_builtin_uniform(input, name)) + ; // reclaim space from name buffer (don't advance offset) + else + { + input->name = name; + name_buffer_offset += name_len + 1; // include NULL terminator + } +#if SUPPORT_LEGACY_GLSL } +#endif #if DEBUG_SHADER_INTERFACE printf("uniform[%u] '%s' at location %d\n", i, name, input->location); @@ -122,12 +129,18 @@ ShaderInterface* ShaderInterface_create(GLint program) input->location = glGetAttribLocation(program, name); -#if TRUST_NO_ONE - assert(input->location != -1); +#if SUPPORT_LEGACY_GLSL + if (input->location != -1) + { +#elif TRUST_NO_ONE + assert(input->location != -1); #endif - input->name = name; - name_buffer_offset += name_len + 1; // include NULL terminator + input->name = name; + name_buffer_offset += name_len + 1; // include NULL terminator +#if SUPPORT_LEGACY_GLSL + } +#endif #if DEBUG_SHADER_INTERFACE printf("attrib[%u] '%s' at location %d\n", i, name, input->location); @@ -157,6 +170,10 @@ const ShaderInput* ShaderInterface_uniform(const ShaderInterface* shaderface, co { const ShaderInput* uniform = shaderface->inputs + i; +#if SUPPORT_LEGACY_GLSL + if (uniform->name == NULL) continue; +#endif + if (strcmp(uniform->name, name) == 0) return uniform; }