[Mesa-dev] [PATCH 2/3] st/mesa: don't translate blend state when color writes are disabled

Marek Olšák maraeo at gmail.com
Thu Feb 8 15:17:28 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

---
 src/mesa/state_tracker/st_atom_blend.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c
index a5f7edb..2a8da75 100644
--- a/src/mesa/state_tracker/st_atom_blend.c
+++ b/src/mesa/state_tracker/st_atom_blend.c
@@ -146,29 +146,34 @@ st_update_blend( struct st_context *st )
    const struct gl_context *ctx = st->ctx;
    unsigned num_state = 1;
    unsigned i, j;
 
    memset(blend, 0, sizeof(*blend));
 
    if (blend_per_rt(ctx) || colormask_per_rt(ctx)) {
       num_state = ctx->Const.MaxDrawBuffers;
       blend->independent_blend_enable = 1;
    }
+
+   for (i = 0; i < num_state; i++)
+      blend->rt[i].colormask = GET_COLORMASK(ctx->Color.ColorMask, i);
+
    if (ctx->Color.ColorLogicOpEnabled) {
       /* logicop enabled */
       blend->logicop_enable = 1;
       blend->logicop_func = ctx->Color._LogicOp;
    }
    else if (ctx->Color.BlendEnabled && !ctx->Color._AdvancedBlendMode) {
       /* blending enabled */
       for (i = 0, j = 0; i < num_state; i++) {
-         if (!(ctx->Color.BlendEnabled & (1 << i)))
+         if (!(ctx->Color.BlendEnabled & (1 << i)) ||
+             !blend->rt[i].colormask)
             continue;
 
 	 if (ctx->Extensions.ARB_draw_buffers_blend)
             j = i;
 
          blend->rt[i].blend_enable = 1;
          blend->rt[i].rgb_func =
             translate_blend(ctx->Color.Blend[j].EquationRGB);
 
          if (ctx->Color.Blend[i].EquationRGB == GL_MIN ||
@@ -198,23 +203,20 @@ st_update_blend( struct st_context *st )
                translate_blend(ctx->Color.Blend[j].SrcA);
             blend->rt[i].alpha_dst_factor =
                translate_blend(ctx->Color.Blend[j].DstA);
          }
       }
    }
    else {
       /* no blending / logicop */
    }
 
-   for (i = 0; i < num_state; i++)
-      blend->rt[i].colormask = GET_COLORMASK(ctx->Color.ColorMask, i);
-
    blend->dither = ctx->Color.DitherFlag;
 
    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;
    }
-- 
2.7.4



More information about the mesa-dev mailing list