[Piglit] [PATCH 7/9] arb_geometry_shader4: Flat shading with undefined but ignored colors.
Fabian Bieler
fabianbieler at fastmail.fm
Wed Jun 12 09:48:27 PDT 2013
In this test the geometry shader outputs two flat shaded triangles and only
writes the color for the provoking vertex.
>From the ARB_geometry_shader4 spec (section 8.10):
"The values of any unwritten output variables are undefined. The values of all
varying output variables and the special built-in output variables are
undefined after a call to EmitVertex()"
However, in this case the undefined values should be ignored and thus should
not affect the fragment stage.
---
.../execution/flat-shading.shader_test | 80 ++++++++++++++++++++++
1 file changed, 80 insertions(+)
create mode 100644 tests/spec/arb_geometry_shader4/execution/flat-shading.shader_test
diff --git a/tests/spec/arb_geometry_shader4/execution/flat-shading.shader_test b/tests/spec/arb_geometry_shader4/execution/flat-shading.shader_test
new file mode 100644
index 0000000..fba62f4
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/execution/flat-shading.shader_test
@@ -0,0 +1,80 @@
+# Draw two flat shaded triangles and only write the color for the provoking
+# vertex.
+#
+# From the ARB_geometry_shader4 spec (section 8.10):
+# "The values of any unwritten output variables are undefined. The values of all
+# varying output variables and the special built-in output variables are
+# undefined after a call to EmitVertex()"
+#
+# However, in this case the undefined values should be ignored and thus should
+# not affect the fragment stage.
+[require]
+GL >= 2.0
+GLSL >= 1.30
+GL_ARB_geometry_shader4
+
+[vertex shader]
+#version 130
+
+attribute vec4 vertex;
+
+void main()
+{
+ gl_Position = vertex;
+}
+
+[geometry shader]
+#version 130
+#extension GL_ARB_geometry_shader4: enable
+
+flat out vec4 color;
+
+void main()
+{
+ gl_Position = gl_PositionIn[0];
+ /* no color write */
+ EmitVertex();
+ gl_Position = gl_PositionIn[1];
+ /* no color write */
+ EmitVertex();
+ gl_Position = gl_PositionIn[2];
+ color = vec4(0, 1, 0, 1);
+ EmitVertex();
+ EndPrimitive();
+
+ gl_Position = gl_PositionIn[1];
+ /* no color write */
+ EmitVertex();
+ gl_Position = gl_PositionIn[2];
+ /* no color write */
+ EmitVertex();
+ gl_Position = gl_PositionIn[3];
+ color = vec4(0, 1, 0, 1);
+ EmitVertex();
+}
+
+[geometry layout]
+input type GL_LINES_ADJACENCY
+output type GL_TRIANGLE_STRIP
+vertices out 6
+
+[fragment shader]
+#version 130
+
+flat in vec4 color;
+
+void main()
+{
+ gl_FragColor = color;
+}
+
+[vertex data]
+vertex/float/2
+-1.0 -1.0
+ 1.0 -1.0
+-1.0 1.0
+ 1.0 1.0
+
+[test]
+draw arrays GL_LINES_ADJACENCY 0 4
+probe all rgb 0.0 1.0 0.0
--
1.8.1.2
More information about the Piglit
mailing list