From e6bcbd57e36e9b6a6c87deca2aab28b63dfe26cd Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Fri, 7 Apr 2023 15:16:17 +0200 Subject: [PATCH] panfrost: Check blend enabled state in pan_allow_forward_pixel_to_kill() The shader can write to a specific RT, but the blend descriptor gets to decide if the RT is really updated. We need to take that into account when initializing the rt_written local variable in pan_allow_forward_pixel_to_kill() otherwise we might get inconsistent results. Signed-off-by: Boris Brezillon Suggested-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_blend_cso.h | 3 +++ src/gallium/drivers/panfrost/pan_cmdstream.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/panfrost/pan_blend_cso.h b/src/gallium/drivers/panfrost/pan_blend_cso.h index bf3c53d1afe..a2e02a497ac 100644 --- a/src/gallium/drivers/panfrost/pan_blend_cso.h +++ b/src/gallium/drivers/panfrost/pan_blend_cso.h @@ -53,6 +53,9 @@ struct panfrost_blend_state { /* info.load presented as a bitfield for draw call hot paths */ unsigned load_dest_mask : PIPE_MAX_COLOR_BUFS; + + /* info.enabled presented as a bitfield for draw call hot paths */ + unsigned enabled_mask : PIPE_MAX_COLOR_BUFS; }; mali_ptr panfrost_get_blend(struct panfrost_batch *batch, unsigned rt, diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 8b86ad4612e..a5e1000a075 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -500,7 +500,8 @@ pan_allow_forward_pixel_to_kill(struct panfrost_context *ctx, * from reading it directly, or from failing to write it */ unsigned rt_mask = ctx->fb_rt_mask; - uint64_t rt_written = (fs->info.outputs_written >> FRAG_RESULT_DATA0); + uint64_t rt_written = (fs->info.outputs_written >> FRAG_RESULT_DATA0) & + ctx->blend->enabled_mask; bool blend_reads_dest = (ctx->blend->load_dest_mask & rt_mask); bool alpha_to_coverage = ctx->blend->base.alpha_to_coverage; @@ -4281,6 +4282,11 @@ panfrost_create_blend_state(struct pipe_context *pipe, if (so->info[c].load_dest) so->load_dest_mask |= BITFIELD_BIT(c); + /* Bifrost needs to know if any render target loads its + * destination in the hot draw path, so precompute this */ + if (so->info[c].enabled) + so->enabled_mask |= BITFIELD_BIT(c); + /* Converting equations to Mali style is expensive, do it at * CSO create time instead of draw-time */ if (so->info[c].fixed_function) {