<div dir="ltr">Sorry for the slow responses, Nick. I got behind in patch review in the last two weeks and I'm only just now catching up.<br><div><br>On 16 September 2013 09:35, 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 | 12 ++<br>
.../glsl-1.50/execution/geometry/CMakeLists.gl.txt | 2 +<br>
.../geometry/gs-input-layout-qualifiers.c | 137 ++++++++++++++++++++<br>
.../geometry/gs-output-layout-qualifiers.c | 139 +++++++++++++++++++++<br>
4 files changed, 290 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 dc36841..9db40af 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -981,6 +981,18 @@ for layout_type in ['points', 'lines', 'lines_adjacency', 'triangles',<br>
'glsl-1.50-gs-mismatch-prim-type {0}'.format(<br>
layout_type))<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 f01dc1c..012663d 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>
@@ -16,3 +16,5 @@ piglit_add_executable (glsl-1.50-geometry-primitive-types primitive-types.c)<br>
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-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..ff95f00<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/execution/geometry/gs-input-layout-qualifiers.c<br>
@@ -0,0 +1,137 @@<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>
+ "out vec4 pos;\n"<br>
+ "void main() {\n"<br>
+ " pos = 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>
+ "in vec4 pos[];\n"<br>
+ "void main() {\n"<br>
+ " for(int i = 0; i < pos.length(); i++) {\n"<br>
+ " gl_Position = pos[i];\n"<br>
+ " EmitVertex();\n"<br>
+ " }\n"<br>
+ "}\n";<br>
+static const char *fstext =<br>
+ "#version 150\n"<br>
+ "out vec4 color;\n"<br>
+ "void main() {\n"<br>
+ " color = vec4(1.);\n"<br>
+ "}\n";<br></blockquote><div><br></div><div>The implementation should check at compile time whether the given layout qualifier is valid, so I don't think it's necessary to include vertex and fragment shaders. It should be enough to just compile a geometry shader and see if it succeeds. Also I don't think it's necessary for it to be a "realistic" geometry shader--you can just make the main function empty.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+static GLuint prog;<br>
+<br>
+char *invalids[] = {"line_strip",<br>
+ "triangle_strip"}; <br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+const char *layout;<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+ GLuint vs = 0, gs = 0, fs = 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>
+ fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fstext);<br>
+ glAttachShader(prog, vs);<br>
+ glAttachShader(prog, gs);<br>
+ glAttachShader(prog, fs);<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(invalids); i++) {<br>
+ if(strcmp(layout, invalids[i]) == 0) {<br></blockquote><div><br></div><div>I'm a little bothered by this logic, since it relies for correctness on the fact that all.tests only ever executes it with points, lines, line_strip, lines_adjacency, triangles, triangle_strip, or triangles_adjaency. If someone ever tried to run the test with an argument of "triangle_ham_sandwich", it would assume that it was valid (because it's not in the "invalids" array), and do the wrong test.<br>
<br>Can we replace the "invalids" array with a "valids" array, and invert the logic?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ 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>
+<br>
+ pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);<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..ba4f67c<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/execution/geometry/gs-output-layout-qualifiers.c<br></blockquote><div><br></div><div>Similar comments apply to gs-output-layout-qualifiers.c as well.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
@@ -0,0 +1,139 @@<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>
+ "out vec4 pos;\n"<br>
+ "void main() {\n"<br>
+ " pos = vertex;\n"<br>
+ "}\n";<br>
+<br>
+static const char *gstemplate =<br>
+ "#version 150\n"<br>
+ "#define LAYOUT_OUT %s\n"<br>
+ "layout(triangles) in;\n"<br>
+ "layout(LAYOUT_OUT, max_vertices = 3) out;\n"<br>
+ "in vec4 pos[];\n"<br>
+ "void main() {\n"<br>
+ " for(int i = 0; i < pos.length(); i++) {\n"<br>
+ " gl_Position = pos[i];\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.);\n"<br>
+ "}\n";<br>
+<br>
+static GLuint prog;<br>
+<br>
+char *invalids[] = {"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, fs = 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>
+ fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fstext);<br>
+ glAttachShader(prog, vs);<br>
+ glAttachShader(prog, gs);<br>
+ glAttachShader(prog, fs);<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(invalids); i++) {<br>
+ if(strcmp(layout, invalids[i]) == 0) {<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>
+<br>
+ pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+ return 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></div>