Gawain: add (temp) legacy GLSL support to ShaderInterface

A temporary measure needed by GPU_basic_shader.

Part of T51164
This commit is contained in:
Mike Erwin
2017-04-12 18:03:18 -04:00
parent 02fd9a1aaf
commit c61b7b0263

View File

@@ -14,6 +14,7 @@
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
#define SUPPORT_LEGACY_GLSL 1
#define DEBUG_SHADER_INTERFACE 0 #define DEBUG_SHADER_INTERFACE 0
#if DEBUG_SHADER_INTERFACE #if DEBUG_SHADER_INTERFACE
@@ -92,17 +93,23 @@ ShaderInterface* ShaderInterface_create(GLint program)
input->location = glGetUniformLocation(program, name); input->location = glGetUniformLocation(program, name);
#if TRUST_NO_ONE #if SUPPORT_LEGACY_GLSL
assert(input->location != -1); if (input->location != -1)
{
#elif TRUST_NO_ONE
assert(input->location != -1);
#endif #endif
if (setup_builtin_uniform(input, name)) if (setup_builtin_uniform(input, name))
; // reclaim space from name buffer (don't advance offset) ; // reclaim space from name buffer (don't advance offset)
else else
{ {
input->name = name; input->name = name;
name_buffer_offset += name_len + 1; // include NULL terminator name_buffer_offset += name_len + 1; // include NULL terminator
}
#if SUPPORT_LEGACY_GLSL
} }
#endif
#if DEBUG_SHADER_INTERFACE #if DEBUG_SHADER_INTERFACE
printf("uniform[%u] '%s' at location %d\n", i, name, input->location); 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); input->location = glGetAttribLocation(program, name);
#if TRUST_NO_ONE #if SUPPORT_LEGACY_GLSL
assert(input->location != -1); if (input->location != -1)
{
#elif TRUST_NO_ONE
assert(input->location != -1);
#endif #endif
input->name = name; input->name = name;
name_buffer_offset += name_len + 1; // include NULL terminator name_buffer_offset += name_len + 1; // include NULL terminator
#if SUPPORT_LEGACY_GLSL
}
#endif
#if DEBUG_SHADER_INTERFACE #if DEBUG_SHADER_INTERFACE
printf("attrib[%u] '%s' at location %d\n", i, name, input->location); 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; const ShaderInput* uniform = shaderface->inputs + i;
#if SUPPORT_LEGACY_GLSL
if (uniform->name == NULL) continue;
#endif
if (strcmp(uniform->name, name) == 0) if (strcmp(uniform->name, name) == 0)
return uniform; return uniform;
} }