radeonsi: add si_resource_copy_buffer

Same as si_resource_copy_resource except it only supports buffers.

Also make sure that si_compute_clear_copy_buffer doesn't do
anything when has_gfx_compute is false.

Reviewed-by: David Rosca <david.rosca@amd.com>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41133>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2026-05-04 11:27:55 +02:00
parent 838ce62f3a
commit 5f56a0e057
3 changed files with 27 additions and 0 deletions

View file

@ -841,6 +841,24 @@ void si_clear_buffer(struct si_context *sctx, struct pipe_resource *dst,
si_cp_dma_clear_buffer(sctx, &sctx->gfx_cs, dst, offset, size, *clear_value);
}
void si_resource_copy_buffer(struct pipe_context *ctx, struct pipe_resource *dst,
unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz,
struct pipe_resource *src, unsigned src_level,
const struct pipe_box *src_box)
{
struct si_context *sctx = (struct si_context *)ctx;
/* This function only handles buffers. */
if (dst->target != PIPE_BUFFER || src->target != PIPE_BUFFER) {
assert(false);
return;
}
si_barrier_before_simple_buffer_op(sctx, 0, dst, src);
si_copy_buffer(sctx, dst, src, dstx, src_box->x, src_box->width);
si_barrier_after_simple_buffer_op(sctx, 0, dst, src);
}
static uint64_t si_resource_get_address(struct pipe_screen *screen,
struct pipe_resource *resource)
{
@ -898,4 +916,6 @@ void si_init_buffer_functions(struct si_context *sctx)
sctx->b.texture_subdata = u_default_texture_subdata;
sctx->b.buffer_subdata = si_buffer_subdata;
sctx->b.resource_commit = si_resource_commit;
if (!sctx->b.resource_copy_region)
sctx->b.resource_copy_region = si_resource_copy_buffer;
}

View file

@ -156,6 +156,9 @@ bool si_compute_clear_copy_buffer(struct si_context *sctx, struct pipe_resource
assert(!src || src->target != PIPE_BUFFER || src_offset + size <= src->width0);
bool is_copy = src != NULL;
if (!sctx->screen->has_gfx_compute)
return false;
struct ac_cs_clear_copy_buffer_options options = {
.nir_options = sctx->screen->nir_options,
.info = &sctx->screen->info,

View file

@ -1445,6 +1445,10 @@ void si_clear_buffer(struct si_context *sctx, struct pipe_resource *dst,
bool render_condition_enable);
void si_copy_buffer(struct si_context *sctx, struct pipe_resource *dst, struct pipe_resource *src,
uint64_t dst_offset, uint64_t src_offset, unsigned size);
void si_resource_copy_buffer(struct pipe_context *ctx, struct pipe_resource *dst,
unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz,
struct pipe_resource *src, unsigned src_level,
const struct pipe_box *src_box);
/* si_clear.c */
#define SI_CLEAR_TYPE_CMASK (1 << 0)