r600g: Fix non-independent blend state.
authorJulian Adams <joolsa@gmail.com>
Wed, 6 Apr 2011 19:04:08 +0000 (21:04 +0200)
committerHenri Verbeet <hverbeet@gmail.com>
Wed, 6 Apr 2011 19:16:40 +0000 (21:16 +0200)
This fixes piglit fbo/fbo-drawbuffers-blend-add.

Signed-off-by: Henri Verbeet <hverbeet@gmail.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_state.c

index 8f93eb86fc6b18dd3a080843c55f9a4d2407edb9..97f9a07b013633851f5c7f05e4a2f140df3c6d3e 100644 (file)
@@ -107,15 +107,18 @@ static void *evergreen_create_blend_state(struct pipe_context *ctx,
        r600_pipe_state_add_reg(rstate, R_028C3C_PA_SC_AA_MASK, 0xFFFFFFFF, 0xFFFFFFFF, NULL);
 
        for (int i = 0; i < 8; i++) {
-               unsigned eqRGB = state->rt[i].rgb_func;
-               unsigned srcRGB = state->rt[i].rgb_src_factor;
-               unsigned dstRGB = state->rt[i].rgb_dst_factor;
-               unsigned eqA = state->rt[i].alpha_func;
-               unsigned srcA = state->rt[i].alpha_src_factor;
-               unsigned dstA = state->rt[i].alpha_dst_factor;
+               /* state->rt entries > 0 only written if independent blending */
+               const int j = state->independent_blend_enable ? i : 0;
+
+               unsigned eqRGB = state->rt[j].rgb_func;
+               unsigned srcRGB = state->rt[j].rgb_src_factor;
+               unsigned dstRGB = state->rt[j].rgb_dst_factor;
+               unsigned eqA = state->rt[j].alpha_func;
+               unsigned srcA = state->rt[j].alpha_src_factor;
+               unsigned dstA = state->rt[j].alpha_dst_factor;
 
                blend_cntl[i] = 0;
-               if (!state->rt[i].blend_enable)
+               if (!state->rt[j].blend_enable)
                        continue;
 
                blend_cntl[i] |= S_028780_BLEND_CONTROL_ENABLE(1);
index e202056ef5dc2b5192147fa2c79613c47e5f5c78..7ab6965c92e22dff6b8af2932df379368c574694 100644 (file)
@@ -161,16 +161,19 @@ static void *r600_create_blend_state(struct pipe_context *ctx,
                                color_control, 0xFFFFFFFD, NULL);
 
        for (int i = 0; i < 8; i++) {
-               unsigned eqRGB = state->rt[i].rgb_func;
-               unsigned srcRGB = state->rt[i].rgb_src_factor;
-               unsigned dstRGB = state->rt[i].rgb_dst_factor;
+               /* state->rt entries > 0 only written if independent blending */
+               const int j = state->independent_blend_enable ? i : 0;
 
-               unsigned eqA = state->rt[i].alpha_func;
-               unsigned srcA = state->rt[i].alpha_src_factor;
-               unsigned dstA = state->rt[i].alpha_dst_factor;
+               unsigned eqRGB = state->rt[j].rgb_func;
+               unsigned srcRGB = state->rt[j].rgb_src_factor;
+               unsigned dstRGB = state->rt[j].rgb_dst_factor;
+
+               unsigned eqA = state->rt[j].alpha_func;
+               unsigned srcA = state->rt[j].alpha_src_factor;
+               unsigned dstA = state->rt[j].alpha_dst_factor;
                uint32_t bc = 0;
 
-               if (!state->rt[i].blend_enable)
+               if (!state->rt[j].blend_enable)
                        continue;
 
                bc |= S_028804_COLOR_COMB_FCN(r600_translate_blend_function(eqRGB));