<div dir="ltr">On 22 January 2013 00:51, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>

<br>
For now, just drop the value on the floor.<br>
<br>
Signed-off-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
---<br>
 src/glsl/ast.h          | 12 ++++++-----<br>
 src/glsl/glsl_parser.yy | 55 ++++++++++++++++++++++++++++++++++++++-----------<br>
 2 files changed, 50 insertions(+), 17 deletions(-)<br>
<br>
diff --git a/src/glsl/ast.h b/src/glsl/ast.h<br>
index bcec6bb..e525cb2 100644<br>
--- a/src/glsl/ast.h<br>
+++ b/src/glsl/ast.h<br>
@@ -804,12 +804,12 @@ public:<br>
 class ast_uniform_block : public ast_node {<br>
 public:<br>
    ast_uniform_block(ast_type_qualifier layout,<br>
-                    const char *block_name,<br>
-                    ast_declarator_list *member_list,<br>
-                     const char *instance_name)<br>
-   : layout(layout), block_name(block_name), instance_name(instance_name)<br>
+                     const char *instance_name,<br>
+                    ast_expression *array_size)<br>
+   : layout(layout), block_name(NULL), instance_name(instance_name),<br>
+     array_size(array_size)<br>
    {<br>
-      declarations.push_degenerate_list_at_head(&member_list->link);<br>
+      /* empty */<br>
    }<br>
<br>
    virtual ir_rvalue *hir(exec_list *instructions,<br>
@@ -820,6 +820,8 @@ public:<br>
    const char *instance_name;<br>
    /** List of ast_declarator_list * */<br>
    exec_list declarations;<br>
+<br>
+   ast_expression *array_size;<br></blockquote><div><br></div><div>It would be nice to have a comment here explaining that this member is NULL if the ast_uniform_block lacks array nature.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

 };<br>
 /*@}*/<br>
<br>
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy<br>
index 81ae5d5..154ce2d 100644<br>
--- a/src/glsl/glsl_parser.yy<br>
+++ b/src/glsl/glsl_parser.yy<br>
@@ -79,6 +79,7 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)<br>
    ast_case_label_list *case_label_list;<br>
    ast_case_statement *case_statement;<br>
    ast_case_statement_list *case_statement_list;<br>
+   ast_uniform_block *uniform_block;<br>
<br>
    struct {<br>
       ast_node *cond;<br>
@@ -112,7 +113,7 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)<br>
 %token STRUCT VOID_TOK WHILE<br>
 %token <identifier> IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER<br>
 %type <identifier> any_identifier<br>
-%type <identifier> instance_name_opt<br>
+%type <uniform_block> instance_name_opt<br>
 %token <real> FLOATCONSTANT<br>
 %token <n> INTCONSTANT UINTCONSTANT BOOLCONSTANT<br>
 %token <identifier> FIELD_SELECTION<br>
@@ -221,7 +222,8 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg)<br>
 %type <node> declaration<br>
 %type <node> declaration_statement<br>
 %type <node> jump_statement<br>
-%type <node> uniform_block basic_uniform_block<br>
+%type <node> uniform_block<br>
+%type <uniform_block> basic_uniform_block<br>
 %type <struct_specifier> struct_specifier<br>
 %type <declarator_list> struct_declaration_list<br>
 %type <declarator_list> struct_declaration<br>
@@ -1891,7 +1893,7 @@ uniform_block:<br>
        }<br>
        | layout_qualifier basic_uniform_block<br>
        {<br>
-          ast_uniform_block *block = (ast_uniform_block *) $2;<br>
+          ast_uniform_block *block = $2;<br>
           if (!block->layout.merge_qualifier(& @1, state, $1)) {<br>
              YYERROR;<br>
           }<br>
@@ -1902,9 +1904,10 @@ uniform_block:<br>
 basic_uniform_block:<br>
        UNIFORM NEW_IDENTIFIER '{' member_list '}' instance_name_opt ';'<br>
        {<br>
-          void *ctx = state;<br>
-          $$ = new(ctx) ast_uniform_block(*state->default_uniform_qualifier,<br>
-                                          $2, $4, $6);<br>
+          ast_uniform_block *const block = $6;<br>
+<br>
+          block->block_name = $2;<br>
+          block->declarations.push_degenerate_list_at_head(& $4->link);<br>
<br>
           if (!state->ARB_uniform_buffer_object_enable) {<br>
              _mesa_glsl_error(& @1, state,<br>
@@ -1915,21 +1918,49 @@ basic_uniform_block:<br>
                                 "#version 140 / GL_ARB_uniform_buffer_object "<br>
                                 "required for defining uniform blocks\n");<br>
           }<br>
+<br>
+          /* Since block arrays require names, and both features are added in<br>
+           * the same language versions, we don't have to explicitly<br>
+           * version-check both things.<br>
+           */<br>
+          if (block->instance_name != NULL<br>
+              && !(state->language_version == 300 && state->es_shader)) {<br></blockquote><div><br></div><div>This would be another good place to use _mesa_glsl_parse_state::is_version().  Or, if you prefer, you can use _mesa_glsl_parse_state::check_version(), which also takes care of generating an appropriate error message.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+             _mesa_glsl_error(& @1, state,<br>
+                              "#version 300 es required for using uniform "<br>
+                              "blocks with an instance name\n");<br>
+          }<br>
+<br>
+          $$ = block;<br>
        }<br>
        ;<br>
<br>
 instance_name_opt:<br>
        /* empty */<br>
        {<br>
-          $$ = NULL;<br>
+          $$ = new(state) ast_uniform_block(*state->default_uniform_qualifier,<br>
+                                            NULL,<br>
+                                            NULL);<br>
        }<br>
        | NEW_IDENTIFIER<br>
        {<br>
-          if (!(state->language_version == 300 && state->es_shader)) {<br>
-             _mesa_glsl_error(& @1, state,<br>
-                              "#version 300 es required for using uniform "<br>
-                              "blocks with an instance name\n");<br>
-          }<br>
+          $$ = new(state) ast_uniform_block(*state->default_uniform_qualifier,<br>
+                                            $1,<br>
+                                            NULL);<br>
+       }<br>
+       | NEW_IDENTIFIER '[' constant_expression ']'<br>
+       {<br>
+          $$ = new(state) ast_uniform_block(*state->default_uniform_qualifier,<br>
+                                            $1,<br>
+                                            $3);<br>
+       }<br>
+       | NEW_IDENTIFIER '[' ']'<br>
+       {<br>
+          _mesa_glsl_error(& @1, state,<br>
+                           "instance block arrays must be explicitly sized\n");<br>
+<br>
+          $$ = new(state) ast_uniform_block(*state->default_uniform_qualifier,<br>
+                                            $1,<br>
+                                            NULL);<br>
        }<br>
        ;<br>
<span class=""><font color="#888888"><br>
--<br>
1.7.11.7<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div><div class="gmail_extra">With those changes,<br><br></div><div class="gmail_extra">Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
</div></div>