This tests unrolling of some loops with a single exit point but where the exact trip count is unknown, only the max iteration count is known. --- ...ariable-iteration-limit-unroll.shader_test | 62 ++++++++++++++++ ...riable-iteration-limit-unroll2.shader_test | 73 +++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 tests/spec/glsl-1.10/execution/vs-loop-variable-iteration-limit-unroll.shader_test create mode 100644 tests/spec/glsl-1.10/execution/vs-loop-variable-iteration-limit-unroll2.shader_test
diff --git a/tests/spec/glsl-1.10/execution/vs-loop-variable-iteration-limit-unroll.shader_test b/tests/spec/glsl-1.10/execution/vs-loop-variable-iteration-limit-unroll.shader_test new file mode 100644 index 000000000..588abe011 --- /dev/null +++ b/tests/spec/glsl-1.10/execution/vs-loop-variable-iteration-limit-unroll.shader_test @@ -0,0 +1,62 @@ +# This tests unrolling of a loop with a single exit point but where the +# exact trip count is unknown, only the max iteration count (4) is known. +# +# 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() +{ + vec4 colour_array[4]; + + colour_array[0] = vec4(0.0, 0.25, 0.0, 1.0); + colour_array[1] = vec4(0.0, 0.5, 0.0, 1.0); + colour_array[2] = vec4(0.0, 0.75, 0.0, 1.0); + colour_array[3] = vec4(0.0, 1.0, 0.0, 1.0); + + gl_Position = gl_Vertex; + + vec4 colour = vec4(1.0, 1.0, 1.0, 1.0); + for (int i = 0; i < loop_count; i++) { + colour = colour_array[i]; + } + + 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 0 +draw rect -1 -1 2 2 +probe all rgba 1.0 1.0 1.0 1.0 + +uniform int loop_count 1 +draw rect -1 -1 2 2 +probe all rgba 0.0 0.25 0.0 1.0 + +uniform int loop_count 2 +draw rect -1 -1 2 2 +probe all rgba 0.0 0.5 0.0 1.0 + +uniform int loop_count 3 +draw rect -1 -1 2 2 +probe all rgba 0.0 0.75 0.0 1.0 + +uniform int loop_count 4 +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 + +uniform int loop_count 5 +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/glsl-1.10/execution/vs-loop-variable-iteration-limit-unroll2.shader_test b/tests/spec/glsl-1.10/execution/vs-loop-variable-iteration-limit-unroll2.shader_test new file mode 100644 index 000000000..b05bcb8ed --- /dev/null +++ b/tests/spec/glsl-1.10/execution/vs-loop-variable-iteration-limit-unroll2.shader_test @@ -0,0 +1,73 @@ +# This tests unrolling of a loop with a single exit point but where the +# exact trip count is unknown, only the max iteration count (4) is known. +# +# 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); + + int i = 0; + while (i < loop_count && i < 4) { + if (i == 0) + colour = vec4(0.0, 0.25, 0.0, 1.0); + + if (i == 1) + colour = vec4(0.0, 0.5, 0.0, 1.0); + + if (i == 2) + colour = vec4(0.0, 0.75, 0.0, 1.0); + + if (i == 3) + colour = vec4(0.0, 1.0, 0.0, 1.0); + + /* This should be unreachable */ + if (i >= 4) + colour = vec4(1.0, 0.0, 0.0, 1.0); + + i++; + } + + 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 0 +draw rect -1 -1 2 2 +probe all rgba 1.0 1.0 1.0 1.0 + +uniform int loop_count 1 +draw rect -1 -1 2 2 +probe all rgba 0.0 0.25 0.0 1.0 + +uniform int loop_count 2 +draw rect -1 -1 2 2 +probe all rgba 0.0 0.5 0.0 1.0 + +uniform int loop_count 3 +draw rect -1 -1 2 2 +probe all rgba 0.0 0.75 0.0 1.0 + +uniform int loop_count 4 +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 + +uniform int loop_count 5 +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 -- 2.19.2 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit