[Piglit] [PATCH 1/2] Geometry shaders: Test gl_ClipDistance input (GLSL 1.50)
Paul Berry
stereotype441 at gmail.com
Wed Jun 12 12:39:31 PDT 2013
On 12 June 2013 02:29, Fabian Bieler <fabianbieler at fastmail.fm> wrote:
> On 2013-06-12 01:50, Paul Berry wrote:
> > This patch adds piglit tests to ensure that gl_ClipDistance works
> > properly as a geometry shader input.
> [...]
> > +in gl_PerVertex {
> > + float gl_ClipDistance[2];
> > +} gl_in[];
> I'm not sure if it's ok to leave out members when redeclaring built-in
> interface blocks (gl_Position and gl_PointSize in this case). I didn't find
> anything on this in the spec but a quick google search indicates it's
> common practice so it should probably be ok.
> [...]
>
My observation of the nVidia proprietary driver is that it doesn't care
whether you leave out members when redeclaring built-in interface blocks,
provided that you don't try to use the members that you leave out. Jordan,
you've looked at interface blocks more recently than I have. Do you have
an opinion on this?
> > diff --git
> a/tests/spec/glsl-1.50/execution/geometry/clip-distance-bulk-copy.shader_test
> b/tests/spec/glsl-1.50/execution/geometry/clip-distance-bulk-copy.shader_test
> > new file mode 100644
> > index 0000000..fbdee46
> > --- /dev/null
> > +++
> b/tests/spec/glsl-1.50/execution/geometry/clip-distance-bulk-copy.shader_test
> > @@ -0,0 +1,93 @@
> > +# This test checks that the geometry shader can perform a bulk copy of
> > +# the entire gl_ClipDistance array from input to output.
> > +
> > +[require]
> > +GL >= 2.0
> Up to version 3.0 OpenGL only mandates the support of up to 6 user defined
> clip planes/distances. The version requirement should probably be bumped to
> 3.1 or only 6 clip distances should be used. This also applies to the same
> test in the next patch of the series.
>
Yes, but GLSL 1.30 onward require that gl_MaxClipDistances be at least 8.
Since this test requires GLSL 1.50 (see line below) there shouldn't be a
problem.
> > +GLSL >= 1.50
> > +
> > +[vertex shader]
> > +#version 150
> > +
> > +in vec4 vertex;
> > +in float offset;
> > +out float offset_to_gs;
> > +out float gl_ClipDistance[8];
> Shouldn't gl_ClipDistance be redeclared inside the gl_PerVertex interface
> block? I know the spec allows redeclaring gl_TexCoord at global scope in
> the compatibility profile but it explicitly states:
> "This treatment is a special case for gl_TexCoord[], not a general method
> for redeclaring members of blocks." (glsl spec v1.5 page 79 (page 85 of the
> PDF)).
>
Good point. I'll fix this.
> > +
> > +void main()
> > +{
> > + gl_Position = vertex;
> > + offset_to_gs = offset;
> > + for (int i = 0; i < 8; i++) {
> > + gl_ClipDistance[i] = offset + float(i);
> > + }
> > +}
> > +
> > +[geometry shader]
> > +#version 150
> > +
> > +layout(triangles) in;
> > +layout(triangle_strip, max_vertices = 3) out;
> > +
> > +in float offset_to_gs[3];
> > +in gl_PerVertex {
> > + vec4 gl_Position;
> > + float gl_ClipDistance[8];
> > +} gl_in[];
> > +out float offset_to_fs;
> > +out gl_PerVertex {
> > + vec4 gl_Position;
> > + float gl_ClipDistance[8];
> > +};
> > +
> > +void main()
> > +{
> > + bool ok = true;
> > + for (int i = 0; i < 3; i++) {
> > + gl_Position = gl_in[i].gl_Position;
> > + gl_ClipDistance = gl_in[i].gl_ClipDistance;
> > + offset_to_fs = offset_to_gs[i];
> > + EmitVertex();
> > + }
> > +}
> > +
> > +[fragment shader]
> > +#version 150
> > +
> > +in float gl_ClipDistance[8];
> > +in float offset_to_fs;
> > +
> > +void main()
> > +{
> > + bool ok = true;
> > + for (int i = 0; i < 8; i++) {
> > + if (distance(gl_ClipDistance[i], offset_to_fs + float(i)) > 1e-6)
> > + ok = false;
> > + }
> > + if (ok)
> > + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
> > + else
> > + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
> > +}
> > +
> > +[vertex data]
> > +vertex/float/2 offset/float/1
> > +-1.0 -1.0 1.0
> > + 1.0 -1.0 2.0
> > + 1.0 1.0 3.0
> > +-1.0 1.0 4.0
> > +
> > +[test]
> > +# Since the fragment shader's gl_ClipDistance array is only defined
> > +# for elements that have clipping enabled, we need to enable all 8
> > +# clip planes. Fortunately the values we use for gl_ClipDistance are
> > +# always positive, so no pixels are actually clipped.
> > +enable GL_CLIP_PLANE0
> > +enable GL_CLIP_PLANE1
> > +enable GL_CLIP_PLANE2
> > +enable GL_CLIP_PLANE3
> > +enable GL_CLIP_PLANE4
> > +enable GL_CLIP_PLANE5
> > +enable GL_CLIP_PLANE6
> > +enable GL_CLIP_PLANE7
> > +draw arrays GL_TRIANGLE_FAN 0 4
> > +probe all rgba 0.0 1.0 0.0 1.0
> [...]
>
> Otherwise, the series looks good to me.
>
> Fabian
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130612/00f0a0f7/attachment.html>
More information about the Piglit
mailing list