Commit: c61b7b02635f90529b8c08a6914e87dda5f77df0
Author: Mike Erwin
Date:   Wed Apr 12 18:03:18 2017 -0400
Branches: blender2.8
https://developer.blender.org/rBc61b7b02635f90529b8c08a6914e87dda5f77df0

Gawain: add (temp) legacy GLSL support to ShaderInterface

A temporary measure needed by GPU_basic_shader.

Part of T51164

===================================================================

M       intern/gawain/src/shader_interface.c

===================================================================

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 <stddef.h>
 #include <string.h>
 
+#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;
                }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to