<div dir="ltr">On 28 August 2013 14: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">
---<br>
 tests/spec/glsl-1.50/CMakeLists.gl.txt             |  22 +++<br>
 tests/spec/glsl-1.50/CMakeLists.txt                |   1 +<br>
 .../glsl-1.50/gs-mismatch-prim-type-lines-adj.c    | 167 +++++++++++++++++++++<br>
 tests/spec/glsl-1.50/gs-mismatch-prim-type-lines.c | 167 +++++++++++++++++++++<br>
 .../spec/glsl-1.50/gs-mismatch-prim-type-points.c  | 167 +++++++++++++++++++++<br>
 .../gs-mismatch-prim-type-triangles-adj.c          | 166 ++++++++++++++++++++<br>
 .../glsl-1.50/gs-mismatch-prim-type-triangles.c    | 166 ++++++++++++++++++++<br>
 7 files changed, 856 insertions(+)<br>
 create mode 100644 tests/spec/glsl-1.50/CMakeLists.gl.txt<br>
 create mode 100644 tests/spec/glsl-1.50/gs-mismatch-prim-type-lines-adj.c<br>
 create mode 100644 tests/spec/glsl-1.50/gs-mismatch-prim-type-lines.c<br>
 create mode 100644 tests/spec/glsl-1.50/gs-mismatch-prim-type-points.c<br>
 create mode 100644 tests/spec/glsl-1.50/gs-mismatch-prim-type-triangles-adj.c<br>
 create mode 100644 tests/spec/glsl-1.50/gs-mismatch-prim-type-triangles.c<br></blockquote><div><br></div>Taken individually, the tests look reasonable.  But I'm concerned about the amount of code duplication between them.  There are 5 new .c files, and all of them are exactly the same except for a minor comment change, the geometry shader input layout, and the valids[] and invalids[] arrays.  Can we change these to a single .c file that uses a command-line argument to choose which input layout to test?  For an example of how to do this, have a look at tests/spec/glsl-1.50/execution/geometry/primitive-types.c.<br>
