Mesa (master): r300g: fix blending default state + alpha separate.

Dave Airlie airlied at kemper.freedesktop.org
Sun Oct 11 09:31:03 UTC 2009


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

Author: Dave Airlie <airlied at redhat.com>
Date:   Sun Oct 11 19:12:24 2009 +1000

r300g: fix blending default state + alpha separate.

this makes the default state same as r300

---

 src/gallium/drivers/r300/r300_state.c |   41 +++++++++++++++++++++++++-------
 1 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 88cb9af..3cef285 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -46,23 +46,46 @@ static void* r300_create_blend_state(struct pipe_context* pipe,
 {
     struct r300_blend_state* blend = CALLOC_STRUCT(r300_blend_state);
 
+    {
+	unsigned eqRGB = state->rgb_func;
+	unsigned srcRGB = state->rgb_src_factor;
+	unsigned dstRGB = state->rgb_dst_factor;
+
+	unsigned eqA = state->alpha_func;
+	unsigned srcA = state->alpha_src_factor;
+	unsigned dstA = state->alpha_dst_factor;
+
+	if (srcA != srcRGB ||
+	    dstA != dstRGB ||
+	    eqA != eqRGB) {
+	    blend->alpha_blend_control =
+		r300_translate_blend_function(eqA) |
+		(r300_translate_blend_factor(srcA) <<
+                    R300_SRC_BLEND_SHIFT) |
+                (r300_translate_blend_factor(dstA) <<
+		 R300_DST_BLEND_SHIFT);
+	    blend->blend_control |= R300_ALPHA_BLEND_ENABLE |
+		R300_SEPARATE_ALPHA_ENABLE;
+	} else {
+	    blend->alpha_blend_control = R300_COMB_FCN_ADD_CLAMP |
+		(R300_BLEND_GL_ONE << R300_SRC_BLEND_SHIFT) |
+		(R300_BLEND_GL_ZERO << R300_DST_BLEND_SHIFT);
+	}
+    }
     if (state->blend_enable) {
         /* XXX for now, always do separate alpha...
          * is it faster to do it with one reg? */
-        blend->blend_control = R300_ALPHA_BLEND_ENABLE |
-                R300_SEPARATE_ALPHA_ENABLE |
-                R300_READ_ENABLE |
+        blend->blend_control |= R300_READ_ENABLE |
                 r300_translate_blend_function(state->rgb_func) |
                 (r300_translate_blend_factor(state->rgb_src_factor) <<
                     R300_SRC_BLEND_SHIFT) |
                 (r300_translate_blend_factor(state->rgb_dst_factor) <<
                     R300_DST_BLEND_SHIFT);
-        blend->alpha_blend_control =
-                r300_translate_blend_function(state->alpha_func) |
-                (r300_translate_blend_factor(state->alpha_src_factor) <<
-                    R300_SRC_BLEND_SHIFT) |
-                (r300_translate_blend_factor(state->alpha_dst_factor) <<
-                    R300_DST_BLEND_SHIFT);
+    } else {
+	blend->blend_control = 
+	    R300_COMB_FCN_ADD_CLAMP |
+	    (R300_BLEND_GL_ONE << R300_SRC_BLEND_SHIFT) |
+	    (R300_BLEND_GL_ZERO << R300_DST_BLEND_SHIFT);
     }
 
     /* PIPE_LOGICOP_* don't need to be translated, fortunately. */




More information about the mesa-commit mailing list