[Piglit] [PATCH] Test a geometry shader that does an item-by-item copy of gl_ClipDistance.

Anuj Phogat anuj.phogat at gmail.com
Tue Nov 26 10:30:37 PST 2013


On Fri, Nov 22, 2013 at 1:11 PM, Paul Berry <stereotype441 at gmail.com> wrote:
> This is similar to the existing test "clip-distance-bulk-copy", except
> that it copies the elements of gl_ClipDistance one at a time instead
> of as a bulk assignment.
>
> This test is known to crash with Mesa as of commit ec79c05.
> ---
>  .../clip-distance-itemized-copy.shader_test        | 98 ++++++++++++++++++++++
>  1 file changed, 98 insertions(+)
>  create mode 100644 tests/spec/glsl-1.50/execution/geometry/clip-distance-itemized-copy.shader_test
>
> diff --git a/tests/spec/glsl-1.50/execution/geometry/clip-distance-itemized-copy.shader_test b/tests/spec/glsl-1.50/execution/geometry/clip-distance-itemized-copy.shader_test
> new file mode 100644
> index 0000000..3494110
> --- /dev/null
> +++ b/tests/spec/glsl-1.50/execution/geometry/clip-distance-itemized-copy.shader_test
> @@ -0,0 +1,98 @@
> +# This test checks that the geometry shader can perform an
> +# item-by-item copy of the entire gl_ClipDistance array from input to
> +# output.
> +
> +[require]
> +GL >= 2.0
> +GLSL >= 1.50
> +
> +[vertex shader]
> +#version 150
> +
> +in vec4 vertex;
> +in float offset;
> +out float offset_to_gs;
> +out gl_PerVertex {
> +  vec4 gl_Position;
> +  float gl_ClipDistance[8];
> +};
> +
> +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;
> +    for (int j = 0; j < 8; j++)
> +      gl_ClipDistance[j] = gl_in[i].gl_ClipDistance[j];
> +    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
> --
> 1.8.4.2
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit

Test crashes with Mesa master due to an assertion failure.
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>


More information about the Piglit mailing list