Blitting is expected to happen in to all the draw buffers set using glDrawBuffers().
Signed-off-by: Anuj Phogat <[email protected]> --- tests/all.py | 6 + .../ext_framebuffer_multisample/CMakeLists.gl.txt | 1 + .../blit-multiple-render-targets.cpp | 170 +++++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 tests/spec/ext_framebuffer_multisample/blit-multiple-render-targets.cpp diff --git a/tests/all.py b/tests/all.py index a67e725..94102df 100644 --- a/tests/all.py +++ b/tests/all.py @@ -2474,6 +2474,12 @@ for num_samples in MSAA_SAMPLE_COUNTS: ext_framebuffer_multisample[test_name] = concurrent_test( executable) +for num_samples in TEST_SAMPLE_COUNTS: + test_name = ' '.join(['blit-multiple-render-targets', str(num_samples)]) + executable = 'ext_framebuffer_multisample-{0}'.format( + test_name) + ext_framebuffer_multisample[test_name] = concurrent_test(executable) + # Note: the interpolation tests also check for sensible behaviour with # non-multisampled framebuffers, so go ahead and test them with # num_samples==0 as well. diff --git a/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt b/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt index a50f7e3..d16762e 100644 --- a/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt +++ b/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt @@ -24,6 +24,7 @@ piglit_add_executable (ext_framebuffer_multisample-alpha-to-one-msaa-disabled co piglit_add_executable (ext_framebuffer_multisample-alpha-to-one-single-sample-buffer common.cpp draw-buffers-common.cpp alpha-to-one-single-sample-buffer.cpp) piglit_add_executable (ext_framebuffer_multisample-bitmap common.cpp bitmap.cpp) +piglit_add_executable (ext_framebuffer_multisample-blit-multiple-render-targets blit-multiple-render-targets.cpp) piglit_add_executable (ext_framebuffer_multisample-blit-flipped common.cpp blit-flipped.cpp) piglit_add_executable (ext_framebuffer_multisample-blit-mismatched-samples common.cpp blit-mismatched-samples.cpp) piglit_add_executable (ext_framebuffer_multisample-blit-mismatched-sizes common.cpp blit-mismatched-sizes.cpp) diff --git a/tests/spec/ext_framebuffer_multisample/blit-multiple-render-targets.cpp b/tests/spec/ext_framebuffer_multisample/blit-multiple-render-targets.cpp new file mode 100644 index 0000000..219d3a0 --- /dev/null +++ b/tests/spec/ext_framebuffer_multisample/blit-multiple-render-targets.cpp @@ -0,0 +1,170 @@ +/* + * Copyright © 2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +/** \file blit-multiple-render-targets.cpp + * + * This test verifies that glBlitFramebuffer() works as expected in case of + * multiple render targets. + * + * From Section 4.3.2, page 268 of OpenGL 4.0 spec: + * + * "When the color buffer is transferred, values are taken from the read + * buffer of the read framebuffer and written to each of the draw buffers + * of the draw framebuffer." + **/ + +#include "piglit-fbo.h" +using namespace piglit_util_fbo; + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA; + +PIGLIT_GL_TEST_CONFIG_END + +static Fbo multisample_fbo; + +void +print_usage_and_exit(char *prog_name) +{ + printf("Usage: %s <num_samples>\n", prog_name); + piglit_report_result(PIGLIT_FAIL); +} + + +extern "C" void +piglit_init(int argc, char **argv) +{ + if (argc != 2) + print_usage_and_exit(argv[0]); + + /* 1st arg: num_samples */ + char *endptr = NULL; + int num_samples = strtol(argv[1], &endptr, 0); + if (endptr != argv[1] + strlen(argv[1])) + print_usage_and_exit(argv[0]); + + piglit_require_extension("GL_ARB_framebuffer_object"); + + /* Skip the test if num_samples > GL_MAX_SAMPLES */ + GLint max_samples; + glGetIntegerv(GL_MAX_SAMPLES, &max_samples); + if (num_samples > max_samples) + piglit_report_result(PIGLIT_SKIP); + + FboConfig Config(num_samples, piglit_width, piglit_height); + + /* Setup fbo with renderbuffer and texture attachments */ + Config.num_rb_attachments = 2; + Config.rb_attachment[0] = GL_COLOR_ATTACHMENT0; + Config.rb_attachment[1] = GL_COLOR_ATTACHMENT1; + + Config.num_tex_attachments = 4; + for (int i = 0; i < Config.num_tex_attachments; i++) + Config.tex_attachment[i] = GL_COLOR_ATTACHMENT2 + i; + + multisample_fbo.setup(Config); + + if (!piglit_check_gl_error(GL_NO_ERROR)) { + piglit_report_result(PIGLIT_FAIL); + } +} + +extern "C" enum piglit_result +piglit_display() +{ + bool pass = true; + const GLenum bufs[] = + {GL_COLOR_ATTACHMENT1, + GL_COLOR_ATTACHMENT4, + GL_COLOR_ATTACHMENT5, + + GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT2, + GL_COLOR_ATTACHMENT3}; + + const float expected[][4] = + {{0.0, 1.0, 0.0, 1.0}, /* GL_COLOR_ATTACHMENT1 */ + {0.0, 1.0, 0.0, 1.0}, /* GL_COLOR_ATTACHMENT4 */ + {0.0, 1.0, 0.0, 1.0}, /* GL_COLOR_ATTACHMENT5 */ + + {0.0, 0.0, 1.0, 1.0}, /* GL_COLOR_ATTACHMENT0 */ + {0.0, 0.0, 1.0, 1.0}, /* GL_COLOR_ATTACHMENT2 */ + {0.0, 0.0, 1.0, 1.0}};/* GL_COLOR_ATTACHMENT3 */ + + /* Clear piglit_winsys_fbo to green color */ + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo); + glClearColor(0.0, 1.0, 0.0, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + + /* Clear all color attachements of multisample_fbo to blue color */ + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, multisample_fbo.handle); + glDrawBuffers(6, bufs); + glClearColor(0.0, 0.0, 1.0, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + + /* Set the draw buffers for BlitFramebuffer */ + glDrawBuffers(3, bufs); + + /* Blit from piglit_winsys_fbo to multisample_fbo. Blitting should + * happen in to all the draw buffers set above. + */ + glBindFramebuffer(GL_READ_FRAMEBUFFER, piglit_winsys_fbo); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, multisample_fbo.handle); + glBlitFramebuffer(0, 0, piglit_width, piglit_height, + 0, 0, piglit_width, piglit_height, + GL_COLOR_BUFFER_BIT, + GL_NEAREST); + + for (unsigned i = 0; i < ARRAY_SIZE(bufs); i++) { + bool result =true; + + /* Resolve the contents of multisample_fbo in to + * piglit_winsys_fbo. + */ + glBindFramebuffer(GL_READ_FRAMEBUFFER, multisample_fbo.handle); + glReadBuffer(bufs[i]); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo); + glClearColor(0.0, 0.0, 0.0, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + + glBlitFramebuffer(0, 0, piglit_width, piglit_height, + 0, 0, piglit_width, piglit_height, + GL_COLOR_BUFFER_BIT, + GL_NEAREST); + + /* Verify the contents */ + glBindFramebuffer(GL_READ_FRAMEBUFFER, piglit_winsys_fbo); + result = piglit_probe_rect_rgba(0, 0, piglit_width, + piglit_height, expected[i]); + pass = result && pass; + printf("Attachment = GL_COLOR_ATTACHMENT%d, Result = %s\n", + bufs[i] - GL_COLOR_ATTACHMENT0, + result ? "pass" : "fail"); + piglit_present_results(); + } + + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} -- 1.8.3.1 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
