From 77bbdcdfcd8ad354a6e556b7440ea160fa62db85 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 16 May 2017 10:11:54 +0200 Subject: radeonsi: add a slab allocator for bindless descriptors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For each texture/image handles, we need to allocate a new buffer for the bindless descriptor. But when the number of buffers added to the current CS becomes high, the overhead in the winsys (and in the kernel) is important. To reduce this bottleneck, the idea is to suballocate the bindless descriptors using a slab similar to the one used in the winsys. Currently, a buffer can hold 1024 bindless descriptors but this limit is arbitrary and could be changed in the future for some reasons. Once a slab is allocated the "base" buffer is added to a per-context list. Signed-off-by: Samuel Pitoiset Reviewed-by: Marek Olšák --- src/gallium/drivers/radeonsi/si_pipe.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/gallium/drivers/radeonsi/si_pipe.c') diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 031e4731bf0..14fe9dd6a36 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -94,6 +94,9 @@ static void si_destroy_context(struct pipe_context *context) r600_resource_reference(&sctx->last_trace_buf, NULL); radeon_clear_saved_cs(&sctx->last_gfx); + pb_slabs_deinit(&sctx->bindless_descriptor_slabs); + util_dynarray_fini(&sctx->bindless_descriptors); + FREE(sctx); } @@ -316,6 +319,15 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, sctx->tm = si_create_llvm_target_machine(sscreen); + /* Create a slab allocator for all bindless descriptors. */ + if (!pb_slabs_init(&sctx->bindless_descriptor_slabs, 6, 6, 1, sctx, + si_bindless_descriptor_can_reclaim_slab, + si_bindless_descriptor_slab_alloc, + si_bindless_descriptor_slab_free)) + goto fail; + + util_dynarray_init(&sctx->bindless_descriptors, NULL); + return &sctx->b.b; fail: fprintf(stderr, "radeonsi: Failed to create a context.\n"); -- cgit v1.2.3