diff options
author | Anuj Phogat <anuj.phogat@gmail.com> | 2012-07-16 11:25:22 -0700 |
---|---|---|
committer | Anuj Phogat <anuj.phogat@gmail.com> | 2012-07-18 10:50:57 -0700 |
commit | 4f024ae1ad72c25ccc3678893ce37e33b6fecabd (patch) | |
tree | f73e8e2bb8f238dfce8377b3f778482c39c0fbaa | |
parent | 79a61076c0d77f8999f32e3ba59fb7bc031cd6d7 (diff) |
msaa: Add depth buffer testing to sample-alpha-to-coverage test case
Tests the depth buffer only for coverage value equal to 0.0 and 1.0 because
depth buffer behaviour is undefined for intermediate coverage values.
This test found an issue with the current implemantation of msaa for i965
on mesa. Following patch on mesa makes this test to pass:
[PATCH] i965/msaa: Set KILL_ENABLE when GL_ALPHA_TO_COVERAGE enabled
commit 6c355cca9149e43850cf27f2d0821fab1e7a69f5
Reviewed-by: Paul Berry <stereotype441@gmail.com>
-rw-r--r-- | tests/all.tests | 9 | ||||
-rw-r--r-- | tests/spec/ext_framebuffer_multisample/sample-alpha-to-coverage.cpp | 47 |
2 files changed, 36 insertions, 20 deletions
diff --git a/tests/all.tests b/tests/all.tests index f1550b426..74ddae5eb 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -1422,10 +1422,11 @@ for num_samples in MSAA_SAMPLE_COUNTS: ext_framebuffer_multisample[test_name] = PlainExecTest(executable) for num_samples in MSAA_SAMPLE_COUNTS: - test_name = ' '.join(['sample-alpha-to-coverage', str(num_samples)]) - executable = 'ext_framebuffer_multisample-{0} -auto'.format( - test_name) - ext_framebuffer_multisample[test_name] = PlainExecTest(executable) + for buffer_type in ('color', 'depth'): + test_name = ' '.join(['sample-alpha-to-coverage', str(num_samples), buffer_type]) + executable = 'ext_framebuffer_multisample-{0} -auto'.format( + test_name) + ext_framebuffer_multisample[test_name] = PlainExecTest(executable) for num_samples in MSAA_SAMPLE_COUNTS: test_name = ' '.join(['sample-alpha-to-one', str(num_samples)]) diff --git a/tests/spec/ext_framebuffer_multisample/sample-alpha-to-coverage.cpp b/tests/spec/ext_framebuffer_multisample/sample-alpha-to-coverage.cpp index b8ccf5de1..0559adc3b 100644 --- a/tests/spec/ext_framebuffer_multisample/sample-alpha-to-coverage.cpp +++ b/tests/spec/ext_framebuffer_multisample/sample-alpha-to-coverage.cpp @@ -44,23 +44,29 @@ */ PIGLIT_GL_TEST_MAIN(512 /*window_width*/, - 768 /*window_height*/, + 256 /*window_height*/, GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA) +static GLenum buffer_to_test; + void print_usage_and_exit(char *prog_name) { - printf("Usage: %s <num_samples>\n", prog_name); + printf("Usage: %s <num_samples> <test_type>\n" + " where <test_type> is one of:\n" + " color\n" + " depth\n", + prog_name); piglit_report_result(PIGLIT_FAIL); } void piglit_init(int argc, char **argv) { + const int num_attachments = 1; int samples; - int num_attachments = 1; - - if (argc < 2) + piglit_require_gl_version(30); + if (argc < 3) print_usage_and_exit(argv[0]); { char *endptr = NULL; @@ -68,8 +74,14 @@ piglit_init(int argc, char **argv) if (endptr != argv[1] + strlen(argv[1])) print_usage_and_exit(argv[0]); } - - piglit_require_gl_version(30); + if (strcmp(argv[2], "color") == 0) { + buffer_to_test = GL_COLOR_BUFFER_BIT; + } else if (strcmp(argv[2], "depth") == 0) { + buffer_to_test = GL_DEPTH_BUFFER_BIT; + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_ALWAYS); + } else + print_usage_and_exit(argv[0]); int pattern_width = piglit_width / 2; int pattern_height = piglit_height / num_attachments; @@ -89,7 +101,7 @@ piglit_init(int argc, char **argv) pattern_width, pattern_height, num_attachments, - GL_COLOR_BUFFER_BIT, + buffer_to_test, GL_RGBA); shader_compile(); } @@ -103,13 +115,13 @@ piglit_display() glClear(GL_COLOR_BUFFER_BIT); allocate_data_arrays(); - /* Reference image drawn when sample_alpha_to_coverage is enabled, - * doesn't represent an expected image. Reference image is drawn only - * to visualize the image difference caused by enabling - * sample_alpha_to_coverage + /* Reference image drawn here doesn't represent an expected image. + * Reference image is drawn only to visualize the image difference + * caused by enabling sample_alpha_to_coverage in test image. */ - draw_reference_image(true /* sample_alpha_to_coverage */, - false /* sample_alpha_to_one */); + if(buffer_to_test == GL_COLOR_BUFFER_BIT) + draw_reference_image(true /* sample_alpha_to_coverage */, + false /* sample_alpha_to_one */); draw_test_image(true /* sample_alpha_to_coverage */, false /* sample_alpha_to_one */); @@ -123,12 +135,15 @@ piglit_display() * of 1 / num_samples makes image compare (test / reference image) * unsuitable for this test. */ - pass = probe_framebuffer_color() && pass; + if(buffer_to_test == GL_COLOR_BUFFER_BIT) + pass = probe_framebuffer_color() && pass; + else if (buffer_to_test == GL_DEPTH_BUFFER_BIT) + pass = probe_framebuffer_depth() && pass; /* Free the memory allocated for data arrays */ free_data_arrays(); - if (!piglit_automatic) + if (!piglit_automatic && buffer_to_test == GL_COLOR_BUFFER_BIT) piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; |