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.
Signed-off-by: Chris Forbes <[email protected]> --- tests/all.tests | 4 + .../spec/arb_texture_multisample/CMakeLists.gl.txt | 3 + .../sample-mask-execution.c | 108 +++++++++++++++++++++ .../arb_texture_multisample/sample-mask-value.c | 50 ++++++++++ tests/spec/arb_texture_multisample/sample-mask.c | 46 +++++++++ 5 files changed, 211 insertions(+) create mode 100644 tests/spec/arb_texture_multisample/sample-mask-execution.c create mode 100644 tests/spec/arb_texture_multisample/sample-mask-value.c create mode 100644 tests/spec/arb_texture_multisample/sample-mask.c diff --git a/tests/all.tests b/tests/all.tests index 9963e46..6c455c4 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -846,6 +846,10 @@ spec['ARB_texture_multisample'] = arb_texture_multisample add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-minmax') add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-fb-completeness') 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 d4cd51f..f13b062 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 0000000..c8bd401 --- /dev/null +++ b/tests/spec/arb_texture_multisample/sample-mask-execution.c @@ -0,0 +1,108 @@ +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 30; + + config.window_width = 64; + config.window_height = 64; + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_ALPHA; + +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 0000000..586a132 --- /dev/null +++ b/tests/spec/arb_texture_multisample/sample-mask-value.c @@ -0,0 +1,50 @@ +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 30; + + config.window_width = 10; + config.window_height = 10; + 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 0000000..cffd080 --- /dev/null +++ b/tests/spec/arb_texture_multisample/sample-mask.c @@ -0,0 +1,46 @@ +#include "piglit-util-gl-common.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 30; + + config.window_width = 10; + config.window_height = 10; + 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); +} -- 1.8.1 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
