On 22 June 2012 20:19, Paul Berry <span dir="ltr"><<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@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">
<div class="im">On 22 June 2012 14:40, Paul Berry <span dir="ltr"><<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a>></span> wrote:<br></div><div class="gmail_quote"><div class="im">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On 20 June 2012 19:01, Anuj Phogat <span dir="ltr"><<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>></span> wrote:<br></div><div class="gmail_quote"><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div>This test varifies that with GL_SAMPLE_ALPHA_TO_COVERAGE enabled, the coverage<br>
value is set by fragment alpha value. Coverage value decides the number of<br>
samples in multisample buffer covered by an incoming fragment, which receive<br>
the fragment data.<br>
<br>
</div>It also includes testing of GL_SAMPLE_ALPHA_TO_COVERAGE with GL_SAMPLE_ALPHA_TO_ONE<br>
enabled.<br>
<br>
V2: Add testing for coverage values which may result in dithering for all sample<br>
    counts. Dropping the testing for multisample depth buffer.<br></blockquote></div><div><br>This patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a>><br>

</div></div></blockquote></div><div><br>BTW, I just noticed that we don't yet have any tests for GL_SAMPLE_COVERAGE_INVERT.  Would it be possible to add that to this test (preferably as a command line parameter)?<br>
</div></div></blockquote><div><br>I'm sorry, please ignore this.  I got confused between "sample coverage" and "sample alpha to coverage".<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="gmail_quote"><div> </div><div><div class="h5">
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div> </div><div><div>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><br>
Signed-off-by: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>><br>
---<br>
</div>This test fails on AMD's catalyst drivers with GL_SAMPLE_ALPHA_TO_ONE enabled. But<br>
as I remember it passed on NVIDIA last time. I will confirm it before pushing the<br>
test case.<br>
<div><br>
 tests/all.tests                                    |    6 +<br>
 .../ext_framebuffer_multisample/CMakeLists.gl.txt  |    1 +<br>
</div> .../sample-alpha-to-coverage.cpp                   |  412 ++++++++++++++++++++<br>
 3 files changed, 419 insertions(+), 0 deletions(-)<br>
<div> create mode 100644 tests/spec/ext_framebuffer_multisample/sample-alpha-to-coverage.cpp<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
</div>index 5fdc9e7..6745037 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -1391,6 +1391,12 @@ for num_samples in (2, 4, 8, 16, 32):<br>
<div>                 test_name)<br>
         ext_framebuffer_multisample[test_name] = PlainExecTest(executable)<br>
