summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Arceri <timothy.arceri@collabora.com>2016-12-22 11:41:44 +1100
committerTimothy Arceri <timothy.arceri@collabora.com>2016-12-23 10:46:40 +1100
commit86437ab9e8e1e89029697eb3a0d67ef2c5a3e96c (patch)
treeb9eff2a68bdeebe91216f8ca9bb48c229124949c
parent41d512234fda625dcdca5b016b37b1a0168c6f78 (diff)
glsl-1.10: test unrolling of loops with various control flow
-rw-r--r--tests/spec/glsl-1.10/execution/vs-loop-complex-unroll-cf-before-terminators.shader_test56
-rw-r--r--tests/spec/glsl-1.10/execution/vs-loop-complex-unroll-cf-inside-terminator.shader_test61
-rw-r--r--tests/spec/glsl-1.10/execution/vs-loop-simple-unroll-cf-inside-terminator.shader_test60
3 files changed, 177 insertions, 0 deletions
diff --git a/tests/spec/glsl-1.10/execution/vs-loop-complex-unroll-cf-before-terminators.shader_test b/tests/spec/glsl-1.10/execution/vs-loop-complex-unroll-cf-before-terminators.shader_test
new file mode 100644
index 000000000..9e766220d
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/vs-loop-complex-unroll-cf-before-terminators.shader_test
@@ -0,0 +1,56 @@
+# This tests unrolling of a loop with two exit point where the trip count
+# of one of the exits is known and the other unknown (conditional on uniform).
+#
+# Here we test that control flow that comes before the terminators is properly
+# inserted into the unrolled loop.
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+uniform int a;
+
+void main()
+{
+ gl_Position = gl_Vertex;
+
+ vec4 colour = vec4(1.0, 0.0, 0.0, 1.0);
+
+ int i = 0;
+ int j = 0;
+ do {
+ if (i == 2) {
+ colour = vec4(0.0, 0.0, 1.0, 1.0);
+ j++; // we use this so the if doesn't get reduced to a series of bcsel
+ } else {
+ colour = vec4(0.0, 1.0, 0.0, 1.0);
+ }
+
+ i++;
+ j++;
+
+ if (i >= 3) {
+ if (j != 4)
+ colour = vec4(1.0, 0.0, 0.0, 1.0);
+ break;
+ }
+ } while (a == 1);
+
+ gl_FrontColor = colour;
+}
+
+[fragment shader]
+void main()
+{
+ gl_FragColor = gl_Color;
+}
+
+[test]
+clear color 0.5 0.5 0.5 0.5
+
+uniform int a 0
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+
+uniform int a 1
+draw rect -1 -1 2 2
+probe all rgba 0.0 0.0 1.0 1.0
diff --git a/tests/spec/glsl-1.10/execution/vs-loop-complex-unroll-cf-inside-terminator.shader_test b/tests/spec/glsl-1.10/execution/vs-loop-complex-unroll-cf-inside-terminator.shader_test
new file mode 100644
index 000000000..9501e58b1
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/vs-loop-complex-unroll-cf-inside-terminator.shader_test
@@ -0,0 +1,61 @@
+# This tests unrolling of a loop with two exit point where the trip count
+# of one of the exits is known and the other unknown (conditional on uniform).
+#
+# Here we test that control flow nested inside the limiting terminator is
+# correctly unrolled.
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+uniform int a;
+
+void main()
+{
+ gl_Position = gl_Vertex;
+
+ vec4 colour = vec4(1.0, 0.0, 0.0, 1.0);
+
+ int i = 0;
+ int j = 0;
+ do {
+ i++;
+ j++;
+
+ if (i >= 3) {
+ if (i == 3) {
+ colour = vec4(0.0, 0.0, 1.0, 1.0);
+ j++; // we use this so the if doesn't get reduced to a series of bcsel
+ if (j != 5)
+ colour = vec4(1.0, 0.0, 0.0, 1.0);
+ } else {
+ colour = vec4(1.0, 0.0, 0.0, 1.0);
+ }
+ break;
+ } else {
+ if (i != 1) {
+ j++;
+ } else {
+ colour = vec4(0.0, 1.0, 0.0, 1.0);
+ }
+ }
+ } while (a == 1);
+
+ gl_FrontColor = colour;
+}
+
+[fragment shader]
+void main()
+{
+ gl_FragColor = gl_Color;
+}
+
+[test]
+clear color 0.5 0.5 0.5 0.5
+
+uniform int a 0
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+
+uniform int a 1
+draw rect -1 -1 2 2
+probe all rgba 0.0 0.0 1.0 1.0
diff --git a/tests/spec/glsl-1.10/execution/vs-loop-simple-unroll-cf-inside-terminator.shader_test b/tests/spec/glsl-1.10/execution/vs-loop-simple-unroll-cf-inside-terminator.shader_test
new file mode 100644
index 000000000..182e65655
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/vs-loop-simple-unroll-cf-inside-terminator.shader_test
@@ -0,0 +1,60 @@
+# This tests unrolling of a loop with a single exit point.
+#
+# Here we test that control flow nested inside the limiting terminator is
+# correctly unrolled.
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+void main()
+{
+ gl_Position = gl_Vertex;
+
+ vec4 colour = vec4(1.0, 0.0, 0.0, 1.0);
+
+ int i = 0;
+ int j = 0; // we use this so the if doesn't get reduced to a series of bcsel
+ do {
+ i++;
+ j++;
+
+ if (i >= 3) {
+ if (i == 3) {
+ colour = vec4(0.0, 1.0, 0.0, 1.0);
+ j++;
+ if (j != 6)
+ colour = vec4(1.0, 0.0, 1.0, 1.0);
+ } else {
+ colour = vec4(1.0, 1.0, 0.0, 1.0);
+ }
+ break;
+ } else {
+ if (i != 1) {
+ j++;
+ }
+ }
+
+ if (i >= 5) {
+ j++; // unreachable
+ break;
+ } else {
+ if (i != 1) {
+ j++;
+ }
+ }
+ } while (i < 4);
+
+ gl_FrontColor = colour;
+}
+
+[fragment shader]
+void main()
+{
+ gl_FragColor = gl_Color;
+}
+
+[test]
+clear color 0.5 0.5 0.5 0.5
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0