This is for checking that the compiler outputs the correct optimization when clamp is bounded within 0.0 and 1.0.
Signed-off-by: Abdiel Janulgue <[email protected]> --- .../execution/fs-clamp-bounds.shader_test | 28 +++++++++++++++++++ .../execution/vs-clamp-bounds.shader_test | 32 ++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 tests/spec/glsl-1.10/execution/fs-clamp-bounds.shader_test create mode 100644 tests/spec/glsl-1.10/execution/vs-clamp-bounds.shader_test diff --git a/tests/spec/glsl-1.10/execution/fs-clamp-bounds.shader_test b/tests/spec/glsl-1.10/execution/fs-clamp-bounds.shader_test new file mode 100644 index 0000000..13233e8 --- /dev/null +++ b/tests/spec/glsl-1.10/execution/fs-clamp-bounds.shader_test @@ -0,0 +1,28 @@ +[require] +GLSL >= 1.10 + +[vertex shader] +void main() +{ + gl_Position = gl_Vertex; +} + +[fragment shader] +uniform bool low_bound; +uniform vec4 v; + +void main() +{ + gl_FragColor = low_bound ? clamp(v, 0.2, 1.0) : clamp(v, 0.0, 0.9); +} + +[test] +uniform int low_bound 0 +uniform vec4 v 0.25 1.0 2.0 0.25 +draw rect -1 -1 2 2 +probe all rgba 0.25 0.9 0.9 0.25 + +uniform int low_bound 1 +uniform vec4 v 0.25 1.0 2.0 0.25 +draw rect -1 -1 2 2 +probe all rgba 0.25 1.0 1.0 0.25 diff --git a/tests/spec/glsl-1.10/execution/vs-clamp-bounds.shader_test b/tests/spec/glsl-1.10/execution/vs-clamp-bounds.shader_test new file mode 100644 index 0000000..6b40dc0 --- /dev/null +++ b/tests/spec/glsl-1.10/execution/vs-clamp-bounds.shader_test @@ -0,0 +1,32 @@ +[require] +GLSL >= 1.10 + +[vertex shader] +uniform bool low_bound; +uniform vec4 v; +varying vec4 color; + +void main() +{ + color = low_bound ? clamp(v, 0.2, 1.0) : clamp(v, 0.0, 0.9); + gl_Position = gl_Vertex; +} + +[fragment shader] +varying vec4 color; + +void main() +{ + gl_FragColor = color; +} + +[test] +uniform int low_bound 0 +uniform vec4 v 0.25 1.0 2.0 0.25 +draw rect -1 -1 2 2 +probe all rgba 0.25 0.9 0.9 0.25 + +uniform int low_bound 1 +uniform vec4 v 0.25 1.0 2.0 0.25 +draw rect -1 -1 2 2 +probe all rgba 0.25 1.0 1.0 0.25 -- 1.9.1 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
