34 lines
955 B
C++
34 lines
955 B
C++
|
|
#include "iwa/util/growing_descriptor_pool.hpp"
|
|
|
|
#include <utility>
|
|
|
|
#include "iwa/device.hpp"
|
|
|
|
namespace iwa
|
|
{
|
|
GrowingDescriptorPool::GrowingDescriptorPool(ObjectPtr<Device> owner, GrowingDescriptorPoolCreationArgs args)
|
|
: super_t(std::move(owner)), mCreationArgs(std::move(args))
|
|
{
|
|
|
|
}
|
|
|
|
ObjectPtr<DescriptorSet> GrowingDescriptorPool::allocateDescriptorSet(const DescriptorSetAllocateArgs& args)
|
|
{
|
|
for (const ObjectPtr<DescriptorPool>& pool : mPools)
|
|
{
|
|
try
|
|
{
|
|
return pool->allocateDescriptorSet(args);
|
|
}
|
|
catch (vk::FragmentedPoolError&) {}
|
|
catch (vk::OutOfPoolMemoryError&) {}
|
|
// any other error shall be forwarded
|
|
}
|
|
|
|
// couldn't allocate in any of the existing pools, create a new one
|
|
mPools.push_back(getOwner()->createChild<DescriptorPool>(mCreationArgs));
|
|
return mPools.back()->allocateDescriptorSet(args); // raise any error that may occur
|
|
}
|
|
} // namespace iwa
|