From a10704111283692cebd264f9375083e191bbf95d Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 23 Sep 2024 12:58:59 +0200 Subject: [PATCH] radeonsi: implement resource_get_address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Acked-by: Adam Jackson Reviewed-by: Marek Olšák Part-of: --- docs/features.txt | 2 +- docs/relnotes/new_features.txt | 2 +- src/gallium/drivers/radeonsi/si_buffer.c | 13 +++++++++++++ src/gallium/drivers/radeonsi/si_compute.c | 9 +++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/features.txt b/docs/features.txt index 01e49ea3188..c3c883d490a 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -854,7 +854,7 @@ Rusticl extensions that are not part of any OpenCL version: cl_khr_terminate_context not started cl_khr_throttle_hints not started cl_khr_work_group_uniform_arithmetic not started - cl_ext_buffer_device_address DONE (iris, llvmpipe, zink) + cl_ext_buffer_device_address DONE (iris, llvmpipe, radeonsi, zink) cl_arm_non_uniform_work_group_size not started cl_arm_shared_virtual_memory in progress (nvc0) cl_intel_required_subgroup_size in progress (available with RUSTICL_FEATURES=intel) diff --git a/docs/relnotes/new_features.txt b/docs/relnotes/new_features.txt index 20f0d5299f2..7ff6fc675a0 100644 --- a/docs/relnotes/new_features.txt +++ b/docs/relnotes/new_features.txt @@ -27,7 +27,7 @@ VK_EXT_image_2d_view_of_3d on panvk VK_EXT_texel_buffer_alignment on panvk cl_khr_kernel_clock on freedreno, iris, llvmpipe, nvc0, panfrost, radeonsi and zink with llvm-19 or newer GL_KHR_texture_compression_astc_hdr on panfrost and asahi -cl_ext_buffer_device_address on iris, llvmpipe and zink +cl_ext_buffer_device_address on iris, llvmpipe, radeonsi and zink Completed OpenCL 2.0 coarse grain buffer SVM support for iris VK_EXT_shader_subgroup_ballot on panvk VK_EXT_shader_subgroup_vote on panvk diff --git a/src/gallium/drivers/radeonsi/si_buffer.c b/src/gallium/drivers/radeonsi/si_buffer.c index adacf4e2735..cb187c17fd2 100644 --- a/src/gallium/drivers/radeonsi/si_buffer.c +++ b/src/gallium/drivers/radeonsi/si_buffer.c @@ -256,6 +256,11 @@ static bool si_invalidate_buffer(struct si_context *sctx, struct si_resource *bu if (buf->b.is_user_ptr) return false; + /* Can't reallocate when this resource can't change its address. + */ + if (buf->b.b.flags & PIPE_RESOURCE_FLAG_FIXED_ADDRESS) + return false; + /* Check if mapping this buffer would cause waiting for the GPU. */ if (!si_is_buffer_idle(sctx, buf, RADEON_USAGE_READWRITE)) { /* Reallocate the buffer in the same pipe_resource. */ @@ -776,11 +781,19 @@ static bool si_resource_commit(struct pipe_context *pctx, struct pipe_resource * return si_texture_commit(ctx, res, level, box, commit); } +static uint64_t si_resource_get_address(struct pipe_screen *screen, + struct pipe_resource *resource) +{ + struct si_resource *res = si_resource(resource); + return res->gpu_address; +} + void si_init_screen_buffer_functions(struct si_screen *sscreen) { sscreen->b.resource_create = si_resource_create; sscreen->b.resource_destroy = si_resource_destroy; sscreen->b.resource_from_user_memory = si_buffer_from_user_memory; + sscreen->b.resource_get_address = si_resource_get_address; } void si_init_buffer_functions(struct si_context *sctx) diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c index 1a28efc1f04..6c2f9a70a47 100644 --- a/src/gallium/drivers/radeonsi/si_compute.c +++ b/src/gallium/drivers/radeonsi/si_compute.c @@ -968,6 +968,15 @@ static void si_launch_grid(struct pipe_context *ctx, const struct pipe_grid_info RADEON_USAGE_READWRITE | RADEON_PRIO_SHADER_RW_BUFFER); } + for (unsigned i = 0; i < info->num_globals; i++) { + struct si_resource *buffer = si_resource(info->globals[i]); + if (!buffer) { + continue; + } + radeon_add_to_buffer_list(sctx, &sctx->gfx_cs, buffer, + RADEON_USAGE_READWRITE | RADEON_PRIO_SHADER_RW_BUFFER); + } + /* Registers that are not read from memory should be set before this: */ si_emit_barrier_direct(sctx);