[Piglit] [PATCH 2/2] glsl: Validate structure-in-structure usage

Ian Romanick idr at freedesktop.org
Wed Jun 26 17:25:17 PDT 2013


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

Both GLSL ES 1.00 and GLSL 1.20 disallow structure declarations inside
other structure declarations.  However, both allow (previously declared)
structures inside other structures.

Mesa currently passes the GLSL ES 1.00 test, but it fails the GLSL 1.20
test.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Tom Gall <tom.gall at linaro.org>
---
 .../embedded-struct-01.vert                        | 28 ++++++++++++
 .../embedded-struct-02.vert                        | 30 +++++++++++++
 .../embedded-struct-01.vert                        | 48 +++++++++++++++++++++
 .../embedded-struct-02.vert                        | 50 ++++++++++++++++++++++
 4 files changed, 156 insertions(+)
 create mode 100644 tests/spec/glsl-1.20/compiler/structure-and-array-operations/embedded-struct-01.vert
 create mode 100644 tests/spec/glsl-1.20/compiler/structure-and-array-operations/embedded-struct-02.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/embedded-struct-01.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/embedded-struct-02.vert

diff --git a/tests/spec/glsl-1.20/compiler/structure-and-array-operations/embedded-struct-01.vert b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/embedded-struct-01.vert
new file mode 100644
index 0000000..ce86388
--- /dev/null
+++ b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/embedded-struct-01.vert
@@ -0,0 +1,28 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.20
+ * [end config]
+ *
+ * From section 4.1.8 ("Structures") of the GLSL 1.20 spec:
+ *
+ *     "Anonymous structures are not supported. Embedded structures
+ *     are not supported.
+ *
+ *         struct S { float f; };
+ *
+ *         struct T {
+ *             S;              // Error: anonymous structures disallowed
+ *             struct { ... }; // Error: embedded structures disallowed
+ *             S s;            // Okay: nested structures with name are allowed
+ *         };"
+ */
+#version 120
+
+struct T {
+    struct { float f; } s; // Error: embedded structures disallowed
+};
+
+void main()
+{
+    gl_Position = vec4(1);
+}
diff --git a/tests/spec/glsl-1.20/compiler/structure-and-array-operations/embedded-struct-02.vert b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/embedded-struct-02.vert
new file mode 100644
index 0000000..b104662
--- /dev/null
+++ b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/embedded-struct-02.vert
@@ -0,0 +1,30 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.20
+ * [end config]
+ *
+ * From section 4.1.8 ("Structures") of the GLSL 1.20 spec:
+ *
+ *     "Anonymous structures are not supported. Embedded structures
+ *     are not supported.
+ *
+ *         struct S { float f; };
+ *
+ *         struct T {
+ *             S;              // Error: anonymous structures disallowed
+ *             struct { ... }; // Error: embedded structures disallowed
+ *             S s;            // Okay: nested structures with name are allowed
+ *         };"
+ */
+#version 120
+
+struct S { float f; };
+
+struct T {
+    S s;            // Okay: nested structures with name are allowed
+};
+
+void main()
+{
+    gl_Position = vec4(1);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/embedded-struct-01.vert b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/embedded-struct-01.vert
new file mode 100644
index 0000000..06e42c7
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/embedded-struct-01.vert
@@ -0,0 +1,48 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * From section 4.1.8 ("Structures") of the GLSL ES 1.00 spec:
+ *
+ *     "Embedded structure definitions are not supported:
+ *
+ *     Example 1:
+ *
+ *         struct S
+ *         {
+ *             struct T // error: embedded structure definition is not supported.
+ *             {
+ *                 int a;
+ *             } t;
+ *             int b:
+ *         };
+ *         
+ *     Example 2:
+ *
+ *         struct T
+ *         {
+ *             int a;
+ *         };
+ *
+ *         struct S
+ *         {
+ *             T t;    // ok.
+ *             int b;
+ *         };"
+ */
+#version 100
+
+struct S
+{
+    struct T // error: embedded structure definition is not supported.
+    {
+        int a;
+    } t;
+    int b;
+};
+
+void main()
+{
+    gl_Position = vec4(1);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/embedded-struct-02.vert b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/embedded-struct-02.vert
new file mode 100644
index 0000000..82c356e
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/embedded-struct-02.vert
@@ -0,0 +1,50 @@
+/* [config]
+ * expect_result: pass
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * From section 4.1.8 ("Structures") of the GLSL ES 1.00 spec:
+ *
+ *     "Embedded structure definitions are not supported:
+ *
+ *     Example 1:
+ *
+ *         struct S
+ *         {
+ *             struct T // error: embedded structure definition is not supported.
+ *             {
+ *                 int a;
+ *             } t;
+ *             int b:
+ *         };
+ *         
+ *     Example 2:
+ *
+ *         struct T
+ *         {
+ *             int a;
+ *         };
+ *
+ *         struct S
+ *         {
+ *             T t;    // ok.
+ *             int b;
+ *         };"
+ */
+#version 100
+
+struct T
+{
+    int a;
+};
+
+struct S
+{
+    T t;    // ok.
+    int b;
+};
+
+void main()
+{
+    gl_Position = vec4(1);
+}
-- 
1.8.1.4



More information about the Piglit mailing list