[Piglit] [PATCH 4/4] glsl-1.20: Add tests for clip vertex.

Paul Berry stereotype441 at gmail.com
Fri Jun 24 14:41:56 PDT 2011


Test the functionality of gl_ClipVertex by creating 6 clip planes that
chop a rectangle into a hexagon, and then probe to verify the
hexagon's shape.
---
 .../execution/vs-clip-vertex-01.shader_test        |   55 ++++++++++++++++++
 .../execution/vs-clip-vertex-02.shader_test        |   60 ++++++++++++++++++++
 2 files changed, 115 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/glsl-1.20/execution/vs-clip-vertex-01.shader_test
 create mode 100644 tests/spec/glsl-1.20/execution/vs-clip-vertex-02.shader_test

diff --git a/tests/spec/glsl-1.20/execution/vs-clip-vertex-01.shader_test b/tests/spec/glsl-1.20/execution/vs-clip-vertex-01.shader_test
new file mode 100644
index 0000000..773936b
--- /dev/null
+++ b/tests/spec/glsl-1.20/execution/vs-clip-vertex-01.shader_test
@@ -0,0 +1,55 @@
+# [description]
+# Use all 6 clip planes to clip a rectangle to a hexagon shape.
+#
+# In this test, gl_Position and gl_ClipVertex are the same.
+
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+#version 120
+void main(void)
+{
+	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+
+	gl_ClipVertex = gl_Position;
+}
+
+[fragment shader]
+#version 120
+void main(void)
+{
+	gl_FragColor = vec4(1, 1, 1, 1);
+}
+
+[test]
+ortho 0 1 0 1
+clip plane 0 0 1 0 0.5
+clip plane 1 -1 1 0 0.8
+clip plane 2 -1 -1 0 0.8
+clip plane 3 0 -1 0 0.5
+clip plane 4 1 -1 0 0.8
+clip plane 5 1 1 0 0.8
+enable GL_CLIP_PLANE0
+enable GL_CLIP_PLANE1
+enable GL_CLIP_PLANE2
+enable GL_CLIP_PLANE3
+enable GL_CLIP_PLANE4
+enable GL_CLIP_PLANE5
+draw rect 0.1 0.1 0.8 0.8
+
+# Test points inside each hexagon edge
+relative probe rgba (0.3, 0.4) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.5, 0.3) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.7, 0.4) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.7, 0.6) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.5, 0.7) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.3, 0.6) (1.0, 1.0, 1.0, 1.0)
+
+# Test points outside each hexagon edge
+relative probe rgba (0.2, 0.3) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.5, 0.2) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.8, 0.3) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.8, 0.7) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.5, 0.8) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.2, 0.7) (0.0, 0.0, 0.0, 0.0)
diff --git a/tests/spec/glsl-1.20/execution/vs-clip-vertex-02.shader_test b/tests/spec/glsl-1.20/execution/vs-clip-vertex-02.shader_test
new file mode 100644
index 0000000..ae1440d
--- /dev/null
+++ b/tests/spec/glsl-1.20/execution/vs-clip-vertex-02.shader_test
@@ -0,0 +1,60 @@
+# [description]
+# Use all 6 clip planes to clip a rectangle to a hexagon shape.
+#
+# In this test, gl_Position and gl_ClipVertex are different to verify
+# that gl_Position determines screen position and gl_ClipVertex
+# determines clipping.
+
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+#version 120
+void main(void)
+{
+	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+
+	// Transform gl_ClipVertex in an arbitrary way so that
+	// we can verify it is being used for clipping instead of
+	// gl_Position.
+	gl_ClipVertex = gl_Vertex * vec4(10.0, 10.0, 1.0, 1.0);
+}
+
+[fragment shader]
+#version 120
+void main(void)
+{
+	gl_FragColor = vec4(1, 1, 1, 1);
+}
+
+[test]
+ortho 0 1 0 1
+clip plane 0 0 1 0 -2.5
+clip plane 1 -1 1 0 4
+clip plane 2 -1 -1 0 14
+clip plane 3 0 -1 0 7.5
+clip plane 4 1 -1 0 4
+clip plane 5 1 1 0 -6
+enable GL_CLIP_PLANE0
+enable GL_CLIP_PLANE1
+enable GL_CLIP_PLANE2
+enable GL_CLIP_PLANE3
+enable GL_CLIP_PLANE4
+enable GL_CLIP_PLANE5
+draw rect 0.1 0.1 0.8 0.8
+
+# Test points inside each hexagon edge
+relative probe rgba (0.3, 0.4) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.5, 0.3) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.7, 0.4) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.7, 0.6) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.5, 0.7) (1.0, 1.0, 1.0, 1.0)
+relative probe rgba (0.3, 0.6) (1.0, 1.0, 1.0, 1.0)
+
+# Test points outside each hexagon edge
+relative probe rgba (0.2, 0.3) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.5, 0.2) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.8, 0.3) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.8, 0.7) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.5, 0.8) (0.0, 0.0, 0.0, 0.0)
+relative probe rgba (0.2, 0.7) (0.0, 0.0, 0.0, 0.0)
-- 
1.7.5.4



More information about the Piglit mailing list