Am 23.03.2013 01:41, schrieb Ian Romanick:
> On 03/22/2013 03:28 PM, [email protected] wrote:
>> From: Roland Scheidegger <[email protected]>
>>
>> Similar to glsl-fs-main-return (and glsl-vs-main-return), this is testing
>> using return in main. Contrary to the these other tests, this hits both
>> the cases where the return path is and is NOT taken (the gallivm code
>> got it wrong and always did an early exit which got unnoticed by the
>> existing tests, see https://bugs.freedesktop.org/show_bug.cgi?id=62357).
>> It also needs glsl 1.30 (even though this is not specific to what's
>> tested
>> here).
>
> Are there any drivers in Mesa that don't expose GLSL 1.30 but would
> benefit from this test?
I don't think so but I'm not sure.
>
>> ---
>> .../glsl-fs-main-return-conditional.shader_test | 34
>> ++++++++++++++++++++
>> 1 file changed, 34 insertions(+)
>> create mode 100644
>> tests/shaders/glsl-fs-main-return-conditional.shader_test
>>
>> diff --git a/tests/shaders/glsl-fs-main-return-conditional.shader_test
>> b/tests/shaders/glsl-fs-main-return-conditional.shader_test
>> new file mode 100644
>> index 0000000..124a4cd
>> --- /dev/null
>> +++ b/tests/shaders/glsl-fs-main-return-conditional.shader_test
>> @@ -0,0 +1,34 @@
>> +[require]
>> +GLSL >= 1.30
>> +
>> +[vertex shader]
>> +#version 130
>> +void main()
>> +{
>> + gl_Position = gl_Vertex;
>> +}
>> +
>> +[fragment shader]
>> +#version 130
>> +uniform vec4 v;
>
> This could just be
>
> const vec4 v = vec4(0., 1., 0., 1.);
>
> and delete the uniform setting in the [test] section.
Yeah I guess this was a uniform originally so the compiler wouldn't just
get rid of the conditional altogether but since the condition no longer
depends on it this is unnecessary.
>
>> +
>> +void main()
>> +{
>> + uint posintx = uint(gl_FragCoord.x);
>> + uint one = uint(1);
>> + gl_FragColor = v;
>> + if ((posintx & one) == one) {
>> + return; // return for every second pixel
>> + }
>> + gl_FragColor = vec4(1.0) - v;
>> +}
>
> It seems like this could be done as:
>
> void main()
> {
> floor x = floor(gl_FragCoord.x - 0.5);
>
> gl_FragCoord = v;
> if (mod(x, 2.0) > epsilon)
> return;
>
> gl_FragColor = vec4(1.0) - v;
> }
Sounds like a good idea, I forgot about the mod() which gets rid of glsl
1.30 requirement. In fact the floor is unnecessary too can simplify this
more. I'll send out another version...
Roland
_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit