ac/nir/meta: use the clear/copy compute shader if CP DMA doesn't support sparse

ac_prepare_cs_clear_copy_buffer determines whether to use CP DMA, and
the driver obeys that.

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39841>
This commit is contained in:
Marek Olšák 2026-02-11 22:46:02 -05:00 committed by Marge Bot
parent bbcfab9f4f
commit 62cce3abcd
3 changed files with 5 additions and 0 deletions

View file

@ -173,6 +173,7 @@ struct ac_cs_clear_copy_buffer_info {
bool render_condition_enabled;
bool dst_is_vram;
bool src_is_vram;
bool dst_is_sparse;
bool src_is_sparse;
};

View file

@ -351,8 +351,11 @@ ac_prepare_cs_clear_copy_buffer(const struct ac_cs_clear_copy_buffer_options *op
/* This doesn't fail very often because the only possible fallback is CP DMA, which doesn't
* support the render condition.
*
* CP DMA doesn't support sparse on GFX6-9, so we must use compute for that.
*/
if (options->fail_if_slow && !info->render_condition_enabled && options->info->has_cp_dma &&
((!info->src_is_sparse && !info->dst_is_sparse) || options->info->cp_dma_supports_sparse) &&
!options->info->cp_sdma_ge_use_system_memory_scope) {
switch (options->info->gfx_level) {
/* GFX6-8: CP DMA clears are so slow that we risk getting a GPU timeout. CP DMA copies

View file

@ -174,6 +174,7 @@ bool si_compute_clear_copy_buffer(struct si_context *sctx, struct pipe_resource
.render_condition_enabled = render_condition_enable,
.dst_is_vram = si_resource(dst)->domains & RADEON_DOMAIN_VRAM,
.src_is_vram = src && si_resource(src)->domains & RADEON_DOMAIN_VRAM,
.dst_is_sparse = dst->flags & PIPE_RESOURCE_FLAG_SPARSE,
.src_is_sparse = src && src->flags & PIPE_RESOURCE_FLAG_SPARSE,
};
memcpy(info.clear_value, clear_value, clear_value_size);