r300g: fix blending with blend color and RGBA formats
authorMarek Olšák <maraeo@gmail.com>
Fri, 1 Feb 2013 19:59:38 +0000 (20:59 +0100)
committerMarek Olšák <maraeo@gmail.com>
Wed, 6 Feb 2013 13:31:23 +0000 (14:31 +0100)
NOTE: This is a candidate for the stable branches.

src/gallium/drivers/r300/r300_state.c

index fd02f82bc9e06f047510911b842726ea9a45c551..377b726296bb957afca12a5960f98fd71424fb82 100644 (file)
@@ -487,6 +487,7 @@ static void r300_set_blend_color(struct pipe_context* pipe,
         (struct r300_blend_color_state*)r300->blend_color_state.state;
     struct pipe_blend_color c;
     enum pipe_format format = fb->nr_cbufs ? fb->cbufs[0]->format : 0;
+    float tmp;
     CB_LOCALS;
 
     state->state = *color; /* Save it, so that we can reuse it in set_fb_state */
@@ -513,6 +514,13 @@ static void r300_set_blend_color(struct pipe_context* pipe,
             c.color[2] = c.color[3];
             break;
 
+        case PIPE_FORMAT_R8G8B8A8_UNORM:
+        case PIPE_FORMAT_R8G8B8X8_UNORM:
+            tmp = c.color[0];
+            c.color[0] = c.color[2];
+            c.color[2] = tmp;
+            break;
+
         default:;
         }
     }
@@ -919,6 +927,9 @@ r300_set_framebuffer_state(struct pipe_context* pipe,
     /* Need to reset clamping or colormask. */
     r300_mark_atom_dirty(r300, &r300->blend_state);
 
+    /* Re-swizzle the blend color. */
+    r300_set_blend_color(pipe, &((struct r300_blend_color_state*)r300->blend_color_state.state)->state);
+
     /* If zsbuf is set from NULL to non-NULL or vice versa.. */
     if (!!old_state->zsbuf != !!state->zsbuf) {
         r300_mark_atom_dirty(r300, &r300->dsa_state);