mesa/st: fix _BlendForceAlphaToOneDraw bitfield use

Previously we were assuming that all color attachments were active.

Fixes: 4f28e2827c ("mesa: fix blending when using luminance/intensity emulation")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35014>
(cherry picked from commit c1d00c9a1a)
This commit is contained in:
Timothy Arceri 2025-05-16 15:23:28 +10:00 committed by Eric Engestrom
parent 443a4a6d15
commit c8da6675ff
4 changed files with 8 additions and 7 deletions

View file

@ -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

View file

@ -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);
}
/**

View file

@ -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 */

View file

@ -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);