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

Author: Jordan Justen <[email protected]>
Date:   Sun Mar 15 13:53:06 2015 -0700

glsl: Parse shared keyword for compute shader variables

v2:
 * Move shared parsing under storage qualifiers (tarceri)
 * Fail to compile if shared is used in non-compute shader (tarceri)
 * Use separate shared_storage bit for shared variables (tarceri)

Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>

---

 src/glsl/ast.h          |    1 +
 src/glsl/ast_to_hir.cpp |    6 ++++++
 src/glsl/ast_type.cpp   |    3 ++-
 src/glsl/glsl_lexer.ll  |    2 ++
 src/glsl/glsl_parser.yy |    6 ++++++
 5 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index e803e6d..1b75234 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -448,6 +448,7 @@ struct ast_type_qualifier {
         unsigned patch:1;
         unsigned uniform:1;
         unsigned buffer:1;
+        unsigned shared_storage:1;
         unsigned smooth:1;
         unsigned flat:1;
         unsigned noperspective:1;
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 5a22820..a8eaecc 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -3089,6 +3089,12 @@ apply_type_qualifier_to_variable(const struct 
ast_type_qualifier *qual,
                        "members");
    }
 
+   if (qual->flags.q.shared_storage && state->stage != MESA_SHADER_COMPUTE) {
+      _mesa_glsl_error(loc, state,
+                       "the shared storage qualifiers can only be used with "
+                       "compute shaders");
+   }
+
    if (qual->flags.q.row_major || qual->flags.q.column_major) {
       validate_matrix_layout_for_type(state, loc, var->type, var);
    }
diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp
index 08a4504..79134c1 100644
--- a/src/glsl/ast_type.cpp
+++ b/src/glsl/ast_type.cpp
@@ -85,7 +85,8 @@ ast_type_qualifier::has_storage() const
           || this->flags.q.in
           || this->flags.q.out
           || this->flags.q.uniform
-          || this->flags.q.buffer;
+          || this->flags.q.buffer
+          || this->flags.q.shared_storage;
 }
 
 bool
diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index 2142817..e59f93e 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -414,6 +414,8 @@ writeonly      KEYWORD_WITH_ALT(420, 300, 420, 310, 
yyextra->ARB_shader_image_lo
 
 atomic_uint     KEYWORD_WITH_ALT(420, 300, 420, 310, 
yyextra->ARB_shader_atomic_counters_enable, ATOMIC_UINT);
 
+shared          KEYWORD_WITH_ALT(430, 310, 430, 310, 
yyextra->ARB_compute_shader_enable, SHARED);
+
 struct         return STRUCT;
 void           return VOID_TOK;
 
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 4636435..4ac8e45 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -165,6 +165,7 @@ static bool match_layout_qualifier(const char *s1, const 
char *s2,
 %token IMAGE1DSHADOW IMAGE2DSHADOW IMAGE1DARRAYSHADOW IMAGE2DARRAYSHADOW
 %token COHERENT VOLATILE RESTRICT READONLY WRITEONLY
 %token ATOMIC_UINT
+%token SHARED
 %token STRUCT VOID_TOK WHILE
 %token <identifier> IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER
 %type <identifier> any_identifier
@@ -1929,6 +1930,11 @@ storage_qualifier:
       memset(& $$, 0, sizeof($$));
       $$.flags.q.buffer = 1;
    }
+   | SHARED
+   {
+      memset(& $$, 0, sizeof($$));
+      $$.flags.q.shared_storage = 1;
+   }
    ;
 
 memory_qualifier:

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to