<div dir="ltr">On 21 October 2013 09:51, 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">

<div>v2: Tests check against list of valid layouts instead of invalid layouts<br>
<br>
</div>v3: Remove vertex shader info, remove linking, check compile status, rewrite error messages<br>
<div>---<br>
 tests/all.tests                                    |  12 ++<br>
 .../glsl-1.50/execution/geometry/CMakeLists.gl.txt |   2 +<br>
</div> .../geometry/gs-input-layout-qualifiers.c          | 133 +++++++++++++++++++++<br>
 .../geometry/gs-output-layout-qualifiers.c         | 130 ++++++++++++++++++++<br>
 4 files changed, 277 insertions(+)<br>
<div> 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>
</div>index c919f19..2485b39 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -1017,6 +1017,18 @@ for prim_type in ['GL_TRIANGLE_STRIP', 'GL_TRIANGLE_STRIP_ADJACENCY']:<br>
<div>                             '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>
</div>index 3e6bc4b..d759c6b 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>
@@ -19,3 +19,5 @@ piglit_add_executable (glsl-1.50-gs-emits-too-few-verts gs-emits-too-few-verts.c<br>
<div> 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>
</div>index 0000000..0afc4e8<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/execution/geometry/gs-input-layout-qualifiers.c<br>
@@ -0,0 +1,133 @@<br>
<div><div>+/**<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>
</div></div><div>+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></div></blockquote><div><br></div><div>Since the test isn't trying to link the program anymore, you should be able to drop this variable entirely (as well as the calls to glCreateProgram() and glAttachShader() below).<br>

</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
+<br>
+char *valids[] = {"points",<br>
+                 "lines",<br>
+                 "lines_adjacency",<br>
+                 "triangles",<br>
+                 "triangles_adjacency"};<br>
+<br>
+const char *layout;<br>
+<br>
</div>+static void<br>
+print_usage_and_exit(const char *prog_name)<br>
+{<br>
+       printf("Usage: %s <input_layout>\n"<br>
+              "  where <input_layout> is the qualifier to test to see if it\n"<br>
+              "  is a valid geometry shader input layout qualifier\n",<br>
+              prog_name);<br>
+       piglit_report_result(PIGLIT_FAIL);<br>
+}<br>
<div>+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
</div>+       GLuint gs = 0;<br>
+       GLint gsCompiled = GL_TRUE;<br>
<div>+       char* gstext = NULL;<br>
+       int i = 0;<br>
+       bool pass = true;<br>
+<br>
+       /* Parse params */<br>
+       if (argc != 2) {<br>
</div>+               print_usage_and_exit(argv[0]);<br>
<div>+       }<br>
+<br>
+       layout = argv[1];<br>
+       if (layout == NULL) {<br>
+               printf("%s failed\n", argv[0]);<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br></div></blockquote><div><br></div><div>You can drop this if-block.  Since you've already checked that argc is 2, it's impossible for argv[1] to be NULL.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>
+<br>
+       prog = glCreateProgram(); <br></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
</div>+       asprintf(&gstext, gstemplate, layout);<br>
+       gs = glCreateShader(GL_GEOMETRY_SHADER);<br>
+       glShaderSource(gs, 1, (const GLchar **) &gstext, NULL);<br>
+       glCompileShader(gs);<br>
<div>+       glAttachShader(prog, gs);<br>
+       free(gstext);<br>
+ <br></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
</div>+       /* check if the current layout is valid */<br>
<div>+       for(i = 0; i < ARRAY_SIZE(valids); i++) {<br>
+               if(strcmp(layout, valids[i]) == 0) {<br>
</div>+                       glGetShaderiv(gs, GL_COMPILE_STATUS,<br>
+                                       &gsCompiled);<br>
+                       if(gsCompiled != GL_TRUE) {<br>
+                               printf("Failed to compile.\n");<br>
+                               pass = false;<br>
+                       }<br>
<div>+<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>
</div>+       /* if the layout was not valid... */<br>
<div>+       printf("\"%s\" is an invalid input qualifier "<br>
+               "but geometry shader still compiled.\n",<br>
+               layout);<br>
+       piglit_report_result(PIGLIT_FAIL);<br></div></blockquote><div><br></div><div>If the command-line argument doesn't match any of the strings in the "valids" array, then we can't just fail.  We need to verify that a compile error occurred.  I've sent out a suggested fix.<br>

</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
+}<br>
+<br>
</div><div>+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>
</div>index 0000000..232b8f3<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/execution/geometry/gs-output-layout-qualifiers.c<br>
@@ -0,0 +1,130 @@<br>
<div><div>+/**<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>
</div></div><div>+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>
</div>+static void<br>
+print_usage_and_exit(const char *prog_name)<br>
+{<br>
+       printf("Usage: %s <output_layout>\n"<br>
+              "  where <output_layout> is the qualifier to test to see if it\n"<br>
+              "  is a valid geometry shader output layout qualifier\n",<br>
+              prog_name);<br>
+       piglit_report_result(PIGLIT_FAIL);<br>
+}<br>
<div>+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
</div>+       GLuint gs = 0;<br>
+       GLint gsCompiled = GL_TRUE;<br>
<div>+       char* gstext = NULL;<br>
+       int i = 0;<br>
+       bool pass = true;<br>
+<br>
+       /* Parse params */<br>
+       if (argc != 2) {<br>
</div>+               print_usage_and_exit(argv[0]);<br>
<div>+       }<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>
</div>+       asprintf(&gstext, gstemplate, layout);<br>
+       gs = glCreateShader(GL_GEOMETRY_SHADER);<br>
+       glShaderSource(gs, 1, (const GLchar **) &gstext, NULL);<br>
+       glCompileShader(gs);<br>
<div>+       glAttachShader(prog, gs);<br>
+       free(gstext);<br>
+<br>
</div>+       /* check if the current layout is valid */<br>
<div>+       for(i = 0; i < ARRAY_SIZE(valids); i++) {<br>
+               if(strcmp(layout, valids[i]) == 0) {<br>
</div>+                       glGetShaderiv(gs, GL_COMPILE_STATUS,<br>
+                                       &gsCompiled);<br>
+                       if(gsCompiled != GL_TRUE) {<br>
+                               printf("Failed to compile.\n");<br>
+                               pass = false;<br>
+                       }<br>
<div>+<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>
</div>+       /* if the layout was not valid... */<br>
<div>+       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>
</div><div><div>+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       return PIGLIT_FAIL;<br>
+}<br>
--<br>
1.8.3.1<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org" target="_blank">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>
</div></div></blockquote></div><br></div></div>