[Piglit] [PATCH] glsl-1.20: Test that a literal array of structs can be dereferenced.

Paul Berry stereotype441 at gmail.com
Sun Jul 14 09:26:17 PDT 2013


A bug currently in Mesa (as of commit b616d01) causes these tests to
segfault.
---
 .../fs-deref-literal-array-of-structs.shader_test  | 38 ++++++++++++++++++++++
 .../vs-deref-literal-array-of-structs.shader_test  | 33 +++++++++++++++++++
 2 files changed, 71 insertions(+)
 create mode 100644 tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs.shader_test
 create mode 100644 tests/spec/glsl-1.20/execution/vs-deref-literal-array-of-structs.shader_test

diff --git a/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs.shader_test b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs.shader_test
new file mode 100644
index 0000000..07c0f9b
--- /dev/null
+++ b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs.shader_test
@@ -0,0 +1,38 @@
+# Verify that an array of structs appearing in the shader as a literal
+# can be successfully dereferenced to access the values inside the
+# structs.
+
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+void main()
+{
+  gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+struct Foo {
+  int value;
+};
+
+uniform int i;
+uniform int expected_value;
+
+void main()
+{
+  int actual_value = Foo[2](Foo(100), Foo(200))[i].value;
+  if (actual_value == expected_value)
+    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[test]
+uniform int i 0
+uniform int expected_value 100
+draw rect -1 -1 2 1
+uniform int i 1
+uniform int expected_value 200
+draw rect -1 0 2 1
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/glsl-1.20/execution/vs-deref-literal-array-of-structs.shader_test b/tests/spec/glsl-1.20/execution/vs-deref-literal-array-of-structs.shader_test
new file mode 100644
index 0000000..efad1be
--- /dev/null
+++ b/tests/spec/glsl-1.20/execution/vs-deref-literal-array-of-structs.shader_test
@@ -0,0 +1,33 @@
+# Verify that an array of structs appearing in the shader as a literal
+# can be successfully dereferenced to access the values inside the
+# structs.
+
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+struct Foo {
+  int value;
+};
+
+uniform int i;
+uniform int expected_value;
+
+void main()
+{
+  gl_Position = gl_Vertex;
+  int actual_value = Foo[2](Foo(100), Foo(200))[i].value;
+  if (actual_value == expected_value)
+    gl_FrontColor = vec4(0.0, 1.0, 0.0, 1.0);
+  else
+    gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[test]
+uniform int i 0
+uniform int expected_value 100
+draw rect -1 -1 2 1
+uniform int i 1
+uniform int expected_value 200
+draw rect -1 0 2 1
+probe all rgba 0.0 1.0 0.0 1.0
-- 
1.8.3.2



More information about the Piglit mailing list