[Piglit] [PATCH 1/2] glsl-1.20: add a test that gl_ClipVertex actually affects all primitive types

Nicolai Hähnle nhaehnle at gmail.com
Thu Dec 15 15:38:45 UTC 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Exposes a bug on radeonsi for the points case.
---
 .../clipping/vs-clip-vertex-primitives.shader_test | 72 ++++++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-primitives.shader_test

diff --git a/tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-primitives.shader_test b/tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-primitives.shader_test
new file mode 100644
index 0000000..6acd7fd
--- /dev/null
+++ b/tests/spec/glsl-1.20/execution/clipping/vs-clip-vertex-primitives.shader_test
@@ -0,0 +1,72 @@
+# Verify that gl_ClipVertex affects different primitive types correctly.
+
+[require]
+GLSL >= 1.20
+
+[vertex shader]
+#version 120
+
+attribute vec2 in_pos;
+
+uniform vec2 u_offset;
+uniform float u_clipdist;
+
+void main(void)
+{
+	gl_Position = gl_ModelViewProjectionMatrix * vec4(u_offset + in_pos, 0, 1);
+
+	gl_ClipVertex = vec4(0, 0, 0, u_clipdist);
+}
+
+[fragment shader]
+#version 120
+void main(void)
+{
+	gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[vertex data]
+in_pos/float/2
+ 0  0
+10  0
+ 0 10
+10 10
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+
+clip plane 0 0.0 0.0 0.0 1.0 # accept points where gl_ClipVertex.w >= 0
+enable GL_CLIP_PLANE0
+
+ortho
+
+# Test that primitives are clipped with a negative distance
+uniform float u_clipdist -1
+
+uniform vec2 u_offset 0.5 0.5
+draw arrays GL_POINTS 0 1
+probe rect rgba ( 0, 0, 20, 20) (0, 0, 0, 0)
+
+uniform vec2 u_offset 20 0.5
+draw arrays GL_LINES 0 2
+probe rect rgba (20, 0, 20, 20) (0, 0, 0, 0)
+
+uniform vec2 u_offset 40 0
+draw arrays GL_TRIANGLE_STRIP 0 4
+probe rect rgba (40, 0, 20, 20) (0, 0, 0, 0)
+
+# Test that primitives are not clipped with zero distance
+uniform float u_clipdist 0
+
+uniform vec2 u_offset 0.5 20.5
+draw arrays GL_POINTS 0 1
+probe rect rgba ( 0, 20, 1, 1) (1, 0, 0, 1)
+
+uniform vec2 u_offset 20 20.5
+draw arrays GL_LINES 0 2
+probe rect rgba (20, 20, 10, 1) (1, 0, 0, 1)
+
+uniform vec2 u_offset 40 20
+draw arrays GL_TRIANGLE_STRIP 0 4
+probe rect rgba (40, 20, 10, 10) (1, 0, 0, 1)
-- 
2.7.4



More information about the Piglit mailing list