[Piglit] [PATCH] arb_gpu_shader_fp64: add glsl algebraic tests

Tapani Pälli tapani.palli at intel.com
Sun Feb 15 21:57:30 PST 2015


On 02/13/2015 04:17 PM, Ilia Mirkin wrote:
> On Fri, Feb 13, 2015 at 7:32 AM, Tapani Pälli <tapani.palli at intel.com> wrote:
>> add tests for add, csel, div, mul, neg operations
>>
>> v2: correct alpha values (Chris Forbes),
>>      + changes to use distance and tolerance in the tests and
>>      making sure that all calculation and comparison happens in doubles
>>
>> All tests pass on Nvidia GeForce 660 (binary driver version 331.38)
>>
>> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
>> ---
>>   .../glsl-algebraic-add-double.shader_test          | 29 ++++++++++++++++++++++
>>   .../glsl-algebraic-csel-double.shader_test         | 20 +++++++++++++++
>>   .../glsl-algebraic-div-double.shader_test          | 29 ++++++++++++++++++++++
>>   .../glsl-algebraic-mul-double.shader_test          | 29 ++++++++++++++++++++++
>>   .../glsl-algebraic-neg-double.shader_test          | 20 +++++++++++++++
>>   .../glsl-algebraic-sub-double.shader_test          | 29 ++++++++++++++++++++++
>>   6 files changed, 156 insertions(+)
>>   create mode 100644 tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-add-double.shader_test
>>   create mode 100644 tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-csel-double.shader_test
>>   create mode 100644 tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-div-double.shader_test
>>   create mode 100644 tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-mul-double.shader_test
>>   create mode 100644 tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-neg-double.shader_test
>>   create mode 100644 tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-sub-double.shader_test
>>
>> diff --git a/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-add-double.shader_test b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-add-double.shader_test
>> new file mode 100644
>> index 0000000..19d3af4
>> --- /dev/null
>> +++ b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-add-double.shader_test
>> @@ -0,0 +1,29 @@
>> +[require]
>> +GLSL >= 1.50
>> +GL_ARB_gpu_shader_fp64
>> +
>> +[vertex shader passthrough]
>> +
>> +[fragment shader]
>> +#version 150
>> +#extension GL_ARB_gpu_shader_fp64 : enable
>> +uniform dvec4 a;
>> +uniform dvec4 b;
>> +uniform dvec4 expected;
>> +const double tolerance = 1.0000000000000002e-05;
>
> That should probably be LF.

Yes, that's missing.

>> +void main()
>> +{
>> +       dvec4 result = dvec4(a + b);
>
> Why the dvec4? Also, what does this test add that the existing
> generated tests don't have? (e.g. fs-op-add-dvec4-dvec4)

I wanted to have the distance comparison happen with actual double 
values resulted from calculation instead of converting first to float 
and compare that.

To be honest, I'm not sure if these tests add anything to the generated 
tests. What I see is that the generated tests seem quite complex and 
debugging is much easier with simple tests, most bugs in the Intel 
driver backend fp64 implementation were found with even smaller tests 
than these. I'm ok with not having these in the tree, I just corrected 
them to use the distance always, the previous tests I sent were too 
strict and would not pass on Intel.


>> +
>> +       if (distance(expected, result) < tolerance)
>> +               gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
>> +       else
>> +               gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
>> +}
>> +
>> +[test]
>> +uniform dvec4 a 0.2 0.8 0.1 0.0
>> +uniform dvec4 b 0.3 0.2 0.7 1.0
>> +uniform dvec4 expected 0.5 1.0 0.8 1.0
>> +draw rect -1 -1 2 2
>> +probe all rgba 0.0 1.0 0.0 1.0
>> diff --git a/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-csel-double.shader_test b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-csel-double.shader_test
>> new file mode 100644
>> index 0000000..e8bf9f8
>> --- /dev/null
>> +++ b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-csel-double.shader_test
>> @@ -0,0 +1,20 @@
>> +[require]
>> +GLSL >= 1.50
>> +GL_ARB_gpu_shader_fp64
>> +
>> +[vertex shader passthrough]
>> +
>> +[fragment shader]
>> +#version 150
>> +#extension GL_ARB_gpu_shader_fp64 : enable
>> +void main()
>> +{
>> +       const double small = 1.0lf;
>> +       const double big = 2.0lf;
>> +       double val = (big > small) ? 1.0lf : 0.0lf;
>> +       gl_FragColor = vec4(val, 0.0, val, 1.0);
>> +}
>> +
>> +[test]
>> +draw rect -1 -1 2 2
>> +probe all rgb 1.0 0 1.0
>
> Usually we do green for success... how about
>
> vec4(0, val, 0, 1)

Ok that's fine, I don't quite agree on the 'default green' idea though. 
I think ideally Piglit should use more randomized (but hardcoded) colors 
and patterns of those instead of complete solid colors (and always the 
same) which has the possibility to hide implementation issues.

