Mesa (master): i965/msaa: Disable alpha-to-{coverage, one} when drawbuffer zero is in integer format

Anuj Phogat aphogat at kemper.freedesktop.org
Wed Jul 18 19:27:11 UTC 2012


Module: Mesa
Branch: master
Commit: cd5cd85a43dc43f62274be72d3252503dfc88bab
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd5cd85a43dc43f62274be72d3252503dfc88bab

Author: Anuj Phogat <anuj.phogat at gmail.com>
Date:   Wed Jul 18 11:41:15 2012 -0700

i965/msaa: Disable alpha-to-{coverage, one} when drawbuffer zero is in integer format

OpenGL specification 3.3 (page 196), section 4.1.3 says:
If drawbuffer zero is not NONE and the buffer it references has an
integer format, the SAMPLE_ALPHA_TO_COVERAGE and SAMPLE_ALPHA_TO_ONE
operations are skipped."
This should work properly even if there are other draw buffers that
are not in integer format.

This patch makes following piglit tests pass on mesa:
int-draw-buffers-alpha-to-coverage
int-draw-buffers-alpha-to-one

Reviewed-by: Chad Versace <chad.versace at linux.intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>

---

 src/mesa/drivers/dri/i965/gen6_cc.c |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen6_cc.c b/src/mesa/drivers/dri/i965/gen6_cc.c
index e0523ef..6aeaaa2 100644
--- a/src/mesa/drivers/dri/i965/gen6_cc.c
+++ b/src/mesa/drivers/dri/i965/gen6_cc.c
@@ -35,6 +35,7 @@
 static void
 gen6_upload_blend_state(struct brw_context *brw)
 {
+   bool is_buffer_zero_integer_format = false;
    struct gl_context *ctx = &brw->intel.ctx;
    struct gen6_blend_state *blend;
    int b;
@@ -68,7 +69,6 @@ gen6_upload_blend_state(struct brw_context *brw)
 	 rb_type = GL_UNSIGNED_NORMALIZED;
 
       /* Used for implementing the following bit of GL_EXT_texture_integer:
-       *
        *     "Per-fragment operations that require floating-point color
        *      components, including multisample alpha operations, alpha test,
        *      blending, and dithering, have no effect when the corresponding
@@ -76,6 +76,9 @@ gen6_upload_blend_state(struct brw_context *brw)
       */
       integer = (rb_type == GL_INT || rb_type == GL_UNSIGNED_INT);
 
+      if(b == 0 && integer)
+         is_buffer_zero_integer_format = true;
+
       /* _NEW_COLOR */
       if (ctx->Color.ColorLogicOpEnabled) {
 	 /* Floating point RTs should have no effect from LogicOp,
@@ -162,12 +165,23 @@ gen6_upload_blend_state(struct brw_context *brw)
       blend[b].blend1.write_disable_b = !ctx->Color.ColorMask[b][2];
       blend[b].blend1.write_disable_a = !ctx->Color.ColorMask[b][3];
 
-      /* _NEW_MULTISAMPLE */
-      blend[b].blend1.alpha_to_coverage =
-         ctx->Multisample._Enabled && ctx->Multisample.SampleAlphaToCoverage;
-      blend[b].blend1.alpha_to_one =
-         ctx->Multisample._Enabled && ctx->Multisample.SampleAlphaToOne;
-      blend[b].blend1.alpha_to_coverage_dither = (brw->intel.gen >= 7);
+      /* OpenGL specification 3.3 (page 196), section 4.1.3 says:
+       * "If drawbuffer zero is not NONE and the buffer it references has an
+       * integer format, the SAMPLE_ALPHA_TO_COVERAGE and SAMPLE_ALPHA_TO_ONE
+       * operations are skipped."
+       */
+      if(!is_buffer_zero_integer_format) {
+         /* _NEW_MULTISAMPLE */
+         blend[b].blend1.alpha_to_coverage =
+            ctx->Multisample._Enabled && ctx->Multisample.SampleAlphaToCoverage;
+         blend[b].blend1.alpha_to_one =
+            ctx->Multisample._Enabled && ctx->Multisample.SampleAlphaToOne;
+         blend[b].blend1.alpha_to_coverage_dither = (brw->intel.gen >= 7);
+      }
+      else {
+         blend[b].blend1.alpha_to_coverage = false;
+         blend[b].blend1.alpha_to_one = false;
+      }
    }
 
    brw->state.dirty.cache |= CACHE_NEW_BLEND_STATE;




More information about the mesa-commit mailing list