[Piglit] [PATCH] glsl-1.30: add a new test for signed division by powers of two

Ilia Mirkin imirkin at alum.mit.edu
Sat Jun 9 17:51:11 UTC 2018


Seems fine, but a handful of comments:

On Sat, Jun 9, 2018 at 12:00 PM, Rhys Perry <pendingchaos02 at gmail.com> wrote:
> Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
> ---
>  .../execution/fs-po2-division-int.shader_test      | 74 ++++++++++++++++++++++
>  1 file changed, 74 insertions(+)
>  create mode 100644 tests/spec/glsl-1.30/execution/fs-po2-division-int.shader_test
>
> diff --git a/tests/spec/glsl-1.30/execution/fs-po2-division-int.shader_test b/tests/spec/glsl-1.30/execution/fs-po2-division-int.shader_test
> new file mode 100644
> index 000000000..44075f74c
> --- /dev/null
> +++ b/tests/spec/glsl-1.30/execution/fs-po2-division-int.shader_test

Maybe pow2?

> @@ -0,0 +1,74 @@
> +# Test signed division by constant powers of two
> +
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +#version 130
> +uniform int one;

Here's a fun trick I like to use with piglits

> +uniform int neg1;

uniform int neg1 = -1;

That way, no need to explicitly set it in the [test] section below.

> +uniform int fifteen;
> +uniform int negfifteen;
> +uniform int intmax;
> +uniform int intmin;
> +
> +void main()
> +{
> +       gl_FragColor = vec4(1.0);
> +
> +       if (one / 2 != 0)
> +               gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0);
> +
> +       if (one / -2 != 0)
> +               gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0);
> +
> +       if (neg1 / 2 != 0)
> +               gl_FragColor = vec4(0.0, 0.0, 1.0, 0.0);
> +
> +       if (neg1 / -2 != 0)
> +               gl_FragColor = vec4(1.0, 1.0, 0.0, 0.0);
> +
> +       if (fifteen / 8 != 1)
> +               gl_FragColor = vec4(0.0, 1.0, 1.0, 0.0);
> +
> +       if (fifteen / -8 != -1)
> +               gl_FragColor = vec4(1.0, 0.0, 1.0, 0.0);
> +
> +       if (negfifteen / 8 != -1)
> +               gl_FragColor = vec4(0.25, 0.0, 0.0, 0.0);
> +
> +       if (negfifteen / -8 != 1)
> +               gl_FragColor = vec4(0.0, 0.25, 0.0, 0.0);
> +
> +       /* really high numbers from here on */
> +
> +       if (intmin / 8 != -268435456)
> +               gl_FragColor = vec4(0.5, 0.0, 0.0, 0.0);
> +
> +       if (intmax / 8 != 268435455)
> +               gl_FragColor = vec4(0.0, 0.5, 0.0, 0.0);
> +
> +       if (intmin / -2147483648 != 1)
> +               gl_FragColor = vec4(0.0, 0.0, 0.5, 0.0);
> +
> +       if (intmax / 2147483647 != 1)
> +               gl_FragColor = vec4(0.5, 0.5, 0.0, 0.0);

You probably know this, but 2147483647 isn't a power of two... either
refocus this test on div-by-imm or move this to a separate test which
does that.

> +
> +       if (intmin / 2147483647 != -1)
> +               gl_FragColor = vec4(0.0, 0.5, 0.5, 0.0);
> +
> +       if (intmax / -2147483648 != 0)
> +               gl_FragColor = vec4(0.5, 0.0, 0.5, 0.0);
> +}
> +
> +[test]
> +uniform int one 1
> +uniform int neg1 -1
> +uniform int fifteen 15
> +uniform int negfifteen -15
> +uniform int intmax 2147483647
> +uniform int intmin -2147483648
> +draw rect -1 -1 2 2
> +probe all rgba 1.0 1.0 1.0 1.0
> --
> 2.14.4
>


More information about the Piglit mailing list