[Piglit] [PATCH] glsl-1.20: Test sizing an array by initialization after the array has been accessed

Ian Romanick idr at freedesktop.org
Thu Dec 5 13:17:11 PST 2013


From: Ian Romanick <ian.d.romanick at intel.com>

The "big-enough" test verifies that the compiler accepts an initializer
can be used to size an array after an access (to the previously
implicitly size) array has been seen when the access would have been
in-bounds in the sized array.

The "too-small" test verifies that the compiler rejects an initializer
can be used to size an array after an access (to the previously
implicitly size) array has been seen when the access would have been
out-of-bounds in the sized array.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Timothy Arceri <t_arceri at yahoo.com.au>
---
 .../array-resize-after-access-big-enough.vert        | 20 ++++++++++++++++++++
 .../array-resize-after-access-too-small.vert         | 20 ++++++++++++++++++++
 2 files changed, 40 insertions(+)
 create mode 100644 tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-resize-after-access-big-enough.vert
 create mode 100644 tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-resize-after-access-too-small.vert

diff --git a/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-resize-after-access-big-enough.vert b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-resize-after-access-big-enough.vert
new file mode 100644
index 0000000..1e21b2d
--- /dev/null
+++ b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-resize-after-access-big-enough.vert
@@ -0,0 +1,20 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.20
+ * [end config]
+ */
+#version 120
+
+float x[];
+
+void foo() { x[1] = 2.; }
+
+// The array must be at least 2 elements because of the previous
+// access to x[1].
+float x[] = float[2](1., 2.);
+
+void main()
+{
+	foo();
+	gl_Position = vec4(x[0]);
+}
diff --git a/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-resize-after-access-too-small.vert b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-resize-after-access-too-small.vert
new file mode 100644
index 0000000..ebee5e6
--- /dev/null
+++ b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-resize-after-access-too-small.vert
@@ -0,0 +1,20 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.20
+ * [end config]
+ */
+#version 120
+
+float x[];
+
+void foo() { x[3] = 2.; }
+
+// The array must be at least 4 elements because of the previous
+// access to x[3].
+float x[] = float[2](1., 2.);
+
+void main()
+{
+	foo();
+	gl_Position = vec4(x[0]);
+}
-- 
1.8.1.4



More information about the Piglit mailing list