[Mesa-dev] [PATCH 3/5] glsl: Fail if gl_FragCoord layouts don't match.

Fabian Bieler fabianbieler at fastmail.fm
Wed May 8 15:51:04 PDT 2013


Fail compile if gl_FragCoord is redeclared with different layout qualifiers in
one shader.
---
 src/glsl/ast_to_hir.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 63fbd5a..d6362b0 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2213,6 +2213,16 @@ get_variable_being_redeclared(ir_variable *var, ast_declaration *decl,
       /* Allow redeclaration of gl_FragCoord for ARB_fcc layout
        * qualifiers.
        */
+
+      /* Prevent inconsistent redeclaration of layout qualifier. */
+      if (earlier->redeclared
+	  && (earlier->origin_upper_left != var->origin_upper_left ||
+	      earlier->pixel_center_integer != var->pixel_center_integer)) {
+	 _mesa_glsl_error(&loc, state,
+			  "`gl_FragCoord' redeclared with different layout "
+			  "qualifier");
+      }
+
       earlier->origin_upper_left = var->origin_upper_left;
       earlier->pixel_center_integer = var->pixel_center_integer;
 
-- 
1.8.1.2



More information about the mesa-dev mailing list