From baf4802e3e92b1512472d553dacbfbb2185c995b Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 25 Apr 2019 22:23:23 -0500 Subject: [PATCH] anv: Better handle 32-byte alignment of descriptor set buffers In c520f4dec9c, we chose to align the sizes of descriptor set buffers to 32 bytes. We have to align the descriptor set buffer to 32B so that it's valid for using with push constants. We align the size as well so we don't leave lots of holes with util_vma_heap_alloc. Unfortunately, we were only aligning it for alloc and not for free so we were still creating piles of holes when we delete descriptor sets. This causes terrible perf for the allocator once we've deleted piles of descriptor sets. This commit reworks the code so that we align the descriptor set buffer size to 32B for both alloc and free. The result is that it takes the new crucible vkResetDescriptorPool from 104.567719 to 2.898354 seconds. Fixes: c520f4dec9c "anv: Add a concept of a descriptor buffer" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110497 Reviewed-by: Lionel Landwerlin --- src/intel/vulkan/anv_descriptor_set.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c index 63fd8c69608..7ffdb1cceff 100644 --- a/src/intel/vulkan/anv_descriptor_set.c +++ b/src/intel/vulkan/anv_descriptor_set.c @@ -899,9 +899,9 @@ anv_descriptor_set_create(struct anv_device *device, /* Align the size to 32 so that alignment gaps don't cause extra holes * in the heap which can lead to bad performance. */ + uint32_t set_buffer_size = ALIGN(layout->descriptor_buffer_size, 32); uint64_t pool_vma_offset = - util_vma_heap_alloc(&pool->bo_heap, - ALIGN(layout->descriptor_buffer_size, 32), 32); + util_vma_heap_alloc(&pool->bo_heap, set_buffer_size, 32); if (pool_vma_offset == 0) { anv_descriptor_pool_free_set(pool, set); return vk_error(VK_ERROR_FRAGMENTED_POOL); @@ -909,7 +909,7 @@ anv_descriptor_set_create(struct anv_device *device, assert(pool_vma_offset >= POOL_HEAP_OFFSET && pool_vma_offset - POOL_HEAP_OFFSET <= INT32_MAX); set->desc_mem.offset = pool_vma_offset - POOL_HEAP_OFFSET; - set->desc_mem.alloc_size = layout->descriptor_buffer_size; + set->desc_mem.alloc_size = set_buffer_size; set->desc_mem.map = pool->bo.map + set->desc_mem.offset; set->desc_surface_state = anv_descriptor_pool_alloc_state(pool); -- 2.30.2