<div dir="ltr">On 23 August 2013 12:17, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</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 class="HOEnZb"><div class="h5">On 08/11/2013 10:32 PM, Paul Berry wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
  tests/all.tests                                    |   9 +<br>
  tests/spec/glsl-1.50/<u></u>execution/CMakeLists.txt      |   1 +<br>
  .../glsl-1.50/execution/<u></u>geometry/CMakeLists.gl.txt |  13 +<br>
  .../glsl-1.50/execution/<u></u>geometry/CMakeLists.txt    |   1 +<br>
  .../glsl-1.50/execution/<u></u>geometry/end-primitive.c   | 393 +++++++++++++++++++++<br>
  5 files changed, 417 insertions(+)<br>
  create mode 100644 tests/spec/glsl-1.50/<u></u>execution/geometry/CMakeLists.<u></u>gl.txt<br>
  create mode 100644 tests/spec/glsl-1.50/<u></u>execution/geometry/CMakeLists.<u></u>txt<br>
  create mode 100644 tests/spec/glsl-1.50/<u></u>execution/geometry/end-<u></u>primitive.c<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index a914a2a..bebb69a 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -910,6 +910,15 @@ for draw in ['', 'indexed']:<br>
                              ('arb_geometry_shader4-ignore-<u></u>adjacent-vertices '<br>
                               'core {0} {1}').format(draw, prim))<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>
