[Piglit] [PATCH] glsl-1.50: Test illegal uses of unsized arrays in interface blocks.

Paul Berry stereotype441 at gmail.com
Fri Sep 27 13:37:30 PDT 2013


These tests verify that unsized arrays appearing inside interface
blocks are subject to the same restrictions as unsized arrays
appearing outside interface blocks (e.g. they can't be used in bulk
assignment, they don't support .length(), and they can't be accessed
using a non-constant index).

Since it's likely that these restrictions are enforced by the same
code as for unsized arrays appearing outside of interface blocks,
these are just a few touch tests; we don't exhaustively test all
possible types of access in every shader type.
---
 ...ment-to-unsized-array-in-unnamed-ifc-block.vert | 27 ++++++++++++++++++++++
 ...length-of-unsized-array-in-array-ifc-block.geom | 27 ++++++++++++++++++++++
 ...access-to-unsized-array-in-named-ifc-block.frag | 23 ++++++++++++++++++
 3 files changed, 77 insertions(+)
 create mode 100644 tests/spec/glsl-1.50/compiler/illegal-assignment-to-unsized-array-in-unnamed-ifc-block.vert
 create mode 100644 tests/spec/glsl-1.50/compiler/illegal-length-of-unsized-array-in-array-ifc-block.geom
 create mode 100644 tests/spec/glsl-1.50/compiler/illegal-nonconst-access-to-unsized-array-in-named-ifc-block.frag

diff --git a/tests/spec/glsl-1.50/compiler/illegal-assignment-to-unsized-array-in-unnamed-ifc-block.vert b/tests/spec/glsl-1.50/compiler/illegal-assignment-to-unsized-array-in-unnamed-ifc-block.vert
new file mode 100644
index 0000000..7df2868
--- /dev/null
+++ b/tests/spec/glsl-1.50/compiler/illegal-assignment-to-unsized-array-in-unnamed-ifc-block.vert
@@ -0,0 +1,27 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// check_link: true
+// [end config]
+//
+// Test that if an interface block contains an unsized array, it is
+// illegal to use it as the LHS of a bulk assignment (even if both the
+// LHS and the RHS of the assignment have the same implied array
+// size).
+//
+// This test uses an unnamed interface block.
+
+#version 150
+
+out block {
+  float foo[];
+};
+
+void main()
+{
+  float bar[];
+  bar[0] = 1.0;
+  bar[1] = 2.0;
+  foo = bar;
+  foo[1] = 3.0;
+}
diff --git a/tests/spec/glsl-1.50/compiler/illegal-length-of-unsized-array-in-array-ifc-block.geom b/tests/spec/glsl-1.50/compiler/illegal-length-of-unsized-array-in-array-ifc-block.geom
new file mode 100644
index 0000000..e00bc24
--- /dev/null
+++ b/tests/spec/glsl-1.50/compiler/illegal-length-of-unsized-array-in-array-ifc-block.geom
@@ -0,0 +1,27 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// check_link: true
+// [end config]
+//
+// Test that if an interface block contains an unsized array, it is
+// illegal to call .length() on it.
+//
+// This test uses an interface block array.
+
+#version 150
+
+layout(triangles) in;
+layout(points, max_vertices = 1) out;
+
+in block {
+  float foo[];
+} inst[];
+
+out vec2 bar;
+
+void main()
+{
+  bar = vec2(inst[0].foo[0], inst[0].foo.length());
+  EmitVertex();
+}
diff --git a/tests/spec/glsl-1.50/compiler/illegal-nonconst-access-to-unsized-array-in-named-ifc-block.frag b/tests/spec/glsl-1.50/compiler/illegal-nonconst-access-to-unsized-array-in-named-ifc-block.frag
new file mode 100644
index 0000000..c5f0e92
--- /dev/null
+++ b/tests/spec/glsl-1.50/compiler/illegal-nonconst-access-to-unsized-array-in-named-ifc-block.frag
@@ -0,0 +1,23 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// check_link: true
+// [end config]
+//
+// Test that if an interface block contains an unsized array, it is
+// illegal to access it using a non-constant index.
+//
+// This test uses a named interface block.
+
+#version 150
+
+in block {
+  float foo[];
+} inst;
+
+uniform int bar;
+
+void main()
+{
+  gl_FragColor = vec4(inst.foo[bar]);
+}
-- 
1.8.4



More information about the Piglit mailing list