[Mesa-dev] [PATCH 05/32] glsl: Parse non-array uniform block instance names in GLSL ES 3.00.

Paul Berry stereotype441 at gmail.com
Wed Jan 23 13:43:52 PST 2013


On 22 January 2013 00:51, Ian Romanick <idr at freedesktop.org> wrote:

> From: Kenneth Graunke <kenneth at whitecape.org>
>
> In GLSL ES 3.00 (and GLSL 1.50), uniform blocks can have an associated
> "instance name", which essentially namespaces the variables inside.
>
> This patch adds basic parsing for this new feature, but doesn't yet hook
> it up to actually do anything yet.
>
> It does not support for arrays of interface blocks; a later commit will
> take care of that.
>
> This change temporarily regresses the piglit test
> interface-name-access-without-interface-name.vert.  This shader failed
> to compile before (the expected result), but it failed to compile for
> the wrong reason.  This is not a real regression.
> ---
>  src/glsl/ast.h          |  6 ++++--
>  src/glsl/glsl_parser.yy | 20 ++++++++++++++++++--
>  2 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/src/glsl/ast.h b/src/glsl/ast.h
> index 5074782..bcec6bb 100644
> --- a/src/glsl/ast.h
> +++ b/src/glsl/ast.h
> @@ -805,8 +805,9 @@ class ast_uniform_block : public ast_node {
>  public:
>     ast_uniform_block(ast_type_qualifier layout,
>                      const char *block_name,
> -                    ast_declarator_list *member_list)
> -   : layout(layout), block_name(block_name)
> +                    ast_declarator_list *member_list,
> +                     const char *instance_name)
> +   : layout(layout), block_name(block_name), instance_name(instance_name)
>     {
>        declarations.push_degenerate_list_at_head(&member_list->link);
>     }
> @@ -816,6 +817,7 @@ public:
>
>     ast_type_qualifier layout;
>     const char *block_name;
> +   const char *instance_name;
>

It would be nice to have a comment above this field explaining that
instance_name is NULL if there is no instance name.


>     /** List of ast_declarator_list * */
>     exec_list declarations;
>  };
> diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
> index 1617366..81ae5d5 100644
> --- a/src/glsl/glsl_parser.yy
> +++ b/src/glsl/glsl_parser.yy
> @@ -112,6 +112,7 @@ static void yyerror(YYLTYPE *loc,
> _mesa_glsl_parse_state *st, const char *msg)
>  %token STRUCT VOID_TOK WHILE
>  %token <identifier> IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER
>  %type <identifier> any_identifier
> +%type <identifier> instance_name_opt
>  %token <real> FLOATCONSTANT
>  %token <n> INTCONSTANT UINTCONSTANT BOOLCONSTANT
>  %token <identifier> FIELD_SELECTION
> @@ -1899,11 +1900,11 @@ uniform_block:
>         ;
>
>  basic_uniform_block:
> -       UNIFORM NEW_IDENTIFIER '{' member_list '}' ';'
> +       UNIFORM NEW_IDENTIFIER '{' member_list '}' instance_name_opt ';'
>         {
>            void *ctx = state;
>            $$ = new(ctx)
> ast_uniform_block(*state->default_uniform_qualifier,
> -                                          $2, $4);
> +                                          $2, $4, $6);
>
>            if (!state->ARB_uniform_buffer_object_enable) {
>               _mesa_glsl_error(& @1, state,
> @@ -1917,6 +1918,21 @@ basic_uniform_block:
>         }
>         ;
>
> +instance_name_opt:
> +       /* empty */
> +       {
> +          $$ = NULL;
> +       }
> +       | NEW_IDENTIFIER
> +       {
> +          if (!(state->language_version == 300 && state->es_shader)) {
>

I've been trying to replace ad-hoc cheks like this with calls to a common
function that does the same job:

if (!state->is_version(150, 300)) {


> +             _mesa_glsl_error(& @1, state,
> +                              "#version 300 es required for using uniform
> "
> +                              "blocks with an instance name\n");
> +          }
> +       }
> +       ;
> +
>  member_list:
>         member_declaration
>         {
> --
> 1.7.11.7
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>

With those two minor changes, this patch is:

Reviewed-by: Paul Berry <stereotype441 at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130123/de548b1e/attachment-0001.html>


More information about the mesa-dev mailing list