diff options
author | Chris Forbes <chrisf@ijw.co.nz> | 2013-01-05 19:28:27 +1300 |
---|---|---|
committer | Chris Forbes <chrisf@ijw.co.nz> | 2013-03-03 21:02:41 +1300 |
commit | 15aa37e12946c13aede64bc995527fa85b8c7087 (patch) | |
tree | 7093bac586e78f18c9d55cb3e3fa7a014c09e45c | |
parent | a3b8edf7a19c5b2ca54f634d36cf74ebca411558 (diff) |
arb_texture_multisample: new tests for sample mask
Adds tests for sample mask:
- Initial state
- Fetching of each sample mask word
- Execution test via rendering with various masks to a multisample FBO,
then downsampling via glBlitFramebuffer and checking the result.
V2: - Don't specify window size when we don't care.
V4: - Add missing copyright notice.
Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
-rw-r--r-- | tests/all.tests | 4 | ||||
-rw-r--r-- | tests/spec/arb_texture_multisample/CMakeLists.gl.txt | 3 | ||||
-rw-r--r-- | tests/spec/arb_texture_multisample/sample-mask-execution.c | 128 | ||||
-rw-r--r-- | tests/spec/arb_texture_multisample/sample-mask-value.c | 69 | ||||
-rw-r--r-- | tests/spec/arb_texture_multisample/sample-mask.c | 65 |
5 files changed, 269 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests index 30e31612..f6488c04 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -872,6 +872,10 @@ for sample_count in MSAA_SAMPLE_COUNTS: spec['ARB_texture_multisample/fb-completeness/%d' % (sample_count,)] = \ concurrent_test('arb_texture_multisample-fb-completeness %d' % (sample_count,)) add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-texstate') +add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-sample-mask') +add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-sample-mask-value') +add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-sample-mask-execution') +add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-sample-mask-execution -tex') # Group AMD_shader_stencil_export spec['AMD_shader_stencil_export'] = Group() diff --git a/tests/spec/arb_texture_multisample/CMakeLists.gl.txt b/tests/spec/arb_texture_multisample/CMakeLists.gl.txt index d4cd51f0..f13b0625 100644 --- a/tests/spec/arb_texture_multisample/CMakeLists.gl.txt +++ b/tests/spec/arb_texture_multisample/CMakeLists.gl.txt @@ -13,5 +13,8 @@ link_libraries ( piglit_add_executable (arb_texture_multisample-minmax minmax.c) piglit_add_executable (arb_texture_multisample-fb-completeness fb-completeness.c) piglit_add_executable (arb_texture_multisample-texstate texstate.c) +piglit_add_executable (arb_texture_multisample-sample-mask sample-mask.c) +piglit_add_executable (arb_texture_multisample-sample-mask-value sample-mask-value.c) +piglit_add_executable (arb_texture_multisample-sample-mask-execution sample-mask-execution.c) # vim: ft=cmake: diff --git a/tests/spec/arb_texture_multisample/sample-mask-execution.c b/tests/spec/arb_texture_multisample/sample-mask-execution.c new file mode 100644 index 00000000..bc10fb05 --- /dev/null +++ b/tests/spec/arb_texture_multisample/sample-mask-execution.c @@ -0,0 +1,128 @@ +/* + * Copyright © 2013 Chris Forbes + * + * 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. + */ +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 30; + + config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE; + +PIGLIT_GL_TEST_CONFIG_END + +/* test execution of sample masking. + * - set mask to half the samples + * - render a red thing + * - set mask to the other half of the samples + * - render a blue thing + * + * - blit from the MSAA buffer to the winsys buffer + * - ensure that the pixels are purple + */ + +GLuint fbo, tex; + +enum piglit_result +piglit_display(void) +{ + float half_purple[] = { 0.5f, 0.5f, 0.0f, 1.0f }; + bool pass = true; + + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + glClearColor(0.2, 0.2, 0.2, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + + glEnable(GL_SAMPLE_MASK); + + glSampleMaski(0, 0x3); /* first and second samples */ + glColor4f(1.0, 0.0, 0.0, 1.0); + piglit_draw_rect(-1,-1,2,2); + + glSampleMaski(0, 0xc); /* third and fourth samples */ + glColor4f(0.0, 1.0, 0.0, 1.0); + piglit_draw_rect(-1,-1,2,2); + + glDisable(GL_SAMPLE_MASK); + + if (!piglit_check_gl_error(GL_NO_ERROR)) + piglit_report_result(PIGLIT_FAIL); + + glFinish(); + + glBindFramebuffer(GL_FRAMEBUFFER, piglit_winsys_fbo); + glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); + glBlitFramebuffer(0, 0, 64, 64, 0, 0, 64, 64, + GL_COLOR_BUFFER_BIT, GL_NEAREST); + + if (!piglit_check_gl_error(GL_NO_ERROR)) + piglit_report_result(PIGLIT_FAIL); + + glBindFramebuffer(GL_READ_FRAMEBUFFER, piglit_winsys_fbo); + + /* the resolve done by the blit should + * blend the red and blue samples together */ + pass = piglit_probe_pixel_rgba(32, 32, half_purple) && pass; + + piglit_present_results(); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + bool use_multisample_texture = false; + + piglit_require_extension("GL_ARB_texture_multisample"); + + while (++argv,--argc) { + if (!strcmp(*argv, "-tex")) + use_multisample_texture = true; + } + + glGenFramebuffers(1, &fbo); + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + + if (use_multisample_texture) { + /* use a multisample texture */ + printf("Using GL_TEXTURE_2D_MULTISAMPLE\n"); + + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex); + glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, + 4, GL_RGBA, 64, 64, GL_TRUE); + + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_TEXTURE_2D_MULTISAMPLE, tex, 0); + } + else { + /* use a classic renderbuffer */ + printf("Using classic MSAA renderbuffer\n"); + + glGenRenderbuffers(1, &tex); + glBindRenderbuffer(GL_RENDERBUFFER, tex); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA, 64, 64); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_RENDERBUFFER, tex); + } +} diff --git a/tests/spec/arb_texture_multisample/sample-mask-value.c b/tests/spec/arb_texture_multisample/sample-mask-value.c new file mode 100644 index 00000000..35f30866 --- /dev/null +++ b/tests/spec/arb_texture_multisample/sample-mask-value.c @@ -0,0 +1,69 @@ +/* + * Copyright © 2013 Chris Forbes + * + * 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. + */ +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 30; + config.window_visual = PIGLIT_GL_VISUAL_RGB; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + GLint maxMaskWords = 0, result = 0, mask = 0; + int i; + + piglit_require_extension("GL_ARB_texture_multisample"); + + glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &maxMaskWords); + + for (i=0; i < maxMaskWords; i++) { + glGetIntegeri_v(GL_SAMPLE_MASK_VALUE, i, &mask); + + if (!piglit_check_gl_error(GL_NO_ERROR)) { + printf("Could not get word %d of sample mask value\n", i); + piglit_report_result(PIGLIT_FAIL); + } + + if ((GLuint)mask != ~0u) { + printf("Initial mask for word %d is bogus; expected all bits set, got %08x\n", + i, mask); + } + } + + printf("Checking that correct errors are generated for out of bounds\n"); + glGetIntegeri_v(GL_SAMPLE_MASK_VALUE, maxMaskWords, &result); + + if (!piglit_check_gl_error(GL_INVALID_VALUE)) + piglit_report_result(PIGLIT_FAIL); + + piglit_report_result(PIGLIT_PASS); +} diff --git a/tests/spec/arb_texture_multisample/sample-mask.c b/tests/spec/arb_texture_multisample/sample-mask.c new file mode 100644 index 00000000..0ea4c632 --- /dev/null +++ b/tests/spec/arb_texture_multisample/sample-mask.c @@ -0,0 +1,65 @@ +/* + * Copyright © 2013 Chris Forbes + * + * 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. + */ +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 30; + config.window_visual = PIGLIT_GL_VISUAL_RGB; + +PIGLIT_GL_TEST_CONFIG_END + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + GLint maskOn = 0; + piglit_require_extension("GL_ARB_texture_multisample"); + + printf("Checking GL_SAMPLE_MASK exists\n"); + if (glIsEnabled(GL_SAMPLE_MASK)) { + printf("GL_SAMPLE_MASK enabled by default, should be disabled.\n"); + piglit_report_result(PIGLIT_FAIL); + } + + if (!piglit_check_gl_error(GL_NO_ERROR)) + piglit_report_result(PIGLIT_FAIL); + + printf("Checking GL_SAMPLE_MASK works with GetIntegerv\n"); + glGetIntegerv(GL_SAMPLE_MASK, &maskOn); + + if (!piglit_check_gl_error(GL_NO_ERROR)) + piglit_report_result(PIGLIT_FAIL); + + if (maskOn) { + printf("GetIntegerv(GL_SAMPLE_MASK) true by default, should be false\n"); + piglit_report_result(PIGLIT_FAIL); + } + + piglit_report_result(PIGLIT_PASS); +} |