From bc6d22b92002dc43a8c742ab234717147d63ad87 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 29 Oct 2021 15:12:50 +0200 Subject: [PATCH] radeonsi: fix ps_uses_fbfetch value MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Part-of: --- 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 6ea4610..7c3ae2e 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 26f32d4..672c7e1 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; -- 2.7.4