[Piglit] [PATCH] glsl-1.10: Add simple test to check for code generated by clamp bounded within 1, 0
Ian Romanick
idr at freedesktop.org
Tue Jun 24 08:35:27 PDT 2014
On 06/23/2014 01:18 PM, Abdiel Janulgue wrote:
> 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 <abdiel.janulgue at linux.intel.com>
> ---
> .../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
This second draw will completely over-write the first draw. When run
without -auto this makes it impossible to see (in the window on the
screen) an error in the first draw. Instead,
draw rect -1 -1 1 2
...
draw rect 0 -1 1 2
for both tests. That also means you'll need to either use a different
probe or change the way results are generated.
> +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
>
More information about the Piglit
mailing list