From 7adb3c0f7f96f2c95f903de5a59815e772061b63 Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Tue, 18 Jan 2022 11:42:28 +0100 Subject: [PATCH] radv: Use larger arena sizes. For some games that take like 400 MiB of shader binaries, the number of shader arenas ends up going >1500. Cut that down a bit by using larger arenas. 8 MiB should still be decent with small BAR and should still cut things down from ~1500 to ~50 buffers. Reviewed-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_constants.h | 2 ++ src/amd/vulkan/radv_private.h | 1 + src/amd/vulkan/radv_shader.c | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/amd/vulkan/radv_constants.h b/src/amd/vulkan/radv_constants.h index 9cc911eb8d5..5787f042316 100644 --- a/src/amd/vulkan/radv_constants.h +++ b/src/amd/vulkan/radv_constants.h @@ -99,6 +99,8 @@ #define RADV_SHADER_ALLOC_ALIGNMENT 256 #define RADV_SHADER_ALLOC_MIN_ARENA_SIZE (256 * 1024) +/* 256 KiB << 5 = 8 MiB */ +#define RADV_SHADER_ALLOC_MAX_ARENA_SIZE_SHIFT 5u #define RADV_SHADER_ALLOC_MIN_SIZE_CLASS 8 #define RADV_SHADER_ALLOC_MAX_SIZE_CLASS 15 #define RADV_SHADER_ALLOC_NUM_FREE_LISTS \ diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 7c7d90e749b..7a56d08f5ec 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -798,6 +798,7 @@ struct radv_device { uint32_t fmask_mrt_offset_counter; struct list_head shader_arenas; + unsigned shader_arena_shift; uint8_t shader_free_list_mask; struct list_head shader_free_lists[RADV_SHADER_ALLOC_NUM_FREE_LISTS]; struct list_head shader_block_obj_pool; diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index e951c772378..f915d947137 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -1299,7 +1299,10 @@ radv_alloc_shader_memory(struct radv_device *device, uint32_t size, void *ptr) if (!arena) goto fail; - unsigned arena_size = MAX2(RADV_SHADER_ALLOC_MIN_ARENA_SIZE, size); + unsigned arena_size = + MAX2(RADV_SHADER_ALLOC_MIN_ARENA_SIZE + << MIN2(RADV_SHADER_ALLOC_MAX_ARENA_SIZE_SHIFT, device->shader_arena_shift), + size); VkResult result = device->ws->buffer_create( device->ws, arena_size, RADV_SHADER_ALLOC_ALIGNMENT, RADEON_DOMAIN_VRAM, RADEON_FLAG_NO_INTERPROCESS_SHARING | RADEON_FLAG_32BIT | @@ -1335,6 +1338,7 @@ radv_alloc_shader_memory(struct radv_device *device, uint32_t size, void *ptr) add_hole(device, hole); } + ++device->shader_arena_shift; list_addtail(&arena->list, &device->shader_arenas); mtx_unlock(&device->shader_arena_mutex);