[Piglit] [PATCH] glsl-fs-clamp-[234]: New tests for a bug Chad noticed in saturate handling.

Ian Romanick idr at freedesktop.org
Mon Apr 11 17:15:55 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/11/2011 04:24 PM, Eric Anholt wrote:
> The point here is to try to catch the cases where the compiler turns a
> min/max of a variable float with constant vectors into a saturate of a
> float.

Catch in what way?  Is this just to make sure we generate the correct
values or that we generate good code?

The tests look good, but we may as well try to hit all the scalar/vector
combinations.  Most of my "coverage" tests like that are generated by
scripts. :)

> We never actually failed, becase we aren't writemasking in ir_to_mesa
                            because

> (so the full temporary vector would be filled anyway), and because in
> brw_fs.cpp we had split up the expression to scalars already.
> ---
>  tests/shaders/glsl-fs-clamp-2.shader_test |   29 +++++++++++++++++++++++++++++
>  tests/shaders/glsl-fs-clamp-3.shader_test |   29 +++++++++++++++++++++++++++++
>  tests/shaders/glsl-fs-clamp-4.shader_test |   29 +++++++++++++++++++++++++++++
>  3 files changed, 87 insertions(+), 0 deletions(-)
>  create mode 100644 tests/shaders/glsl-fs-clamp-2.shader_test
>  create mode 100644 tests/shaders/glsl-fs-clamp-3.shader_test
>  create mode 100644 tests/shaders/glsl-fs-clamp-4.shader_test
> 
> diff --git a/tests/shaders/glsl-fs-clamp-2.shader_test b/tests/shaders/glsl-fs-clamp-2.shader_test
> new file mode 100644
> index 0000000..5d856ca
> --- /dev/null
> +++ b/tests/shaders/glsl-fs-clamp-2.shader_test
> @@ -0,0 +1,29 @@
> +[require]
> +GLSL >= 1.10
> +
> +[vertex shader]
> +varying vec4 color;
> +
> +void main()
> +{
> +	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> +	/* Renormalize to [-1, 2] */
> +	color = (gl_Vertex + 1.0) * 3.0 / 2.0 - 1.0;
> +}
> +
> +[fragment shader]
> +varying vec4 color;
> +
> +void main()
> +{
> +	float x = min(1.0, max(0.0, color.x)) * 0.5 + 0.25;
> +	float y = min(1.0, max(0.0, color.y)) * 0.5 + 0.25;
> +	gl_FragColor = vec4(x, y, 0.0, 0.0);
> +}
> +
> +[test]
> +draw rect -1 -1 2 2
> +relative probe rgba (0.0, 0.0) (0.25, 0.25, 0.0, 0.0)
> +relative probe rgba (1.0, 0.0) (0.75, 0.25, 0.0, 0.0)
> +relative probe rgba (0.0, 1.0) (0.25, 0.75, 0.0, 0.0)
> +relative probe rgba (1.0, 1.0) (0.75, 0.75, 0.0, 0.0)
> diff --git a/tests/shaders/glsl-fs-clamp-3.shader_test b/tests/shaders/glsl-fs-clamp-3.shader_test
> new file mode 100644
> index 0000000..ec61790
> --- /dev/null
> +++ b/tests/shaders/glsl-fs-clamp-3.shader_test
> @@ -0,0 +1,29 @@
> +[require]
> +GLSL >= 1.10
> +
> +[vertex shader]
> +varying vec4 color;
> +
> +void main()
> +{
> +	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> +	/* Renormalize to [-1, 2] */
> +	color = (gl_Vertex + 1.0) * 3.0 / 2.0 - 1.0;
> +}
> +
> +[fragment shader]
> +varying vec4 color;
> +
> +void main()
> +{
> +	vec2 x = min(vec2(1.0), max(0.0, color.x)) * 0.5 + 0.25;
> +	vec2 y = min(vec2(1.0), max(0.0, color.y)) * 0.5 + 0.25;
> +	gl_FragColor = vec4(x.y, y.y, 0.0, 0.0);
> +}
> +
> +[test]
> +draw rect -1 -1 2 2
> +relative probe rgba (0.0, 0.0) (0.25, 0.25, 0.0, 0.0)
> +relative probe rgba (1.0, 0.0) (0.75, 0.25, 0.0, 0.0)
> +relative probe rgba (0.0, 1.0) (0.25, 0.75, 0.0, 0.0)
> +relative probe rgba (1.0, 1.0) (0.75, 0.75, 0.0, 0.0)
> diff --git a/tests/shaders/glsl-fs-clamp-4.shader_test b/tests/shaders/glsl-fs-clamp-4.shader_test
> new file mode 100644
> index 0000000..829ac28
> --- /dev/null
> +++ b/tests/shaders/glsl-fs-clamp-4.shader_test
> @@ -0,0 +1,29 @@
> +[require]
> +GLSL >= 1.10
> +
> +[vertex shader]
> +varying vec4 color;
> +
> +void main()
> +{
> +	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> +	/* Renormalize to [-1, 2] */
> +	color = (gl_Vertex + 1.0) * 3.0 / 2.0 - 1.0;
> +}
> +
> +[fragment shader]
> +varying vec4 color;
> +
> +void main()
> +{
> +	vec2 x = min(max(vec2(0.0), color.x), 1.0) * 0.5 + 0.25;
> +	vec2 y = min(max(vec2(0.0), color.y), 1.0) * 0.5 + 0.25;
> +	gl_FragColor = vec4(x.y, y.y, 0.0, 0.0);
> +}
> +
> +[test]
> +draw rect -1 -1 2 2
> +relative probe rgba (0.0, 0.0) (0.25, 0.25, 0.0, 0.0)
> +relative probe rgba (1.0, 0.0) (0.75, 0.25, 0.0, 0.0)
> +relative probe rgba (0.0, 1.0) (0.25, 0.75, 0.0, 0.0)
> +relative probe rgba (1.0, 1.0) (0.75, 0.75, 0.0, 0.0)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk2jmbsACgkQX1gOwKyEAw/avQCeITBan3ImY0h3++SQGM5GcOYm
QvUAmgOrIpxc7OULO5y4umtiNuvpaYEC
=GAc5
-----END PGP SIGNATURE-----


More information about the Piglit mailing list