[Piglit] [PATCH] Add 5 additional tests for arb_cull_distance

Dylan Baker baker.dylan.c at gmail.com
Thu May 21 16:08:43 PDT 2015


On Thu, May 21, 2015 at 11:45:32PM +0200, Tobias Klausmann wrote:
> These five tests are testing the actual culling.
> Short description:
> If a positive value is supplied to gl_CullDistance, the vertex is inside the
> cull volume. If a negative value is supplied, the vertex is outside the cull
> volume and is discarded.
> 
> Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
> ---
>  ...-distance-vertex-inside-cull-volume.shader_test | 41 +++++++++++++++
>  ...e-vertex-inside-outside-cull-volume.shader_test | 58 ++++++++++++++++++++
>  .../vs-cull-distance-vertex-on-plane.shader_test   | 41 +++++++++++++++
>  ...side-cull-volume-inside-clip-volume.shader_test | 61 ++++++++++++++++++++++
>  ...distance-vertex-outside-cull-volume.shader_test | 44 ++++++++++++++++
>  5 files changed, 245 insertions(+)
>  create mode 100644 tests/spec/arb_cull_distance/vs-cull-distance-vertex-inside-cull-volume.shader_test
>  create mode 100644 tests/spec/arb_cull_distance/vs-cull-distance-vertex-inside-outside-cull-volume.shader_test
>  create mode 100644 tests/spec/arb_cull_distance/vs-cull-distance-vertex-on-plane.shader_test
>  create mode 100644 tests/spec/arb_cull_distance/vs-cull-distance-vertex-outside-cull-volume-inside-clip-volume.shader_test
>  create mode 100644 tests/spec/arb_cull_distance/vs-cull-distance-vertex-outside-cull-volume.shader_test
> 
> diff --git a/tests/spec/arb_cull_distance/vs-cull-distance-vertex-inside-cull-volume.shader_test b/tests/spec/arb_cull_distance/vs-cull-distance-vertex-inside-cull-volume.shader_test
> new file mode 100644
> index 0000000..5dfa194
> --- /dev/null
> +++ b/tests/spec/arb_cull_distance/vs-cull-distance-vertex-inside-cull-volume.shader_test
> @@ -0,0 +1,41 @@
> +# [description]

Does this tag actually do anything?

