initial commit
This commit is contained in:
33
source/util/growing_descriptor_pool.cpp
Normal file
33
source/util/growing_descriptor_pool.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
#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
|
||||
Reference in New Issue
Block a user