[Piglit] [PATCH 8/9] arb_geometry_shader4: Draw more vertices than allowed.
Fabian Bieler
fabianbieler at fastmail.fm
Wed Jun 12 10:37:21 PDT 2013
Test a geometry shader that emits more vertices than allowed per
GEOMETRY_VERTICES_OUT.
>From the ARB_geometry_shader4 spec (section 8.10):
"If a geometry shader, in one invocation, emits more vertices than the value
GEOMETRY_VERTICES_OUT_ARB, these emits may have no effect."
However the shader should execute without error and the valid vertices should
be drawn.
Test this with a geometry shader that tries to emit 14 but is only allowed to
emit 8 and one that tries to emit 510 but is only allowed to emit 256 vertices.
---
.../execution/output-overrun-14verts.shader_test | 78 ++++++++++++++++++++++
.../execution/output-overrun-510verts.shader_test | 78 ++++++++++++++++++++++
2 files changed, 156 insertions(+)
create mode 100644 tests/spec/arb_geometry_shader4/execution/output-overrun-14verts.shader_test
create mode 100644 tests/spec/arb_geometry_shader4/execution/output-overrun-510verts.shader_test
diff --git a/tests/spec/arb_geometry_shader4/execution/output-overrun-14verts.shader_test b/tests/spec/arb_geometry_shader4/execution/output-overrun-14verts.shader_test
new file mode 100644
index 0000000..e25d159
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/execution/output-overrun-14verts.shader_test
@@ -0,0 +1,78 @@
+# Emit more vertices than allowed.
+#
+# From the ARB_geometry_shader4 spec (section 8.10):
+# "If a geometry shader, in one invocation, emits more vertices than the value
+# GEOMETRY_VERTICES_OUT_ARB, these emits may have no effect."
+#
+# The geometry shader emits a triangle strip with 14 vertices (12 triangles)
+# that cover the entire screen in a single row of isosceles triangles. Only
+# allow the geomtry shader to emit a total of 8 vertices (6 triangles) via
+# GEOMETRY_VERTICES_OUT. Invoke the geometry shader twice. The first time it
+# draws the strip left to right, the second time vice versa. Thus, regardless
+# whether the supernumerous vertices are drawn or ignored the entire screen
+# should be filled.
+[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
+
+/* Should always be even and >= 4. */
+uniform int count;
+
+void main()
+{
+ for (int i = 0; i < count / 2; ++i) {
+ float p = float(i) / float(count / 2 - 1);
+ gl_Position = gl_PositionIn[0] + p *
+ (gl_PositionIn[2] - gl_PositionIn[0]);
+ EmitVertex();
+ gl_Position = gl_PositionIn[1] + p *
+ (gl_PositionIn[3] - gl_PositionIn[1]);
+ EmitVertex();
+ }
+}
+
+[geometry layout]
+input type GL_LINES_ADJACENCY
+output type GL_TRIANGLE_STRIP
+vertices out 8
+
+[fragment shader]
+#version 110
+
+void main()
+{
+ gl_FragColor = vec4(0, 1, 0, 1);
+}
+
+[vertex data]
+vertex/float/2
+-1.0 1.0
+-1.0 -1.0
+ 1.0 1.0
+ 1.0 -1.0
+ 1.0 -1.0
+ 1.0 1.0
+-1.0 -1.0
+-1.0 1.0
+
+[test]
+uniform int count 14
+clear color 0.0 0.0 0.0 0.0
+clear
+draw arrays GL_LINES_ADJACENCY 0 8
+probe all rgb 0.0 1.0 0.0
diff --git a/tests/spec/arb_geometry_shader4/execution/output-overrun-510verts.shader_test b/tests/spec/arb_geometry_shader4/execution/output-overrun-510verts.shader_test
new file mode 100644
index 0000000..2c5a293
--- /dev/null
+++ b/tests/spec/arb_geometry_shader4/execution/output-overrun-510verts.shader_test
@@ -0,0 +1,78 @@
+# Emit more vertices than allowed.
+#
+# From the ARB_geometry_shader4 spec (section 8.10):
+# "If a geometry shader, in one invocation, emits more vertices than the value
+# GEOMETRY_VERTICES_OUT_ARB, these emits may have no effect."
+#
+# The geometry shader emits a triangle strip with 510 vertices (508 triangles)
+# that cover the entire screen in a single row of isosceles triangles. Only
+# allow the geomtry shader to emit a total of 256 vertices (254 triangles) via
+# GEOMETRY_VERTICES_OUT. Invoke the geometry shader twice. The first time it
+# draws the strip left to right, the second time vice versa. Thus, regardless
+# whether the supernumerous vertices are drawn or ignored the entire screen
+# should be filled.
+[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
+
+/* Should always be even and >= 4. */
+uniform int count;
+
+void main()
+{
+ for (int i = 0; i < count / 2; ++i) {
+ float p = float(i) / float(count / 2 - 1);
+ gl_Position = gl_PositionIn[0] + p *
+ (gl_PositionIn[2] - gl_PositionIn[0]);
+ EmitVertex();
+ gl_Position = gl_PositionIn[1] + p *
+ (gl_PositionIn[3] - gl_PositionIn[1]);
+ EmitVertex();
+ }
+}
+
+[geometry layout]
+input type GL_LINES_ADJACENCY
+output type GL_TRIANGLE_STRIP
+vertices out 256
+
+[fragment shader]
+#version 110
+
+void main()
+{
+ gl_FragColor = vec4(0, 1, 0, 1);
+}
+
+[vertex data]
+vertex/float/2
+-1.0 1.0
+-1.0 -1.0
+ 1.0 1.0
+ 1.0 -1.0
+ 1.0 -1.0
+ 1.0 1.0
+-1.0 -1.0
+-1.0 1.0
+
+[test]
+uniform int count 510
+clear color 0.0 0.0 0.0 0.0
+clear
+draw arrays GL_LINES_ADJACENCY 0 8
+probe all rgb 0.0 1.0 0.0
--
1.8.1.2
More information about the Piglit
mailing list