nvk: Early-out impossible descriptor allocations

Also, return VK_ERROR_FRAGMENTED_POOL when appropriate.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28494>
This commit is contained in:
M Henning
2024-03-30 14:33:47 -04:00
committed by Marge Bot
parent aac2a31b3d
commit e808a1ead4
+6 -1
View File
@@ -487,9 +487,14 @@ nvk_descriptor_pool_alloc(struct nvk_descriptor_pool *pool,
uint64_t *addr_out, void **map_out)
{
assert(size > 0);
assert(size % alignment == 0);
if (size > pool->heap.free_size)
return VK_ERROR_OUT_OF_POOL_MEMORY;
uint64_t addr = util_vma_heap_alloc(&pool->heap, size, alignment);
if (addr == 0)
return VK_ERROR_OUT_OF_POOL_MEMORY;
return VK_ERROR_FRAGMENTED_POOL;
assert(addr >= pool->bo->offset);
assert(addr + size <= pool->bo->offset + pool->bo->size);