glsl: ignore default qualifier declarations when checking for duplicate layout qualifiers
authorSamuel Iglesias Gonsalvez <siglesias@igalia.com>
Thu, 3 Sep 2015 07:47:56 +0000 (09:47 +0200)
committerSamuel Iglesias Gonsalvez <siglesias@igalia.com>
Fri, 25 Sep 2015 06:39:21 +0000 (08:39 +0200)
Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
src/glsl/ast.h
src/glsl/glsl_parser.yy
src/glsl/glsl_parser_extras.cpp

index d8c6cea7832574bc11d3badf544e42f12cf3dab9..335f426d4182bd8bc16d9adf0e016890110ca1c4 100644 (file)
@@ -639,6 +639,9 @@ struct ast_type_qualifier {
     */
    glsl_base_type image_base_type;
 
+   /** Flag to know if this represents a default value for a qualifier */
+   bool is_default_qualifier;
+
    /**
     * Return true if and only if an interpolation qualifier is present.
     */
index 4dd5384dac82ba256ecc9dc9e4c7f0079f567f5d..42108a3c1b633b2478d5bf27ace688cecca1e7b0 100644 (file)
@@ -2599,7 +2599,8 @@ interface_block:
    {
       ast_interface_block *block = (ast_interface_block *) $2;
 
-      if (!state->has_420pack() && block->layout.has_layout()) {
+      if (!state->has_420pack() && block->layout.has_layout() &&
+          !block->layout.is_default_qualifier) {
          _mesa_glsl_error(&@1, state, "duplicate layout(...) qualifiers");
          YYERROR;
       }
@@ -2608,6 +2609,8 @@ interface_block:
          YYERROR;
       }
 
+      block->layout.is_default_qualifier = false;
+
       foreach_list_typed (ast_declarator_list, member, link, &block->declarations) {
          ast_type_qualifier& qualifier = member->type->qualifier;
          if (qualifier.flags.q.stream && qualifier.stream != block->layout.stream) {
index dae5261dacac49d51ab543cb45d7a3d7e5fb4b6b..7d976c26f8cf8134c29ac21bd8273a5fe8d2fae3 100644 (file)
@@ -242,6 +242,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
    this->default_uniform_qualifier = new(this) ast_type_qualifier();
    this->default_uniform_qualifier->flags.q.shared = 1;
    this->default_uniform_qualifier->flags.q.column_major = 1;
+   this->default_uniform_qualifier->is_default_qualifier = true;
 
    this->fs_uses_gl_fragcoord = false;
    this->fs_redeclares_gl_fragcoord = false;