[09/10] glsl-es-1.00: array fn, array structure and redeclaration tests

Message ID 1367013224-21359-9-git-send-email-tom.gall@linaro.org
State New
Headers show

Commit Message

Tom Gall April 26, 2013, 9:53 p.m.
Add to tests/spec/glsl-es-1.00/compiler/structure-and-array-operations
glslparser tests for array declarations, array of structures and
redeclarations.

Signed-off-by: Tom Gall <tom.gall@linaro.org>
---
 .../array-of-any-type.vert                         |   43 ++++++++++++++++++++
 ...ay-of-array-function-parameter-declaration.frag |   19 +++++++++
 ...ay-of-array-function-parameter-declaration.vert |   19 +++++++++
 ...ray-of-array-function-parameter-definition.frag |   22 ++++++++++
 ...ray-of-array-function-parameter-definition.vert |   22 ++++++++++
 .../array-of-array-structure-field.frag            |   21 ++++++++++
 .../array-of-array-structure-field.vert            |   21 ++++++++++
 .../array-of-struct-of-array.vert                  |   21 ++++++++++
 .../array-of-struct.vert                           |   21 ++++++++++
 .../array-redeclaration-01.vert                    |   36 ++++++++++++++++
 .../array-redeclaration-initializer.vert           |   33 +++++++++++++++
 .../array-redeclaration-too-small.vert             |   33 +++++++++++++++
 .../array-redeclaration-wrong-base-type.vert       |   34 ++++++++++++++++
 .../array-shadow-redeclaration.vert                |   29 +++++++++++++
 14 files changed, 374 insertions(+)
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-any-type.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-declaration.frag
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-declaration.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-definition.frag
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-definition.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-structure-field.frag
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-structure-field.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-struct-of-array.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-struct.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-01.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-initializer.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-too-small.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-wrong-base-type.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-shadow-redeclaration.vert

Patch

diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-any-type.vert b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-any-type.vert
new file mode 100644
index 0000000..35b8a0a
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-any-type.vert
@@ -0,0 +1,43 @@ 
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * From page 24 of the GLSL ES 1.00.17 spec:
+ *
+ *     "All basic types and structures can be formed into arrays."
+ */
+
+
+uniform float array01[1];
+uniform int array02[1];
+uniform bool array03[1];
+uniform vec2 array04[1];
+uniform vec3 array05[1];
+uniform vec4 array06[1];
+uniform ivec2 array07[1];
+uniform ivec3 array08[1];
+uniform ivec4 array09[1];
+uniform bvec2 array10[1];
+uniform bvec3 array11[1];
+uniform bvec4 array12[1];
+uniform mat2 array13[1];
+uniform mat2x2 array14[1];
+uniform mat2x3 array15[1];
+uniform mat2x4 array16[1];
+uniform mat3 array17[1];
+uniform mat3x2 array18[1];
+uniform mat3x3 array19[1];
+uniform mat3x4 array20[1];
+uniform mat4 array21[1];
+uniform mat4x2 array22[1];
+uniform mat4x3 array23[1];
+uniform mat4x4 array24[1];
+uniform sampler1D array25[1];
+uniform sampler2D array26[1];
+uniform sampler3D array27[1];
+uniform samplerCube array28[1];
+uniform sampler1DShadow array29[1];
+uniform sampler2DShadow array30[1];
+
+void main() { gl_Position = vec4(0.0); }
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-declaration.frag b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-declaration.frag
new file mode 100644
index 0000000..5a8c086
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-declaration.frag
@@ -0,0 +1,19 @@ 
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * From page 24 of the GLSL ES 1.00.17 spec:
+ *
+ *     "Only one-dimensional arrays may be declared."
+ */
+
+
+attribute vec4 vert;
+
+void foo(vec4 [2] x[2]);
+
+void main()
+{
+  gl_FragData[0] = vec4(0.0);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-declaration.vert b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-declaration.vert
new file mode 100644
index 0000000..54e972f
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-declaration.vert
@@ -0,0 +1,19 @@ 
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * From page 24 of the GLSL ES 1.00.17 spec:
+ *
+ *     "Only one-dimensional arrays may be declared."
+ */
+
+
+attribute vec4 vert;
+
+void foo(vec4 [2] x[2]);
+
+void main()
+{
+  gl_Position = vert;
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-definition.frag b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-definition.frag
new file mode 100644
index 0000000..4dde84f
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-definition.frag
@@ -0,0 +1,22 @@ 
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * From page 24 of the GLSL ES 1.00 spec:
+ *
+ *     "Only one-dimensional arrays may be declared."
+ */
+
+
+attribute vec4 vert;
+
+void foo(vec4 [2] x[2])
+{
+  gl_Position = vert;
+}
+
+void main()
+{
+  gl_FragData[0] = vec4(0.0);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-definition.vert b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-definition.vert
new file mode 100644
index 0000000..b19d95f
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-function-parameter-definition.vert
@@ -0,0 +1,22 @@ 
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * From page 24 of the GLSL ES 1.00 spec:
+ *
+ *     "Only one-dimensional arrays may be declared."
+ */
+
+
+attribute vec4 vert;
+
+void foo(vec4 [2] x[2])
+{
+  gl_Position = vert;
+}
+
+void main()
+{
+  gl_Position = vert;
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-structure-field.frag b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-structure-field.frag
new file mode 100644
index 0000000..8cf163f
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-structure-field.frag
@@ -0,0 +1,21 @@ 
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * From page 24 of the GLSL ES 1.00 spec:
+ *
+ *     "Only one-dimensional arrays may be declared."
+ */
+
+
+attribute vec4 vert;
+
+struct S {
+  vec4 [2] x[2];
+};
+
+void main()
+{
+  gl_FragData[0] = vec4(0.0);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-structure-field.vert b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-structure-field.vert
new file mode 100644
index 0000000..cab65c5
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-array-structure-field.vert
@@ -0,0 +1,21 @@ 
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * From page 24 of the GLSL ES 1.00 spec:
+ *
+ *     "Only one-dimensional arrays may be declared."
+ */
+
+
+attribute vec4 vert;
+
+struct S {
+  vec4 [2] x[2];
+};
+
+void main()
+{
+  gl_Position = vert;
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-struct-of-array.vert b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-struct-of-array.vert
new file mode 100644
index 0000000..1036068
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-struct-of-array.vert
@@ -0,0 +1,21 @@ 
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * From page 24 of the GLSL ES 1.00.17 spec:
+ *
+ *     "All basic types and structures can be formed into arrays."
+ */
+
+
+struct s {
+  float x[3];
+  int y;
+};
+
+void main()
+{
+  s a[2];
+  gl_Position = vec4(a.length() + a.x.length());
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-struct.vert b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-struct.vert
new file mode 100644
index 0000000..19409c0
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-of-struct.vert
@@ -0,0 +1,21 @@ 
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * From page 24 of the GLSL ES 1.00.17 spec:
+ *
+ *     "All basic types and structures can be formed into arrays."
+ */
+
+
+struct s {
+  float x;
+  int y;
+};
+
+void main()
+{
+  s a[2];
+  gl_Position = vec4(a.length());
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-01.vert b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-01.vert
new file mode 100644
index 0000000..db0ab6b
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-01.vert
@@ -0,0 +1,36 @@ 
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Page 24, GLSL ES 1.00.17 spec:
+ *
+ * " The array size must be an integral constant expression (see Section 4.3.3
+ *   "Integral Constant Expressions") greater than zero."
+ *
+ * Further Section 10.17 Unsized Array Declarations on page 93 states:
+ *
+ * "gl_TexCoord is part of fixed functionality so unsigned arrays should be
+ *  removed for GLSL ES
+ *
+ *  RESOLUTION: Remove unsized array declarations"
+ */
+
+
+float a_function(vec4[6]);
+
+void main()
+{
+  vec4 [] an_array;
+
+  an_array[0] = vec4(0);
+  an_array[1] = vec4(1);
+  an_array[2] = vec4(2);
+  an_array[3] = vec4(3);
+  an_array[4] = vec4(4);
+  an_array[5] = vec4(5);
+
+  vec4 [6] an_array;
+
+  gl_Position = vec4(a_function(an_array));
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-initializer.vert b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-initializer.vert
new file mode 100644
index 0000000..02ad37b
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-initializer.vert
@@ -0,0 +1,33 @@ 
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Page 24, GLSL ES 1.00.17 spec:
+ *
+ * " The array size must be an integral constant expression (see Section 4.3.3
+ *   "Integral Constant Expressions") greater than zero."
+ *
+ * Further Section 10.17 Unsized Array Declarations on page 93 states:
+ *
+ * "gl_TexCoord is part of fixed functionality so unsigned arrays should be
+ *  removed for GLSL ES
+ *
+ *  RESOLUTION: Remove unsized array declarations"
+ */
+
+
+float a_function(float[3]);
+
+void main()
+{
+  float [] an_array;
+
+  an_array[0] = 0.0;
+  an_array[1] = 1.0;
+  an_array[2] = 2.0;
+
+  float [] an_array = float[](2.0, 1.0, 0.0);
+
+  gl_Position = vec4(a_function(an_array));
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-too-small.vert b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-too-small.vert
new file mode 100644
index 0000000..6ed8a05
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-too-small.vert
@@ -0,0 +1,33 @@ 
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Page 24, GLSL ES 1.00.17 spec:
+ *
+ * " The array size must be an integral constant expression (see Section 4.3.3
+ *   "Integral Constant Expressions") greater than zero."
+ *
+ * Further Section 10.17 Unsized Array Declarations on page 93 states:
+ *
+ * "gl_TexCoord is part of fixed functionality so unsigned arrays should be
+ *  removed for GLSL ES
+ *
+ *  RESOLUTION: Remove unsized array declarations"
+ */
+
+
+float a_function(float[2]);
+
+void main()
+{
+  float [] an_array;
+
+  an_array[0] = 0.0;
+  an_array[1] = 1.0;
+  an_array[2] = 2.0;
+
+  float [2] an_array;
+
+  gl_Position = vec4(a_function(an_array));
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-wrong-base-type.vert b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-wrong-base-type.vert
new file mode 100644
index 0000000..c41b23c
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-redeclaration-wrong-base-type.vert
@@ -0,0 +1,34 @@ 
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Page 24, GLSL ES 1.00.17 spec:
+ *
+ * " The array size must be an integral constant expression (see Section 4.3.3
+ *   "Integral Constant Expressions") greater than zero."
+ *
+ * Further Section 10.17 Unsized Array Declarations on page 93 states:
+ *
+ * "gl_TexCoord is part of fixed functionality so unsigned arrays should be
+ *  removed for GLSL ES
+ *
+ *  RESOLUTION: Remove unsized array declarations"
+ */
+
+
+float a_function(float[3]);
+float a_function(vec4[3]);
+
+void main()
+{
+  float [] an_array;
+
+  an_array[0] = 0.0;
+  an_array[1] = 1.0;
+  an_array[2] = 2.0;
+
+  vec4 [3] an_array;
+
+  gl_Position = vec4(a_function(an_array));
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-shadow-redeclaration.vert b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-shadow-redeclaration.vert
new file mode 100644
index 0000000..38b1133
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/array-shadow-redeclaration.vert
@@ -0,0 +1,29 @@ 
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * Page 26 of the GLSL ES 1.00.17 spec:
+ *
+ * "Within a compilation unit a variable with the same name cannot
+ * be re-declared in the same scope. However a nested scope can
+ * override an outer scope's declaration of a particular variable name."
+ */
+
+
+attribute vec4 v;
+
+void main()
+{
+  float a[];
+
+  a[3] = 1.2;   // Implicitly size "a" to have 4 elements.
+
+  {
+    float a[4]; // this declaration shadows the previous
+  }
+
+  a.length();   // illegal - "a' is not explicitly sized
+
+  gl_Position = v;
+}