Mesa (main): radeonsi: fix ps_uses_fbfetch value

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Nov 4 09:04:40 UTC 2021


Module: Mesa
Branch: main
Commit: bc6d22b92002dc43a8c742ab234717147d63ad87
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bc6d22b92002dc43a8c742ab234717147d63ad87

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Fri Oct 29 15:12:50 2021 +0200

radeonsi: fix ps_uses_fbfetch value

si_update_ps_colorbuf0_slot used blitter_running as a way to detect
recursive calls.
Unfortunately this catch too many cases; for instance a backtrace
like:
  #0 si_update_ps_colorbuf0_slot
  #1 si_set_framebuffer_state
  #2 do_blits
  [...]
  #5 si_blit
  #6 si_copy_region_with_blit

Would end-up not updating ps_uses_fbfetch; so if the new fb_state is
something like:
  cbufs = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, zsbuf = 0x55b8987545e0}

We can have ps_uses_fbfetch=true but cbufs[0] = NULL, which causes a
crash later in si_ps_key_update_framebuffer.

This commit fixes intermittent crashes in KHR-GL46.stencil_texturing.functional.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13550>

---

 src/gallium/drivers/radeonsi/si_descriptors.c | 11 +++++++++--
 src/gallium/drivers/radeonsi/si_pipe.h        |  1 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index 6ea4610f774..7c3ae2eb8ce 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -931,8 +931,11 @@ void si_update_ps_colorbuf0_slot(struct si_context *sctx)
    struct pipe_surface *surf = NULL;
 
    /* si_texture_disable_dcc can get us here again. */
-   if (sctx->blitter_running)
+   if (sctx->in_update_ps_colorbuf0_slot) {
+      assert(!sctx->ps_uses_fbfetch || sctx->framebuffer.state.cbufs[0]);
       return;
+   }
+   sctx->in_update_ps_colorbuf0_slot = true;
 
    /* See whether FBFETCH is used and color buffer 0 is set. */
    if (sctx->shader.ps.cso && sctx->shader.ps.cso->info.base.fs.uses_fbfetch_output &&
@@ -940,8 +943,11 @@ void si_update_ps_colorbuf0_slot(struct si_context *sctx)
       surf = sctx->framebuffer.state.cbufs[0];
 
    /* Return if FBFETCH transitions from disabled to disabled. */
-   if (!buffers->buffers[slot] && !surf)
+   if (!buffers->buffers[slot] && !surf) {
+      assert(!sctx->ps_uses_fbfetch);
+      sctx->in_update_ps_colorbuf0_slot = false;
       return;
+   }
 
    sctx->ps_uses_fbfetch = surf != NULL;
    si_update_ps_iter_samples(sctx);
@@ -989,6 +995,7 @@ void si_update_ps_colorbuf0_slot(struct si_context *sctx)
    }
 
    sctx->descriptors_dirty |= 1u << SI_DESCS_INTERNAL;
+   sctx->in_update_ps_colorbuf0_slot = false;
 }
 
 /* SAMPLER STATES */
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
index 26f32d42c36..672c7e1d321 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -984,6 +984,7 @@ struct si_context {
    uint16_t prefetch_L2_mask;
 
    bool blitter_running;
+   bool in_update_ps_colorbuf0_slot;
    bool is_noop:1;
    bool has_graphics:1;
    bool gfx_flush_in_progress : 1;



More information about the mesa-commit mailing list