[Piglit] [PATCH 3/5] Test use of gl_ClipDistance with uint indices.

Paul Berry stereotype441 at gmail.com
Fri Sep 23 18:54:17 PDT 2011


Because of the way the gl_ClipDistance array is handled in Mesa,
accesses using a uint index may not take precisely the same code path
as accesses using an int index.  This test verifies that
gl_ClipDistance works properly when it is accessed using a uint index.

Tested using the nVidia proprietary Linux driver.
---
 .../vs-clip-distance-uint-index.shader_test        |   78 ++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-uint-index.shader_test

diff --git a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-uint-index.shader_test b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-uint-index.shader_test
new file mode 100644
index 0000000..9cdc788
--- /dev/null
+++ b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-uint-index.shader_test
@@ -0,0 +1,78 @@
+# [description]
+# Verify that gl_ClipDistance works properly when accessed with a
+# uint index.
+#
+# This test uses all 8 gl_ClipDistance values to clip a rectangle to
+# an octagon shape.
+#
+# The octagon is centered at (0.5, 0.5), and has a small radius
+# (distance from center to perpendicular edge) of 0.4.
+
+[require]
+GLSL >= 1.30
+
+[vertex shader]
+#version 130
+
+out float gl_ClipDistance[8];
+
+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 < 8; ++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));
+
+		// Reject points whose 2D coordinate, projected onto
+		// that unit vector, is greater than 0.4.
+		gl_ClipDistance[j] = 0.4 - dot(u, coord);
+	}
+}
+
+[fragment shader]
+#version 130
+void main(void)
+{
+	gl_FragColor = vec4(1, 1, 1, 1);
+}
+
+[test]
+ortho 0 1 0 1
+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 rect 0.0 0.0 1.0 1.0
+
+# Test points inside each hexagon edge
+relative probe rgba (0.850, 0.500) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.747, 0.747) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.500, 0.850) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.253, 0.747) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.150, 0.500) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.253, 0.253) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.500, 0.150) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.747, 0.253) (1.0, 1.0, 1.0, 1.0)
+
+# Test points outside each hexagon edge
+relative probe rgba (0.950, 0.500) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.818, 0.818) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.500, 0.950) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.182, 0.818) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.050, 0.500) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.182, 0.182) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.500, 0.050) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.818, 0.182) (0.0, 0.0, 0.0, 0.0)
-- 
1.7.6.2



More information about the Piglit mailing list