[Piglit] [PATCH] glsl-1.50: Test compilation of interface blocks containing unsized arrays.

Paul Berry stereotype441 at gmail.com
Sat Sep 21 11:22:17 PDT 2013


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 compiler tests to verify that in and out blocks can
contain unsized arrays.

Verified using the NVIDIA proprietary driver for Linux.
---
 ...interface-blocks-containing-unsized-arrays.frag | 20 ++++++++++++++++
 ...interface-blocks-containing-unsized-arrays.geom | 27 ++++++++++++++++++++++
 ...interface-blocks-containing-unsized-arrays.vert | 20 ++++++++++++++++
 3 files changed, 67 insertions(+)
 create mode 100644 tests/spec/glsl-1.50/compiler/interface-blocks-containing-unsized-arrays.frag
 create mode 100644 tests/spec/glsl-1.50/compiler/interface-blocks-containing-unsized-arrays.geom
 create mode 100644 tests/spec/glsl-1.50/compiler/interface-blocks-containing-unsized-arrays.vert

diff --git a/tests/spec/glsl-1.50/compiler/interface-blocks-containing-unsized-arrays.frag b/tests/spec/glsl-1.50/compiler/interface-blocks-containing-unsized-arrays.frag
new file mode 100644
index 0000000..2c31c0c
--- /dev/null
+++ b/tests/spec/glsl-1.50/compiler/interface-blocks-containing-unsized-arrays.frag
@@ -0,0 +1,20 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.50
+// check_link: true
+// [end config]
+//
+// Test that an interface block may contain members which are unsized
+// arrays.  Both GLSL 1.10 and GLSL 1.20 style array declarations are
+// tested.
+
+#version 150
+
+in block {
+  float foo[];
+  float[] bar;
+} inst;
+
+void main()
+{
+}
diff --git a/tests/spec/glsl-1.50/compiler/interface-blocks-containing-unsized-arrays.geom b/tests/spec/glsl-1.50/compiler/interface-blocks-containing-unsized-arrays.geom
new file mode 100644
index 0000000..169122d
--- /dev/null
+++ b/tests/spec/glsl-1.50/compiler/interface-blocks-containing-unsized-arrays.geom
@@ -0,0 +1,27 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.50
+// check_link: true
+// [end config]
+//
+// Test that an interface block may contain members which are unsized
+// arrays.  Both GLSL 1.10 and GLSL 1.20 style array declarations are
+// tested.
+
+#version 150
+layout(triangles) in;
+layout(triangle_strip, max_vertices = 3) out;
+
+in block {
+  float foo[];
+  float[] bar;
+} inst_in[];
+
+out block {
+  float foo[];
+  float[] bar;
+} inst_out;
+
+void main()
+{
+}
diff --git a/tests/spec/glsl-1.50/compiler/interface-blocks-containing-unsized-arrays.vert b/tests/spec/glsl-1.50/compiler/interface-blocks-containing-unsized-arrays.vert
new file mode 100644
index 0000000..ac0d495
--- /dev/null
+++ b/tests/spec/glsl-1.50/compiler/interface-blocks-containing-unsized-arrays.vert
@@ -0,0 +1,20 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.50
+// check_link: true
+// [end config]
+//
+// Test that an interface block may contain members which are unsized
+// arrays.  Both GLSL 1.10 and GLSL 1.20 style array declarations are
+// tested.
+
+#version 150
+
+out block {
+  float foo[];
+  float[] bar;
+} inst;
+
+void main()
+{
+}
-- 
1.8.4



More information about the Piglit mailing list