Commit baf4802e authored by Jason Ekstrand's avatar Jason Ekstrand
Browse files

anv: Better handle 32-byte alignment of descriptor set buffers

In c520f4de, 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

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: c520f4de "anv: Add a concept of a descriptor buffer"

Reviewed-by: Lionel Landwerlin's avatarLionel Landwerlin <>
parent d946cbe9
......@@ -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 =
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-> = pool-> + set->desc_mem.offset;
set->desc_surface_state = anv_descriptor_pool_alloc_state(pool);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment