[Piglit] [PATCH 3/4] glsl-1.50: Emmit more vertices than allowed in gs.
Fabian Bieler
fabianbieler at fastmail.fm
Mon Mar 3 00:38:26 PST 2014
Test a geometry shader that emits more vertices than allowed per
max_vertices layout.
>From the OpenGL 3.2 (Core Profile) spec (section 2.12.4, page 86):
"If a single invocation of a geometry shader emits more vertices than
this [max_vertices] value, the emitted vertices may have no effect."
This test assumes that "the emitted vertices" only refers to the
supernumerous vertices.
In any case, the shader should execute without error.
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.
Signed-off-by: Fabian Bieler <fabianbieler at fastmail.fm>
---
.../geometry/output-overrun-14verts.shader_test | 72 ++++++++++++++++++++++
.../geometry/output-overrun-510verts.shader_test | 72 ++++++++++++++++++++++
2 files changed, 144 insertions(+)
create mode 100644 tests/spec/glsl-1.50/execution/geometry/output-overrun-14verts.shader_test
create mode 100644 tests/spec/glsl-1.50/execution/geometry/output-overrun-510verts.shader_test
diff --git a/tests/spec/glsl-1.50/execution/geometry/output-overrun-14verts.shader_test b/tests/spec/glsl-1.50/execution/geometry/output-overrun-14verts.shader_test
new file mode 100644
index 0000000..939ef70
--- /dev/null
+++ b/tests/spec/glsl-1.50/execution/geometry/output-overrun-14verts.shader_test
@@ -0,0 +1,72 @@
+# Emit more vertices than allowed.
+#
+# From the OpenGL 3.2 (Core Profile) spec (section 2.12.4, page 86):
+# "If a single invocation of a geometry shader emits more vertices than
+# this [max_vertices] value, the emitted vertices may have no effect."
+#
+# This test assumes that "the emitted vertices" only refers to the
+# supernumerous vertices.
+# In any case, the shader should execute without error.
+#
+# 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
+# the max_vertices layout. 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]
+GLSL >= 1.50
+
+[vertex shader]
+in vec4 vertex;
+
+void main()
+{
+ gl_Position = vertex;
+}
+
+[geometry shader]
+layout(lines_adjacency) in;
+layout(triangle_strip, max_vertices = 8) out;
+
+/* 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_in[0].gl_Position + p *
+ (gl_in[2].gl_Position - gl_in[0].gl_Position);
+ EmitVertex();
+ gl_Position = gl_in[1].gl_Position + p *
+ (gl_in[3].gl_Position - gl_in[1].gl_Position);
+ EmitVertex();
+ }
+}
+
+[fragment shader]
+
+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 1.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/glsl-1.50/execution/geometry/output-overrun-510verts.shader_test b/tests/spec/glsl-1.50/execution/geometry/output-overrun-510verts.shader_test
new file mode 100644
index 0000000..48ca276
--- /dev/null
+++ b/tests/spec/glsl-1.50/execution/geometry/output-overrun-510verts.shader_test
@@ -0,0 +1,72 @@
+# Emit more vertices than allowed.
+#
+# From the OpenGL 3.2 (Core Profile) spec (section 2.12.4, page 86):
+# "If a single invocation of a geometry shader emits more vertices than
+# this [max_vertices] value, the emitted vertices may have no effect."
+#
+# This test assumes that "the emitted vertices" only refers to the
+# supernumerous vertices.
+# In any case, the shader should execute without error.
+#
+# 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
+# the max_vertices layout. 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]
+GLSL >= 1.50
+
+[vertex shader]
+in vec4 vertex;
+
+void main()
+{
+ gl_Position = vertex;
+}
+
+[geometry shader]
+layout(lines_adjacency) in;
+layout(triangle_strip, max_vertices = 256) out;
+
+/* 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_in[0].gl_Position + p *
+ (gl_in[2].gl_Position - gl_in[0].gl_Position);
+ EmitVertex();
+ gl_Position = gl_in[1].gl_Position + p *
+ (gl_in[3].gl_Position - gl_in[1].gl_Position);
+ EmitVertex();
+ }
+}
+
+[fragment shader]
+
+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 1.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.3.2
More information about the Piglit
mailing list