radeonsi: drop two unused variables in create_function()
[mesa.git] / src / mesa / state_tracker / st_atom_blend.c
index 50d240a7b217824c233a28cc5634b6948b8536c2..103c500802990671114497115f5af4d144c00043 100644 (file)
@@ -39,6 +39,7 @@
 #include "pipe/p_defines.h"
 #include "cso_cache/cso_context.h"
 
+#include "framebuffer.h"
 #include "main/macros.h"
 
 /**
@@ -175,7 +176,7 @@ static GLboolean
 blend_per_rt(const struct gl_context *ctx)
 {
    if (ctx->Color.BlendEnabled &&
-      (ctx->Color.BlendEnabled != ((1 << ctx->Const.MaxDrawBuffers) - 1))) {
+      (ctx->Color.BlendEnabled != ((1U << ctx->Const.MaxDrawBuffers) - 1))) {
       /* This can only happen if GL_EXT_draw_buffers2 is enabled */
       return GL_TRUE;
    }
@@ -186,8 +187,8 @@ blend_per_rt(const struct gl_context *ctx)
    return GL_FALSE;
 }
 
-static void 
-update_blend( struct st_context *st )
+void
+st_update_blend( struct st_context *st )
 {
    struct pipe_blend_state *blend = &st->state.blend;
    const struct gl_context *ctx = st->ctx;
@@ -205,7 +206,7 @@ update_blend( struct st_context *st )
       blend->logicop_enable = 1;
       blend->logicop_func = translate_logicop(ctx->Color.LogicOp);
    }
-   else if (ctx->Color.BlendEnabled) {
+   else if (ctx->Color.BlendEnabled && !ctx->Color._AdvancedBlendMode) {
       /* blending enabled */
       for (i = 0, j = 0; i < num_state; i++) {
 
@@ -263,33 +264,25 @@ update_blend( struct st_context *st )
          blend->rt[i].colormask |= PIPE_MASK_A;
    }
 
-   if (ctx->Color.DitherFlag)
-      blend->dither = 1;
+   blend->dither = ctx->Color.DitherFlag;
 
-   if (ctx->Multisample.Enabled) {
-      /* unlike in gallium/d3d10 these operations are only performed
-         if msaa is enabled */
-      if (ctx->Multisample.SampleAlphaToCoverage)
-         blend->alpha_to_coverage = 1;
-      if (ctx->Multisample.SampleAlphaToOne)
-         blend->alpha_to_one = 1;
+   if (_mesa_is_multisample_enabled(ctx) &&
+       !(ctx->DrawBuffer->_IntegerBuffers & 0x1)) {
+      /* Unlike in gallium/d3d10 these operations are only performed
+       * if both msaa is enabled and we have a multisample buffer.
+       */
+      blend->alpha_to_coverage = ctx->Multisample.SampleAlphaToCoverage;
+      blend->alpha_to_one = ctx->Multisample.SampleAlphaToOne;
    }
 
    cso_set_blend(st->cso_context, blend);
-
-   {
-      struct pipe_blend_color bc;
-      COPY_4FV(bc.color, ctx->Color.BlendColorUnclamped);
-      cso_set_blend_color(st->cso_context, &bc);
-   }
 }
 
+void
+st_update_blend_color(struct st_context *st)
+{
+   struct pipe_blend_color bc;
 
-const struct st_tracked_state st_update_blend = {
-   "st_update_blend",                                  /* name */
-   {                                                   /* dirty */
-      (_NEW_COLOR | _NEW_MULTISAMPLE),  /* XXX _NEW_BLEND someday? */  /* mesa */
-      0,                                               /* st */
-   },
-   update_blend,                                       /* update */
-};
+   COPY_4FV(bc.color, st->ctx->Color.BlendColorUnclamped);
+   cso_set_blend_color(st->cso_context, &bc);
+}