[Mesa-dev] [PATCH 8/8] glsl: simplified ast_type_qualifier::merge_[in|out]_qualifier API

Andres Gomez agomez at igalia.com
Wed Oct 26 15:30:51 UTC 2016


Since we modified the way in which multiple repetitions of the same
layout-qualifier-name in a single declaration collapse into the
ast_type_qualifier class, we can simplify the merge_[in|out]_qualifier
APIs through removing the create_node parameter.

Signed-off-by: Andres Gomez <agomez at igalia.com>
---
 src/compiler/glsl/ast.h          |  4 ++--
 src/compiler/glsl/ast_type.cpp   | 18 +++++++-----------
 src/compiler/glsl/glsl_parser.yy |  4 ++--
 3 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
index 875506f..f03f1b5 100644
--- a/src/compiler/glsl/ast.h
+++ b/src/compiler/glsl/ast.h
@@ -758,12 +758,12 @@ struct ast_type_qualifier {
    bool merge_out_qualifier(YYLTYPE *loc,
                            _mesa_glsl_parse_state *state,
                            const ast_type_qualifier &q,
-                           ast_node* &node, bool create_node);
+                           ast_node* &node);
 
    bool merge_in_qualifier(YYLTYPE *loc,
                            _mesa_glsl_parse_state *state,
                            const ast_type_qualifier &q,
-                           ast_node* &node, bool create_node);
+                           ast_node* &node);
 
    /**
     * Push pending layout qualifiers to the global values.
diff --git a/src/compiler/glsl/ast_type.cpp b/src/compiler/glsl/ast_type.cpp
index ce451c2..2a19293 100644
--- a/src/compiler/glsl/ast_type.cpp
+++ b/src/compiler/glsl/ast_type.cpp
@@ -368,7 +368,7 @@ bool
 ast_type_qualifier::merge_out_qualifier(YYLTYPE *loc,
                                         _mesa_glsl_parse_state *state,
                                         const ast_type_qualifier &q,
-                                        ast_node* &node, bool create_node)
+                                        ast_node* &node)
 {
    void *mem_ctx = state;
    const bool r = this->merge_qualifier(loc, state, q, false);
@@ -402,9 +402,7 @@ ast_type_qualifier::merge_out_qualifier(YYLTYPE *loc,
       valid_out_mask.flags.q.max_vertices = 1;
       valid_out_mask.flags.q.prim_type = 1;
    } else if (state->stage == MESA_SHADER_TESS_CTRL) {
-      if (create_node) {
-         node = new(mem_ctx) ast_tcs_output_layout(*loc);
-      }
+      node = new(mem_ctx) ast_tcs_output_layout(*loc);
       valid_out_mask.flags.q.vertices = 1;
       valid_out_mask.flags.q.explicit_xfb_buffer = 1;
       valid_out_mask.flags.q.xfb_buffer = 1;
@@ -441,7 +439,7 @@ bool
 ast_type_qualifier::merge_in_qualifier(YYLTYPE *loc,
                                        _mesa_glsl_parse_state *state,
                                        const ast_type_qualifier &q,
-                                       ast_node* &node, bool create_node)
+                                       ast_node* &node)
 {
    void *mem_ctx = state;
    bool create_gs_ast = false;
@@ -585,12 +583,10 @@ ast_type_qualifier::merge_in_qualifier(YYLTYPE *loc,
       state->cs_input_local_size_variable_specified = true;
    }
 
-   if (create_node) {
-      if (create_gs_ast) {
-         node = new(mem_ctx) ast_gs_input_layout(*loc, q.prim_type);
-      } else if (create_cs_ast) {
-         node = new(mem_ctx) ast_cs_input_layout(*loc, q.local_size);
-      }
+   if (create_gs_ast) {
+      node = new(mem_ctx) ast_gs_input_layout(*loc, q.prim_type);
+   } else if (create_cs_ast) {
+      node = new(mem_ctx) ast_cs_input_layout(*loc, q.local_size);
    }
 
    return true;
diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy
index 6767ce3..8e6c5e8 100644
--- a/src/compiler/glsl/glsl_parser.yy
+++ b/src/compiler/glsl/glsl_parser.yy
@@ -2933,7 +2933,7 @@ layout_defaults:
    {
       $$ = NULL;
       if (!state->in_qualifier->
-             merge_in_qualifier(& @1, state, $1, $$, true)) {
+             merge_in_qualifier(& @1, state, $1, $$)) {
          YYERROR;
       }
       if (!state->in_qualifier->push_to_global(& @1, state)) {
@@ -2944,7 +2944,7 @@ layout_defaults:
    {
       $$ = NULL;
       if (!state->out_qualifier->
-             merge_out_qualifier(& @1, state, $1, $$, true)) {
+             merge_out_qualifier(& @1, state, $1, $$)) {
          YYERROR;
       }
       if (!state->out_qualifier->push_to_global(& @1, state)) {
-- 
2.9.3



More information about the mesa-dev mailing list