> +# Use one gl_CullDistance values to _not_ "cull" away a vertex with a positive
> +# value supplied to gl_CullDistance.
> +#
> +# The gl_CullDistance variable provides a mechanism for controlling user
> +# culling. The element gl_CullDistance[i] specifies a cull distance for each
> +# plane i. A distance of 0.0 means that the vertex is on the plane, a positive
> +# distance means that the vertex is insider the cull volume, and a negative
> +# distance means that the point is outside the cull volume. Primitives whose
> +# vertices all have a negative clip distance for plane i will be discarded. 
> +
> +[require]
> +GLSL >= 1.30
> +GL_ARB_cull_distance
> +
> +[vertex shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +
> +out float gl_CullDistance[1];
> +
> +void main(void)
> +{
> +	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> +	gl_CullDistance[0] = 1;
> +}
> +
> +[fragment shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +
> +void main(void)
> +{
> +	gl_FragColor = vec4(0, 1, 0, 1);
> +}
> +
> +[test]
> +clear color 1.0 0.0 0.0 1.0
> +clear
> +draw rect -1 -1 2 2
> +probe all rgba 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/arb_cull_distance/vs-cull-distance-vertex-inside-outside-cull-volume.shader_test b/tests/spec/arb_cull_distance/vs-cull-distance-vertex-inside-outside-cull-volume.shader_test
> new file mode 100644
> index 0000000..1b0df9b
> --- /dev/null
> +++ b/tests/spec/arb_cull_distance/vs-cull-distance-vertex-inside-outside-cull-volume.shader_test
> @@ -0,0 +1,58 @@
> +# [description]
> +# Use 4 gl_CullDistance values to "cull" away some vertices with negative values
> +# supplied to gl_CullDistance.
> +#
> +# The gl_CullDistance variable provides a mechanism for controlling user
> +# culling. The element gl_CullDistance[i] specifies a cull distance for each
> +# plane i. A distance of 0.0 means that the vertex is on the plane, a positive
> +# distance means that the vertex is insider the cull volume, and a negative
> +# distance means that the point is outside the cull volume. Primitives whose
> +# vertices all have a negative clip distance for plane i will be discarded. 
> +
> +[require]
> +GLSL >= 1.30
> +GL_ARB_cull_distance
> +
> +[vertex shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +
> +out float gl_CullDistance[4];
> +
> +void main(void)
> +{
> +         gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> +
> +         // Compute 2D cordinates relative to a center point of (0.5,
> +         // 0.5).
> +         vec2 coord = gl_Vertex.xy - vec2(0.5, 0.5);
> +
> +         for (int i = 0; i < 4; ++i) {
> +                  uint j = uint(i);
> +
> +                  // Compute a unit vector in the direction i*45deg from
> +                  // the x axis.
> +                  float angle = i*(3.141592653589793/4);
> +                  vec2 u = vec2(cos(angle), sin(angle));
> +
> +                  gl_CullDistance[j] = -0.5 - dot(u, coord);
> +         }
> +}
> +
> +[fragment shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +
> +void main(void)
> +{
> +         gl_FragColor = vec4(0, 1, 1, 1);
> +}
> +
> +[test]
> +clear color 0.0 1.0 0.0 1.0
> +clear
> +ortho 0 2 0 2
> +draw rect 0.0 0.0 1.0 1.0
> +
> +relative probe rgba (0.100, 0.100) (0.0, 1.0, 1.0, 1.0)
> +relative probe rgba (0.900, 0.900) (0.0, 1.0, 0.0, 1.0)
> diff --git a/tests/spec/arb_cull_distance/vs-cull-distance-vertex-on-plane.shader_test b/tests/spec/arb_cull_distance/vs-cull-distance-vertex-on-plane.shader_test
> new file mode 100644
> index 0000000..40b74ce
> --- /dev/null
> +++ b/tests/spec/arb_cull_distance/vs-cull-distance-vertex-on-plane.shader_test
> @@ -0,0 +1,41 @@
> +# [description]
> +# Use one gl_CullDistance values to _not_ "cull" away a vertex with it on
> +# the plane (gl_CullDistance=0).
> +#
> +# The gl_CullDistance variable provides a mechanism for controlling user
> +# culling. The element gl_CullDistance[i] specifies a cull distance for each
> +# plane i. A distance of 0.0 means that the vertex is on the plane, a positive
> +# distance means that the vertex is insider the cull volume, and a negative
> +# distance means that the point is outside the cull volume. Primitives whose
> +# vertices all have a negative clip distance for plane i will be discarded. 
> +
> +[require]
> +GLSL >= 1.30
> +GL_ARB_cull_distance
> +
> +[vertex shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +
> +out float gl_CullDistance[1];
> +
> +void main(void)
> +{
> +	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> +	gl_CullDistance[0] = 0;
> +}
> +
> +[fragment shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +
> +void main(void)
> +{
> +	gl_FragColor = vec4(0, 1, 0, 1);
> +}
> +
> +[test]
> +clear color 1.0 0.0 0.0 1.0
> +clear
> +draw rect -1 -1 2 2
> +probe all rgba 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/arb_cull_distance/vs-cull-distance-vertex-outside-cull-volume-inside-clip-volume.shader_test b/tests/spec/arb_cull_distance/vs-cull-distance-vertex-outside-cull-volume-inside-clip-volume.shader_test
> new file mode 100644
> index 0000000..a060ac1
> --- /dev/null
> +++ b/tests/spec/arb_cull_distance/vs-cull-distance-vertex-outside-cull-volume-inside-clip-volume.shader_test
> @@ -0,0 +1,61 @@
> +# [description]
> +# Use two gl_CullDistance values to "cull" away some vertices with negative
> +# values. Additionally use two gl_ClipDistance values with positive values to
> +# see if gl_CullDistance and gl_ClipDistance are different arrays.
> +#
> +# The gl_CullDistance variable provides a mechanism for controlling user
> +# culling. The element gl_CullDistance[i] specifies a cull distance for each
> +# plane i. A distance of 0.0 means that the vertex is on the plane, a positive
> +# distance means that the vertex is insider the cull volume, and a negative
> +# distance means that the point is outside the cull volume. Primitives whose
> +# vertices all have a negative clip distance for plane i will be discarded. 
> +
> +[require]
> +GLSL >= 1.30
> +GL_ARB_cull_distance
> +
> +[vertex shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +
> +out float gl_ClipDistance[2];
> +out float gl_CullDistance[2];
> +
> +void main(void)
> +{
> +         gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> +
> +         // Compute 2D cordinates relative to a center point of (0.5,
> +         // 0.5).
> +         vec2 coord = gl_Vertex.xy - vec2(0.5, 0.5);
> +
> +         for (int i = 0; i < 2; ++i) {
> +                  uint j = uint(i);
> +
> +                  // Compute a unit vector in the direction i*45deg from
> +                  // the x axis.
> +                  float angle = i*(3.141592653589793/4);
> +                  vec2 u = vec2(cos(angle), sin(angle));
> +
> +                  gl_CullDistance[j] = -0.5 - dot(u, coord);
> +                  gl_ClipDistance[j] = 1 - dot(u, coord);
> +         }
> +}
> +
> +[fragment shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +
> +void main(void)
> +{
> +         gl_FragColor = vec4(0, 1, 1, 1);
> +}
> +
> +[test]
> +clear color 0.0 1.0 0.0 1.0
> +clear
> +ortho 0 2 0 2
> +draw rect 0.0 0.0 1.0 1.0
> +
> +relative probe rgba (0.100, 0.100) (0.0, 1.0, 1.0, 1.0)
> +relative probe rgba (0.900, 0.900) (0.0, 1.0, 0.0, 1.0)
> diff --git a/tests/spec/arb_cull_distance/vs-cull-distance-vertex-outside-cull-volume.shader_test b/tests/spec/arb_cull_distance/vs-cull-distance-vertex-outside-cull-volume.shader_test
> new file mode 100644
> index 0000000..7ad7e5f
> --- /dev/null
> +++ b/tests/spec/arb_cull_distance/vs-cull-distance-vertex-outside-cull-volume.shader_test
> @@ -0,0 +1,44 @@
> +# [description]
> +# Use one gl_CullDistance values to "cull" away a vertex with a negative value
> +# supplied to gl_CullDistance.
> +#
> +# The gl_CullDistance variable provides a mechanism for controlling user
> +# culling. The element gl_CullDistance[i] specifies a cull distance for each
> +# plane i. A distance of 0.0 means that the vertex is on the plane, a positive
> +# distance means that the vertex is insider the cull volume, and a negative
> +# distance means that the point is outside the cull volume. Primitives whose
> +# vertices all have a negative clip distance for plane i will be discarded. 
> +
> +[require]
> +GLSL >= 1.30
> +GL_ARB_cull_distance
> +
> +[vertex shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +
> +out float gl_CullDistance[1];
> +
> +void main(void)
> +{
> +         gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> +
> +         gl_CullDistance[0] = -1;
> +}
> +
> +[fragment shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +
> +void main(void)
> +{
> +         gl_FragColor = vec4(1, 0, 0, 1);
> +}
> +
> +[test]
> +clear color 0.0 1.0 0.0 1.0
> +clear
> +ortho 0 1 0 1
> +draw rect 1.0 0.0 0.0 1.0
> +
> +probe all rgba 0.0 1.0 0.0 1.0
> -- 
> 2.4.1
> 
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20150521/e93d6f5e/attachment.sig>


More information about the Piglit mailing list