[Piglit] [PATCH] glsl-1.10: complex loop unrolling tests
Timothy Arceri
timothy.arceri at collabora.com
Wed Sep 14 00:01:37 UTC 2016
These test so called complex loop unrolling in Mesa which just means
unrolling a loop with two exits where the trip count is only known
for one of the exits.
---
.../execution/vs-loop-complex-unroll.shader_test | 66 ++++++++++++++++++++++
.../vs-loop-zero-iterations-two-exits.shader_test | 41 ++++++++++++++
.../vs-loop-zero-iterations-two-exits2.shader_test | 41 ++++++++++++++
3 files changed, 148 insertions(+)
create mode 100644 tests/spec/glsl-1.10/execution/vs-loop-complex-unroll.shader_test
create mode 100644 tests/spec/glsl-1.10/execution/vs-loop-zero-iterations-two-exits.shader_test
create mode 100644 tests/spec/glsl-1.10/execution/vs-loop-zero-iterations-two-exits2.shader_test
diff --git a/tests/spec/glsl-1.10/execution/vs-loop-complex-unroll.shader_test b/tests/spec/glsl-1.10/execution/vs-loop-complex-unroll.shader_test
new file mode 100644
index 0000000..fda74f9
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/vs-loop-complex-unroll.shader_test
@@ -0,0 +1,66 @@
+# This tests unrolling of a loop with two exit point where the trip count
+# of one of the exits is know and the other unknow (loop_count uniform).
+#
+# Here we test all possible outcomes for the loop and also add some
+# unreachable code to make sure it is not accessable after unrolling.
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+uniform int loop_count;
+
+void main()
+{
+ gl_Position = gl_Vertex;
+
+ vec4 colour = vec4(1.0, 1.0, 1.0, 1.0);
+ vec4 colour2 = vec4(0.0, 0.0, 0.0, 1.0);
+ for (int i = 0; i < loop_count; i++) {
+
+ if (i > 1) {
+ colour = vec4(1.0, 0.0, 0.0, 1.0);
+ }
+
+ if (i > 1) {
+ break;
+ }
+
+ colour = vec4(0.0, 1.0, 0.0, 1.0);
+
+ /* This should be unreachable */
+ if (i >= 2) {
+ colour2 = vec4(0.0, 1.0, 0.0, 1.0);
+ }
+ }
+
+ gl_FrontColor = colour + colour2;
+}
+
+[fragment shader]
+void main()
+{
+ gl_FragColor = gl_Color;
+}
+
+[test]
+clear color 0.5 0.5 0.5 0.5
+
+uniform int loop_count 4
+draw rect -1 -1 2 2
+probe all rgba 1.0 0.0 0.0 1.0
+
+uniform int loop_count 3
+draw rect -1 -1 2 2
+probe all rgba 1.0 0.0 0.0 1.0
+
+uniform int loop_count 2
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+
+uniform int loop_count 1
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+
+uniform int loop_count 0
+draw rect -1 -1 2 2
+probe all rgba 1.0 1.0 1.0 1.0
diff --git a/tests/spec/glsl-1.10/execution/vs-loop-zero-iterations-two-exits.shader_test b/tests/spec/glsl-1.10/execution/vs-loop-zero-iterations-two-exits.shader_test
new file mode 100644
index 0000000..00ea585
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/vs-loop-zero-iterations-two-exits.shader_test
@@ -0,0 +1,41 @@
+# This tests unrolling of a loop with two exit point where the trip count
+# of one of the exits is know to be zero and the other unknow
+# (loop_count uniform).
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+uniform int loop_count;
+
+void main()
+{
+ gl_Position = gl_Vertex;
+
+ vec4 colour = vec4(1.0, 0.0, 0.0, 1.0);
+
+ for (int i = 0; i < loop_count; i++) {
+ colour = vec4(0.0, 1.0, 0.0, 1.0);
+
+ if (i == 0)
+ break;
+ }
+
+ gl_FrontColor = colour;
+}
+
+[fragment shader]
+void main()
+{
+ gl_FragColor = gl_Color;
+}
+
+[test]
+clear color 0.5 0.5 0.5 0.5
+
+uniform int loop_count 1
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+
+uniform int loop_count 0
+draw rect -1 -1 2 2
+probe all rgba 1.0 0.0 0.0 1.0
diff --git a/tests/spec/glsl-1.10/execution/vs-loop-zero-iterations-two-exits2.shader_test b/tests/spec/glsl-1.10/execution/vs-loop-zero-iterations-two-exits2.shader_test
new file mode 100644
index 0000000..d458e0e
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/vs-loop-zero-iterations-two-exits2.shader_test
@@ -0,0 +1,41 @@
+# This tests unrolling of a loop with two exit point where the trip count
+# of one of the exits is know to be zero and the other unknow
+# (loop_count uniform).
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+uniform int loop_count;
+
+void main()
+{
+ gl_Position = gl_Vertex;
+
+ vec4 colour = vec4(1.0, 0.0, 0.0, 1.0);
+
+ for (int i = 0; i < 0; i++) {
+ colour = vec4(0.0, 1.0, 0.0, 1.0);
+
+ if (i == loop_count)
+ break;
+ }
+
+ gl_FrontColor = colour;
+}
+
+[fragment shader]
+void main()
+{
+ gl_FragColor = gl_Color;
+}
+
+[test]
+clear color 0.5 0.5 0.5 0.5
+
+uniform int loop_count 1
+draw rect -1 -1 2 2
+probe all rgba 1.0 0.0 0.0 1.0
+
+uniform int loop_count 0
+draw rect -1 -1 2 2
+probe all rgba 1.0 0.0 0.0 1.0
--
2.7.4
More information about the Piglit
mailing list