<br>
+for num_samples in (2, 4, 8, 16, 32):<br>
</div>+        test_name = ' '.join(['sample-alpha-to-coverage', str(num_samples)])<br>
<div>+        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>
</div>index c746328..c6566be 100644<br>
--- a/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt<br>
+++ b/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt<br>
@@ -29,6 +29,7 @@ piglit_add_executable (ext_framebuffer_multisample-renderbuffer-samples renderbu<br>
<div> piglit_add_executable (ext_framebuffer_multisample-renderbufferstorage-samples renderbufferstorage-samples.c)<br>
 piglit_add_executable (ext_framebuffer_multisample-samples samples.c)<br>
 piglit_add_executable (ext_framebuffer_multisample-sample-coverage common.cpp sample-coverage.cpp)<br>
+piglit_add_executable (ext_framebuffer_multisample-sample-alpha-to-coverage common.cpp sample-alpha-to-coverage.cpp)<br>
 piglit_add_executable (ext_framebuffer_multisample-turn-on-off common.cpp turn-on-off.cpp)<br>
 piglit_add_executable (ext_framebuffer_multisample-unaligned-blit common.cpp unaligned-blit.cpp)<br>
 piglit_add_executable (ext_framebuffer_multisample-upsample common.cpp upsample.cpp)<br>
diff --git a/tests/spec/ext_framebuffer_multisample/sample-alpha-to-coverage.cpp b/tests/spec/ext_framebuffer_multisample/sample-alpha-to-coverage.cpp<br>
new file mode 100644<br>
</div>index 0000000..540396b<br>
--- /dev/null<br>
+++ b/tests/spec/ext_framebuffer_multisample/sample-alpha-to-coverage.cpp<br>
@@ -0,0 +1,412 @@<br>
<div><div>+/*<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 sample-alpha-to-coverage.cpp<br>
+ *<br>
</div></div>+ * Verify GL_SAMPLE_ALPHA_TO_COVERAGE with multisample FBO.<br>
+ *<br>
+ * This test operates by drawing a test pattern to multisample_fbo with<br>
<div>+ * GL_SAMPLE_ALPHA_TO_COVERAGE disabled.<br>
+ *<br>
</div>+ * Blit the multisample_fbo to top half of window system framebuffer. This<br>
+ * is used as reference image to visually compare the difference caused by<br>
+ * sample alpha to coverage value.<br>
<div>+ *<br>
+ * Compute the expected color values based on the coverage value used to<br>
+ * draw the test pattern.<br>
+ *<br>
</div>+ * Clear the multisample framebuffer to a unique color. Draw the same test<br>
+ * pattern in multisample buffer with GL_SAMPLE_ALPHA_TO_COVERAGE enabled.<br>
+ * Resolve the multisample FBO by  blitting it to a single sample FBO. Blit<br>
+ * the resolve_fbo to bottom half of window system framebuffer. This is our<br>
+ * test image.<br>
+ *<br>
+ * Probe the rectangles in bottom half of window system framebuffer and<br>
+ * compare with expected color values. OpenGL 3.0 specification intends<br>
+ * to allow (but not require) the implementation to produce a dithering<br>
+ * effect when the coverage value is not a strict multiple of 1/num_samples.<br>
+ * We will skip computing expected values and probing for such rectangles.<br>
+ * They are drawn just to look for dithering by human inspection.<br>
+ *<br>
+ * Repeat the above testing with GL_SAMPLE_ALPHA_TO_ONE enabled / disabled.<br>
+ * when both GL_SAMPLE_ALPHA_TO_ONE and GL_SAMPLE_ALPHA_TO_COVERAGE are<br>
+ * enabled, GL_SAMPLE_ALPHA_TO_COVERAGE takes effect first. i.e. the<br>
+ * coverage value is computed from the alpha value before the alpha value<br>
+ * is changed to 1.<br>
+ *<br>
+ * Note: glSampleCoverage() takes effect in the graphics pipeline before<br>
+ * the point where the output of the fragment shader is split into the<br>
+ * various buffers. So it's very likely that if glSampleCoverage() works<br>
+ * properly for color buffers, it will work properly for depth and stencil<br>
+ * buffers too.<br>
<div>+ *<br>
+ * Author: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>><br>
+ */<br>
+<br>
+int piglit_width = 512; int piglit_height = 256;<br>
</div>+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA ;<br>
+const int pattern_width = 512; const int pattern_height = 128;<br>
<div>+<br>
+static Fbo ms_fbo, resolve_fbo;<br>
</div>+static GLbitfield buffer_to_test;<br>
+<br>
+static float *coverage = NULL;<br>
+static float *color = NULL;<br>
+static float *expected = NULL;<br>
+<br>
+static int num_samples;<br>
+static int num_rects;<br>
+static int prog;<br>
+static int color_loc;<br>
+static int depth_loc;<br>
+<br>
+static const float bg_color[4] = { 0.4, 0.6, 0.0, 0.8 };<br>
<div><div>+<br>
+static const char *vert =<br>
+       "#version 130\n"<br>
+       "in vec2 pos;\n"<br>
+       "uniform float depth;\n"<br>
+       "void main()\n"<br>
+       "{\n"<br>
+       "  vec4 eye_pos = gl_ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);\n"<br>
+       "  gl_Position = vec4(eye_pos.xy, depth, 1.0);\n"<br>
+       "}\n";<br>
+<br>
+static const char *frag =<br>
+       "#version 130\n"<br>
+       "uniform vec4 color;\n"<br>
+       "void main()\n"<br>
+       "{\n"<br>
+       "  gl_FragColor = color;\n"<br>
+       "}\n";<br>
+<br>
+void<br>
+shader_compile()<br>
+{<br>
+       /* Compile program */<br>
+       GLint vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vert);<br>
+       GLint fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, frag);<br>
+       prog = piglit_link_simple_program(vs, fs);<br>
+<br>
+       if (!piglit_link_check_status(prog)) {<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+       }<br>
+<br>
+       glBindAttribLocation(prog, 0, "pos");<br>
+       glEnableVertexAttribArray(0);<br>
+<br>
+       /* Set up uniforms */<br>
+       glUseProgram(prog);<br>
+       color_loc = glGetUniformLocation(prog, "color");<br>
+       depth_loc = glGetUniformLocation(prog, "depth");<br>
+}<br>
+<br>
+void<br>
+draw_pattern(bool sample_alpha_to_coverage, bool sample_alpha_to_one)<br>
+{<br>
</div></div>+       glUseProgram(prog);<br>
<div>+       glClearColor(bg_color[0], bg_color[1],<br>
+                    bg_color[2], bg_color[3]);<br>
+       glClear(buffer_to_test);<br>
+<br>
</div>+       if (sample_alpha_to_coverage)<br>
+               glEnable (GL_SAMPLE_ALPHA_TO_COVERAGE);<br>
+<br>
+       if (sample_alpha_to_one)<br>
+               glEnable (GL_SAMPLE_ALPHA_TO_ONE);<br>
+<br>
+       unsigned int indices[6] = {0, 1, 2, 0, 2, 3};<br>
+<br>
+       for (int i = 0; i < num_rects; ++i) {<br>
+<br>
+               float vertex_data[4][2] = {<br>
+               { 0.0f + i * (pattern_width / num_rects),   0.0f           },<br>
+               { 0.0f + i * (pattern_width / num_rects),   pattern_height },<br>
+               { (i + 1.0f) * (pattern_width / num_rects), pattern_height },<br>
+               { (i + 1.0f) * (pattern_width / num_rects), 0.0f           } };<br>
<div>+<br>
+               glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE,<br>
</div>+                                     sizeof(vertex_data[0]),<br>
<div>+                                     (void *) vertex_data);<br>
+<br>
</div>+               glUniform4fv(color_loc, 1, (color + i * 4));<br>
+               glUniform1f(depth_loc, 0.0f);<br>
+               glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT,<br>
+                              (void *) indices);<br>
<div>+       }<br>
+       if (sample_alpha_to_coverage)<br>
+               glDisable (GL_SAMPLE_ALPHA_TO_COVERAGE);<br>
+<br>
+       if (sample_alpha_to_one)<br>
+               glDisable (GL_SAMPLE_ALPHA_TO_ONE);<br>
+}<br>
+<br>
+void<br>
+print_usage_and_exit(char *prog_name)<br>
+{<br>
</div>+       printf("Usage: %s <num_samples>\n", prog_name);<br>
<div>+       piglit_report_result(PIGLIT_FAIL);<br>
+}<br>
+<br>
+void<br>
+compute_expected(bool sample_alpha_to_one)<br>
+{<br>
+       int i, j;<br>
+<br>
</div>+       /* Sample alpha to coverage doesn't affect single sample FBO */<br>
+       if(num_samples == 0) {<br>
+               for(i = 0; i < 4; i++)<br>
+                       expected[i] = color[i];<br>
+               return;<br>
+       }<br>
<div>+<br>
+       /* Fragment's alpha value is directly used as coverage value */<br>
</div>+       for (i = 0; i < num_rects; i++)<br>
+               coverage[i] = color[i * 4 + 3];<br>
<div>+<br>
+       /* Coverage value decides the number of samples in multisample buffer<br>
+        * covered by an incoming fragment, which will then receive the fragment<br>
+        * data. When the multisample buffer is resolved it will be blended<br>
+        * with the background color which will be written to the remaining<br>
+        * samples.<br>
+        * Page 254 (page 270 of the PDF) of the OpenGL 3.0 spec says:<br>
+        * "The method of combination is not specified, though a simple average<br>
+        * computed independently for each color component is recommended."<br>
+        */<br>
+       if(buffer_to_test == GL_COLOR_BUFFER_BIT) {<br>
</div>+               for (i = 0; i < num_rects; i++) {<br>
+<br>
+                       float samples_used = coverage[i] * num_samples;<br>
+                       /* Exepected color values are computed only for integer<br>
+                        * number of samples_used<br>
+                        */<br>
+                       if(samples_used == (int)samples_used) {<br>
+<br>
+                               for(j =0; j < 4; j++)<br>
+                                       expected[i * 4 + j] =<br>
+                                       color[i * 4 + j] * coverage[i] +<br>
<div>+                                       bg_color[j] * (1 - coverage[i]);<br>
+<br>
+                               if (sample_alpha_to_one)<br>
</div>+                                       expected[i * 4 + 3] =<br>
+                                       1.0 * coverage[i] +<br>
<div>+                                       bg_color[3] * (1 - coverage[i]);<br>
+                       }<br>
+               }<br>
+       }<br>
</div>+}<br>
+<br>
+bool<br>
+probe_framebuffer_color(bool sample_alpha_to_one)<br>
<div>+{<br>
+       bool result = true;<br>
</div>+       glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);<br>
+<br>
+       for (int i = 0; i < num_rects; i++) {<br>
+               float samples_used = coverage[i] * num_samples;<br>
+<br>
+               /* Only probe rectangles with coverage value which is a strict<br>
+                *  multiple of 1 / num_samples.<br>
+                */<br>
+               if(samples_used == (int)samples_used) {<br>
+                       result = piglit_probe_rect_rgba(<br>
+                                i * (pattern_width / num_rects),<br>
+                                0,<br>
+                                pattern_width / num_rects,<br>
+                                pattern_height,<br>
+                                expected + i * 4)<br>
<div>+                                && result;<br>
+               }<br>
+       }<br>
</div><div>+       return result;<br>
+}<br>
+<br>
+bool<br>
+test_sample_alpha_to_coverage(bool sample_alpha_to_one)<br>
+{<br>
+       bool result = true;<br>
+       compute_expected(sample_alpha_to_one);<br>
+<br>
</div><div>+       /* Draw test pattern in multisample ms_fbo with<br>
</div>+        * GL_SAMPLE_ALPHA_TO_COVERAGE enabled<br>
<div>+        */<br>
+       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ms_fbo.handle);<br>
</div>+       draw_pattern(true /* sample_alpha_to_coverage */ , sample_alpha_to_one);<br>
<div>+<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>
+                         buffer_to_test, GL_NEAREST);<br>
+<br>
</div>+       /* Blit resolve_fbo to the bottom half of window system framebuffer.<br>
<div>+        * 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>
+                         buffer_to_test, GL_NEAREST);<br>
+<br>
</div>+       /* Probe the bottom half of default framebuffer and compare to the<br>
<div>+        * expected values */<br>
+       if (buffer_to_test == GL_COLOR_BUFFER_BIT)<br>
</div>+               result = probe_framebuffer_color(sample_alpha_to_one) && result;<br>
<div>+<br>
+       result = piglit_check_gl_error(GL_NO_ERROR) && result;<br>
+       return result;<br>
+}<br>
+<br>
</div>+void<br>
+allocate_data_arrays(void)<br>
+{<br>
+       /* Draw 2N + 1 rectangles for N samples, each with a unique color<br>
+        * and coverage value<br>
+        */<br>
+       num_rects = 2 * num_samples + 1;<br>
+<br>
+       /* Allocate data arrays based on number of samples used */<br>
+       color = (float *) malloc(num_rects * 4 * sizeof(float));<br>
+       coverage = (float *) malloc(num_rects * sizeof(float));<br>
+       expected = (float *) malloc(num_rects * 4 * sizeof(float));<br>
+<br>
+       for(int i = 0; i < num_rects; i++) {<br>
+               /* Randomly select color for each rectangle */<br>
+               color[i * 4 + 0] = (rand() % 1000) * .001;<br>
+               color[i * 4 + 1] = (rand() % 1000) * .001;<br>
+               color[i * 4 + 2] = (rand() % 1000) * .001;<br>
+               /* Alpha value will be used as coverage */<br>
+               color[i * 4 + 3] = i * (1.0 / (2 * num_samples));<br>
+       }<br>
+}<br>
+<br>
+void<br>
+free_data_arrays(void)<br>
+{<br>
+       if(color != NULL) {<br>
+               free(color);<br>
+               color = NULL;<br>
+       }<br>
+       if(coverage != NULL) {<br>
+               free(coverage);<br>
+               coverage = NULL;<br>
+       }<br>
+       if(expected != NULL) {<br>
+               free(expected);<br>
+               expected = NULL;<br>
<div>+       }<br>
+}<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
</div>+       int samples;<br>
+       if (argc < 2)<br>
<div>+               print_usage_and_exit(argv[0]);<br>
+       {<br>
+               char *endptr = NULL;<br>
</div>+               samples = strtol(argv[1], &endptr, 0);<br>
<div>+               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>
</div>+       /* Skip the test if samples > GL_MAX_SAMPLES */<br>
<div>+       GLint max_samples;<br>
+       glGetIntegerv(GL_MAX_SAMPLES, &max_samples);<br>
+<br>
</div>+       if (samples > max_samples)<br>
+               piglit_report_result(PIGLIT_SKIP);<br>
+<br>
+       /* Setup frame buffer objects with required configuration */<br>
+       ms_fbo.setup(FboConfig(samples, pattern_width, pattern_height));<br>
+       resolve_fbo.setup(FboConfig(0, pattern_width, pattern_height));<br>
+<br>
+        if (!piglit_check_gl_error(GL_NO_ERROR)) {<br>
+               printf("Error setting up frame buffer objects\n");<br>
+               piglit_report_result(PIGLIT_FAIL);<br>
+        }<br>
+<br>
+       /* Query the number of samples used in ms_fbo. OpenGL implementation<br>
+        * may create FBO with more samples per pixel than what is requested.<br>
+        */<br>
+       glBindRenderbuffer(GL_RENDERBUFFER, ms_fbo.color_rb);<br>
+       glGetRenderbufferParameteriv(GL_RENDERBUFFER,<br>
+                                    GL_RENDERBUFFER_SAMPLES,<br>
+                                    &num_samples);<br>
<div>+<br>
+       buffer_to_test = GL_COLOR_BUFFER_BIT;<br>
</div>+       shader_compile();<br>
<div>+}<br>
+<br>
+enum piglit_result<br>
+piglit_display()<br>
+{<br>
+       bool pass = true;<br>
</div>+       allocate_data_arrays();<br>
+<br>
+       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);<br>
<div>+       glClearColor(0.0, 0.0, 0.0, 1.0);<br>
</div>+       glClear(buffer_to_test);<br>
<div>+<br>
+       /* Draw test pattern in multisample ms_fbo with<br>
</div>+        * GL_SAMPLE_ALPHA_TO_COVERAGE disabled.<br>
+        */<br>
<div>+       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ms_fbo.handle);<br>
+       ms_fbo.set_viewport();<br>
</div>+       draw_pattern(false /* sample_alpha_to_coverage */,<br>
+                    false /* sample_alpha_to_one */ );<br>
+<br>
+       /* Blit ms_fbo to the top half of window system framebuffer. This<br>
+        * is our reference image to visually compare the effect of MSAA<br>
+        * with sample alpha to coverage.<br>
<div>+        */<br>
+       glBindFramebuffer(GL_READ_FRAMEBUFFER, ms_fbo.handle);<br>
+       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);<br>
+       glBlitFramebuffer(0, 0,<br>
</div>+                         pattern_width, pattern_height,<br>
+                         0, pattern_height,<br>
+                         pattern_width, 2 * pattern_height,<br>
+                         buffer_to_test, GL_NEAREST);<br>
+<br>
+       /* Test with sample_alpha_to_one = false */<br>
+       pass = test_sample_alpha_to_coverage(false) && pass;<br>
+<br>
+       /* Test sample alpha to coverage with sample_alpha_to_one = true */<br>
+       pass = test_sample_alpha_to_coverage(true) && pass;<br>
+<br>
+       /* Free the memory allocated for data arrays */<br>
+       free_data_arrays();<br>
<div><div>+<br>
+       if (!piglit_automatic &&<br>
+           buffer_to_test != GL_DEPTH_BUFFER_BIT)<br>
+               piglit_present_results();<br>
+<br>
+       return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
--<br>
1.7.7.6<br>
<br>
</div></div></blockquote></div></div></div><br>
</blockquote></div></div></div><br>
</blockquote></div><br>