Mesa (master): glsl: move default layout qualifier rules out of the parser

Timothy Arceri tarceri at kemper.freedesktop.org
Tue Jan 19 21:07:01 UTC 2016


Module: Mesa
Branch: master
Commit: a0a93470e3413d5a5890d988462bb898362bd68f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a0a93470e3413d5a5890d988462bb898362bd68f

Author: Timothy Arceri <timothy.arceri at collabora.com>
Date:   Mon Jan 18 19:13:03 2016 +1100

glsl: move default layout qualifier rules out of the parser

Acked-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Chris Forbes <chrisf at ijw.co.nz>

---

 src/glsl/ast_type.cpp   | 22 +++++++++++++++++++++-
 src/glsl/glsl_parser.yy | 29 ++---------------------------
 2 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp
index 4e75016..e59d1b2 100644
--- a/src/glsl/ast_type.cpp
+++ b/src/glsl/ast_type.cpp
@@ -296,8 +296,28 @@ ast_type_qualifier::merge_out_qualifier(YYLTYPE *loc,
    void *mem_ctx = state;
    const bool r = this->merge_qualifier(loc, state, q);
 
-   if (state->stage == MESA_SHADER_TESS_CTRL) {
+   if (state->stage == MESA_SHADER_GEOMETRY) {
+      if (q.flags.q.prim_type) {
+         /* Make sure this is a valid output primitive type. */
+         switch (q.prim_type) {
+         case GL_POINTS:
+         case GL_LINE_STRIP:
+         case GL_TRIANGLE_STRIP:
+            break;
+         default:
+            _mesa_glsl_error(loc, state, "invalid geometry shader output "
+                             "primitive type");
+            break;
+         }
+      }
+
+      /* Allow future assigments of global out's stream id value */
+      this->flags.q.explicit_stream = 0;
+   } else if (state->stage == MESA_SHADER_TESS_CTRL) {
       node = new(mem_ctx) ast_tcs_output_layout(*loc);
+   } else {
+      _mesa_glsl_error(loc, state, "out layout qualifiers only valid in "
+                       "tessellation control or geometry shaders");
    }
 
    return r;
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 462ca45..925cb82 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -2786,33 +2786,8 @@ layout_out_defaults:
    layout_qualifier OUT_TOK ';'
    {
       $$ = NULL;
-      if (state->stage == MESA_SHADER_GEOMETRY) {
-         if ($1.flags.q.prim_type) {
-            /* Make sure this is a valid output primitive type. */
-            switch ($1.prim_type) {
-            case GL_POINTS:
-            case GL_LINE_STRIP:
-            case GL_TRIANGLE_STRIP:
-               break;
-            default:
-               _mesa_glsl_error(&@1, state, "invalid geometry shader output "
-                                "primitive type");
-               break;
-            }
-         }
-         if (!state->out_qualifier->merge_qualifier(& @1, state, $1))
-            YYERROR;
-
-         /* Allow future assigments of global out's stream id value */
-         state->out_qualifier->flags.q.explicit_stream = 0;
-      } else if (state->stage == MESA_SHADER_TESS_CTRL) {
-         if (!state->out_qualifier->merge_out_qualifier(& @1, state, $1, $$))
-            YYERROR;
-      } else {
-         _mesa_glsl_error(& @1, state,
-                          "out layout qualifiers only valid in "
-                          "tessellation control or geometry shaders");
-      }
+      if (!state->out_qualifier->merge_out_qualifier(& @1, state, $1, $$))
+         YYERROR;
    }
    ;
 




More information about the mesa-commit mailing list