panfrost: Check blend enabled state in pan_allow_forward_pixel_to_kill()
authorBoris Brezillon <boris.brezillon@collabora.com>
Fri, 7 Apr 2023 13:16:17 +0000 (15:16 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 3 May 2023 19:02:21 +0000 (19:02 +0000)
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 <boris.brezillon@collabora.com>
Suggested-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22465>

src/gallium/drivers/panfrost/pan_blend_cso.h
src/gallium/drivers/panfrost/pan_cmdstream.c

index bf3c53d..a2e02a4 100644 (file)
@@ -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,
index 8b86ad4..a5e1000 100644 (file)
@@ -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) {