>> diff --git a/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-div-double.shader_test b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-div-double.shader_test
>> new file mode 100644
>> index 0000000..df27a8c
>> --- /dev/null
>> +++ b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-div-double.shader_test
>> @@ -0,0 +1,29 @@
>> +[require]
>> +GLSL >= 1.50
>> +GL_ARB_gpu_shader_fp64
>> +
>> +[vertex shader passthrough]
>> +
>> +[fragment shader]
>> +#version 150
>> +#extension GL_ARB_gpu_shader_fp64 : enable
>> +uniform dvec4 a;
>> +uniform dvec4 b;
>> +uniform dvec4 expected;
>> +const double tolerance = 1.0000000000000002e-05;
>
> lf
>
>> +void main()
>> +{
>> +       dvec4 result = dvec4(a / b);
>
> Why dvec? Also same question about this vs fs-op-div-dvec4-dvec4.
>
>> +
>> +       if (distance(expected, result) < tolerance)
>> +               gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
>> +       else
>> +               gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
>> +}
>> +
>> +[test]
>> +uniform dvec4 a 1.0 0.6 1.0 1.0
>> +uniform dvec4 b 2.0 3.0 4.0 1.0
>> +uniform dvec4 expected 0.5 0.2 0.25 1.0
>> +draw rect -1 -1 2 2
>> +probe all rgba 0.0 1.0 0.0 1.0
>> diff --git a/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-mul-double.shader_test b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-mul-double.shader_test
>> new file mode 100644
>> index 0000000..d425670
>> --- /dev/null
>> +++ b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-mul-double.shader_test
>> @@ -0,0 +1,29 @@
>> +[require]
>> +GLSL >= 1.50
>> +GL_ARB_gpu_shader_fp64
>> +
>> +[vertex shader passthrough]
>> +
>> +[fragment shader]
>> +#version 150
>> +#extension GL_ARB_gpu_shader_fp64 : enable
>> +uniform dvec4 a;
>> +uniform dvec4 b;
>> +uniform dvec4 expected;
>> +const double tolerance = 1.0000000000000002e-05;
>> +void main()
>> +{
>> +       dvec4 result = dvec4(a * b);
>
> fs-op-mult-dvec4-dvec4?
>
>> +
>> +       if (distance(expected, result) < tolerance)
>> +               gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
>> +       else
>> +               gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
>> +}
>> +
>> +[test]
>> +uniform dvec4 a 2.0 1.0 1.0 1.0
>> +uniform dvec4 b 0.5 0.2 0.7 1.0
>> +uniform dvec4 expected 1.0 0.2 0.7 1.0
>> +draw rect -1 -1 2 2
>> +probe all rgba 0.0 1.0 0.0 1.0
>> diff --git a/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-neg-double.shader_test b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-neg-double.shader_test
>> new file mode 100644
>> index 0000000..3dc6c13
>> --- /dev/null
>> +++ b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-neg-double.shader_test
>> @@ -0,0 +1,20 @@
>> +[require]
>> +GLSL >= 1.50
>> +GL_ARB_gpu_shader_fp64
>> +
>> +[vertex shader passthrough]
>> +
>> +[fragment shader]
>> +#version 150
>> +#extension GL_ARB_gpu_shader_fp64 : enable
>> +uniform vec4 color;
>> +void main()
>> +{
>> +       dvec4 dcolor = color;
>
> Make more sense to just make color a dvec4... but I guess this works either way.
>
>> +       gl_FragColor = vec4(-dcolor);
>> +}
>> +
>> +[test]
>> +uniform vec4 color 1.0 -1.0 0.0 0.0
>> +draw rect -1 -1 2 2
>> +probe rgb 1 1 0.0 1.0 0.0
>> diff --git a/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-sub-double.shader_test b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-sub-double.shader_test
>> new file mode 100644
>> index 0000000..e9c5ffb
>> --- /dev/null
>> +++ b/tests/spec/arb_gpu_shader_fp64/execution/built-in-functions/glsl-algebraic-sub-double.shader_test
>> @@ -0,0 +1,29 @@
>> +[require]
>> +GLSL >= 1.50
>> +GL_ARB_gpu_shader_fp64
>> +
>> +[vertex shader passthrough]
>> +
>> +[fragment shader]
>> +#version 150
>> +#extension GL_ARB_gpu_shader_fp64 : enable
>> +uniform dvec4 a;
>> +uniform dvec4 b;
>> +uniform dvec4 expected;
>> +const double tolerance = 1.0000000000000002e-05;
>> +void main()
>> +{
>> +       dvec4 result = dvec4(a - b);
>
> fs-op-sub-dvec4-dvec4
>
>> +
>> +       if (distance(expected, result) < tolerance)
>> +               gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
>> +       else
>> +               gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
>> +}
>> +
>> +[test]
>> +uniform dvec4 a 0.3 0.8 0.9 1.0
>> +uniform dvec4 b 0.2 0.2 0.1 0.0
>> +uniform dvec4 expected 0.1 0.6 0.8 1.0
>> +draw rect -1 -1 2 2
>> +probe all rgba 0.0 1.0 0.0 1.0
>> --
>> 2.1.0
>>


More information about the Piglit mailing list