[Piglit] [PATCH] piglit: Add tests to validate switch statements in OpenGL 3.0.

Ian Romanick idr at freedesktop.org
Wed Aug 24 12:40:49 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/24/2011 12:00 PM, Ian Romanick wrote:
> On 08/23/2011 09:25 AM, Paul Berry wrote:
>> Another pattern I've found useful is to write the shader so that its
>> behavior depends on the setting of uniforms rather than on screen
>> coordinates.  It makes for a more boring-looking render, but it can be
>> a lot easier to reason about what's going on in the test.  For
>> example, here's an alternative version of this test using uniforms:
> 
> In this case, I think it's useful to use something in a varying.  We do
> need to test using varyings as switch-statement controls.  A lot of
> tests will do some modification of the incoming gl_Vertex to map it to
> [0,1] in the vertex shader.
> 
> This might be a place to test integer varyings, too.  Assuming ortho is
> used, a vertex shader like this should do the trick:
> 
> #version 130
> flat out ivec2 control;

Ignore this whole bit about integer varyings.  Integer varyings must be
used with the 'flat' qualifier, and the flat qualifier means that
there's no interpolation (duh).  This is not what we want.

> void main() {
> 	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> 	control = ivec2(gl_Vertex * 2.0);
> }
> 
> Then the fragment shader can just do some simple integer math on control
> to generate the correct switch value for the quadrant.  For that, I'd
> recommend something like:
> 
>     value = (control.y << 2) | control.x;

This, however, is still a good idea.  It just means we need to move the
ivec(vec2) cast from my bogus vertex shader to the fragment shader.

> The switch statement would handle 0, 1, 4, and 5.  Other values should
> generate the error color.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk5VU8EACgkQX1gOwKyEAw80bgCgjAFvX/JpKYbWLyLk1LHa8fiq
e64AoJZg+ns9a34qY8ZD+6LHHRzE/sqU
=N5C4
-----END PGP SIGNATURE-----


More information about the Piglit mailing list