[Piglit] [PATCH] Add a clipping test that draws an extremely large triangle.

Kenneth Graunke kenneth at whitecape.org
Fri May 4 17:10:02 PDT 2012


This is meant to test i965 guardband clipping limits.  If programmed
incorrectly, guardband clipping can let primitives larger than the
maximum supported size slip through, causing vertices to get clamped and
primitives to render incorrectly.

This test draws a 65000x9000 pixel triangle, which poses no problem if
properly clipped.  If clamped, the slope and position change.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 tests/shaders/really-big-triangle.shader_test |   49 +++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 tests/shaders/really-big-triangle.shader_test

diff --git a/tests/shaders/really-big-triangle.shader_test b/tests/shaders/really-big-triangle.shader_test
new file mode 100644
index 0000000..5a71458
--- /dev/null
+++ b/tests/shaders/really-big-triangle.shader_test
@@ -0,0 +1,49 @@
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+/**
+ * Test i965 guardband limits by drawing a really huge triangle.  The
+ * guardband allows primitives to be trivially accepted by the clip stage
+ * without incurring the overhead of actual clipping.  However, there are
+ * generation-specific limits on the size of a primitive, and software is
+ * supposed to ensure that clipping reduces primitives to not exceed that.
+ * Otherwise, coordinates are clamped to fit within that range, causing
+ * the primitive to be drawn incorrectly.
+ *
+ * This makes sure we program the guardband size correctly; otherwise, the
+ * triangle's vertices will be clamped instead of clipped, resulting in a
+ * change in position and slope.
+ */
+attribute vec4 vertex;
+void main()
+{
+	gl_Position = gl_ModelViewProjectionMatrix * vertex;
+}
+
+[fragment shader]
+void main()
+{
+	gl_FragColor = vec4(1.0);
+}
+
+[vertex data]
+vertex/float/2
+-28000.0 -3700.0
+ 37000.0 -3700.0
+ 37000.0  5300.0
+
+[test]
+clear color 0.0 0.0 0.0 0.0
+clear
+ortho
+draw arrays GL_TRIANGLE_FAN 0 3
+probe rgb   2 175 1.0 1.0 1.0
+probe rgb 122 192 1.0 1.0 1.0
+probe rgb 201 203 1.0 1.0 1.0
+probe rgb 245 199 1.0 1.0 1.0
+
+probe rgb   2 180 0.0 0.0 0.0
+probe rgb 122 198 0.0 0.0 0.0
+probe rgb 201 208 0.0 0.0 0.0
+probe rgb 245 214 0.0 0.0 0.0
-- 
1.7.10



More information about the Piglit mailing list