diff options
author | Timothy Arceri <tarceri@itsqueeze.com> | 2018-12-07 11:23:09 +1100 |
---|---|---|
committer | Timothy Arceri <tarceri@itsqueeze.com> | 2018-12-18 10:35:38 +1100 |
commit | bfb83e09f0e9cc36459cd505ee9eae3099ad1b1d (patch) | |
tree | 0f93dafcb7ce498f34bc60f92834b105beebb507 | |
parent | b227bb35f8b665f40c0acc4546fa4c038c8eb549 (diff) |
glsl-1.10: test unrolling loops with variable iteration limits
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.
-rw-r--r-- | tests/spec/glsl-1.10/execution/vs-loop-variable-iteration-limit-unroll.shader_test | 71 | ||||
-rw-r--r-- | tests/spec/glsl-1.10/execution/vs-loop-variable-iteration-limit-unroll2.shader_test | 73 |
2 files changed, 144 insertions, 0 deletions
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..8ed023be4 --- /dev/null +++ b/tests/spec/glsl-1.10/execution/vs-loop-variable-iteration-limit-unroll.shader_test @@ -0,0 +1,71 @@ +# 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; + for(int i = 0; i < min(loop_count, 4); i++) { + 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); + } + + 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 |