Mesa (master): i965/gen6: Fix blending state when no color buffer is bound.

Eric Anholt anholt at kemper.freedesktop.org
Wed May 18 21:23:48 UTC 2011


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

Author: Eric Anholt <eric at anholt.net>
Date:   Wed May 11 14:07:44 2011 -0700

i965/gen6: Fix blending state when no color buffer is bound.

This is part of fixing fbo-alphatest-nocolor -- a regression in
35e8fe5c99b285f348cb8a1bba2931f120f7c0a1 after the initial regression,
that had us using a garbage BLEND_STATE[0] (in particular, the alpha
test enable) if no color buffer was bound.

---

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

diff --git a/src/mesa/drivers/dri/i965/gen6_cc.c b/src/mesa/drivers/dri/i965/gen6_cc.c
index 66357f0..2b16d6c 100644
--- a/src/mesa/drivers/dri/i965/gen6_cc.c
+++ b/src/mesa/drivers/dri/i965/gen6_cc.c
@@ -39,8 +39,18 @@ prepare_blend_state(struct brw_context *brw)
    struct gen6_blend_state *blend;
    int b;
    int nr_draw_buffers = ctx->DrawBuffer->_NumColorDrawBuffers;
-   int size = sizeof(*blend) * nr_draw_buffers;
-
+   int size;
+
+   /* We need at least one BLEND_STATE written, because we might do
+    * thread dispatch even if _NumColorDrawBuffers is 0 (for example
+    * for computed depth or alpha test), which will do an FB write
+    * with render target 0, which will reference BLEND_STATE[0] for
+    * alpha test enable.
+    */
+   if (nr_draw_buffers == 0 && ctx->Color.AlphaEnabled)
+      nr_draw_buffers = 1;
+
+   size = sizeof(*blend) * nr_draw_buffers;
    blend = brw_state_batch(brw, size, 64, &brw->cc.blend_state_offset);
 
    memset(blend, 0, size);




More information about the mesa-commit mailing list