12 return errorResult == VK_ERROR_FRAGMENTED_POOL ||
13 errorResult == VK_ERROR_OUT_OF_POOL_MEMORY;
48 other.ownerPool =
nullptr;
61 other.ownerPool =
nullptr;
88 VkDescriptorSetAllocateInfo allocInfo{ .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO };
89 allocInfo.descriptorPool =
vkPool;
90 allocInfo.descriptorSetCount = 1;
91 allocInfo.pSetLayouts = &layout;
93 const VkResult result = vkAllocateDescriptorSets(implPool->
_device, &allocInfo, &builtSet);
94 if (result != VK_SUCCESS)
97 if (IsMemoryError(result))
111 Divide::DIVIDE_ASSERT( retryCount < (
Divide::U8_MAX - 1u),
"DescriptorAllocatorHandle::Allocate failed to allocate descriptor sets: memory error!");
113 return Allocate(layout, builtSet, retryCount + 1);
118 Divide::DIVIDE_UNEXPECTED_CALL();
138 if ( targetSize > 0u )
140 sizes.push_back( { sz.type, targetSize } );
144 VkDescriptorPoolCreateInfo pool_info = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO };
145 pool_info.flags = flags;
146 pool_info.maxSets = count;
148 pool_info.pPoolSizes = sizes.data();
150 VkDescriptorPool descriptorPool;
151 vkCreateDescriptorPool(
_device, &pool_info,
nullptr, &descriptorPool);
153 return descriptorPool;
160 vkDestroyDescriptorPool(
_device, allocator.pool,
nullptr);
167 vkDestroyDescriptorPool(
_device, allocator.
pool,
nullptr);
171 vkDestroyDescriptorPool(
_device, allocator.
pool,
nullptr);
186 vkResetDescriptorPool(
_device, al.pool, VkDescriptorPoolResetFlags{ 0 });
195 vkResetDescriptorPool(
_device, al.pool, VkDescriptorPoolResetFlags{ 0 });
209 s.multiplier = multiplier;
238 bool foundAllocator =
false;
248 foundAllocator =
true;
261 allocator.pool =
createPool(2000, poolIndex == 0 ? VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT : 0 );
262 foundAllocator =
true;
267 ret.vkPool = allocator.pool;
268 ret.poolIdx = poolIndex;
#define PROFILE_SCOPE_AUTO(CATEGORY)
#define PROFILE_SCOPE(NAME, CATEGORY)
static DescriptorAllocatorPool * Create(const VkDevice &device, Divide::I32 nFrames=3)
void SetPoolSizeMultiplier(VkDescriptorType type, float multiplier)
Not thread safe! Override the pool size for a specific descriptor type. This will be used new pools a...
Divide::vector< DescriptorAllocator > _clearAllocators
VkDescriptorPool createPool(Divide::I32 count, VkDescriptorPoolCreateFlags flags)
void Flip()
Not thread safe! Switches default allocators to the next frame. When frames loop it will reset the de...
~DescriptorAllocatorPool()
void ReturnAllocator(DescriptorAllocatorHandle &handle, bool bIsFull)
Divide::vector< std::unique_ptr< PoolStorage > > _descriptorPools
DescriptorAllocatorHandle GetAllocator()
constexpr Optick::Category::Type Graphics
std::lock_guard< mutex > LockGuard
constexpr U32 to_U32(const T value)
eastl::vector< Type > vector
bool IsMemoryError(const VkResult errorResult) noexcept
DescriptorAllocatorHandle & operator=(const DescriptorAllocatorHandle &)=delete
bool Allocate(const VkDescriptorSetLayout &layout, VkDescriptorSet &builtSet, Divide::U8 retryCount=0u)
Allocate new descriptor. handle has to be valid returns true if allocation succeeded,...
void Return()
Return this handle to the pool. Will make this handle orphaned.
DescriptorAllocatorHandle()=default
~DescriptorAllocatorHandle()
DescriptorAllocatorPool * ownerPool
Divide::vector< PoolSize > sizes