Mesa (master): glsl: Add parser support for unsized arrays in interface blocks.

Paul Berry stereotype441 at kemper.freedesktop.org
Wed Oct 9 23:50:54 UTC 2013


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

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Sat Sep 21 11:24:12 2013 -0700

glsl: Add parser support for unsized arrays in interface blocks.

Although it's not explicitly stated in the GLSL 1.50 spec, unsized
arrays are allowed in interface blocks.

section 1.2.3 (Changes from revision 5 of version 1.5) of the GLSL
1.50 spec says:

    * Completed full update to grammar section.  Tested spec examples
      against it:

      ...

      * add unsized arrays for block members

And section 7.1 (Vertex and Geometry Shader Special Variables)
includes an unsized array in the built-in gl_PerVertex interface
block:

    out gl_PerVertex {
        vec4 gl_Position;
        float gl_PointSize;
        float gl_ClipDistance[];
    };

Furthermore, GLSL 4.30 contains an example of an unsized array
occurring inside an interface block.  From section 4.3.9 (Interface
Blocks):

    uniform Transform {  // API uses "Transform[2]" to refer to instance 2
        mat4           ModelViewMatrix;
        mat4           ModelViewProjectionMatrix;
        vec4           a[];  // array will get implicitly sized
        float          Deformation;
    } transforms[4];

This patch adds the parser rule to support unsized arrays inside
interface blocks.  Later patches in the series will add the
appropriate semantics to handle them.

Fixes piglit tests:
- spec/glsl-1.50/execution/unsized-in-unnamed-interface-block
- spec/glsl-1.50/linker/unsized-in-unnamed-interface-block

Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

---

 src/glsl/glsl_parser.yy |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 912931a..a1d593f 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1752,6 +1752,12 @@ struct_declarator:
       $$ = new(ctx) ast_declaration($1, false, NULL, NULL);
       $$->set_location(yylloc);
    }
+   | any_identifier '[' ']'
+   {
+      void *ctx = state;
+      $$ = new(ctx) ast_declaration($1, true, NULL, NULL);
+      $$->set_location(yylloc);
+   }
    | any_identifier '[' constant_expression ']'
    {
       void *ctx = state;




More information about the mesa-commit mailing list