From c8da6675ffcf8995182d378131c272d23945e4f9 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Fri, 16 May 2025 15:23:28 +1000 Subject: [PATCH] mesa/st: fix _BlendForceAlphaToOneDraw bitfield use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously we were assuming that all color attachments were active. Fixes: 4f28e2827c9c ("mesa: fix blending when using luminance/intensity emulation") Reviewed-by: Marek Olšák Part-of: (cherry picked from commit c1d00c9a1aad8af3d5a5e4e1b23ac788cb34280e) --- .pick_status.json | 2 +- src/mesa/main/buffers.c | 3 +++ src/mesa/main/mtypes.h | 3 ++- src/mesa/state_tracker/st_atom_blend.c | 7 ++----- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index f56a1eb4034..e298a4fb3ee 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -3754,7 +3754,7 @@ "description": "mesa/st: fix _BlendForceAlphaToOneDraw bitfield use", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "4f28e2827c9ccc26dc608a870209b4deab7b5882", "notes": null diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index e395319a094..bc0888f9169 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -760,6 +760,9 @@ _mesa_update_drawbuffer_masks(struct gl_context *ctx, { update_drawbuffer_mask(ctx, fb, &ctx->DrawBuffer->_IntegerBuffers, &ctx->DrawBuffer->_IntegerDrawBuffers); + update_drawbuffer_mask(ctx, fb, &ctx->DrawBuffer->_BlendForceAlphaToOne, + &ctx->DrawBuffer->_BlendForceAlphaToOneDraw); + } /** diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 00270e04229..2ede8070289 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2691,7 +2691,8 @@ struct gl_framebuffer GLbitfield _IntegerBuffers; /**< Which color buffer attachments are integer valued */ GLbitfield _IntegerDrawBuffers; /**< Which color draw buffers are integer valued */ - GLbitfield _BlendForceAlphaToOne; /**< Which color buffers need blend factor adjustment */ + GLbitfield _BlendForceAlphaToOne; /**< Which color attachments need blend factor adjustment */ + GLbitfield _BlendForceAlphaToOneDraw; /**< Which color buffers need blend factor adjustment */ GLbitfield _IsRGB; /**< Which color buffers have an RGB base format? */ GLbitfield _FP32Buffers; /**< Which color buffers are FP32 */ diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index 9ba4b44d57d..f0253683711 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -182,7 +182,7 @@ blend_per_rt(const struct st_context *st, unsigned num_cb) return GL_TRUE; } - if (ctx->DrawBuffer->_BlendForceAlphaToOne) { + if (ctx->DrawBuffer->_BlendForceAlphaToOneDraw) { /* Overriding requires independent blend functions (not just enables), * requiring drivers to expose pipe_caps.indep_blend_func. */ @@ -320,10 +320,7 @@ st_update_blend( struct st_context *st ) translate_blend(ctx->Color.Blend[j].DstA); } - const struct gl_renderbuffer *rb = - ctx->DrawBuffer->_ColorDrawBuffers[i]; - - if (rb && (ctx->DrawBuffer->_BlendForceAlphaToOne & (1 << i))) { + if (ctx->DrawBuffer->_BlendForceAlphaToOneDraw & (1 << i)) { struct pipe_rt_blend_state *rt = &blend->rt[i]; rt->rgb_src_factor = fix_xrgb_alpha(rt->rgb_src_factor); rt->rgb_dst_factor = fix_xrgb_alpha(rt->rgb_dst_factor);