[Piglit] [PATCH 2/2] glsl-es-3.00: Verify serveral cases of uniform blocks w/instance names

Ian Romanick idr at freedesktop.org
Sat Dec 8 12:48:03 PST 2012


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

Each specific test contains justification in a header comment block.  So
far, these are only compiler tests.  Execution tests will follow
eventually.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Kenneth Graunke <kenneth at whitecape.org>
---
 .../compiler/uniform_block/block-array.vert        | 37 ++++++++++++++++++++++
 ...terface-name-access-without-interface-name.vert | 27 ++++++++++++++++
 ...ce-name-array-access-with-noncontant-index.vert | 24 ++++++++++++++
 .../interface-name-array-access-without-index.vert | 22 +++++++++++++
 .../uniform_block/interface-name-array.vert        | 23 ++++++++++++++
 .../uniform_block/interface-name-basic.vert        | 23 ++++++++++++++
 ...interface-name-field-clashes-with-function.vert | 35 ++++++++++++++++++++
 .../interface-name-field-clashes-with-struct.vert  | 34 ++++++++++++++++++++
 ...interface-name-field-clashes-with-variable.vert | 32 +++++++++++++++++++
 9 files changed, 257 insertions(+)
 create mode 100644 tests/spec/glsl-es-3.00/compiler/uniform_block/block-array.vert
 create mode 100644 tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-access-without-interface-name.vert
 create mode 100644 tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-array-access-with-noncontant-index.vert
 create mode 100644 tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-array-access-without-index.vert
 create mode 100644 tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-array.vert
 create mode 100644 tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-basic.vert
 create mode 100644 tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-field-clashes-with-function.vert
 create mode 100644 tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-field-clashes-with-struct.vert
 create mode 100644 tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-field-clashes-with-variable.vert

