[Piglit] [PATCH v5 3/3] arb_shader_precision: add manually written tests for a*b+c and fma()
Ilia Mirkin
imirkin at alum.mit.edu
Fri Apr 3 14:20:39 PDT 2015
On Fri, Apr 3, 2015 at 5:00 PM, Micah Fedke <micah.fedke at collabora.co.uk> wrote:
>
> ---
> .../fs-fma-float-float-float.shader_test | 56 +++++++++++++++
> .../fs-manual-fma-float-float-float.shader_test | 56 +++++++++++++++
> .../gs-fma-float-float-float.shader_test | 80 ++++++++++++++++++++++
> .../gs-manual-fma-float-float-float.shader_test | 80 ++++++++++++++++++++++
> .../vs-fma-float-float-float.shader_test | 65 ++++++++++++++++++
> .../vs-manual-fma-float-float-float.shader_test | 65 ++++++++++++++++++
> 6 files changed, 402 insertions(+)
> create mode 100644 tests/spec/arb_shader_precision/fs-fma-float-float-float.shader_test
> create mode 100644 tests/spec/arb_shader_precision/fs-manual-fma-float-float-float.shader_test
> create mode 100644 tests/spec/arb_shader_precision/gs-fma-float-float-float.shader_test
> create mode 100644 tests/spec/arb_shader_precision/gs-manual-fma-float-float-float.shader_test
> create mode 100644 tests/spec/arb_shader_precision/vs-fma-float-float-float.shader_test
> create mode 100644 tests/spec/arb_shader_precision/vs-manual-fma-float-float-float.shader_test
>
> diff --git a/tests/spec/arb_shader_precision/fs-fma-float-float-float.shader_test b/tests/spec/arb_shader_precision/fs-fma-float-float-float.shader_test
> new file mode 100644
> index 0000000..f8b186a
> --- /dev/null
> +++ b/tests/spec/arb_shader_precision/fs-fma-float-float-float.shader_test
> @@ -0,0 +1,56 @@
> +
Get rid of this leading newline
> +[require]
> +GLSL >= 4.00
You also need to say you require GL_ARB_shader_precision, otherwise
this will show up as fail rather than skip. IIRC you just write
GL_ARB_shader_precision on a line by itself, but check other shader
tests for what they do.
Also, please double-check that tests/gpu.py is picking these up, or if
you need to add something in there. Dylan has refactored it a lot, but
it used to be that you had to explicitly add directories in. Perhaps
that's a thing of the past though.
Otherwise this patch is Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
I didn't double-check your math, but I'm trusting you :) I guess I
should check it with nouveau and turning off the auto-fma
optimization.
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +#extension GL_ARB_shader_precision : require
> +uniform float arg0;
> +uniform float arg1;
> +uniform float arg2;
> +uniform float expected_a;
> +uniform float expected_b;
> +
> +void main()
> +{
> + float result = fma(arg0, arg1, arg2);
> + gl_FragColor = result == expected_a || result == expected_b ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[vertex data]
> +piglit_vertex/float/2
> +-1.0 -1.0
> + 1.0 -1.0
> + 1.0 1.0
> +-1.0 1.0
> +
> +[test]
> +uniform float arg0 -2.99999993e-02
> +uniform float arg1 -8.50000024e-01
> +uniform float arg2 -2.54999995e-02
> +uniform float expected_a 0.00000000e+00
> +uniform float expected_b 6.22123464e-10
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 0 0 0.0 1.0 0.0 1.0
> +uniform float arg0 1.66999996e+00
> +uniform float arg1 6.60000026e-01
> +uniform float arg2 1.00000036e+00
> +uniform float expected_a 2.10220027e+00
> +uniform float expected_b 2.10220051e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 1 0 0.0 1.0 0.0 1.0
> +uniform float arg0 -2.99999993e-02
> +uniform float arg1 6.60000026e-01
> +uniform float arg2 1.41949999e+00
> +uniform float expected_a 1.39970005e+00
> +uniform float expected_b 1.39970005e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 2 0 0.0 1.0 0.0 1.0
> +uniform float arg0 1.87000000e+00
> +uniform float arg1 -2.99999993e-02
> +uniform float arg2 1.56979990e+00
> +uniform float expected_a 1.51369989e+00
> +uniform float expected_b 1.51369989e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 3 0 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/arb_shader_precision/fs-manual-fma-float-float-float.shader_test b/tests/spec/arb_shader_precision/fs-manual-fma-float-float-float.shader_test
> new file mode 100644
> index 0000000..e8ade84
> --- /dev/null
> +++ b/tests/spec/arb_shader_precision/fs-manual-fma-float-float-float.shader_test
> @@ -0,0 +1,56 @@
> +
> +[require]
> +GLSL >= 4.00
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +#extension GL_ARB_shader_precision : require
> +uniform float arg0;
> +uniform float arg1;
> +uniform float arg2;
> +uniform float expected_a;
> +uniform float expected_b;
> +
> +void main()
> +{
> + float result = arg0 * arg1 + arg2;
> + gl_FragColor = result == expected_a || result == expected_b ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[vertex data]
> +piglit_vertex/float/2
> +-1.0 -1.0
> + 1.0 -1.0
> + 1.0 1.0
> +-1.0 1.0
> +
> +[test]
> +uniform float arg0 -2.99999993e-02
> +uniform float arg1 -8.50000024e-01
> +uniform float arg2 -2.54999995e-02
> +uniform float expected_a 0.00000000e+00
> +uniform float expected_b 6.22123464e-10
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 0 0 0.0 1.0 0.0 1.0
> +uniform float arg0 1.66999996e+00
> +uniform float arg1 6.60000026e-01
> +uniform float arg2 1.00000036e+00
> +uniform float expected_a 2.10220027e+00
> +uniform float expected_b 2.10220051e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 1 0 0.0 1.0 0.0 1.0
> +uniform float arg0 -2.99999993e-02
> +uniform float arg1 6.60000026e-01
> +uniform float arg2 1.41949999e+00
> +uniform float expected_a 1.39970005e+00
> +uniform float expected_b 1.39970005e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 2 0 0.0 1.0 0.0 1.0
> +uniform float arg0 1.87000000e+00
> +uniform float arg1 -2.99999993e-02
> +uniform float arg2 1.56979990e+00
> +uniform float expected_a 1.51369989e+00
> +uniform float expected_b 1.51369989e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 3 0 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/arb_shader_precision/gs-fma-float-float-float.shader_test b/tests/spec/arb_shader_precision/gs-fma-float-float-float.shader_test
> new file mode 100644
> index 0000000..12fcb53
> --- /dev/null
> +++ b/tests/spec/arb_shader_precision/gs-fma-float-float-float.shader_test
> @@ -0,0 +1,80 @@
> +
> +[require]
> +GLSL >= 4.00
> +
> +[vertex shader]
> +in vec4 piglit_vertex;
> +flat out vec4 vertex_to_gs;
> +void main()
> +{
> + vertex_to_gs = piglit_vertex;
> +}
> +
> +[geometry shader]
> +#extension GL_ARB_shader_precision : require
> +layout(triangles) in;
> +layout(triangle_strip, max_vertices = 3) out;
> +flat in vec4 vertex_to_gs[3];
> +flat out vec4 color;
> +uniform float arg0;
> +uniform float arg1;
> +uniform float arg2;
> +uniform float expected_a;
> +uniform float expected_b;
> +
> +void main()
> +{
> + vec4 tmp_color;
> + float result = fma(arg0, arg1, arg2);
> + tmp_color = result == expected_a || result == expected_b ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> + for (int i = 0; i < 3; i++) {
> + gl_Position = vertex_to_gs[i];
> + color = tmp_color;
> + EmitVertex();
> + }
> +}
> +
> +[fragment shader]
> +flat in vec4 color;
> +
> +void main()
> +{
> + gl_FragColor = color;
> +}
> +
> +[vertex data]
> +piglit_vertex/float/2
> +-1.0 -1.0
> + 1.0 -1.0
> + 1.0 1.0
> +-1.0 1.0
> +
> +[test]
> +uniform float arg0 -2.99999993e-02
> +uniform float arg1 -8.50000024e-01
> +uniform float arg2 -2.54999995e-02
> +uniform float expected_a 0.00000000e+00
> +uniform float expected_b 6.22123464e-10
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 0 0 0.0 1.0 0.0 1.0
> +uniform float arg0 1.66999996e+00
> +uniform float arg1 6.60000026e-01
> +uniform float arg2 1.00000036e+00
> +uniform float expected_a 2.10220027e+00
> +uniform float expected_b 2.10220051e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 1 0 0.0 1.0 0.0 1.0
> +uniform float arg0 -2.99999993e-02
> +uniform float arg1 6.60000026e-01
> +uniform float arg2 1.41949999e+00
> +uniform float expected_a 1.39970005e+00
> +uniform float expected_b 1.39970005e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 2 0 0.0 1.0 0.0 1.0
> +uniform float arg0 1.87000000e+00
> +uniform float arg1 -2.99999993e-02
> +uniform float arg2 1.56979990e+00
> +uniform float expected_a 1.51369989e+00
> +uniform float expected_b 1.51369989e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 3 0 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/arb_shader_precision/gs-manual-fma-float-float-float.shader_test b/tests/spec/arb_shader_precision/gs-manual-fma-float-float-float.shader_test
> new file mode 100644
> index 0000000..eeebfc7
> --- /dev/null
> +++ b/tests/spec/arb_shader_precision/gs-manual-fma-float-float-float.shader_test
> @@ -0,0 +1,80 @@
> +
> +[require]
> +GLSL >= 4.00
> +
> +[vertex shader]
> +in vec4 piglit_vertex;
> +flat out vec4 vertex_to_gs;
> +void main()
> +{
> + vertex_to_gs = piglit_vertex;
> +}
> +
> +[geometry shader]
> +#extension GL_ARB_shader_precision : require
> +layout(triangles) in;
> +layout(triangle_strip, max_vertices = 3) out;
> +flat in vec4 vertex_to_gs[3];
> +flat out vec4 color;
> +uniform float arg0;
> +uniform float arg1;
> +uniform float arg2;
> +uniform float expected_a;
> +uniform float expected_b;
> +
> +void main()
> +{
> + vec4 tmp_color;
> + float result = arg0 * arg1 + arg2;
> + tmp_color = result == expected_a || result == expected_b ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> + for (int i = 0; i < 3; i++) {
> + gl_Position = vertex_to_gs[i];
> + color = tmp_color;
> + EmitVertex();
> + }
> +}
> +
> +[fragment shader]
> +flat in vec4 color;
> +
> +void main()
> +{
> + gl_FragColor = color;
> +}
> +
> +[vertex data]
> +piglit_vertex/float/2
> +-1.0 -1.0
> + 1.0 -1.0
> + 1.0 1.0
> +-1.0 1.0
> +
> +[test]
> +uniform float arg0 -2.99999993e-02
> +uniform float arg1 -8.50000024e-01
> +uniform float arg2 -2.54999995e-02
> +uniform float expected_a 0.00000000e+00
> +uniform float expected_b 6.22123464e-10
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 0 0 0.0 1.0 0.0 1.0
> +uniform float arg0 1.66999996e+00
> +uniform float arg1 6.60000026e-01
> +uniform float arg2 1.00000036e+00
> +uniform float expected_a 2.10220027e+00
> +uniform float expected_b 2.10220051e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 1 0 0.0 1.0 0.0 1.0
> +uniform float arg0 -2.99999993e-02
> +uniform float arg1 6.60000026e-01
> +uniform float arg2 1.41949999e+00
> +uniform float expected_a 1.39970005e+00
> +uniform float expected_b 1.39970005e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 2 0 0.0 1.0 0.0 1.0
> +uniform float arg0 1.87000000e+00
> +uniform float arg1 -2.99999993e-02
> +uniform float arg2 1.56979990e+00
> +uniform float expected_a 1.51369989e+00
> +uniform float expected_b 1.51369989e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 3 0 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/arb_shader_precision/vs-fma-float-float-float.shader_test b/tests/spec/arb_shader_precision/vs-fma-float-float-float.shader_test
> new file mode 100644
> index 0000000..6234ff4
> --- /dev/null
> +++ b/tests/spec/arb_shader_precision/vs-fma-float-float-float.shader_test
> @@ -0,0 +1,65 @@
> +
> +[require]
> +GLSL >= 4.00
> +
> +[vertex shader]
> +#extension GL_ARB_shader_precision : require
> +in vec4 piglit_vertex;
> +flat out vec4 color;
> +uniform float arg0;
> +uniform float arg1;
> +uniform float arg2;
> +uniform float expected_a;
> +uniform float expected_b;
> +
> +void main()
> +{
> + gl_Position = piglit_vertex;
> + float result = fma(arg0, arg1, arg2);
> + color = result == expected_a || result == expected_b ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[fragment shader]
> +flat in vec4 color;
> +
> +void main()
> +{
> + gl_FragColor = color;
> +}
> +
> +[vertex data]
> +piglit_vertex/float/2
> +-1.0 -1.0
> + 1.0 -1.0
> + 1.0 1.0
> +-1.0 1.0
> +
> +[test]
> +uniform float arg0 -2.99999993e-02
> +uniform float arg1 -8.50000024e-01
> +uniform float arg2 -2.54999995e-02
> +uniform float expected_a 0.00000000e+00
> +uniform float expected_b 6.22123464e-10
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 0 0 0.0 1.0 0.0 1.0
> +uniform float arg0 1.66999996e+00
> +uniform float arg1 6.60000026e-01
> +uniform float arg2 1.00000036e+00
> +uniform float expected_a 2.10220027e+00
> +uniform float expected_b 2.10220051e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 1 0 0.0 1.0 0.0 1.0
> +uniform float arg0 -2.99999993e-02
> +uniform float arg1 6.60000026e-01
> +uniform float arg2 1.41949999e+00
> +uniform float expected_a 1.39970005e+00
> +uniform float expected_b 1.39970005e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 2 0 0.0 1.0 0.0 1.0
> +uniform float arg0 1.87000000e+00
> +uniform float arg1 -2.99999993e-02
> +uniform float arg2 1.56979990e+00
> +uniform float expected_a 1.51369989e+00
> +uniform float expected_b 1.51369989e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 3 0 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/arb_shader_precision/vs-manual-fma-float-float-float.shader_test b/tests/spec/arb_shader_precision/vs-manual-fma-float-float-float.shader_test
> new file mode 100644
> index 0000000..4ba2d02
> --- /dev/null
> +++ b/tests/spec/arb_shader_precision/vs-manual-fma-float-float-float.shader_test
> @@ -0,0 +1,65 @@
> +
> +[require]
> +GLSL >= 4.00
> +
> +[vertex shader]
> +#extension GL_ARB_shader_precision : require
> +in vec4 piglit_vertex;
> +flat out vec4 color;
> +uniform float arg0;
> +uniform float arg1;
> +uniform float arg2;
> +uniform float expected_a;
> +uniform float expected_b;
> +
> +void main()
> +{
> + gl_Position = piglit_vertex;
> + float result = arg0 * arg1 + arg2;
> + color = result == expected_a || result == expected_b ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[fragment shader]
> +flat in vec4 color;
> +
> +void main()
> +{
> + gl_FragColor = color;
> +}
> +
> +[vertex data]
> +piglit_vertex/float/2
> +-1.0 -1.0
> + 1.0 -1.0
> + 1.0 1.0
> +-1.0 1.0
> +
> +[test]
> +uniform float arg0 -2.99999993e-02
> +uniform float arg1 -8.50000024e-01
> +uniform float arg2 -2.54999995e-02
> +uniform float expected_a 0.00000000e+00
> +uniform float expected_b 6.22123464e-10
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 0 0 0.0 1.0 0.0 1.0
> +uniform float arg0 1.66999996e+00
> +uniform float arg1 6.60000026e-01
> +uniform float arg2 1.00000036e+00
> +uniform float expected_a 2.10220027e+00
> +uniform float expected_b 2.10220051e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 1 0 0.0 1.0 0.0 1.0
> +uniform float arg0 -2.99999993e-02
> +uniform float arg1 6.60000026e-01
> +uniform float arg2 1.41949999e+00
> +uniform float expected_a 1.39970005e+00
> +uniform float expected_b 1.39970005e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 2 0 0.0 1.0 0.0 1.0
> +uniform float arg0 1.87000000e+00
> +uniform float arg1 -2.99999993e-02
> +uniform float arg2 1.56979990e+00
> +uniform float expected_a 1.51369989e+00
> +uniform float expected_b 1.51369989e+00
> +draw arrays GL_TRIANGLE_FAN 0 4
> +probe rgba 3 0 0.0 1.0 0.0 1.0
> --
> 2.3.5
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
More information about the Piglit
mailing list