--- ...loop-complex-unroll-with-else-break.shader_test | 71 ++++++++++++++++++++++ ...l-else-break-unreachable-then-break.shader_test | 41 +++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 tests/spec/glsl-1.10/execution/vs-loop-complex-unroll-with-else-break.shader_test create mode 100644 tests/spec/glsl-1.10/execution/vs-loop-unroll-else-break-unreachable-then-break.shader_test
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 -- 2.13.5 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit