<div dir="ltr">On 30 September 2013 15:38, 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">v2: Tests check against list of valid layouts instead of invalid layouts<br></blockquote><div><br></div>
<div>Last time I reviewed this patch I pointed out that it's not necessary to have vertex and fragment shaders in the test, since the error is supposed to be detected at compile time.  It looks like you've removed the fragment shader but not the vertex shader.  Can you please also remove the vertex shader (and the linking step)?<br>
<br>Other comments below.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
 tests/all.tests                                    |  12 ++<br>
 .../glsl-1.50/execution/geometry/CMakeLists.gl.txt |   2 +<br>
 .../geometry/gs-input-layout-qualifiers.c          | 128 +++++++++++++++++++++<br>
 .../geometry/gs-output-layout-qualifiers.c         | 125 ++++++++++++++++++++<br>
 4 files changed, 267 insertions(+)<br>
 create mode 100644 tests/spec/glsl-1.50/execution/geometry/gs-input-layout-qualifiers.c<br>
 create mode 100644 tests/spec/glsl-1.50/execution/geometry/gs-output-layout-qualifiers.c<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index d0085d3..f66d9f9 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -999,6 +999,18 @@ for prim_type in ['GL_TRIANGLE_STRIP', 'GL_TRIANGLE_STRIP_ADJACENCY']:<br>
                             'glsl-1.50-geometry-tri-strip-ordering-with-prim-restart {0} {1}'.format(<br>
                                 prim_type, restart_index))<br>
