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);