On 22 May 2012 13:02, Ian Romanick <span dir="ltr">&lt;<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 05/10/2012 06:05 PM, Paul Berry wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This test verifies that blits involving MSAA buffers work properly<br>
even if the source and destination rectangles are located in different<br>
parts of their respective framebuffers, and even if the source and<br>
destination rectangles are not aligned to powers of two.<br>
<br>
These are necessary corner cases to check in i965, where blits that<br>
involve MSAA buffers frequently require special handling when the<br>
source and destination rectangles are different, or are not nicely<br>
aligned.<br>
<br>
v2: Use a tile size of 49 instead of 50, so that source and<br>
destination rectangles are even more poorly aligned.  This exposed a<br>
bug in i965/gen6.<br>
</blockquote>
<br></div>
Other than the nits below,<br>
<br>
Reviewed-by: Ian Romanick &lt;<a href="mailto:ian.d.romanick@intel.com" target="_blank">ian.d.romanick@intel.com</a>&gt;<br></blockquote><div><br>I can go along with your nits.  Thanks for the review.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
---<br>
  tests/all.tests                                    |    8 +<br>
  .../ext_framebuffer_<u></u>multisample/CMakeLists.gl.txt  |    1 +<br>
  .../ext_framebuffer_<u></u>multisample/unaligned-blit.cpp |  232 ++++++++++++++++++++<br>
  3 files changed, 241 insertions(+), 0 deletions(-)<br>
  create mode 100644 tests/spec/ext_framebuffer_<u></u>multisample/unaligned-blit.cpp<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index b2250ba..1f6755d 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -1336,6 +1336,14 @@ for num_samples in (2, 4, 8, 16, 32):<br>
                          test_name)<br>
                  ext_framebuffer_multisample[<u></u>test_name] = PlainExecTest(executable)<br>
