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

Marek Olšák maraeo at gmail.com
Wed Jan 31 19:55:14 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 62042a6..24ef09b 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;
 
    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; i < num_state; i++) {
-         if (!(ctx->Color.BlendEnabled & (1 << i)))
+         if (!(ctx->Color.BlendEnabled & (1 << i)) ||
+             !blend->rt[i].colormask)
             continue;
 
          blend->rt[i].blend_enable = 1;
          blend->rt[i].rgb_func =
             translate_blend(ctx->Color.Blend[i].EquationRGB);
 
          if (ctx->Color.Blend[i].EquationRGB == GL_MIN ||
              ctx->Color.Blend[i].EquationRGB == GL_MAX) {
             /* Min/max are special */
             blend->rt[i].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
@@ -195,23 +200,20 @@ st_update_blend( struct st_context *st )
                translate_blend(ctx->Color.Blend[i].SrcA);
             blend->rt[i].alpha_dst_factor =
                translate_blend(ctx->Color.Blend[i].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