[Piglit] [PATCH] glsl-1.10: Test the sign() function with abs() and negation of its argument
Ian Romanick
idr at freedesktop.org
Wed Jun 27 01:24:15 UTC 2018
On 06/26/2018 05:15 PM, Timothy Arceri wrote:
> On 27/06/18 07:44, Ian Romanick wrote:
>> From: Ian Romanick <ian.d.romanick at intel.com>
>>
>> The fsign(-abs(x)) tests tickle a bug in the Mesa i965 driver that was
>> found by inspection.
>>
>> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
>> ---
>> .../execution/fs-sign-neg-abs.shader_test | 28
>> ++++++++++++++++
>> .../glsl-1.10/execution/fs-sign-neg.shader_test | 26 +++++++++++++++
>> .../execution/vs-sign-neg-abs.shader_test | 38
>> ++++++++++++++++++++++
>> .../glsl-1.10/execution/vs-sign-neg.shader_test | 36
>> ++++++++++++++++++++
>> 4 files changed, 128 insertions(+)
>> create mode 100644
>> tests/spec/glsl-1.10/execution/fs-sign-neg-abs.shader_test
>> create mode 100644
>> tests/spec/glsl-1.10/execution/fs-sign-neg.shader_test
>> create mode 100644
>> tests/spec/glsl-1.10/execution/vs-sign-neg-abs.shader_test
>> create mode 100644
>> tests/spec/glsl-1.10/execution/vs-sign-neg.shader_test
>>
>> diff --git
>> a/tests/spec/glsl-1.10/execution/fs-sign-neg-abs.shader_test
>> b/tests/spec/glsl-1.10/execution/fs-sign-neg-abs.shader_test
>> new file mode 100644
>> index 000000000..285c6e749
>> --- /dev/null
>> +++ b/tests/spec/glsl-1.10/execution/fs-sign-neg-abs.shader_test
>> @@ -0,0 +1,28 @@
>> +[require]
>> +GLSL >= 1.10
>> +
>> +[vertex shader passthrough]
>> +
>> +[fragment shader]
>> +uniform vec4 arg0;
>> +uniform vec4 arg1;
>> +uniform vec4 expect;
>> +
>> +void main()
>> +{
>> + if (sign(-abs(arg0)) != -sign(abs(arg1)))
>> + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
>> + else if (sign(-abs(arg0)) != -abs(sign(arg1)))
>> + gl_FragColor = vec4(0.5, 0.0, 0.5, 1.0);
>> + else if (sign(-abs(arg0)) != expect)
>> + gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
>> + else
>> + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
>> +}
>> +
>> +[test]
>> +uniform vec4 arg0 -5.0 5.0 0.0 0.0
>> +uniform vec4 arg1 -2.0 2.0 0.0 0.0
>> +uniform vec4 expect 1.0 -1.0 0.0 0.0
>
> Shouldn't this be:
>
> uniform vec4 expect -1.0 -1.0 0.0 0.0
You are correct. I had just noticed that after running it through our
CI. I think I've also discovered that we need fp64 versions of these,
and I was going to resend all of it at once.
>> +draw rect -1 -1 2 2
>> +probe rgb 1 1 0.0 1.0 0.0
>> diff --git a/tests/spec/glsl-1.10/execution/fs-sign-neg.shader_test
>> b/tests/spec/glsl-1.10/execution/fs-sign-neg.shader_test
>> new file mode 100644
>> index 000000000..a881fc80f
>> --- /dev/null
>> +++ b/tests/spec/glsl-1.10/execution/fs-sign-neg.shader_test
>> @@ -0,0 +1,26 @@
>> +[require]
>> +GLSL >= 1.10
>> +
>> +[vertex shader passthrough]
>> +
>> +[fragment shader]
>> +uniform vec4 arg0;
>> +uniform vec4 arg1;
>> +uniform vec4 expect;
>> +
>> +void main()
>> +{
>> + if (sign(-arg0) != -sign(arg1))
>> + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
>> + else if (sign(-arg0) != expect)
>> + gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
>> + else
>> + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
>> +}
>> +
>> +[test]
>> +uniform vec4 arg0 -5.0 5.0 0.0 0.0
>> +uniform vec4 arg1 -2.0 2.0 0.0 0.0
>> +uniform vec4 expect 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/glsl-1.10/execution/vs-sign-neg-abs.shader_test
>> b/tests/spec/glsl-1.10/execution/vs-sign-neg-abs.shader_test
>> new file mode 100644
>> index 000000000..e7f0546f3
>> --- /dev/null
>> +++ b/tests/spec/glsl-1.10/execution/vs-sign-neg-abs.shader_test
>> @@ -0,0 +1,38 @@
>> +[require]
>> +GLSL >= 1.10
>> +
>> +[vertex shader]
>> +uniform vec4 arg0;
>> +uniform vec4 arg1;
>> +uniform vec4 expect;
>> +
>> +varying vec4 color;
>> +
>> +void main()
>> +{
>> + if (sign(-abs(arg0)) != -sign(abs(arg1)))
>> + color = vec4(1.0, 0.0, 0.0, 1.0);
>> + else if (sign(-abs(arg0)) != -abs(sign(arg1)))
>> + color = vec4(0.5, 0.0, 0.5, 1.0);
>> + else if (sign(-abs(arg0)) != expect)
>> + color = vec4(0.0, 0.0, 1.0, 1.0);
>> + else
>> + color = vec4(0.0, 1.0, 0.0, 1.0);
>> +
>> + gl_Position = gl_Vertex;
>> +}
>> +
>> +[fragment shader]
>> +varying vec4 color;
>> +
>> +void main()
>> +{
>> + gl_FragColor = color;
>> +}
>> +
>> +[test]
>> +uniform vec4 arg0 -5.0 5.0 0.0 0.0
>> +uniform vec4 arg1 -2.0 2.0 0.0 0.0
>> +uniform vec4 expect 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/glsl-1.10/execution/vs-sign-neg.shader_test
>> b/tests/spec/glsl-1.10/execution/vs-sign-neg.shader_test
>> new file mode 100644
>> index 000000000..0f7526d63
>> --- /dev/null
>> +++ b/tests/spec/glsl-1.10/execution/vs-sign-neg.shader_test
>> @@ -0,0 +1,36 @@
>> +[require]
>> +GLSL >= 1.10
>> +
>> +[vertex shader]
>> +uniform vec4 arg0;
>> +uniform vec4 arg1;
>> +uniform vec4 expect;
>> +
>> +varying vec4 color;
>> +
>> +void main()
>> +{
>> + if (sign(-arg0) != -sign(arg1))
>> + color = vec4(1.0, 0.0, 0.0, 1.0);
>> + else if (sign(-arg0) != expect)
>> + color = vec4(0.0, 0.0, 1.0, 1.0);
>> + else
>> + color = vec4(0.0, 1.0, 0.0, 1.0);
>> +
>> + gl_Position = gl_Vertex;
>> +}
>> +
>> +[fragment shader]
>> +varying vec4 color;
>> +
>> +void main()
>> +{
>> + gl_FragColor = color;
>> +}
>> +
>> +[test]
>> +uniform vec4 arg0 -5.0 5.0 0.0 0.0
>> +uniform vec4 arg1 -2.0 2.0 0.0 0.0
>> +uniform vec4 expect 1.0 -1.0 0.0 0.0
>> +draw rect -1 -1 2 2
>> +probe rgb 1 1 0.0 1.0 0.0
More information about the Piglit
mailing list