st/mesa: Use blend equation and function of first render target for all render target...
authorFabian Bieler <der.fabe@gmx.net>
Thu, 10 Feb 2011 15:45:41 +0000 (16:45 +0100)
committerBrian Paul <brianp@vmware.com>
Mon, 14 Feb 2011 21:37:18 +0000 (14:37 -0700)
If EXT_draw_buffers2 is supported but ARB_draw_buffers_blend isn't
_mesa_BlendFuncSeparateEXT only sets up the blend equation and function for the
first render target. This patch makes sure that update_blend doesn't try to use
the data from other rendertargets in such cases.

Signed-off-by: Brian Paul <brianp@vmware.com>
src/mesa/state_tracker/st_atom_blend.c

index 8a3609e569f48f9d6c2cfc82cefe75e355bb2016..fb1c7a4efee6e222fb891311cf6eee8e3e83e541 100644 (file)
@@ -191,7 +191,7 @@ update_blend( struct st_context *st )
 {
    struct pipe_blend_state *blend = &st->state.blend;
    unsigned num_state = 1;
-   unsigned i;
+   unsigned i, j;
 
    memset(blend, 0, sizeof(*blend));
 
@@ -214,12 +214,15 @@ update_blend( struct st_context *st )
    }
    else if (st->ctx->Color.BlendEnabled) {
       /* blending enabled */
-      for (i = 0; i < num_state; i++) {
+      for (i = 0, j = 0; i < num_state; i++) {
 
          blend->rt[i].blend_enable = (st->ctx->Color.BlendEnabled >> i) & 0x1;
 
+         if (st->ctx->Extensions.ARB_draw_buffers_blend)
+            j = i;
+
          blend->rt[i].rgb_func =
-            translate_blend(st->ctx->Color.Blend[i].EquationRGB);
+            translate_blend(st->ctx->Color.Blend[j].EquationRGB);
 
          if (st->ctx->Color.Blend[i].EquationRGB == GL_MIN ||
              st->ctx->Color.Blend[i].EquationRGB == GL_MAX) {
@@ -229,13 +232,13 @@ update_blend( struct st_context *st )
          }
          else {
             blend->rt[i].rgb_src_factor =
-               translate_blend(st->ctx->Color.Blend[i].SrcRGB);
+               translate_blend(st->ctx->Color.Blend[j].SrcRGB);
             blend->rt[i].rgb_dst_factor =
-               translate_blend(st->ctx->Color.Blend[i].DstRGB);
+               translate_blend(st->ctx->Color.Blend[j].DstRGB);
          }
 
          blend->rt[i].alpha_func =
-            translate_blend(st->ctx->Color.Blend[i].EquationA);
+            translate_blend(st->ctx->Color.Blend[j].EquationA);
 
          if (st->ctx->Color.Blend[i].EquationA == GL_MIN ||
              st->ctx->Color.Blend[i].EquationA == GL_MAX) {
@@ -245,9 +248,9 @@ update_blend( struct st_context *st )
          }
          else {
             blend->rt[i].alpha_src_factor =
-               translate_blend(st->ctx->Color.Blend[i].SrcA);
+               translate_blend(st->ctx->Color.Blend[j].SrcA);
             blend->rt[i].alpha_dst_factor =
-               translate_blend(st->ctx->Color.Blend[i].DstA);
+               translate_blend(st->ctx->Color.Blend[j].DstA);
          }
       }
    }