<div dir="ltr">On 29 August 2013 11:56, Nicholas Mack <span dir="ltr"><<a href="mailto:nichmack@gmail.com" target="_blank">nichmack@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
 tests/all.tests                               |   1 +<br>
 tests/spec/glsl-1.50/CMakeLists.gl.txt        |  13 +++<br>
 tests/spec/glsl-1.50/CMakeLists.txt           |   1 +<br>
 tests/spec/glsl-1.50/gs-emits-too-few-verts.c | 153 ++++++++++++++++++++++++++<br>
 4 files changed, 168 insertions(+)<br>
 create mode 100644 tests/spec/glsl-1.50/CMakeLists.gl.txt<br>
 create mode 100644 tests/spec/glsl-1.50/gs-emits-too-few-verts.c<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index 7ab841e..efea193 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -937,6 +937,7 @@ for draw in ['', 'indexed']:<br>
         add_concurrent_test(spec['glsl-1.50'],<br>
                             ('arb_geometry_shader4-ignore-adjacent-vertices '<br>
                              'core {0} {1}').format(draw, prim))<br>
+spec['glsl-1.50']['gs-emits-too-few-verts'] = concurrent_test('gs-emits-too-few-verts')<br>
<br>
 # max_vertices of 32 and 128 are important transition points for<br>
 # mesa/i965 (they are the number of bits in a float and a vec4,<br>
diff --git a/tests/spec/glsl-1.50/CMakeLists.gl.txt b/tests/spec/glsl-1.50/CMakeLists.gl.txt<br>
new file mode 100644<br>
index 0000000..7609b98<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/CMakeLists.gl.txt<br>
@@ -0,0 +1,13 @@<br>
+include_directories(<br>
+       ${GLEXT_INCLUDE_DIR}<br>
+       ${OPENGL_INCLUDE_PATH}<br>
+)<br>
+<br>
+link_libraries (<br>
+       piglitutil_${piglit_target_api}<br>
+       ${OPENGL_gl_LIBRARY}<br>
+       ${OPENGL_glu_LIBRARY}<br>
+)<br>
+<br>
+piglit_add_executable (gs-emits-too-few-verts gs-emits-too-few-verts.c)<br>
+# vim: ft=cmake:<br>
diff --git a/tests/spec/glsl-1.50/CMakeLists.txt b/tests/spec/glsl-1.50/CMakeLists.txt<br>
index bb76f08..e4126fc 100644<br>
--- a/tests/spec/glsl-1.50/CMakeLists.txt<br>
+++ b/tests/spec/glsl-1.50/CMakeLists.txt<br>
@@ -1 +1,2 @@<br>
 add_subdirectory (execution)<br>
