From d4c066abaf3226d4ceec08f8b64ccb16075da77b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 12 Apr 2024 22:14:54 -0400 Subject: [PATCH] radeonsi: adds flags parameter into si_compute_blit to replace fail_if_slow So that we can also specify sync flags. Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_blit.c | 2 +- src/gallium/drivers/radeonsi/si_compute_blit.c | 13 +++++++------ src/gallium/drivers/radeonsi/si_pipe.h | 4 +++- .../drivers/radeonsi/si_test_image_copy_region.c | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c index e57cedd6e14..d5e9939cd93 100644 --- a/src/gallium/drivers/radeonsi/si_blit.c +++ b/src/gallium/drivers/radeonsi/si_blit.c @@ -1232,7 +1232,7 @@ static void si_blit(struct pipe_context *ctx, const struct pipe_blit_info *info) if (unlikely(sctx->sqtt_enabled)) sctx->sqtt_next_event = EventCmdCopyImage; - if (si_compute_blit(sctx, info, NULL, 0, 0, true)) + if (si_compute_blit(sctx, info, NULL, 0, 0, SI_OP_SYNC_BEFORE_AFTER | SI_OP_FAIL_IF_SLOW)) return; si_gfx_blit(ctx, info); diff --git a/src/gallium/drivers/radeonsi/si_compute_blit.c b/src/gallium/drivers/radeonsi/si_compute_blit.c index 8d1348dc27c..b8087231df7 100644 --- a/src/gallium/drivers/radeonsi/si_compute_blit.c +++ b/src/gallium/drivers/radeonsi/si_compute_blit.c @@ -741,7 +741,8 @@ bool si_compute_clear_image(struct si_context *sctx, struct pipe_resource *tex, info.mask = util_format_is_depth_or_stencil(format) ? PIPE_MASK_ZS : PIPE_MASK_RGBA; info.render_condition_enable = render_condition_enable; - return si_compute_blit(sctx, &info, color, 0, 0, fail_if_slow); + return si_compute_blit(sctx, &info, color, 0, 0, + SI_OP_SYNC_BEFORE_AFTER | (fail_if_slow ? SI_OP_FAIL_IF_SLOW : 0)); } bool si_compute_copy_image(struct si_context *sctx, struct pipe_resource *dst, unsigned dst_level, @@ -852,7 +853,8 @@ bool si_compute_copy_image(struct si_context *sctx, struct pipe_resource *dst, u /* Only the compute blit can copy compressed and subsampled images. */ fail_if_slow &= !dst_access && !src_access; - bool success = si_compute_blit(sctx, &info, NULL, dst_access, src_access, fail_if_slow); + bool success = si_compute_blit(sctx, &info, NULL, dst_access, src_access, + SI_OP_SYNC_BEFORE_AFTER | (fail_if_slow ? SI_OP_FAIL_IF_SLOW : 0)); assert((!dst_access && !src_access) || success); return success; } @@ -863,7 +865,7 @@ typedef struct { bool si_compute_blit(struct si_context *sctx, const struct pipe_blit_info *info, const union pipe_color_union *clear_color, unsigned dst_access, - unsigned src_access, bool fail_if_slow) + unsigned src_access, unsigned flags) { struct si_texture *sdst = (struct si_texture *)info->dst.resource; struct si_texture *ssrc = (struct si_texture *)info->src.resource; @@ -923,7 +925,7 @@ bool si_compute_blit(struct si_context *sctx, const struct pipe_blit_info *info, * * TODO: benchmark the performance on gfx11 */ - if (sctx->gfx_level < GFX11 && sctx->has_graphics && fail_if_slow) + if (sctx->gfx_level < GFX11 && sctx->has_graphics && flags & SI_OP_FAIL_IF_SLOW) return false; if (sctx->gfx_level < GFX10 && !sctx->has_graphics && vi_dcc_enabled(sdst, info->dst.level)) @@ -1207,8 +1209,7 @@ bool si_compute_blit(struct si_context *sctx, const struct pipe_blit_info *info, image[dst_index].u.tex.first_layer = 0; image[dst_index].u.tex.last_layer = util_max_layer(info->dst.resource, info->dst.level); - si_launch_grid_internal_images(sctx, image, is_clear ? 1 : 2, &grid, shader, - SI_OP_SYNC_BEFORE_AFTER | + si_launch_grid_internal_images(sctx, image, is_clear ? 1 : 2, &grid, shader, flags | (info->render_condition_enable ? SI_OP_CS_RENDER_COND_ENABLE : 0)); return true; } diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h index 8a4b798c8e9..c824d001800 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.h +++ b/src/gallium/drivers/radeonsi/si_pipe.h @@ -1477,6 +1477,8 @@ void si_destroy_compute(struct si_compute *program); #define SI_OP_CS_RENDER_COND_ENABLE (1 << 6) #define SI_OP_CPDMA_SKIP_CHECK_CS_SPACE (1 << 7) /* don't call need_cs_space */ #define SI_OP_SYNC_GE_BEFORE (1 << 8) /* only sync VS, TCS, TES, GS */ +/* Only for si_compute_blit: */ +#define SI_OP_FAIL_IF_SLOW (1 << 9) unsigned si_get_flush_flags(struct si_context *sctx, enum si_coherency coher, enum si_cache_policy cache_policy); @@ -1518,7 +1520,7 @@ bool si_compute_copy_image(struct si_context *sctx, struct pipe_resource *dst, u bool fail_if_slow); bool si_compute_blit(struct si_context *sctx, const struct pipe_blit_info *info, const union pipe_color_union *clear_color, unsigned dst_access, - unsigned src_access, bool fail_if_slow); + unsigned src_access, unsigned flags); void si_init_compute_blit_functions(struct si_context *sctx); /* si_cp_dma.c */ diff --git a/src/gallium/drivers/radeonsi/si_test_image_copy_region.c b/src/gallium/drivers/radeonsi/si_test_image_copy_region.c index 49c3f170a3c..5a04951f1ba 100644 --- a/src/gallium/drivers/radeonsi/si_test_image_copy_region.c +++ b/src/gallium/drivers/radeonsi/si_test_image_copy_region.c @@ -929,7 +929,7 @@ void si_test_blit(struct si_screen *sscreen, unsigned test_flags) if (only_cb_resolve) success = si_msaa_resolve_blit_via_CB(ctx, &info); else - success = si_compute_blit(sctx, &info, NULL, 0, 0, false); + success = si_compute_blit(sctx, &info, NULL, 0, 0, SI_OP_SYNC_BEFORE_AFTER); if (success) { printf(" %-7s", only_cb_resolve ? "resolve" : "comp");