On 12 June 2012 12:40, Anuj Phogat <span dir="ltr"><<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>></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">
glBitmap() is expected to work exactly the same way on multisample FBO as<br>
it works on single sample FBO. Test assumes that MSAA accuracy test already<br>
passes.<br>
<br>
Signed-off-by: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com">anuj.phogat@gmail.com</a>><br>
---<br>
tests/all.tests | 6 +<br>
.../ext_framebuffer_multisample/CMakeLists.gl.txt | 1 +<br>
tests/spec/ext_framebuffer_multisample/bitmap.cpp | 185 ++++++++++++++++++++<br>
3 files changed, 192 insertions(+), 0 deletions(-)<br>
create mode 100644 tests/spec/ext_framebuffer_multisample/bitmap.cpp<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index 129a923..10c5351 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -1379,6 +1379,12 @@ for num_samples in (2, 4, 8, 16, 32):<br>
test_name)<br>
ext_framebuffer_multisample[test_name] = PlainExecTest(executable)<br>
<br>
+for num_samples in (2, 4, 8, 16, 32):<br>
+ test_name = ' '.join(['bitmap', str(num_samples)])<br>
+ executable = 'ext_framebuffer_multisample-{0} -auto'.format(<br>
+ test_name)<br>
+ ext_framebuffer_multisample[test_name] = PlainExecTest(executable)<br>
+<br>
ext_framebuffer_object = Group()<br>
spec['EXT_framebuffer_object'] = ext_framebuffer_object<br>
add_fbo_stencil_tests(ext_framebuffer_object, 'GL_STENCIL_INDEX1')<br>
diff --git a/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt b/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt<br>
index 1660067..68fed48 100644<br>
--- a/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt<br>
+++ b/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt<br>
@@ -10,6 +10,7 @@ link_libraries (<br>
)<br>
<br>
piglit_add_executable (ext_framebuffer_multisample-accuracy common.cpp accuracy.cpp)<br>
+piglit_add_executable (ext_framebuffer_multisample-bitmap common.cpp bitmap.cpp)<br>
piglit_add_executable (ext_framebuffer_multisample-dlist dlist.c)<br>
piglit_add_executable (ext_framebuffer_multisample-formats common.cpp formats.cpp)<br>
piglit_add_executable (ext_framebuffer_multisample-line-smooth common.cpp line-smooth.cpp)<br>
diff --git a/tests/spec/ext_framebuffer_multisample/bitmap.cpp b/tests/spec/ext_framebuffer_multisample/bitmap.cpp<br>
new file mode 100644<br>
index 0000000..ec52471<br>
--- /dev/null<br>
+++ b/tests/spec/ext_framebuffer_multisample/bitmap.cpp<br>
@@ -0,0 +1,185 @@<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 "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>
+#include "common.h"<br>
+<br>
+/**<br>
+ * \file bitmap.cpp<br>
+ *<br>
+ * This test case verifies the functionality of glBitmap() with multisample<br>
+ * FBO and assumes that MSAA accuracy test already passes. glBitmap() is<br>
+ * expected to work exactly the same way on multisample FBO as it works on<br>
+ * single sample FBO.<br>
+ *<br>
+ * Test operates by drawing a test pattern in a single sample FBO which<br>
+ * generates a reference image in right half of default framebuffer.<br>
+ *<br>
+ * Draw the same test pattern in multisample buffer and blit it in to a single<br>
+ * sample FBO (resolve_fbo). Then blit the resolve_fbo to left half of window<br>
+ * system framebuffer. This is the test image.<br>
+ *<br>
+ * Compare the two halves of default framebuffer.<br>
+ */<br>
+<br>
+int piglit_width = 512; int piglit_height = 256;<br>
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA ;<br>
+const int pattern_width = 256; const int pattern_height = 256;<br>
+<br>
+static Fbo ms_fbo, resolve_fbo;<br>
+static GLint num_samples;<br>
+<br>
+static GLubyte bitmap[] =<br>
+{<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+ 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,<br>
+};<br></blockquote><div><br>This is a remarkably uniform bitmap. Can we replace it with something that has a little more variation? I'm worried that some possible bugs might not be detected by this test because the bitmap is so uniform. For example, the rightmost two pixels of the entire bitmap are 0's. So if we had a bug that prevented the rightmost 2 pixels of the bitmap from being drawn, the test wouldn't catch it.<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>
+void<br>
+draw_pattern(void)<br>
+{<br>
+ const int w = 32, h = 32;<br>
+<br>
+ glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+ glRasterPos2i (0, 0);<br>
+ glColor3f(1.0, 1.0 , 1.0);<br>
+ for (int i = 0; i < pattern_width / w; i++)<br>
+ glBitmap(w, h, 0.0, 0.0, w, h, bitmap);<br>
+<br>
+ glRasterPos2i (0, pattern_height - h);<br>
+ for (int i = 0; i < pattern_width / w; i++)<br>
+ glBitmap(w, h, 0.0, 0.0, w, -h, bitmap);<br>
+}<br>
+<br>
+void<br>
+print_usage_and_exit(char *prog_name)<br>
+{<br>
+ printf("Usage: %s <num_samples>\n", prog_name);<br>
+ piglit_report_result(PIGLIT_FAIL);<br>
+}<br>
+<br>
+bool<br>
+test_multisample_bitmap()<br>
+{<br>
+ bool result = true;<br>
+<br>
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ms_fbo.handle);<br>
+ draw_pattern();<br>
+<br>
+ /* Blit ms_fbo to resolve_fbo to resolve multisample buffer */<br>
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, ms_fbo.handle);<br>
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolve_fbo.handle);<br>
+ glBlitFramebuffer(0, 0, pattern_width, pattern_height,<br>
+ 0, 0, pattern_width, pattern_height,<br>
+ GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
+<br>
+ /* Blit resolve_fbo to the left half of window system framebuffer.<br>
+ * This is the test image.<br>
+ */<br>
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo.handle);<br>
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);<br>
+ glBlitFramebuffer(0, 0, pattern_width, pattern_height,<br>
+ 0, 0, pattern_width, pattern_height,<br>
+ GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
+<br>
+ /* Check that the left and right halves of the screen match */<br>
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);<br>
+ result = piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width,<br>
+ piglit_height)<br>
+ && result;<br>
+<br>
+ result = piglit_check_gl_error(GL_NO_ERROR) && result;<br>
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);<br>
+ return result;<br>
+}<br>
+<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+ if (argc < 2)<br>
+ print_usage_and_exit(argv[0]);<br>
+ {<br>
+ char *endptr = NULL;<br>
+ num_samples = strtol(argv[1], &endptr, 0);<br>
+ if (endptr != argv[1] + strlen(argv[1]))<br>
+ print_usage_and_exit(argv[0]);<br>
+ }<br>
+<br>
+ piglit_require_gl_version(30);<br>
+ piglit_ortho_projection(pattern_width, pattern_height, GL_TRUE);<br>
+<br>
+ /* Skip the test if num_samples > GL_MAX_SAMPLES or num_samples = 0 */<br>
+ GLint max_samples;<br>
+ glGetIntegerv(GL_MAX_SAMPLES, &max_samples);<br>
+ if (num_samples > max_samples ||<br>
+ num_samples == 0)<br></blockquote><div><br>I think we should drop the "num_samples == 0" check from this and the other tests. When debugging MSAA problems, it's really useful to be able to manually run an MSAA test with num_samples==0. (Of course, all.tests should only run the tests with non-zero sample counts).<br>
</div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ piglit_report_result(PIGLIT_SKIP);<br>
+<br>
+ ms_fbo.setup(FboConfig(num_samples, pattern_width, pattern_height));<br>
+ resolve_fbo.setup(FboConfig(0, pattern_width, pattern_height));<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display()<br>
+{<br>
+ bool pass = true;<br>
+ glClearColor(0.0, 0.0, 0.0, 1.0);<br>
+ glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+ /* Draw test pattern in single sample resolve_fbo */<br>
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolve_fbo.handle);<br>
+ resolve_fbo.set_viewport();<br>
+ draw_pattern();<br>
+<br>
+ /* Blit resolve_fbo to the right half of window system framebuffer. This<br>
+ * is a reference image.<br>
+ */<br>
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo.handle);<br>
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);<br>
+ glBlitFramebuffer(0, 0, pattern_width, pattern_height,<br>
+ pattern_width, 0, 2 * pattern_width, pattern_height,<br>
+ GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
+<br>
+ /* Test drawing bitmap in multisample FBO */<br>
+ pass = test_multisample_bitmap() && pass;<br>
+<br>
+ if (!piglit_automatic)<br>
+ piglit_present_results();<br>
+<br>
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.7.6<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>Assuming those two minor comments are addressed, this patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>