[Piglit] [PATCH v5 3/3] arb_shader_precision: add manually written tests for a*b+c and fma()

Micah Fedke micah.fedke at collabora.co.uk
Thu Apr 16 15:14:02 PDT 2015


Ilia and Ian's comments address here:
http://cgit.collabora.com/git/user/fedke.m/piglit.git/log/?h=complex_tolerances_straight_comments2


-mf

On 04/06/2015 09:16 PM, Ian Romanick wrote:
> On 04/03/2015 02:00 PM, Micah Fedke 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 @@
>> +
>> +[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 = 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
>
> Why not just use 'draw rect -1 -1 2 2'?  I'm also not a fan of tests
> that redraw the whole window multiple times.  Debugging failures that
> aren't in the last subtest is very annoying.
>
> Since there are four subtests, it's better to have each draw to a
> specific region of the window.
>
> draw rect -1 -1 1 1
> ...
> draw rect  1 -1 1 1
> ...
> draw rect -1  1 1 1
> ...
> draw rect  1  1 1 1
>
>> +
>> +[test]
>> +uniform float arg0  -2.99999993e-02
>> +uniform float arg1  -8.50000024e-01
>> +uniform float arg2  -2.54999995e-02
>
> Trying to get bit-exact results using floating point notation always
> makes me nervous.  As of commit d859c94 you can specify float values
> using the raw, IEEE 754 hexadecimal notation.
>
>> +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
>>
>

-- 

Micah Fedke
Collabora Ltd.
+44 1223 362967
https://www.collabora.com/
https://twitter.com/collaboraltd


More information about the Piglit mailing list