<br></div><div class="gmail_quote">Also, two minor nit picks:<br><br><div>- New C tests need to be added to all.tests, or they won't get run.<br><br></div><div>- These tests should go in tests/spec/glsl-1.50/execution/geometry.<br>
</div><br></div><div class="gmail_quote"><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>
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..5ddd05a<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/CMakeLists.gl.txt<br>
@@ -0,0 +1,22 @@<br>
+include_directories(<br>
+${GLEXT_INCLUDE_DIR}<br>
+${OPENGL_INCLUDE_PATH}<br>
+${piglit_SOURCE_DIR}/tests/util<br>
+)<br>
+<br>
+link_libraries (<br>
+piglitutil_${piglit_target_api}<br>
+${OPENGL_gl_LIBRARY}<br>
+${OPENGL_glu_LIBRARY}<br>
+)<br>
+<br>
+piglit_add_executable (glsl-1.50-gs-mismatch-prim-type-lines<br>
+                       gs-mismatch-prim-type-lines.c)<br>
+piglit_add_executable (glsl-1.50-gs-mismatch-prim-type-lines-adj<br>
+                       gs-mismatch-prim-type-lines-adj.c)<br>
+piglit_add_executable (glsl-1.50-gs-mismatch-prim-type-points<br>
+                       gs-mismatch-prim-type-points.c)<br>
+piglit_add_executable (glsl-1.50-gs-mismatch-prim-type-triangles<br>
+                       gs-mismatch-prim-type-triangles.c)<br>
+piglit_add_executable (glsl-1.50-gs-mismatch-prim-type-triangles-adj<br>
+                       gs-mismatch-prim-type-triangles-adj.c)<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-mismatch-prim-type-lines-adj.c b/tests/spec/glsl-1.50/gs-mismatch-prim-type-lines-adj.c<br>
new file mode 100644<br>
index 0000000..1ede844<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/gs-mismatch-prim-type-lines-adj.c<br>
@@ -0,0 +1,167 @@<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.1 (Geometry Shader Input Primitives):<br>
+ *<br>
+ * "If a geometry shader is active, any command that transfers vertices to the<br>
+ *  GL will generate an INVALID_OPERATION error if the primitive mode parameter<br>
+ *  is incompatible with the input primitive type of the currently active<br>
+ *  program object, as discussed below."<br>
+ *<br>
+ * "Geometry shaders that operate on line segments with adjacent vertices are<br>
+ *  valid only for the LINES_ADJACENCY and LINE_STRIP_ADJACENCY primitive<br>
+ *  types."<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(lines_adjacency) 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(); i++) {\n"<br>
+       "               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.);\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>
+static GLenum valids[] = {GL_LINES_ADJACENCY, GL_LINE_STRIP_ADJACENCY};<br>
+static GLenum invalids[] = {GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP,<br>
+                               GL_TRIANGLES, GL_TRIANGLE_STRIP,<br>
+                               GL_TRIANGLE_FAN, GL_TRIANGLES_ADJACENCY,<br>
+                               GL_TRIANGLE_STRIP_ADJACENCY};<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       bool pass = true;<br>
+       int i = 0;<br>
+<br>
+       glClearColor(0.2, 0.2, 0.2, 1.0);<br>
+       glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+       glBindVertexArray(vao);<br>
+       glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuf);<br>
+<br>
+       for(i = 0; i < ARRAY_SIZE(valids); i++) {<br>
+               glDrawElements(valids[i], ARRAY_SIZE(indices),<br>
+                               GL_UNSIGNED_INT, NULL);<br>
+               pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+       }<br>
+<br>
+       for(i = 0; i < ARRAY_SIZE(invalids); i++) {<br>
+               glDrawElements(invalids[i], ARRAY_SIZE(indices),<br>
+                               GL_UNSIGNED_INT, NULL);<br>
+               pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;<br>
+       }<br>
+<br>
+       return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
diff --git a/tests/spec/glsl-1.50/gs-mismatch-prim-type-lines.c b/tests/spec/glsl-1.50/gs-mismatch-prim-type-lines.c<br>
new file mode 100644<br>
index 0000000..9e57648<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/gs-mismatch-prim-type-lines.c<br>
@@ -0,0 +1,167 @@<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.1 (Geometry Shader Input Primitives):<br>
+ *<br>
+ * "If a geometry shader is active, any command that transfers vertices to the<br>
+ *  GL will generate an INVALID_OPERATION error if the primitive mode parameter<br>
+ *  is incompatible with the input primitive type of the currently active<br>
+ *  program object, as discussed below."<br>
+ *<br>
+ * "Geometry shaders that operate on line segments are valid only for the LINES,<br>
+ *  LINE_STRIP, and LINE_LOOP primitive types."<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(lines) 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(); i++) {\n"<br>
+       "               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.);\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>
+static GLenum valids[] = {GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP};<br>
+static GLenum invalids[] = {GL_POINTS, GL_LINES_ADJACENCY,<br>
+                               GL_LINE_STRIP_ADJACENCY,<br>
+                               GL_TRIANGLES, GL_TRIANGLE_STRIP,<br>
+                               GL_TRIANGLE_FAN, GL_TRIANGLES_ADJACENCY,<br>
+                               GL_TRIANGLE_STRIP_ADJACENCY};<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       bool pass = true;<br>
+       int i = 0;<br>
+<br>
+       glClearColor(0.2, 0.2, 0.2, 1.0);<br>
+       glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+       glBindVertexArray(vao);<br>
+       glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuf);<br>
+<br>
+       for(i = 0; i < ARRAY_SIZE(valids); i++) {<br>
+               glDrawElements(valids[i], ARRAY_SIZE(indices),<br>
+                               GL_UNSIGNED_INT, NULL);<br>
+               pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+       }<br>
+<br>
+       for(i = 0; i < ARRAY_SIZE(invalids); i++) {<br>
+               glDrawElements(invalids[i], ARRAY_SIZE(indices),<br>
+                               GL_UNSIGNED_INT, NULL);<br>
+               pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;<br>
+       }<br>
+<br>
+       return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
diff --git a/tests/spec/glsl-1.50/gs-mismatch-prim-type-points.c b/tests/spec/glsl-1.50/gs-mismatch-prim-type-points.c<br>
new file mode 100644<br>
index 0000000..81dbaa7<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/gs-mismatch-prim-type-points.c<br>
@@ -0,0 +1,167 @@<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.1 (Geometry Shader Input Primitives):<br>
+ *<br>
+ * "If a geometry shader is active, any command that transfers vertices to the<br>
+ *  GL will generate an INVALID_OPERATION error if the primitive mode parameter<br>
+ *  is incompatible with the input primitive type of the currently active<br>
+ *  program object, as discussed below."<br>
+ *<br>
+ * "Geometry shaders that operate on points are valid only for the POINTS<br>
+ *  primitive type."<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(points) 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(); i++) {\n"<br>
+       "               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.);\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>
+static GLenum valids[] = {GL_POINTS};<br>
+static GLenum invalids[] = {GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP,<br>
+                               GL_LINES_ADJACENCY, GL_LINE_STRIP_ADJACENCY,<br>
+                               GL_TRIANGLES, GL_TRIANGLE_STRIP,<br>
+                               GL_TRIANGLE_FAN, GL_TRIANGLES_ADJACENCY,<br>
+                               GL_TRIANGLE_STRIP_ADJACENCY};<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       bool pass = true;<br>
+       int i = 0;<br>
+<br>
+       glClearColor(0.2, 0.2, 0.2, 1.0);<br>
+       glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+       glBindVertexArray(vao);<br>
+       glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuf);<br>
+<br>
+       for(i = 0; i < ARRAY_SIZE(valids); i++) {<br>
+               glDrawElements(valids[i], ARRAY_SIZE(indices),<br>
+                               GL_UNSIGNED_INT, NULL);<br>
+               pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+       }<br>
+<br>
+       for(i = 0; i < ARRAY_SIZE(invalids); i++) {<br>
+               glDrawElements(invalids[i], ARRAY_SIZE(indices),<br>
+                               GL_UNSIGNED_INT, NULL);<br>
+               pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;<br>
+       }<br>
+<br>
+       return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
diff --git a/tests/spec/glsl-1.50/gs-mismatch-prim-type-triangles-adj.c b/tests/spec/glsl-1.50/gs-mismatch-prim-type-triangles-adj.c<br>
new file mode 100644<br>
index 0000000..1dbe84f<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/gs-mismatch-prim-type-triangles-adj.c<br>
@@ -0,0 +1,166 @@<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.1 (Geometry Shader Input Primitives):<br>
+ *<br>
+ * "If a geometry shader is active, any command that transfers vertices to the<br>
+ *  GL will generate an INVALID_OPERATION error if the primitive mode parameter<br>
+ *  is incompatible with the input primitive type of the currently active<br>
+ *  program object, as discussed below."<br>
+ *<br>
+ * "Geometry shaders that operate on triangles with adjacent vertices are valid<br>
+ *  for the TRIANGLES_ADJACENCY and TRIANGLE_STRIP_ADJACENCY primitive types."<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_adjacency) 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(); i++) {\n"<br>
+       "               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.);\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>
+static GLenum valids[] = {GL_TRIANGLES_ADJACENCY, GL_TRIANGLE_STRIP_ADJACENCY};<br>
+static GLenum invalids[] = {GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP,<br>
+                               GL_TRIANGLES, GL_TRIANGLE_STRIP,<br>
+                               GL_LINES_ADJACENCY, GL_LINE_STRIP_ADJACENCY,<br>
+                               GL_TRIANGLE_FAN};<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       bool pass = true;<br>
+       int i = 0;<br>
+<br>
+       glClearColor(0.2, 0.2, 0.2, 1.0);<br>
+       glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+       glBindVertexArray(vao);<br>
+       glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuf);<br>
+<br>
+       for(i = 0; i < ARRAY_SIZE(valids); i++) {<br>
+               glDrawElements(valids[i], ARRAY_SIZE(indices),<br>
+                               GL_UNSIGNED_INT, NULL);<br>
+               pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+       }<br>
+<br>
+       for(i = 0; i < ARRAY_SIZE(invalids); i++) {<br>
+               glDrawElements(invalids[i], ARRAY_SIZE(indices),<br>
+                               GL_UNSIGNED_INT, NULL);<br>
+               pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;<br>
+       }<br>
+<br>
+       return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
diff --git a/tests/spec/glsl-1.50/gs-mismatch-prim-type-triangles.c b/tests/spec/glsl-1.50/gs-mismatch-prim-type-triangles.c<br>
new file mode 100644<br>
index 0000000..8872431<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/gs-mismatch-prim-type-triangles.c<br>
@@ -0,0 +1,166 @@<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.1 (Geometry Shader Input Primitives):<br>
+ *<br>
+ * "If a geometry shader is active, any command that transfers vertices to the<br>
+ *  GL will generate an INVALID_OPERATION error if the primitive mode parameter<br>
+ *  is incompatible with the input primitive type of the currently active<br>
+ *  program object, as discussed below."<br>
+ *<br>
+ * "Geometry shaders that operate on triangles are valid for the TRIANGLES,<br>
+ *  TRIANGLE_STRIP and TRIANGLE_FAN primitive types."<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(); i++) {\n"<br>
+       "               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.);\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>
+static GLenum valids[] = {GL_TRIANGLES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN};<br>
+static GLenum invalids[] = {GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP,<br>
+                               GL_LINES_ADJACENCY, GL_LINE_STRIP_ADJACENCY,<br>
+                               GL_TRIANGLES_ADJACENCY,<br>
+                               GL_TRIANGLE_STRIP_ADJACENCY};<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       bool pass = true;<br>
+       int i = 0;<br>
+<br>
+       glClearColor(0.2, 0.2, 0.2, 1.0);<br>
+       glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+       glBindVertexArray(vao);<br>
+       glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuf);<br>
+<br>
+       for(i = 0; i < ARRAY_SIZE(valids); i++) {<br>
+               glDrawElements(valids[i], ARRAY_SIZE(indices),<br>
+                               GL_UNSIGNED_INT, NULL);<br>
+               pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
+       }<br>
+<br>
+       for(i = 0; i < ARRAY_SIZE(invalids); i++) {<br>
+               glDrawElements(invalids[i], ARRAY_SIZE(indices),<br>
+                               GL_UNSIGNED_INT, NULL);<br>
+               pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;<br>
+       }<br>
+<br>
+       return pass ? PIGLIT_PASS : 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>