[Piglit] [PATCH 3/9] arb_geometry_shader4: Test two sided triangles.

Fabian Bieler fabianbieler at fastmail.fm
Mon Jun 24 15:30:40 PDT 2013


Draw 8 triangles on the screen like so:

    +-+-+
    |/|/|
    +-+-+
    |/|/|
    +-+-+

The left 4 triangles are front facing, the right 4 triangles are backfacing.
Flip the top 4 triangles in the geometry shader (swap the first and last vertex)
and write different values to both front and back color. The result should be a
2x2 checkerboard.
---
 .../execution/two-side.shader_test                 | 94 ++++++++++++++++++++++
 1 file changed, 94 insertions(+)
 create mode 100644 tests/spec/arb_geometry_shader4/execution/two-side.shader_test

diff --git a/tests/spec/arb_geometry_shader4/execution/two-side.shader_test b/tests/spec/arb_geometry_shader4/execution/two-side.shader_test
new file mode 100644
index 0000000..59b29bf
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/execution/two-side.shader_test
@@ -0,0 +1,94 @@
+# Draw 8 triangles on the screen like so:
+#
+#     +-+-+
+#     |/|/|
+#     +-+-+
+#     |/|/|
+#     +-+-+
+#
+# The left 4 triangles are front facing, the right 4 triangles are backfacing.
+# Flip the top 4 triangles in the geometry shader (swap the first and last
+# vertex) and write different values to front and back color. The result should
+# be a 2x2 checkerboard.
+[require]
+GL >= 2.0
+GLSL >= 1.10
+GL_ARB_geometry_shader4
+
+[vertex shader]
+#version 110
+
+attribute vec4 vertex;
+
+void main()
+{
+	gl_Position = vertex;
+}
+
+[geometry shader]
+#version 110
+#extension GL_ARB_geometry_shader4: enable
+
+void main()
+{
+	for (int i = 0; i < 3; i++) {
+		/* Flip the triangles in the upper half of the screen. */
+		if (gl_PositionIn[0].y + gl_PositionIn[1].y +
+		    gl_PositionIn[2].y > 0.0)
+			gl_Position = gl_PositionIn[2 - i];
+		else
+			gl_Position = gl_PositionIn[i];
+		gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0);
+		gl_BackColor = vec4(0.0, 1.0, 0.0, 1.0);
+		EmitVertex();
+	}
+}
+
+[geometry layout]
+input type GL_TRIANGLES
+output type GL_TRIANGLE_STRIP
+vertices out 3
+
+[fragment shader]
+#version 110
+
+void main()
+{
+	gl_FragColor = gl_Color;
+}
+
+[vertex data]
+vertex/float/2
+-1.0 -1.0
+ 0.0 -1.0
+ 0.0  0.0
+-1.0 -1.0
+ 0.0  0.0
+-1.0  0.0
+ 0.0 -1.0
+ 0.0  0.0
+ 1.0  0.0
+ 0.0 -1.0
+ 1.0  0.0
+ 1.0 -1.0
+-1.0  0.0
+ 0.0  0.0
+ 0.0  1.0
+-1.0  0.0
+ 0.0  1.0
+-1.0  1.0
+ 0.0  0.0
+ 0.0  1.0
+ 1.0  1.0
+ 0.0  0.0
+ 1.0  1.0
+ 1.0  0.0
+
+
+[test]
+enable GL_VERTEX_PROGRAM_TWO_SIDE
+draw arrays GL_TRIANGLES 0 24
+relative probe rgba (0.25, 0.25) (1.0, 0.0, 0.0, 1.0)
+relative probe rgba (0.75, 0.25) (0.0, 1.0, 0.0, 1.0)
+relative probe rgba (0.25, 0.75) (0.0, 1.0, 0.0, 1.0)
+relative probe rgba (0.75, 0.75) (1.0, 0.0, 0.0, 1.0)
-- 
1.8.1.2



More information about the Piglit mailing list