summaryrefslogtreecommitdiff
path: root/tests/spec/glsl-1.20/execution
diff options
context:
space:
mode:
authorTimothy Arceri <tarceri@itsqueeze.com>2017-06-30 14:25:13 +1000
committerTimothy Arceri <tarceri@itsqueeze.com>2017-07-03 08:22:02 +1000
commitc8f4fd9eeb298a2ef0855927f22634f794ef3eff (patch)
tree7c64e4b8aecaff4e7eb7a7aba8889dd717d53950 /tests/spec/glsl-1.20/execution
parent851cd414ef40e6bcadd4f78d40b1f05910ef629c (diff)
glsl-1.20: better test indirect indexing of literal array of structs
This exposes some existing bugs in gallium and also provides more coverage for when we start packing uniforms. Reviewed-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'tests/spec/glsl-1.20/execution')
-rw-r--r--tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-vec4-member.shader_test39
-rw-r--r--tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members-large-array.shader_test57
-rw-r--r--tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members.shader_test44
3 files changed, 140 insertions, 0 deletions
diff --git a/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-vec4-member.shader_test b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-vec4-member.shader_test
new file mode 100644
index 000000000..a403f6f79
--- /dev/null
+++ b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-vec4-member.shader_test
@@ -0,0 +1,39 @@
+# 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 {
+ ivec4 value;
+};
+
+uniform int i;
+uniform ivec4 expected_value;
+
+void main()
+{
+ ivec4 actual_value = Foo[2](Foo(ivec4(100, 200, 300, 400)),
+ Foo(ivec4(500, 600, 700, 800)))[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 ivec4 expected_value 100 200 300 400
+draw rect -1 -1 2 1
+uniform int i 1
+uniform ivec4 expected_value 500 600 700 800
+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/fs-deref-literal-array-of-structs-with-multiple-members-large-array.shader_test b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members-large-array.shader_test
new file mode 100644
index 000000000..ff2b34da7
--- /dev/null
+++ b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members-large-array.shader_test
@@ -0,0 +1,57 @@
+# Verify that an array of structs appearing in the shader as a literal
+# can be successfully dereferenced to access the values inside the
+# structs.
+#
+# This test has a slightly larger array to better check that we calculate
+# offsets correctly. This exposed a bug in the glsl to tgsi pass in gallium
+# based drivers.
+
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+void main()
+{
+ gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+struct Foo {
+ int value;
+
+ /* A second member of a differnt size ensures we calculate member offsets
+ * correctly.
+ */
+ ivec2 value2;
+};
+
+uniform int i;
+uniform ivec2 expected_value;
+
+void main()
+{
+ ivec2 actual_value = Foo[4](Foo(100, ivec2(200, 300)),
+ Foo(400, ivec2(500, 600)),
+ Foo(700, ivec2(800, 900)),
+ Foo(1000, ivec2(1100, 1200)))[i].value2;
+ 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 ivec2 expected_value 200 300
+draw rect -1 -1 1 1
+uniform int i 1
+uniform ivec2 expected_value 500 600
+draw rect 0 -1 1 1
+probe all rgba 0.0 1.0 0.0 1.0
+uniform int i 0
+uniform ivec2 expected_value 800 900
+draw rect -1 0 1 1
+uniform int i 1
+uniform ivec2 expected_value 1100 1200
+draw rect 0 0 1 1
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members.shader_test b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members.shader_test
new file mode 100644
index 000000000..c7d0e3a54
--- /dev/null
+++ b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members.shader_test
@@ -0,0 +1,44 @@
+# 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;
+
+ /* A second member of a differnt size helps ensures we calculate member
+ * offsets correctly.
+ */
+ ivec2 value2;
+};
+
+uniform int i;
+uniform ivec2 expected_value;
+
+void main()
+{
+ ivec2 actual_value = Foo[2](Foo(100, ivec2(200, 300)),
+ Foo(400, ivec2(500, 600)))[i].value2;
+ 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 ivec2 expected_value 200 300
+draw rect -1 -1 2 1
+uniform int i 1
+uniform ivec2 expected_value 500 600
+draw rect -1 0 2 1
+probe all rgba 0.0 1.0 0.0 1.0