<br>
+for num_samples in (2, 4, 8, 16, 32):<br>
+        for buffer_type in (&#39;color&#39;, &#39;depth&#39;, &#39;stencil&#39;):<br>
+                for blit_type in (&#39;msaa&#39;, &#39;upsample&#39;, &#39;downsample&#39;):<br>
+                        test_name = &#39; &#39;.join([&#39;unaligned-blit&#39;, str(num_samples), buffer_type, blit_type])<br>
+                        executable = &#39;ext_framebuffer_multisample-{<u></u>0} -auto&#39;.format(<br>
+                                test_name)<br>
+                        ext_framebuffer_multisample[<u></u>test_name] = PlainExecTest(executable)<br>
+<br>
  ext_framebuffer_object = Group()<br>
  spec[&#39;EXT_framebuffer_object&#39;] = ext_framebuffer_object<br>
  add_fbo_stencil_tests(ext_<u></u>framebuffer_object, &#39;GL_STENCIL_INDEX1&#39;)<br>
diff --git a/tests/spec/ext_framebuffer_<u></u>multisample/CMakeLists.gl.txt b/tests/spec/ext_framebuffer_<u></u>multisample/CMakeLists.gl.txt<br>
index 475237c..c10043c 100644<br>
--- a/tests/spec/ext_framebuffer_<u></u>multisample/CMakeLists.gl.txt<br>
+++ b/tests/spec/ext_framebuffer_<u></u>multisample/CMakeLists.gl.txt<br>
@@ -24,4 +24,5 @@ piglit_add_executable (ext_framebuffer_multisample-<u></u>renderbuffer-samples renderbu<br>
  piglit_add_executable (ext_framebuffer_multisample-<u></u>renderbufferstorage-samples renderbufferstorage-samples.c)<br>
  piglit_add_executable (ext_framebuffer_multisample-<u></u>samples samples.c)<br>
  piglit_add_executable (ext_framebuffer_multisample-<u></u>turn-on-off common.cpp turn-on-off.cpp)<br>
+piglit_add_executable (ext_framebuffer_multisample-<u></u>unaligned-blit common.cpp unaligned-blit.cpp)<br>
  piglit_add_executable (ext_framebuffer_multisample-<u></u>upsample common.cpp upsample.cpp)<br>
diff --git a/tests/spec/ext_framebuffer_<u></u>multisample/unaligned-blit.cpp b/tests/spec/ext_framebuffer_<u></u>multisample/unaligned-blit.cpp<br>
new file mode 100644<br>
index 0000000..745ee91<br>
--- /dev/null<br>
+++ b/tests/spec/ext_framebuffer_<u></u>multisample/unaligned-blit.cpp<br>
@@ -0,0 +1,232 @@<br>
+/*<br>
+ * Copyright © 2012 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 &quot;Software&quot;),<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 &quot;AS IS&quot;, 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>
+#include &quot;common.h&quot;<br>
+<br>
+/**<br>
+ * \file unaligned-blit.cpp<br>
+ *<br>
+ * Verify the accuracy of blits involving MSAA buffers when the blit<br>
+ * coordinates are not aligned to simple powers of two.<br>
+ *<br>
+ * This test operates through the use of a sequence of blits that<br>
+ * might be called a &quot;scrambling blit&quot;: a source image (whose size is<br>
+ * not a power of two) is divided up into tiles (whose size is also<br>
+ * not a power of two), and these tiles are blitted one at a time from<br>
+ * the source to the destination buffer, permuting the order of the<br>
+ * tiles in a deterministic way.  The scrambling ensures that we test<br>
+ * a wide variety of different offsets and coordinate misalignments.<br>
+ *<br>
+ * The test performs the following operations: First an unscrambled<br>
+ * test image is created in a source buffer, which may or may not be<br>
+ * multisampled.  Then a scrambling blit is used to copy it to a<br>
+ * destination buffer, which also may or may not be multisampled.<br>
+ * Finally, the destination buffer is blitted to the window system<br>
+ * framebuffer, using the inverse permutation.  This should result in<br>
+ * an unscrambled test image.<br>
+ *<br>
+ * To verify that the test image is correct, we produce a reference<br>
+ * image by repeating the same operation using ordinary unscrambled<br>
+ * blits.<br>
+ */<br>
+const int pattern_size = 245;<br>
+const int tile_size = 49;<br>
+const int tiles_across = 5;<br>
+const int num_tiles = tiles_across * tiles_across;<br>
+<br>
+int piglit_width = pattern_size * 2; int piglit_height = pattern_size;<br>
+int piglit_window_mode =<br>
+       GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA | GLUT_DEPTH | GLUT_STENCIL;<br>
+<br>
+<br>
+const int permutation[num_tiles] = {<br>
+       10, 5, 6, 17, 3, 11, 16, 21, 14, 24, 23, 8, 15, 18, 0, 12, 9,<br>
+       4, 22, 19, 20, 2, 7, 13, 1<br>
+};<br>
+<br>
+const int inverse_permutation[num_tiles] = {<br>
+       14, 24, 21, 4, 17, 1, 2, 22, 11, 16, 0, 5, 15, 23, 8, 12, 6,<br>
+       3, 13, 19, 20, 7, 18, 10, 9<br>
+};<br>
+<br>
+Fbo src_fbo;<br>
+Fbo dst_fbo;<br>
+TestPattern *test_pattern = NULL;<br>
+ManifestProgram *manifest_program = NULL;<br>
+GLbitfield buffer_to_test;<br>
+<br>
+void<br>
+scrambling_blit(const int *permutation)<br>
+{<br>
+       for (int i = 0; i&lt;  num_tiles; ++i) {<br>
+               int src_x = (i % tiles_across) * tile_size;<br>
+               int src_y = (i / tiles_across) * tile_size;<br>
+               int dst_x = (permutation[i] % tiles_across) * tile_size;<br>
+               int dst_y = (permutation[i] / tiles_across) * tile_size;<br>
+               glBlitFramebuffer(src_x, src_y,<br>
+                                 src_x + tile_size, src_y + tile_size,<br>
+                                 dst_x, dst_y,<br>
+                                 dst_x + tile_size, dst_y + tile_size,<br>
+                                 buffer_to_test, GL_NEAREST);<br>
+       }<br>
+}<br>
+<br>
+void<br>
+print_usage_and_exit(char *prog_name)<br>
+{<br>
+       printf(&quot;Usage: %s&lt;num_samples&gt;  &lt;buffer_type&gt;  &lt;blit_type&gt;\n&quot;<br>
+              &quot;  where&lt;buffer_type&gt;  is one of:\n&quot;<br>
+              &quot;    color\n&quot;<br>
+              &quot;    stencil\n&quot;<br>
+              &quot;    depth\n&quot;<br>
+              &quot;  and&lt;blit_type&gt;  is one of:\n&quot;<br>
+              &quot;    msaa\n&quot;<br>
+              &quot;    upsample\n&quot;<br>
+              &quot;    downsample\n&quot;,<br>
+              prog_name);<br>
+       piglit_report_result(PIGLIT_<u></u>FAIL);<br>
+}<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+       int num_samples;<br>
+       int src_samples;<br>
+       int dst_samples;<br>
+       if (argc&lt;  4)<br>
+               print_usage_and_exit(argv[0]);<br>
+       {<br>
+               char *endptr = NULL;<br></div></div>
+               num_samples = strtol(argv[1],&amp;endptr, 0);<div class="im"><br>
+               if (endptr != argv[1] + strlen(argv[1]))<br>
+                       print_usage_and_exit(argv[0]);<br>
+       }<br>
</div></blockquote>
<br>
This is weird.  The block doesn&#39;t go with the if-statement, and it isn&#39;t needed in C++.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+       piglit_require_gl_version(30);<br>
+       piglit_require_GLSL_version(<u></u>130);<br>
</blockquote>
<br></div>
GLSL 1.30 is implied by OpenGL 3.0.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
+<br>
+       /* Skip the test if num_samples&gt;  GL_MAX_SAMPLES */<br>
+       GLint max_samples;<br>
+       glGetIntegerv(GL_MAX_SAMPLES,&amp;<u></u>max_samples);<br>
+       if (num_samples&gt;  max_samples)<br>
+               piglit_report_result(PIGLIT_<u></u>SKIP);<br>
+<br>
+       if (strcmp(argv[2], &quot;color&quot;) == 0) {<br>
+               test_pattern = new Triangles();<br>
+               buffer_to_test = GL_COLOR_BUFFER_BIT;<br>
+       } else if (strcmp(argv[2], &quot;depth&quot;) == 0) {<br>
+               test_pattern = new DepthSunburst();<br>
+               manifest_program = new ManifestDepth();<br>
+               buffer_to_test = GL_DEPTH_BUFFER_BIT;<br>
+       } else if (strcmp(argv[2], &quot;stencil&quot;) == 0) {<br>
+               test_pattern = new StencilSunburst();<br>
+               manifest_program = new ManifestStencil();<br>
+               buffer_to_test = GL_STENCIL_BUFFER_BIT;<br>
+       } else {<br>
+               print_usage_and_exit(argv[0]);<br>
+       }<br>
+<br>
+       if (strcmp(argv[3], &quot;msaa&quot;) == 0) {<br>
+               src_samples = dst_samples = num_samples;<br>
+       } else if (strcmp(argv[3], &quot;upsample&quot;) == 0) {<br>
+               src_samples = 0;<br>
+               dst_samples = num_samples;<br>
+       } else if (strcmp(argv[3], &quot;downsample&quot;) == 0) {<br>
+               src_samples = num_samples;<br>
+               dst_samples = 0;<br>
+       } else {<br>
+               print_usage_and_exit(argv[0]);<br>
+       }<br>
+<br>
+       test_pattern-&gt;compile();<br>
+       if (manifest_program)<br>
+               manifest_program-&gt;compile();<br>
+       src_fbo.init(src_samples, pattern_size, pattern_size,<br>
+                    true /* combine_depth_stencil */,<br>
+                    false /* attach_texture */);<br>
+       dst_fbo.init(dst_samples, pattern_size, pattern_size,<br>
+                    true /* combine_depth_stencil */,<br>
+                    false /* attach_texture */);<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display()<br>
+{<br>
+       bool pass = true;<br>
+<br>
+       /* Draw the test pattern in src_fbo. */<br>
+       float proj[4][4] = {<br>
+               { 1, 0, 0, 0 },<br>
+               { 0, 1, 0, 0 },<br>
+               { 0, 0, 1, 0 },<br>
+               { 0, 0, 0, 1 }<br>
+       };<br>
+       glBindFramebuffer(GL_DRAW_<u></u>FRAMEBUFFER, src_fbo.handle);<br>
+       src_fbo.set_viewport();<br>
+       test_pattern-&gt;draw(proj);<br>
+<br>
+       /* Blit from src_fbo to dst_fbo, scrambling the pattern as we go. */<br>
+       glBindFramebuffer(GL_READ_<u></u>FRAMEBUFFER, src_fbo.handle);<br>
+       glBindFramebuffer(GL_DRAW_<u></u>FRAMEBUFFER, dst_fbo.handle);<br>
+       scrambling_blit(permutation);<br>
+<br>
+       /* Blit from dst_fbo to the left half of the window system<br>
+        * framebuffer, unscrambling as we go.<br>
+        */<br>
+       glBindFramebuffer(GL_READ_<u></u>FRAMEBUFFER, dst_fbo.handle);<br>
+       glBindFramebuffer(GL_DRAW_<u></u>FRAMEBUFFER, 0);<br>
+       scrambling_blit(inverse_<u></u>permutation);<br>
+<br>
+       /* Blit from src_fbo to dst_fbo with no scrambling. */<br>
+       glBindFramebuffer(GL_READ_<u></u>FRAMEBUFFER, src_fbo.handle);<br>
+       glBindFramebuffer(GL_DRAW_<u></u>FRAMEBUFFER, dst_fbo.handle);<br>
+       glBlitFramebuffer(0, 0, pattern_size, pattern_size,<br>
+                         0, 0, pattern_size, pattern_size,<br>
+                         buffer_to_test, GL_NEAREST);<br>
+<br>
+       /* Blit from dst_fbo to the right half of the window system<br>
+        * framebuffer, with no scrambling.<br>
+        */<br>
+       glBindFramebuffer(GL_READ_<u></u>FRAMEBUFFER, dst_fbo.handle);<br>
+       glBindFramebuffer(GL_DRAW_<u></u>FRAMEBUFFER, 0);<br>
+       glBlitFramebuffer(0, 0, pattern_size, pattern_size,<br>
+                         pattern_size, 0, pattern_size*2, pattern_size,<br>
+                         buffer_to_test, GL_NEAREST);<br>
+<br>
+       /* If we were testing depth or stencil, manifest the image so<br>
+        * that we can see it.<br>
+        */<br>
+       glViewport(0, 0, piglit_width, piglit_height);<br>
+       if (manifest_program)<br>
+               manifest_program-&gt;run();<br>
+<br>
+       /* Check that the left and right halves of the screen match. */<br>
+       glBindFramebuffer(GL_READ_<u></u>FRAMEBUFFER, 0);<br>
+       pass = piglit_probe_rect_halves_<u></u>equal_rgba(0, 0, piglit_width,<br></div></div>
+                                                  piglit_height)&amp;&amp;  pass;<br>
+<br>
+       pass = piglit_check_gl_error(GL_NO_<u></u>ERROR)&amp;&amp;  pass;<div class="im"><br>
+<br>
+       piglit_present_results();<br>
+<br>
+       return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
</div></blockquote>
<br>
</blockquote></div><br>