<br>
+for input_layout in ['points', 'lines', 'lines_adjacency', 'triangles',<br>
+                       'triangles_adjacency', 'line_strip', 'triangle_strip']:<br>
+    add_concurrent_test(spec['glsl-1.50'],<br>
+                        'glsl-1.50-gs-input-layout-qualifiers {0}'.format(<br>
+                            input_layout))<br>
+<br>
+for output_layout in ['points', 'lines', 'lines_adjacency', 'triangles',<br>
+                       'triangles_adjacency', 'line_strip', 'triangle_strip']:<br>
+    add_concurrent_test(spec['glsl-1.50'],<br>
+                        'glsl-1.50-gs-output-layout-qualifiers {0}'.format(<br>
+                            output_layout))<br>
+<br>
 spec['glsl-3.30'] = Group()<br>
 import_glsl_parser_tests(spec['glsl-3.30'],<br>
                         os.path.join(testsDir, 'spec', 'glsl-3.30'),<br>
diff --git a/tests/spec/glsl-1.50/execution/geometry/CMakeLists.gl.txt b/tests/spec/glsl-1.50/execution/geometry/CMakeLists.gl.txt<br>
index f168f0a..6fc1986 100644<br>
--- a/tests/spec/glsl-1.50/execution/geometry/CMakeLists.gl.txt<br>
+++ b/tests/spec/glsl-1.50/execution/geometry/CMakeLists.gl.txt<br>
@@ -18,3 +18,5 @@ piglit_add_executable (glsl-1.50-gs-emits-too-few-verts gs-emits-too-few-verts.c<br>
 piglit_add_executable (glsl-1.50-getshaderiv-may-return-GS getshaderiv-may-return-GS.c)<br>
 piglit_add_executable (glsl-1.50-gs-mismatch-prim-type gs-mismatch-prim-type.c)<br>
 piglit_add_executable (glsl-1.50-query-gs-prim-types query-gs-prim-types.c)<br>
+piglit_add_executable (glsl-1.50-gs-input-layout-qualifiers gs-input-layout-qualifiers.c)<br>
+piglit_add_executable (glsl-1.50-gs-output-layout-qualifiers gs-output-layout-qualifiers.c)<br>
diff --git a/tests/spec/glsl-1.50/execution/geometry/gs-input-layout-qualifiers.c b/tests/spec/glsl-1.50/execution/geometry/gs-input-layout-qualifiers.c<br>
new file mode 100644<br>
index 0000000..82ec9c5<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/execution/geometry/gs-input-layout-qualifiers.c<br>
@@ -0,0 +1,128 @@<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>
+ * Test that geometry shaders only compile with valid input layout qualifiers<br>
+ *<br>
+ * Section 4.3.8.1(Input Layout Qualifiers) of the GLSL 1.50 spec says:<br>
+ * "Geometry shaders allow input layout qualifiers only on the interface<br>
+ *  qualifier in, not on an input block, block member, or variable. The layout<br>
+ *  qualifier identifiers for geometry shader inputs are<br>
+ *     points<br>
+ *     lines<br>
+ *     lines_adjacency<br>
+ *     triangles<br>
+ *     triangles_adjacency"<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 vec4 vertex;\n"<br>
+       "void main() {\n"<br>
+       "       gl_Position = vertex;\n"<br>
+       "}\n";<br>
+<br>
+static const char *gstemplate =<br>
+       "#version 150\n"<br>
+       "#define LAYOUT_IN %s\n"<br>
+       "layout(LAYOUT_IN) in;\n"<br>
+       "layout(triangle_strip, max_vertices = 3) out;\n"<br>
+       "void main() {\n"<br>
+       "}\n";<br>
+<br>
+static GLuint prog;<br>
+<br>
+char *valids[] = {"points",<br>
+                 "lines",<br>
+                 "lines_adjacency",<br>
+                 "triangles",<br>
+                 "triangles_adjacency"};<br>
+<br>
+const char *layout;<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+       GLuint vs = 0, gs = 0;<br>
+       char* gstext = NULL;<br>
+       int i = 0;<br>
+       bool pass = true;<br>
+<br>
+       /* Parse params */<br>
+       if (argc != 2) {<br>
+               printf("%s failed\n", argv[0]);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+<br>
+       layout = argv[1];<br>
+       if (layout == NULL) {<br>
+               printf("%s failed\n", argv[0]);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br></blockquote><div><br></div><div>The printfs above shouldn't say "...failed"--that makes it sound like a test was run, and the test failed.  They should say something like "invalid arguments".  Or, even better, make a print_usage_and_exit() function that prints a short description of what would constitute valid arguments (see for example tests/spec/glsl-1.50/execution/geometry/end-primitive.c).<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+       prog = glCreateProgram();<br>
+       vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);<br>
+       asprintf(&gstext, gstemplate, layout);<br>
+       gs = piglit_compile_shader_text(GL_GEOMETRY_SHADER, gstext);<br></blockquote><div><br></div><div>Using piglit_compile_shader_text doesn't work, because piglit_compile_shader_text causes an immediate PIGLIT_FAIL if there is a compilation error (see tests/util/piglit-shader.c).  Since a compilation error sometimes means that the test passes, we can't do this.  I would recommend just calling glCreateShader(), glShaderSource(), and glCompileShader() directly.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+       glAttachShader(prog, vs);<br>
+       glAttachShader(prog, gs);<br>
+       free(gstext);<br>
+<br>
+       glLinkProgram(prog);<br>
+       if(!piglit_link_check_status(prog)){<br>
+               glDeleteProgram(prog);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+       else {<br>
+               for(i = 0; i < ARRAY_SIZE(valids); i++) {<br>
+                       if(strcmp(layout, valids[i]) == 0) {<br>
+                               pass = piglit_check_gl_error(GL_NO_ERROR)<br>
+                                       && pass;<br>
+                               piglit_report_result(pass ? PIGLIT_PASS :<br>
+                                                               PIGLIT_FAIL);<br></blockquote><div><br></div><div>It's not sufficient to check for a GL error, because a compile error doesn't lead to a GL error.  You need to check for a compilation error using glGetShaderiv(..., GL_COMPILE_STATUS, ...).<br>
<br></div><div>Similar comments apply to the other file in this patch.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+                       }<br>
+               }<br>
+<br>
+               printf("\"%s\" is an invalid input qualifier "<br>
+                       "but geometry shader still compiled.\n",<br>
+                       layout);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       return PIGLIT_FAIL;<br>
+}<br>
diff --git a/tests/spec/glsl-1.50/execution/geometry/gs-output-layout-qualifiers.c b/tests/spec/glsl-1.50/execution/geometry/gs-output-layout-qualifiers.c<br>
new file mode 100644<br>
index 0000000..6ae5968<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/execution/geometry/gs-output-layout-qualifiers.c<br>
@@ -0,0 +1,125 @@<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>
+ * Test that geometry shaders only compile with valid output layout qualifiers<br>
+ *<br>
+ * Section 4.3.8.2(Output Layout Qualifiers) of the GLSL 1.50 spec says:<br>
+ * "Geometry shaders can have output layout qualifiers only on the interface<br>
+ *  qualifier out, not on an output block or variable declaration.  The layout<br>
+ *  qualifier identifiers for geometry shader outputs are<br>
+ *     points<br>
+ *     line_strip<br>
+ *     triangle_strip<br>
+ *     max_vertices = integer-constant"<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 vec4 vertex;\n"<br>
+       "void main() {\n"<br>
+       "       gl_Position = vertex;\n"<br>
+       "}\n";<br>
+<br>
+static const char *gstemplate =<br>
+       "#version 150\n"<br>
+       "#define LAYOUT_OUT %s\n"<br>
+       "layout(points) in;\n"<br>
+       "layout(LAYOUT_OUT, max_vertices = 3) out;\n"<br>
+       "void main() {\n"<br>
+       "}\n";<br>
+<br>
+static GLuint prog;<br>
+<br>
+char *valids[] = {"points",<br>
+                 "line_strip",<br>
+                 "triangle_strip"};<br>
+<br>
+const char *layout;<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+       GLuint vs = 0, gs = 0;<br>
+       char* gstext = NULL;<br>
+       int i = 0;<br>
+       bool pass = true;<br>
+<br>
+       /* Parse params */<br>
+       if (argc != 2) {<br>
+               printf("%s failed\n", argv[0]);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+<br>
+       layout = argv[1];<br>
+       if (layout == NULL) {<br>
+               printf("%s failed\n", argv[0]);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+<br>
+       prog = glCreateProgram();<br>
+       vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);<br>
+       asprintf(&gstext, gstemplate, layout);<br>
+       gs = piglit_compile_shader_text(GL_GEOMETRY_SHADER, gstext);<br>
+       glAttachShader(prog, vs);<br>
+       glAttachShader(prog, gs);<br>
+       free(gstext);<br>
+<br>
+       glLinkProgram(prog);<br>
+       if(!piglit_link_check_status(prog)){<br>
+               glDeleteProgram(prog);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+       else {<br>
+               for(i = 0; i < ARRAY_SIZE(valids); i++) {<br>
+                       if(strcmp(layout, valids[i]) == 0) {<br>
+                               pass = piglit_check_gl_error(GL_NO_ERROR)<br>
+                                       && pass;<br>
+                               piglit_report_result(pass ? PIGLIT_PASS :<br>
+                                                               PIGLIT_FAIL);<br>
+                       }<br>
+               }<br>
+<br>
+               printf("\"%s\" is an invalid output qualifier "<br>
+                       "but geometry shader still compiled.\n",<br>
+                       layout);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       return PIGLIT_FAIL;<br>
+}<br>
<span class=""><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>