[Piglit] [PATCH] Add two new tests of non-const array sizes.

Paul Berry stereotype441 at gmail.com
Mon Aug 1 16:01:56 PDT 2011


These tests exercise a bug that I'm fixing in Mesa: there should be a
compilation error (but not a crash) if an array size is specified by
an expression involving either:

- a call to a non-builtin function
- or an expression with side effects (such as an assignment).
---
 .../array-size-non-builtin-function.vert           |   18 ++++++++++++++++++
 .../array-size-with-side-effect.vert               |   19 +++++++++++++++++++
 2 files changed, 37 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-non-builtin-function.vert
 create mode 100644 tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-with-side-effect.vert

diff --git a/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-non-builtin-function.vert b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-non-builtin-function.vert
new file mode 100644
index 0000000..fc15e88
--- /dev/null
+++ b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-non-builtin-function.vert
@@ -0,0 +1,18 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.20
+ * [end config]
+ *
+ * From page 19 (page 25 of the PDF) of the GLSL 1.20 spec:
+ *
+ *     "When an array size is specified in a declaration, it must be an
+ *     integral constant expression (see Section 4.3.3 "Constant Expressions")
+ *     greater than zero."
+ */
+#version 120
+
+int foo() { return 3; }
+
+uniform vec4 [foo()] a;
+
+void main() { gl_Position = vec4(0.0); }
diff --git a/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-with-side-effect.vert b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-with-side-effect.vert
new file mode 100644
index 0000000..ccb2388
--- /dev/null
+++ b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/array-size-with-side-effect.vert
@@ -0,0 +1,19 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.20
+ * [end config]
+ *
+ * From page 19 (page 25 of the PDF) of the GLSL 1.20 spec:
+ *
+ *     "When an array size is specified in a declaration, it must be an
+ *     integral constant expression (see Section 4.3.3 "Constant Expressions")
+ *     greater than zero."
+ */
+#version 120
+
+void main()
+{
+  int x;
+  vec4[(x = 3)] a;
+  gl_Position = vec4(0.0);
+}
-- 
1.7.6



More information about the Piglit mailing list