Mesa (10.1): glsl: Only allow `invariant` on shader in/out between stages.

Carl Worth cworth at kemper.freedesktop.org
Wed Apr 23 09:27:25 UTC 2014


Module: Mesa
Branch: 10.1
Commit: 74194a4bfc94b07d200b3caef54c227168273969
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=74194a4bfc94b07d200b3caef54c227168273969

Author: Chris Forbes <chrisf at ijw.co.nz>
Date:   Mon Apr 21 15:45:32 2014 +1200

glsl: Only allow `invariant` on shader in/out between stages.

Previously this was special-cased for VS and FS; it never got updated
when geometry shaders came along. Generalize using is_varying_var() so
this won't be broken again with tessellation.

Note that there are two copies of the logic for `invariant`: It can be
present as part of a new declaration, and also as a redeclaration of an
existing variable or block member.

Fixes the four new piglits:
   spec/glsl-1.50/compiler/invariant-qualifier-*.geom

Note for stable: This won't quite pick cleanly due to whitespace and
state->target -> state->stage renames. Should be straightforward
adjustments though.

Cc: "10.0 10.1" <mesa-stable at lists.freedesktop.org>
Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
(cherry picked from commit 0dfa6e7cf5a1f5207b32140f48cd3870db8a189b)

Conflicts:
	src/glsl/ast_to_hir.cpp

---

 src/glsl/ast_to_hir.cpp |   33 +++++++++------------------------
 1 file changed, 9 insertions(+), 24 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index a2b9456..3a9c124 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2908,16 +2908,10 @@ ast_declarator_list::hir(exec_list *instructions,
 	    _mesa_glsl_error(& loc, state,
 			     "undeclared variable `%s' cannot be marked "
 			     "invariant", decl->identifier);
-	 } else if ((state->stage == MESA_SHADER_VERTEX)
-	       && (earlier->data.mode != ir_var_shader_out)) {
-	    _mesa_glsl_error(& loc, state,
-			     "`%s' cannot be marked invariant, vertex shader "
-			     "outputs only", decl->identifier);
-	 } else if ((state->stage == MESA_SHADER_FRAGMENT)
-	       && (earlier->data.mode != ir_var_shader_in)) {
-	    _mesa_glsl_error(& loc, state,
-			     "`%s' cannot be marked invariant, fragment shader "
-			     "inputs only", decl->identifier);
+	 } else if (!is_varying_var(earlier, state->stage)) {
+	    _mesa_glsl_error(&loc, state,
+			     "`%s' cannot be marked invariant; interfaces between "
+			     "shader stages only.", decl->identifier);
 	 } else if (earlier->data.used) {
 	    _mesa_glsl_error(& loc, state,
 			     "variable `%s' may not be redeclared "
@@ -3092,20 +3086,11 @@ ast_declarator_list::hir(exec_list *instructions,
 				       & loc, false);
 
       if (this->type->qualifier.flags.q.invariant) {
-	 if ((state->stage == MESA_SHADER_VERTEX) &&
-             var->data.mode != ir_var_shader_out) {
-	    _mesa_glsl_error(& loc, state,
-			     "`%s' cannot be marked invariant, vertex shader "
-			     "outputs only", var->name);
-	 } else if ((state->stage == MESA_SHADER_FRAGMENT) &&
-		    var->data.mode != ir_var_shader_in) {
-	    /* FINISHME: Note that this doesn't work for invariant on
-	     * a function signature inval
-	     */
-	    _mesa_glsl_error(& loc, state,
-			     "`%s' cannot be marked invariant, fragment shader "
-			     "inputs only", var->name);
-	 }
+         if (!is_varying_var(var, state->stage)) {
+            _mesa_glsl_error(&loc, state,
+                             "`%s' cannot be marked invariant; interfaces between "
+                             "shader stages only", var->name);
+         }
       }
 
       if (state->current_function != NULL) {




More information about the mesa-commit mailing list