+# respectively), so test around there.  Also test 0, which means the<br>
+# maximum number of geometry shader output vertices supported by the<br>
+# hardware.<br>
+for i in [31, 32, 33, 34, 127, 128, 129, 130, 0]:<br>
+    add_concurrent_test(spec['<u></u>glsl-1.50'],<br>
+                        'glsl-1.50-geometry-end-<u></u>primitive {0}'.format(i))<br>
+<br>
  # Group spec/glsl-es-3.00<br>
  spec['glsl-es-3.00'] = Group()<br>
  import_glsl_parser_tests(spec[<u></u>'glsl-es-3.00'],<br>
diff --git a/tests/spec/glsl-1.50/<u></u>execution/CMakeLists.txt b/tests/spec/glsl-1.50/<u></u>execution/CMakeLists.txt<br>
index 144a306..c0c4f05 100644<br>
--- a/tests/spec/glsl-1.50/<u></u>execution/CMakeLists.txt<br>
+++ b/tests/spec/glsl-1.50/<u></u>execution/CMakeLists.txt<br>
@@ -1 +1,2 @@<br>
  piglit_include_target_api()<br>
+add_subdirectory (geometry)<br>
diff --git a/tests/spec/glsl-1.50/<u></u>execution/geometry/CMakeLists.<u></u>gl.txt b/tests/spec/glsl-1.50/<u></u>execution/geometry/CMakeLists.<u></u>gl.txt<br>
new file mode 100644<br>
index 0000000..d4becb7<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/<u></u>execution/geometry/CMakeLists.<u></u>gl.txt<br>
@@ -0,0 +1,13 @@<br>
+include_directories(<br>
+${GLEXT_INCLUDE_DIR}<br>
+${OPENGL_INCLUDE_PATH}<br>
+${piglit_SOURCE_DIR}/tests/<u></u>util<br>
+)<br>
+<br>
+link_libraries (<br>
+piglitutil_${piglit_target_<u></u>api}<br>
+${OPENGL_gl_LIBRARY}<br>
+${OPENGL_glu_LIBRARY}<br>
+)<br>
+<br>
+piglit_add_executable (glsl-1.50-geometry-end-<u></u>primitive end-primitive.c)<br>
diff --git a/tests/spec/glsl-1.50/<u></u>execution/geometry/CMakeLists.<u></u>txt b/tests/spec/glsl-1.50/<u></u>execution/geometry/CMakeLists.<u></u>txt<br>
new file mode 100644<br>
index 0000000..144a306<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/<u></u>execution/geometry/CMakeLists.<u></u>txt<br>
@@ -0,0 +1 @@<br>
+piglit_include_target_api()<br>
diff --git a/tests/spec/glsl-1.50/<u></u>execution/geometry/end-<u></u>primitive.c b/tests/spec/glsl-1.50/<u></u>execution/geometry/end-<u></u>primitive.c<br>
new file mode 100644<br>
index 0000000..9400229<br>
--- /dev/null<br>
+++ b/tests/spec/glsl-1.50/<u></u>execution/geometry/end-<u></u>primitive.c<br>
@@ -0,0 +1,393 @@<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<br>
+ * DEALINGS IN THE SOFTWARE.<br>
+ */<br>
+<br>
+/**<br>
+ * \file end-primitive.c<br>
+ *<br>
+ * Verify functionality of the geometry shader EndPrimitive() function.<br>
+ *<br>
+ * This test checks that EndPrimitive() works properly for the<br>
+ * combination of output primitive type and max vertex count speficied<br>
+ * on the command line.<br>
+ *<br>
+ * The test operates by sending three POINT primitives down the<br>
+ * pipeline.  The geometry shader converts each POINT primitive into a<br>
+ * triangle_strip containing the requested number of vertices.<br>
+ * EndPrimitive() is called after every third vertex, so the resulting<br>
+ * image consists of discrete triangles.  The triangles are arranged<br>
+ * into a spiral pattern so that the maximum geometry shader output<br>
+ * vertex count can be accommodated without making the triangles too<br>
+ * small.<br>
+ *<br>
+ * Each of the 3 geometry shader invocations calls EndPrimitive() at<br>
+ * different times (the first invocation calls it prior to vertices 0,<br>
+ * 3, 6, 9, etc., the second invocation prior to vertices 1, 4, 7, 10,<br>
+ * etc., and the third invocation prior to vertices 2, 5, 8, 11,<br>
+ * etc.).  The colors of the triangles are red for the first geometry<br>
+ * shader invocation, green for the second, and blue for the third.<br>
+ * So the resulting image should show the entire triangle strip with<br>
+ * colors sequencing in red, green, blue order.<br>
+ *<br>
+ * Colors are communicated from the geometry shader to the fragment<br>
+ * shader by adjusting the value of gl_Position.z.  This allows us to<br>
+ * avoid taking up an extra varying slot to communicate color (which<br>
+ * might reduce the number of vertices we can test, due to<br>
+ * GL_MAX_GEOMETRY_TOTAL_OUTPUT_<u></u>COMPONENTS).<br>
+ *<br>
+ * The test image is drawn twice, once in the manner described above<br>
+ * (the test pattern), and once without using geometry shaders (the<br>
+ * reference pattern).  The test and reference pattern are then<br>
+ * compared.<br>
</blockquote>
<br></div></div>
Brilliant.  I like it.<div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ * The image is drawn with a blend equation of GL_MAX, so that if any<br>
+ * call to EndPrimitive() fails to work, the result will be visible,<br>
+ * even if a subsequent geometry shader invocation draws over the same<br>
+ * part of the image.<br>
+ */<br>
+<br>
+<br>
+#include "piglit-util-gl-common.h"<br>
+<br>
+#define PATTERN_SIZE 256<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+       config.supports_gl_compat_<u></u>version = 32;<br>
+       config.supports_gl_core_<u></u>version = 32;<br>
+       config.window_width = 2*PATTERN_SIZE;<br>
+       config.window_height = PATTERN_SIZE;<br>
+       config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+static GLuint prog_ref, prog_test, fb;<br>
+static int num_vertices;<br>
+<br>
+/**<br>
+ * Function to compute the spiral pattern.  The distance between<br>
+ * adjacent vertices returned by this function is approximately<br>
+ * constant, so the resulting triangles will be approximately equal in<br>
+ * size.<br>
+ */<br>
+static const char *spiral_text =<br>
+       "#version 150\n"<br>
+       "\n"<br>
+       "uniform int num_vertices;\n"<br>
+       "\n"<br>
+       "vec2 spiral(int vertex_id)\n"<br>
+       "{\n"<br>
+       "  float pi = acos(-1.0);\n"<br>
+       "  float radial_spacing = 1.5;\n"<br>
+       "  float spiral_spacing = 0.5;\n"<br>
+       "  float a = 4.0*pi*spiral_spacing/radial_<u></u>spacing;\n"<br>
+       "  float b = radial_spacing/(2*pi);\n"<br>
+       "  float theta = sqrt(a*float(vertex_id + 1));\n"<br>
+       "  float r = b*theta;\n"<br>
+       "  if (vertex_id % 2 == 1) r += 1.0;\n"<br>
+       "  float max_r = b*sqrt(a*float(num_vertices)) + 1.0;\n"<br>
+       "  r /= max_r;\n"<br>
+       "  return r*vec2(cos(theta), sin(theta));\n"<br>
+       "}\n";<br>
</blockquote>
<br></div></div>
I didn't review this code, but I trust that it works.<div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+/**<br>
+ * Vertex shader for drawing the test pattern.  The incoming vertex ID<br>
+ * is passed down into the geometry shader, so that it can tell which<br>
+ * invocation it is.<br>
+ */<br>
+static const char *vs_test_text =<br>
+       "#version 150\n"<br>
+       "\n"<br>
+       "out int end_prim_offset;\n"<br>
+       "\n"<br>
+       "void main()\n"<br>
+       "{\n"<br>
+       "  end_prim_offset = gl_VertexID;\n"<br>
+       "}\n";<br>
+<br>
+/**<br>
+ * Geometry shader for drawing the test pattern.<br>
+ */<br>
+static const char *gs_test_text =<br>
+       "#version 150\n"<br>
+       "\n"<br>
+       "vec2 spiral(int vertex_id);\n"<br>
+       "uniform int num_vertices;\n"<br>
+       "in int end_prim_offset[];\n"<br>
+       "\n"<br>
+       "void main()\n"<br>
+       "{\n"<br>
+       "  int i = 0;\n"<br>
+       "  while (true) {\n"<br>
+       "    if (i % 3 == end_prim_offset[0])\n"<br>
+       "      EndPrimitive();\n"<br>
+       "    if (i == num_vertices)\n"<br>
+       "      break;\n"<br>
+       "    gl_Position = vec4(spiral(i++), end_prim_offset[0]/4.0, 1.0);\n"<br>
+       "    EmitVertex();\n"<br>
+       "  }\n"<br>
+       "}\n";<br>
+<br>
+/**<br>
+ * Printf template for the geometry shader layout.  %d will be filled<br>
+ * in with the number of vertices requested on the command line.<br>
+ */<br>
+static const char *gs_layout_template =<br>
+       "#version 150\n"<br>
+       "\n"<br>
+       "layout(points) in;\n"<br>
+       "layout(triangle_strip, max_vertices = %d) out;\n";<br>
+<br>
+/**<br>
+ * Fragment shader for drawing both the test and reference patterns.<br>
+ */<br>
+static const char *fs_text =<br>
+       "#version 150\n"<br>
+       "\n"<br>
+       "void main()\n"<br>
+       "{\n"<br>
+       "  int end_prim_offset = int(round((gl_FragCoord.z - 0.5) * 8.0));\n"<br>
+       "  const vec4 colors[3] = vec4[3](\n"<br>
+       "    vec4(1.0, 0.0, 0.0, 1.0),\n"<br>
+       "    vec4(0.0, 1.0, 0.0, 1.0),\n"<br>
+       "    vec4(0.0, 0.0, 1.0, 1.0));\n"<br>
+       "  gl_FragColor = colors[end_prim_offset];\n"<br>
+       "}\n";<br>
+<br>
+/**<br>
+ * Vertex shader for drawing the reference pattern.  gl_VertexID takes<br>
+ * the place of the variable i in the geometry shader.<br>
+ */<br>
+static const char *vs_ref_text =<br>
+       "#version 150\n"<br>
+       "\n"<br>
+       "vec2 spiral(int vertex_id);\n"<br>
+       "uniform int end_prim_offset;\n"<br>
+       "\n"<br>
+       "void main()\n"<br>
+       "{\n"<br>
+       "  gl_Position = vec4(spiral(gl_VertexID), end_prim_offset/4.0,\n"<br>
+       "                     1.0);\n"<br>
+       "}\n";<br>
+<br>
+<br>
+static void<br>
+print_usage_and_exit(const char *prog_name)<br>
+{<br>
+       printf("Usage: %s <vertex_count>\n"<br>
+              "  where <vertex_count> is the number of vertices to test, or\n"<br>
+              "  0 to test the maximum possible number of vertices.\n",<br>
+              prog_name);<br>
+       piglit_report_result(PIGLIT_<u></u>FAIL);<br>
+}<br>
+<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+       GLuint vs_spiral, gs_spiral, vs_ref_main, vs_test_main, gs_test_main,<br>
+               gs_layout, fs_main, vao, element_buf, rb;<br>
+       GLint max_gs_out_vertices, max_gs_out_components;<br>
+       int max_testable_vertices;<br>
+       char *text, *endptr;<br>
+<br>
+       /* parse args */<br>
+       if (argc != 2)<br>
+               print_usage_and_exit(argv[0]);<br>
+       endptr = NULL;<br>
+       num_vertices = strtol(argv[1], &endptr, 0);<br>
+       if (endptr != argv[1] + strlen(argv[1]))<br>
+               print_usage_and_exit(argv[0]);<br>
+<br>
+       /* Figure out the maximum number of vertices we can test. */<br>
+       glGetIntegerv(GL_MAX_GEOMETRY_<u></u>OUTPUT_VERTICES, &max_gs_out_vertices);<br>
+       glGetIntegerv(GL_MAX_GEOMETRY_<u></u>TOTAL_OUTPUT_COMPONENTS,<br>
+                     &max_gs_out_components);<br>
+       if (!piglit_check_gl_error(GL_NO_<u></u>ERROR))<br>
+               piglit_report_result(PIGLIT_<u></u>FAIL);<br>
+       max_testable_vertices = MIN2(max_gs_out_vertices,<br>
+                                    max_gs_out_components / 4);<br>
+<br>
+       /* If num_vertices == 0, test the maximum possible number of<br>
+        * vertices.  Otherwise ensure that the requested number is<br>
+        * supported by the implementation.<br>
+        */<br>
+       if (num_vertices == 0)<br>
+               num_vertices = max_testable_vertices;<br>
+       else if (num_vertices > max_testable_vertices) {<br>
+               printf("Can't test more than %d vertices\n",<br>
+                      max_testable_vertices);<br>
+               piglit_report_result(PIGLIT_<u></u>SKIP);<br>
+       }<br>
+<br>
+       /* Compile shaders */<br>
+       vs_spiral = piglit_compile_shader_text(GL_<u></u>VERTEX_SHADER, spiral_text);<br>
+       gs_spiral = piglit_compile_shader_text(GL_<u></u>GEOMETRY_SHADER,<br>
+                                              spiral_text);<br>
+       vs_ref_main = piglit_compile_shader_text(GL_<u></u>VERTEX_SHADER,<br>
+                                                vs_ref_text);<br>
+       vs_test_main = piglit_compile_shader_text(GL_<u></u>VERTEX_SHADER,<br>
+                                                 vs_test_text);<br>
+       gs_test_main = piglit_compile_shader_text(GL_<u></u>GEOMETRY_SHADER,<br>
+                                                 gs_test_text);<br>
+       asprintf(&text, gs_layout_template, num_vertices);<br>
+       gs_layout = piglit_compile_shader_text(GL_<u></u>GEOMETRY_SHADER, text);<br>
+       free(text);<br>
+       fs_main = piglit_compile_shader_text(GL_<u></u>FRAGMENT_SHADER, fs_text);<br>
+<br>
+       prog_ref = glCreateProgram();<br>
+       glAttachShader(prog_ref, vs_ref_main);<br>
+       glAttachShader(prog_ref, vs_spiral);<br>
+       glAttachShader(prog_ref, fs_main);<br>
+       glLinkProgram(prog_ref);<br>
+       if (!piglit_link_check_status(<u></u>prog_ref))<br>
+               piglit_report_result(PIGLIT_<u></u>FAIL);<br>
+<br>
+       prog_test = glCreateProgram();<br>
+       glAttachShader(prog_test, vs_test_main);<br>
+       glAttachShader(prog_test, gs_test_main);<br>
+       glAttachShader(prog_test, gs_spiral);<br>
+       glAttachShader(prog_test, gs_layout);<br>
+       glAttachShader(prog_test, fs_main);<br>
+       glLinkProgram(prog_test);<br>
+       if (!piglit_link_check_status(<u></u>prog_test))<br>
+               piglit_report_result(PIGLIT_<u></u>FAIL);<br>
+<br>
+       glDeleteShader(vs_spiral);<br>
+       glDeleteShader(gs_spiral);<br>
+       glDeleteShader(vs_ref_main);<br>
+       glDeleteShader(vs_test_main);<br>
+       glDeleteShader(gs_test_main);<br>
+       glDeleteShader(gs_layout);<br>
+       glDeleteShader(fs_main);<br>
+<br>
+       /* Various other GL objects needed by the test */<br>
+       glGenVertexArrays(1, &vao);<br>
+       glBindVertexArray(vao);<br>
+       glGenBuffers(1, &element_buf);<br>
+       glBindBuffer(GL_ELEMENT_ARRAY_<u></u>BUFFER, element_buf);<br>
+       glGenFramebuffers(1, &fb);<br>
+       glBindFramebuffer(GL_<u></u>FRAMEBUFFER, fb);<br>
+       glGenRenderbuffers(1, &rb);<br>
+       glBindRenderbuffer(GL_<u></u>RENDERBUFFER, rb);<br>
+       glRenderbufferStorage(GL_<u></u>RENDERBUFFER, GL_RGBA, PATTERN_SIZE,<br>
+                             PATTERN_SIZE);<br>
+       glFramebufferRenderbuffer(GL_<u></u>FRAMEBUFFER, GL_COLOR_ATTACHMENT0,<br>
+                                 GL_RENDERBUFFER, rb);<br>
+<br>
+       if (!piglit_check_gl_error(GL_NO_<u></u>ERROR))<br>
+               piglit_report_result(PIGLIT_<u></u>FAIL);<br>
+}<br>
+<br>
+<br>
+/**<br>
+ * Simulate the action of the 3 geometry shader invocations by making<br>
+ * 3 glDrawElements() calls.  Primitive restart is used to simulate<br>
+ * the action of EndPrimitive().<br>
+ */<br>
+static void<br>
+draw_ref_pattern()<br>
+{<br>
+       int i, vertex_count, end_prim_offset;<br>
+<br>
+       glClear(GL_COLOR_BUFFER_BIT);<br>
+       glUseProgram(prog_ref);<br>
+       glUniform1i(<u></u>glGetUniformLocation(prog_ref, "num_vertices"),<br>
+                   num_vertices);<br>
+       glEnable(GL_PRIMITIVE_RESTART)<u></u>;<br>
+       glPrimitiveRestartIndex(<u></u>0xffffffff);<br>
+<br>
+       for (end_prim_offset = 0; end_prim_offset < 3; end_prim_offset++) {<br>
+               GLuint *index_buffer =<br>
+                       malloc(2 * sizeof(GLuint) * num_vertices);<br>
</blockquote>
<br></div></div>
This is overallocating, right?  Your index buffer would normally be [0, 1, 2, 3, ..] except that you're inserting 0xffffffff every 3 vertices. Wouldn't (num_vertices + ceil(num_vertices/3.) ) * sizeof(GLuint) work? <br>
</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Overallocating shouldn't hurt anything - it's safe and avoids irritating rounding problems - but it might be nice to have a comment saying that's what you're doing.</blockquote><div><br></div><div>Fair enough--I've added a comment.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+               i = vertex_count = 0;<br>
+               while (true) {<br>
+                       if (i % 3 == end_prim_offset)<br>
+                               index_buffer[vertex_count++] = 0xffffffff;<br>
+                       if (i == num_vertices)<br>
+                               break;<br>
+                       index_buffer[vertex_count++] = i++;<br>
+               }<br>
</blockquote>
<br></div>
Wouldn't the following also work?<br>
<br>
while (i < num_vertices) {<div class="im"><br>
        if (i % 3 == end_prim_offset)<br></div>
                index_buffer[vertex_count++] = 0xffffffff;<br>
        index_buffer[vertex_count++] = i++;<br>
}<br>
<br>
You might not get the 0xffffffff at the very end, but since it's the end of your draw call anyway, I don't think it would matter.<br>
<br>
Not a big deal either way.  As is, it matches your shader, and that's worth preserving...</blockquote><div><br></div><div>You're right, your way would have worked too.  I mostly chose to do what I did to mtach the shader :)<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+               glUniform1i(<u></u>glGetUniformLocation(prog_ref, "end_prim_offset"),<br>
+                           end_prim_offset);<br>
+               glBufferData(GL_ELEMENT_ARRAY_<u></u>BUFFER,<br>
+                            sizeof(GLuint) * vertex_count, index_buffer,<br>
+                            GL_STATIC_DRAW);<br>
+               free(index_buffer);<br>
+               glDrawElements(GL_TRIANGLE_<u></u>STRIP, vertex_count,<br>
+                              GL_UNSIGNED_INT, NULL);<br>
+       }<br>
+<br>
+       glDisable(GL_PRIMITIVE_<u></u>RESTART);<br>
+}<br>
+<br>
+<br>
+static void<br>
+draw_test_pattern()<br>
+{<br>
+       glClear(GL_COLOR_BUFFER_BIT);<br>
+       glUseProgram(prog_test);<br>
+       glUniform1i(<u></u>glGetUniformLocation(prog_<u></u>test, "num_vertices"),<br>
+                   num_vertices);<br>
+       glDrawArrays(GL_POINTS, 0, 3);<br>
+}<br>
+<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       bool pass = true;<br>
+<br>
+       glEnable(GL_BLEND);<br>
+       glBlendEquation(GL_MAX);<br>
+<br>
+       /* Left half of the window is the test pattern */<br>
+       glViewport(0, 0, PATTERN_SIZE, PATTERN_SIZE);<br>
+       glBindFramebuffer(GL_DRAW_<u></u>FRAMEBUFFER, fb);<br>
+       draw_test_pattern();<br>
+       glBindFramebuffer(GL_READ_<u></u>FRAMEBUFFER, fb);<br>
+       glBindFramebuffer(GL_DRAW_<u></u>FRAMEBUFFER, piglit_winsys_fbo);<br>
+       glBlitFramebuffer(0, 0, PATTERN_SIZE, PATTERN_SIZE,<br>
+                         0, 0, PATTERN_SIZE, PATTERN_SIZE,<br>
+                         GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
+<br>
+       /* Right half of the window is the reference image */<br>
+       glBindFramebuffer(GL_DRAW_<u></u>FRAMEBUFFER, fb);<br>
+       draw_ref_pattern();<br>
+       glBindFramebuffer(GL_READ_<u></u>FRAMEBUFFER, fb);<br>
+       glBindFramebuffer(GL_DRAW_<u></u>FRAMEBUFFER, piglit_winsys_fbo);<br>
+       glBlitFramebuffer(0, 0, PATTERN_SIZE, PATTERN_SIZE,<br>
+                         PATTERN_SIZE, 0, 2*PATTERN_SIZE, PATTERN_SIZE,<br>
+                         GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
</blockquote>
<br></div></div>
You could probably just adjust the viewport rather than monkeying around with multiple framebuffers and blitting.  Should be simpler.</blockquote><div><br></div><div>That's much simpler, thanks.<br></div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+       if (!piglit_check_gl_error(GL_NO_<u></u>ERROR))<br>
+               pass = false;<br>
+<br>
+       /* Compare window halves */<br>
+       glBindFramebuffer(GL_READ_<u></u>FRAMEBUFFER, piglit_winsys_fbo);<br>
+       pass = piglit_probe_rect_halves_<u></u>equal_rgba(0, 0, 2*PATTERN_SIZE,<br>
+                                                  PATTERN_SIZE) && pass;<br>
+<br>
+       piglit_present_results();<br>
+<br>
+       return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
<br>
</blockquote>
<br></div>
Reviewed-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>><br>
</blockquote></div><br></div></div>