[Mesa-dev] [PATCH 2/2] glsl: Fix redeclaration rules for gl_FragDepth too.

Chris Forbes chrisf at ijw.co.nz
Sat Apr 12 22:30:07 PDT 2014


Previously we disallowed any redeclarations after any use, and detected
conflicting layout qualifiers based on what we know the default to be.

Use ir_variable::data::how_declared instead to determine whether this
has already been redeclared, and allow identical redeclarations after
use, provided the first redeclaration was before the first use.

(These are the same rules as for gl_FragCoord, since the spec language
is identical.)

Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 src/glsl/ast_to_hir.cpp | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index d1eb3e2..535b11b 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2770,14 +2770,15 @@ get_variable_being_redeclared(ir_variable *var, YYLTYPE loc,
        *     Within any shader, the first redeclarations of gl_FragDepth
        *     must appear before any use of gl_FragDepth.
        */
-      if (earlier->data.used) {
-	 _mesa_glsl_error(&loc, state,
-			  "the first redeclaration of gl_FragDepth "
-			  "must appear before any use of gl_FragDepth");
+      if (earlier->data.used &&
+          earlier->data.how_declared == ir_var_declared_implicitly) {
+         _mesa_glsl_error(&loc, state,
+                          "the first redeclaration of gl_FragDepth "
+                          "must appear before any use of gl_FragDepth");
       }
 
       /* Prevent inconsistent redeclaration of depth layout qualifier. */
-      if (earlier->data.depth_layout != ir_depth_layout_none
+      if (earlier->data.how_declared != ir_var_declared_implicitly
 	  && earlier->data.depth_layout != var->data.depth_layout) {
 	 _mesa_glsl_error(&loc, state,
 			  "gl_FragDepth: depth layout is declared here "
-- 
1.9.2



More information about the mesa-dev mailing list