[Piglit] [PATCH 5/6] Add trivial clip tests.

Paul Berry stereotype441 at gmail.com
Sun Sep 4 11:34:32 PDT 2011


These tests verify correct behavior when gl_ClipDistance and
gl_ClipVertex are set to constant values.
---
 .../vs-clip-vertex-const-accept.shader_test        |   40 ++++++++++++++++++++
 .../vs-clip-vertex-const-reject.shader_test        |   40 ++++++++++++++++++++
 .../vs-clip-distance-const-accept.shader_test      |   38 +++++++++++++++++++
 .../vs-clip-distance-const-reject.shader_test      |   38 +++++++++++++++++++
 4 files changed, 156 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-const-accept.shader_test
 create mode 100644 tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-const-reject.shader_test
 create mode 100644 tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-const-accept.shader_test
 create mode 100644 tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-const-reject.shader_test

diff --git a/tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-const-accept.shader_test b/tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-const-accept.shader_test
new file mode 100644
index 0000000..74835eb
--- /dev/null
+++ b/tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-const-accept.shader_test
@@ -0,0 +1,40 @@
+# From the GL 2.1 spec, section 2.17 (Clipping):
+#
+#   All points with eye coordinates (x_e y_e z_e w_e)^T that satisfy
+#
+#                          (x_e)
+#     (p_1' p_2' p_3' p_4')(y_e) >= 0
+#                          (z_e)
+#                          (w_e)
+#
+#   lie in the half-space defined by the plane; points that do not
+#   satisfy this condition do not lie in the half-space.
+#
+# This test checks that gl_ClipVertex works properly for the trivial
+# case where gl_ClipVertex is a constant value satisfying the above
+# inequality.
+
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+#version 120
+void main(void)
+{
+	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+
+	gl_ClipVertex = vec4(1.0, 0.0, 0.0, 0.0);
+}
+
+[fragment shader]
+#version 120
+void main(void)
+{
+	gl_FragColor = vec4(1.0);
+}
+
+[test]
+clip plane 0 1 0 0 0 # accept points where gl_ClipVertex.x >= 0
+enable GL_CLIP_PLANE0
+draw rect -1 -1 2 2
+probe all rgba 1.0 1.0 1.0 1.0
diff --git a/tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-const-reject.shader_test b/tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-const-reject.shader_test
new file mode 100644
index 0000000..78f35e5
--- /dev/null
+++ b/tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-const-reject.shader_test
@@ -0,0 +1,40 @@
+# From the GL 2.1 spec, section 2.17 (Clipping):
+#
+#   All points with eye coordinates (x_e y_e z_e w_e)^T that satisfy
+#
+#                          (x_e)
+#     (p_1' p_2' p_3' p_4')(y_e) >= 0
+#                          (z_e)
+#                          (w_e)
+#
+#   lie in the half-space defined by the plane; points that do not
+#   satisfy this condition do not lie in the half-space.
+#
+# This test checks that gl_ClipVertex works properly for the trivial
+# case where gl_ClipVertex is a constant value not satisfying the
+# above inequality.
+
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+#version 120
+void main(void)
+{
+	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+
+	gl_ClipVertex = vec4(-1.0, 0.0, 0.0, 0.0);
+}
+
+[fragment shader]
+#version 120
+void main(void)
+{
+	gl_FragColor = vec4(1.0);
+}
+
+[test]
+clip plane 0 1 0 0 0 # accept points where gl_ClipVertex.x >= 0
+enable GL_CLIP_PLANE0
+draw rect -1 -1 2 2
+probe all rgba 0.0 0.0 0.0 0.0
diff --git a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-const-accept.shader_test b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-const-accept.shader_test
new file mode 100644
index 0000000..83402ec
--- /dev/null
+++ b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-const-accept.shader_test
@@ -0,0 +1,38 @@
+# From the GL 3.0 spec, section 2.17 (Clipping):
+#
+#   A vertex shader may, instead of writing to gl ClipVertex, write a
+#   single clip distance for each supported clip plane to elements of
+#   the gl_ClipDistance[] array. The half-space corresponding to clip
+#   plane n is then given by the set of points satisfying the
+#   inequality
+#
+#     c_n(P) >= 0
+#
+#   where c_n(P) is the value of clip distance n at point P.
+#
+# This test checks that gl_ClipDistance works properly for the trivial
+# case where gl_ClipDistance[0] is a constant value greater than zero.
+
+[require]
+GLSL >= 1.30
+
+[vertex shader]
+#version 130
+void main(void)
+{
+	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+
+	gl_ClipDistance[0] = 1.0;
+}
+
+[fragment shader]
+#version 130
+void main(void)
+{
+	gl_FragColor = vec4(1.0);
+}
+
+[test]
+enable GL_CLIP_PLANE0
+draw rect -1 -1 2 2
+probe all rgba 1.0 1.0 1.0 1.0
diff --git a/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-const-reject.shader_test b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-const-reject.shader_test
new file mode 100644
index 0000000..44c3113
--- /dev/null
+++ b/tests/spec/glsl-1.30/execution/clipping/vs-clip-distance-const-reject.shader_test
@@ -0,0 +1,38 @@
+# From the GL 3.0 spec, section 2.17 (Clipping):
+#
+#   A vertex shader may, instead of writing to gl ClipVertex, write a
+#   single clip distance for each supported clip plane to elements of
+#   the gl ClipDistance[] array. The half-space corresponding to clip
+#   plane n is then given by the set of points satisfying the
+#   inequality
+#
+#     c_n(P) >= 0
+#
+#   where c_n(P) is the value of clip distance n at point P.
+#
+# This test checks that gl_ClipDistance works properly for the trivial
+# case where gl_ClipDistance[0] is a constant value less than zero.
+
+[require]
+GLSL >= 1.30
+
+[vertex shader]
+#version 130
+void main(void)
+{
+	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+
+	gl_ClipDistance[0] = -1.0;
+}
+
+[fragment shader]
+#version 130
+void main(void)
+{
+	gl_FragColor = vec4(1.0);
+}
+
+[test]
+enable GL_CLIP_PLANE0
+draw rect -1 -1 2 2
+probe all rgba 0.0 0.0 0.0 0.0
-- 
1.7.6



More information about the Piglit mailing list