summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Arceri <tarceri@itsqueeze.com>2017-09-21 17:51:53 +1000
committerTimothy Arceri <tarceri@itsqueeze.com>2017-09-26 14:12:39 +1000
commit3ec1fed3a73c7e5b9dadd239ca81e376a57e39e3 (patch)
tree65e6c8075e5f7c65226ab56141bae5ec1e83c6a9
parentad02adb20cf6fbae548e8e26841c3eea2a939dd8 (diff)
glsl-1.10: add some loop unrolling tests with breaks in else branch
Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
-rw-r--r--tests/spec/glsl-1.10/execution/vs-loop-complex-unroll-with-else-break.shader_test71
-rw-r--r--tests/spec/glsl-1.10/execution/vs-loop-unroll-else-break-unreachable-then-break.shader_test41
2 files changed, 112 insertions, 0 deletions
diff --git a/tests/spec/glsl-1.10/execution/vs-loop-complex-unroll-with-else-break.shader_test b/tests/spec/glsl-1.10/execution/vs-loop-complex-unroll-with-else-break.shader_test
new file mode 100644
index 000000000..d543c3fc9
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/vs-loop-complex-unroll-with-else-break.shader_test
@@ -0,0 +1,71 @@
+# 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 (loop_count uniform).
+#
+# Here we test all possible outcomes for the loop and also add some
+# unreachable code to make sure it is not accessible 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) {
+ colour = vec4(0.0, 1.0, 0.0, 1.0);
+ } else {
+ break;
+ }
+
+ /* Unreachable break */
+ if (i > 2) {
+ break;
+ }
+
+ /* 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-unroll-else-break-unreachable-then-break.shader_test b/tests/spec/glsl-1.10/execution/vs-loop-unroll-else-break-unreachable-then-break.shader_test
new file mode 100644
index 000000000..1e83a6f41
--- /dev/null
+++ b/tests/spec/glsl-1.10/execution/vs-loop-unroll-else-break-unreachable-then-break.shader_test
@@ -0,0 +1,41 @@
+# This tests unrolling of a loop with two exit point where the limiting
+# terminator has its break in the else branch.
+[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, 0.0);
+ for (int i = 0; i < 3; i++) {
+ if (i <= 1) {
+ colour = vec4(0.0, 1.0, 0.0, 1.0);
+ } else {
+ break;
+ }
+
+ /* This should be unreachable */
+ if (i >= 2) {
+ colour2 = vec4(1.0, 0.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
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0