+piglit_include_target_api()<br>
diff --git a/tests/spec/glsl-1.50/gs-emits-too-few-verts.c b/tests/spec/glsl-1.50/gs-emits-too-few-verts.c<br>
new file mode 100644<br>
index 0000000..411e697<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/gs-emits-too-few-verts.c<br>
@@ -0,0 +1,153 @@<br>
+/**<br>
+ * Copyright © 2013 Intel Corporation<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+/**<br>
+ * From the GLSL 3.2 spec, section 2.12.2 (Geometry Shader Output Primitives):<br>
+ *<br>
+ * "If the number of vertices emitted by the geometry shader is not sufficient<br>
+ *  to produce a single primitive, nothing is drawn."<br>
+ */<br>
+<br>
+#include "piglit-util-gl-common.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+       config.supports_gl_compat_version = 32;<br>
+        config.supports_gl_core_version = 32;<br>
+<br>
+       config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+static const char *vstext =<br>
+       "#version 150\n"<br>
+       "in vec3 vertex;\n"<br>
+       "out vec3 pos;\n"<br>
+       "void main() {\n"<br>
+       "       gl_Position = vec4(vertex, 1.);\n"<br>
+       "       pos = vertex;\n"<br>
+       "}\n";<br>
+<br>
+static const char *gstext =<br>
+       "#version 150\n"<br>
+       "layout(triangles) in;\n"<br>
+       "layout(triangles, max_vertices = 3) out;\n"<br>
+       "in vec3 pos[];\n"<br>
+       "void main() {\n"<br>
+       "       for(int i = 0; i < pos.length()-1; i++) {\n"<br></blockquote><div><br></div><div>Since this test isn't trying to validate that pos.length() behaves correctly, I would just replace "pos.length()-1" with "2".  That'll make it more obvious what the test is trying to do.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+       "               gl_Position = vec4(pos[i], 1.);\n"<br>
+       "               EmitVertex();\n"<br>
+       "       }\n"<br>
+       "}\n";<br>
+<br>
+static const char *fstext =<br>
+       "#version 150\n"<br>
+       "out vec4 color;\n"<br>
+       "void main() {\n"<br>
+       "       color = vec4(1., 0., 0., 1.);\n"<br>
+       "}\n";<br>
+<br>
+static GLuint vao;<br>
+static GLuint vertBuff;<br>
+static GLuint indexBuf;<br>
+<br>
+static GLfloat vertices[] = {<br>
+       -1.0, 1.0, 0.0,<br>
+        1.0, 1.0, 0.0,<br>
+        1.0,-1.0, 0.0,<br>
+       -1.0,-1.0, 0.0<br>
+};<br>
+static GLsizei vertSize = sizeof(vertices);<br>
+<br>
+static GLuint indices[] = {<br>
+       0, 1, 2, 0, 2, 3<br>
+};<br>
+static GLsizei indSize = sizeof(indices);<br>
+<br>
+static GLuint prog;<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+       GLuint vs = 0, gs = 0, fs = 0;<br>
+       GLuint vertIndex;<br>
+<br>
+       prog = glCreateProgram();<br>
+       vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);<br>
+       gs = piglit_compile_shader_text(GL_GEOMETRY_SHADER, gstext);<br>
+       fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fstext);<br>
+       glAttachShader(prog, vs);<br>
+       glAttachShader(prog, gs);<br>
+       glAttachShader(prog, fs);<br>
+<br>
+       glLinkProgram(prog);<br>
+       if(!piglit_link_check_status(prog)){<br>
+               glDeleteProgram(prog);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+<br>
+       glUseProgram(prog);<br>
+<br>
+       glGenBuffers(1, &vertBuff);<br>
+       glBindBuffer(GL_ARRAY_BUFFER, vertBuff);<br>
+       glBufferData(GL_ARRAY_BUFFER, vertSize, vertices, GL_STATIC_DRAW);<br>
+<br>
+       glGenBuffers(1, &indexBuf);<br>
+       glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuf);<br>
+       glBufferData(GL_ELEMENT_ARRAY_BUFFER, indSize,<br>
+                       indices, GL_STATIC_DRAW);<br>
+<br>
+       glGenVertexArrays(1, &vao);<br>
+       glBindVertexArray(vao);<br>
+<br>
+       vertIndex = glGetAttribLocation(prog, "vertex");<br>
+<br>
+       glBindBuffer(GL_ARRAY_BUFFER, vertBuff);<br>
+       glEnableVertexAttribArray(vertIndex);<br>
+       glVertexAttribPointer(vertIndex, 3, GL_FLOAT, GL_FALSE, 0, 0);<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       bool pass = true;<br>
+       float grey[] = {.4, .4, .4};<br>
+<br>
+       glClearColor(.4, .4, .4, 1.);<br>
+       glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+       glBindVertexArray(vao);<br>
+       glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuf);<br>
+<br>
+       glDrawElements(GL_TRIANGLES, ARRAY_SIZE(indices),<br>
+                       GL_UNSIGNED_INT, NULL);<br>
+       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+<br>
+       /* Geom shader only emits 2 verts per tri, so it should not draw any */<br>
+       pass = piglit_probe_rect_rgb(0, 0, piglit_width, piglit_height, grey)<br>
+               && pass;<br></blockquote><div><br></div><div>I'd propose an additional check: surround the draw call with a query of GL_PRIMITIVES_GENERATED, and make sure the query returns a value of 0.  That way we can have confidence that the implementation didn't try to do something silly like a draw a degenerate triangle.<br>
<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+       piglit_present_results();<br>
+<br>
+       return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.1<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div></div>