radeonsi: move CB synchronization into si_fb_barrier_after_rendering

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31193>
This commit is contained in:
Marek Olšák
2024-08-23 17:18:28 -04:00
committed by Marge Bot
parent dad0e0131b
commit 75d98f1db4
5 changed files with 25 additions and 34 deletions
+17 -11
View File
@@ -639,16 +639,7 @@ void si_barrier_after_simple_buffer_op(struct si_context *sctx, unsigned flags,
static void si_texture_barrier(struct pipe_context *ctx, unsigned flags)
{
struct si_context *sctx = (struct si_context *)ctx;
si_fb_barrier_after_rendering(sctx);
/* Multisample surfaces are flushed in si_decompress_textures. */
if (sctx->framebuffer.uncompressed_cb_mask) {
si_make_CB_shader_coherent(sctx, sctx->framebuffer.nr_samples,
sctx->framebuffer.CB_has_shader_readable_metadata,
sctx->framebuffer.all_DCC_pipe_aligned);
}
si_fb_barrier_after_rendering((struct si_context *)ctx, SI_FB_BARRIER_SYNC_CB);
}
/* This enforces coherency between shader stores and any past and future access. */
@@ -735,9 +726,12 @@ static void si_set_sampler_depth_decompress_mask(struct si_context *sctx, struct
}
}
void si_fb_barrier_after_rendering(struct si_context *sctx)
void si_fb_barrier_after_rendering(struct si_context *sctx, unsigned flags)
{
if (sctx->gfx_level < GFX12 && !sctx->decompression_enabled) {
/* Setting dirty_level_mask should ignore SI_FB_BARRIER_SYNC_* because it triggers
* decompression, which is not syncing.
*/
if (sctx->framebuffer.state.zsbuf) {
struct pipe_surface *surf = sctx->framebuffer.state.zsbuf;
struct si_texture *tex = (struct si_texture *)surf->texture;
@@ -762,6 +756,18 @@ void si_fb_barrier_after_rendering(struct si_context *sctx)
}
}
}
if (flags & SI_FB_BARRIER_SYNC_CB) {
/* Compressed images (MSAA with FMASK) are flushed on demand in si_decompress_textures.
*
* Synchronize CB only if there is actually a bound color buffer.
*/
if (sctx->framebuffer.uncompressed_cb_mask) {
si_make_CB_shader_coherent(sctx, sctx->framebuffer.nr_samples,
sctx->framebuffer.CB_has_shader_readable_metadata,
sctx->framebuffer.all_DCC_pipe_aligned);
}
}
}
void si_init_barrier_functions(struct si_context *sctx)
+2 -2
View File
@@ -933,7 +933,7 @@ void si_decompress_subresource(struct pipe_context *ctx, struct pipe_resource *t
*/
if (sctx->framebuffer.state.zsbuf && sctx->framebuffer.state.zsbuf->u.tex.level == level &&
sctx->framebuffer.state.zsbuf->texture == tex)
si_fb_barrier_after_rendering(sctx);
si_fb_barrier_after_rendering(sctx, 0);
si_decompress_depth(sctx, stex, planes, level, level, first_layer, last_layer);
} else if (stex->surface.fmask_size || stex->cmask_buffer ||
@@ -946,7 +946,7 @@ void si_decompress_subresource(struct pipe_context *ctx, struct pipe_resource *t
if (sctx->framebuffer.state.cbufs[i] &&
sctx->framebuffer.state.cbufs[i]->u.tex.level == level &&
sctx->framebuffer.state.cbufs[i]->texture == tex) {
si_fb_barrier_after_rendering(sctx);
si_fb_barrier_after_rendering(sctx, SI_FB_BARRIER_SYNC_CB);
break;
}
}
+2 -6
View File
@@ -1193,14 +1193,10 @@ static void si_launch_grid(struct pipe_context *ctx, const struct pipe_grid_info
(sctx->force_shader_coherency.with_db ||
si_check_needs_implicit_sync(sctx, RADEON_USAGE_DB_NEEDS_IMPLICIT_SYNC));
si_fb_barrier_after_rendering(sctx);
si_fb_barrier_after_rendering(sctx, sync_cb ? SI_FB_BARRIER_SYNC_CB : 0);
if (sync_cb) {
if (sync_cb)
sctx->num_draw_calls_sh_coherent.with_cb = sctx->num_draw_calls;
si_make_CB_shader_coherent(sctx, 0,
sctx->framebuffer.CB_has_shader_readable_metadata,
sctx->framebuffer.all_DCC_pipe_aligned);
}
if (sync_db) {
sctx->num_draw_calls_sh_coherent.with_db = sctx->num_draw_calls;
+3 -1
View File
@@ -1364,6 +1364,8 @@ struct si_context {
};
/* si_barrier.c */
#define SI_FB_BARRIER_SYNC_CB BITFIELD_BIT(0)
void si_barrier_before_internal_op(struct si_context *sctx, unsigned flags,
unsigned num_buffers,
const struct pipe_shader_buffer *buffers,
@@ -1380,7 +1382,7 @@ void si_barrier_before_simple_buffer_op(struct si_context *sctx, unsigned flags,
struct pipe_resource *dst, struct pipe_resource *src);
void si_barrier_after_simple_buffer_op(struct si_context *sctx, unsigned flags,
struct pipe_resource *dst, struct pipe_resource *src);
void si_fb_barrier_after_rendering(struct si_context *sctx);
void si_fb_barrier_after_rendering(struct si_context *sctx, unsigned flags);
void si_init_barrier_functions(struct si_context *sctx);
/* si_blit.c */
+1 -14
View File
@@ -2547,7 +2547,7 @@ static void si_set_framebuffer_state(struct pipe_context *ctx,
return;
}
si_fb_barrier_after_rendering(sctx);
si_fb_barrier_after_rendering(sctx, SI_FB_BARRIER_SYNC_CB);
/* Disable DCC if the formats are incompatible. */
if (sctx->gfx_level >= GFX8 && sctx->gfx_level < GFX11) {
@@ -2569,19 +2569,6 @@ static void si_set_framebuffer_state(struct pipe_context *ctx,
}
}
/* When MSAA is enabled, CB and L2 caches are flushed on demand
* (after FMASK decompression). Shader write -> FB read transitions
* cannot happen for MSAA textures, because MSAA shader images are
* not supported.
*
* Only flush and wait for CB if there is actually a bound color buffer.
*/
if (sctx->framebuffer.uncompressed_cb_mask) {
si_make_CB_shader_coherent(sctx, sctx->framebuffer.nr_samples,
sctx->framebuffer.CB_has_shader_readable_metadata,
sctx->framebuffer.all_DCC_pipe_aligned);
}
/* Wait for CS because: shader write -> FB read
* Wait for PS because: texture -> render (eg: glBlitFramebuffer(with src=dst) then glDraw*)
*/