[Mesa-dev] [PATCH] glsl: Cause linking error if some layout qualifiers do not match

Chad Versace chad at chad-versace.us
Mon Oct 25 17:50:26 PDT 2010


From: Chad Versace <chad.versace at intel.com>

When validating a global variable in the linking stage, verify that each of
the layout qualifiers below is identical among all instances of the
global variable:
    - origin_upper_left
    - pixel_center_integer
---
 src/glsl/linker.cpp |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 616ec78..5398272 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -385,6 +385,18 @@ cross_validate_globals(struct gl_shader_program *prog,
 	       existing->explicit_location = true;
 	    }
 
+	    /* Verify that each of the layout qualifiers below is identical among
+	     * all instances of the variable.
+	     */
+	    if ((var->origin_upper_left != existing->origin_upper_left)
+	        || (var->pixel_center_integer != existing->pixel_center_integer))
+	    {
+	       linker_error_printf(prog, "layout qualifiers for %s '%s' "
+	                                 "do not match\n",
+	                                 mode_string(var), var->name);
+	       return false;
+	    }
+
 	    /* FINISHME: Handle non-constant initializers.
 	     */
 	    if (var->constant_value != NULL) {
-- 
1.7.1



More information about the mesa-dev mailing list