diff --git a/tests/spec/glsl-es-3.00/compiler/uniform_block/block-array.vert b/tests/spec/glsl-es-3.00/compiler/uniform_block/block-array.vert
new file mode 100644
index 0000000..ebcf2a4
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/uniform_block/block-array.vert
@@ -0,0 +1,37 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 3.00 es
+ * [end config]
+ *
+ * The GLSL ES 3.00 spec says:
+ *
+ * "interface-block:
+ *     layout-qualifieropt uniform block-name { member-list } instance-nameopt ;
+ *
+ * ...
+ *
+ * instance-name:
+ *     identifier
+ *     identifier [ constant-integral-expression ]"
+ *
+ * If an interface name is not specified, it is impossible to specify an array
+ * size.
+ */
+#version 300 es
+
+uniform transform_data {
+  mat4 mvp;
+  mat3 mv_for_normals;
+} [2];
+
+in vec4 position;
+in vec3 normal;
+
+// normal vector in camera space
+out vec3 normal_cs;
+
+void main()
+{
+  gl_Position = mvp * position;
+  normal_cs = mv_for_normals * normal;
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-access-without-interface-name.vert b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-access-without-interface-name.vert
new file mode 100644
index 0000000..3309768
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-access-without-interface-name.vert
@@ -0,0 +1,27 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 3.00 es
+ * [end config]
+ *
+ * The GLSL ES 3.00 spec says:
+ *
+ *     "If an instance name (instance-name) is used, then it puts all the
+ *     members inside a scope within its own name space, accessed with the
+ *     field selector ( . ) operator (analogously to structures)."
+ *
+ * Accesses to a field of a uniform block that was declared with an instance
+ * name therefore must use that instance name.  Otherwise an error should be
+ * generated.
+ */
+#version 300 es
+
+uniform transform_data {
+  mat4 mvp;
+} camera;
+
+in vec4 position;
+
+void main()
+{
+  gl_Position = mvp * position;
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-array-access-with-noncontant-index.vert b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-array-access-with-noncontant-index.vert
new file mode 100644
index 0000000..cdf7b0e
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-array-access-with-noncontant-index.vert
@@ -0,0 +1,24 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 3.00 es
+ * [end config]
+ *
+ * The GLSL ES 3.00 spec says:
+ *
+ *     "All indexes used to index a uniform block array must be constant
+ *     integral expressions."
+ */
+#version 300 es
+
+uniform transform_data {
+  mat4 mvp;
+} camera[2];
+
+uniform int idx;
+
+in vec4 position;
+
+void main()
+{
+  gl_Position = camera[idx].mvp * position;
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-array-access-without-index.vert b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-array-access-without-index.vert
new file mode 100644
index 0000000..6bf97dc
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-array-access-without-index.vert
@@ -0,0 +1,22 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 3.00 es
+ * [end config]
+ *
+ * The GLSL ES 3.00 spec says:
+ *
+ *     "For blocks declared as arrays, the array index must also be included
+ *     when accessing members..."
+ */
+#version 300 es
+
+uniform transform_data {
+  mat4 mvp;
+} camera[2];
+
+in vec4 position;
+
+void main()
+{
+  gl_Position = camera.mvp * position;
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-array.vert b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-array.vert
new file mode 100644
index 0000000..511fc53
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-array.vert
@@ -0,0 +1,23 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 3.00 es
+ * [end config]
+ */
+#version 300 es
+
+uniform transform_data {
+  mat4 mvp;
+  mat3 mv_for_normals;
+} camera[2];
+
+in vec4 position;
+in vec3 normal;
+
+// normal vector in camera space
+out vec3 normal_cs;
+
+void main()
+{
+  gl_Position = camera[0].mvp * position;
+  normal_cs = camera[1].mv_for_normals * normal;
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-basic.vert b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-basic.vert
new file mode 100644
index 0000000..16d55bd
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-basic.vert
@@ -0,0 +1,23 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 3.00 es
+ * [end config]
+ */
+#version 300 es
+
+uniform transform_data {
+  mat4 mvp;
+  mat3 mv_for_normals;
+} camera;
+
+in vec4 position;
+in vec3 normal;
+
+// normal vector in camera space
+out vec3 normal_cs;
+
+void main()
+{
+  gl_Position = camera.mvp * position;
+  normal_cs = camera.mv_for_normals * normal;
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-field-clashes-with-function.vert b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-field-clashes-with-function.vert
new file mode 100644
index 0000000..898b6d7
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-field-clashes-with-function.vert
@@ -0,0 +1,35 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 3.00 es
+ * [end config]
+ *
+ * The GLSL ES 3.00 spec says:
+ *
+ *     "If an instance name (instance-name) is used, then it puts all the
+ *     members inside a scope within its own name space..."
+ */
+#version 300 es
+
+uniform transform_data {
+  mat4 mvp;
+  mat3 mv_for_normals;
+} camera;
+
+in vec4 position;
+in vec3 normal;
+
+// normal vector in camera space
+out vec3 normal_cs;
+
+// Since the uniform block has an instance name, its mvp field does
+// not actually conflict with this function.
+mat4 mvp(void)
+{
+  return mat4(1.);
+}
+
+void main()
+{
+  gl_Position = camera.mvp * position;
+  normal_cs = camera.mv_for_normals * normal;
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-field-clashes-with-struct.vert b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-field-clashes-with-struct.vert
new file mode 100644
index 0000000..ae7400b
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-field-clashes-with-struct.vert
@@ -0,0 +1,34 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 3.00 es
+ * [end config]
+ *
+ * The GLSL ES 3.00 spec says:
+ *
+ *     "If an instance name (instance-name) is used, then it puts all the
+ *     members inside a scope within its own name space..."
+ */
+#version 300 es
+
+uniform transform_data {
+  mat4 mvp;
+  mat3 mv_for_normals;
+} camera;
+
+in vec4 position;
+in vec3 normal;
+
+// normal vector in camera space
+out vec3 normal_cs;
+
+// Since the uniform block has an instance name, its mvp field does
+// not actually conflict with this structure.
+struct mvp {
+  mat4 real_mvp;
+};
+
+void main()
+{
+  gl_Position = camera.mvp * position;
+  normal_cs = camera.mv_for_normals * normal;
+}
diff --git a/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-field-clashes-with-variable.vert b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-field-clashes-with-variable.vert
new file mode 100644
index 0000000..4e3102e
--- /dev/null
+++ b/tests/spec/glsl-es-3.00/compiler/uniform_block/interface-name-field-clashes-with-variable.vert
@@ -0,0 +1,32 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 3.00 es
+ * [end config]
+ *
+ * The GLSL ES 3.00 spec says:
+ *
+ *     "If an instance name (instance-name) is used, then it puts all the
+ *     members inside a scope within its own name space..."
+ */
+#version 300 es
+
+uniform transform_data {
+  mat4 mvp;
+  mat3 mv_for_normals;
+} camera;
+
+in vec4 position;
+in vec3 normal;
+
+// normal vector in camera space
+out vec3 normal_cs;
+
+// Since the uniform block has an instance name, its mvp field does
+// not actually conflict with this global.
+mat4 mvp;
+
+void main()
+{
+  gl_Position = camera.mvp * position;
+  normal_cs = camera.mv_for_normals * normal;
+}
-- 
1.7.11.7



More information about the Piglit mailing list