VulkanRenderer: Fix descriptor pool release
This commit is contained in:
parent
a7235ab02d
commit
49a2cda0a1
|
|
@ -53,7 +53,7 @@ namespace Nz
|
||||||
using BindingStorage = std::aligned_storage_t<sizeof(VulkanShaderBinding), alignof(VulkanShaderBinding)>;
|
using BindingStorage = std::aligned_storage_t<sizeof(VulkanShaderBinding), alignof(VulkanShaderBinding)>;
|
||||||
|
|
||||||
Bitset<UInt64> freeBindings;
|
Bitset<UInt64> freeBindings;
|
||||||
Vk::DescriptorPool descriptorPool;
|
std::unique_ptr<Vk::DescriptorPool> descriptorPool;
|
||||||
std::unique_ptr<BindingStorage[]> storage;
|
std::unique_ptr<BindingStorage[]> storage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,9 +145,8 @@ namespace Nz
|
||||||
|
|
||||||
inline DescriptorSet& DescriptorSet::operator=(DescriptorSet&& descriptorSet) noexcept
|
inline DescriptorSet& DescriptorSet::operator=(DescriptorSet&& descriptorSet) noexcept
|
||||||
{
|
{
|
||||||
m_pool = descriptorSet.m_pool;
|
|
||||||
|
|
||||||
std::swap(m_handle, descriptorSet.m_handle);
|
std::swap(m_handle, descriptorSet.m_handle);
|
||||||
|
std::swap(m_pool, descriptorSet.m_pool);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,8 +83,10 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
DescriptorPool pool;
|
DescriptorPool pool;
|
||||||
if (!pool.descriptorPool.Create(*m_device, MaxSet, UInt32(poolSizes.size()), poolSizes.data(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT))
|
pool.descriptorPool = std::make_unique<Vk::DescriptorPool>();
|
||||||
throw std::runtime_error("failed to allocate new descriptor pool: " + TranslateVulkanError(pool.descriptorPool.GetLastErrorCode()));
|
|
||||||
|
if (!pool.descriptorPool->Create(*m_device, MaxSet, UInt32(poolSizes.size()), poolSizes.data(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT))
|
||||||
|
throw std::runtime_error("failed to allocate new descriptor pool: " + TranslateVulkanError(pool.descriptorPool->GetLastErrorCode()));
|
||||||
|
|
||||||
pool.freeBindings.Resize(MaxSet, true);
|
pool.freeBindings.Resize(MaxSet, true);
|
||||||
pool.storage = std::make_unique<DescriptorPool::BindingStorage[]>(MaxSet);
|
pool.storage = std::make_unique<DescriptorPool::BindingStorage[]>(MaxSet);
|
||||||
|
|
@ -100,10 +102,10 @@ namespace Nz
|
||||||
if (freeBindingId == pool.freeBindings.npos)
|
if (freeBindingId == pool.freeBindings.npos)
|
||||||
return {}; //< No free binding in this pool
|
return {}; //< No free binding in this pool
|
||||||
|
|
||||||
Vk::DescriptorSet descriptorSet = pool.descriptorPool.AllocateDescriptorSet(m_descriptorSetLayout);
|
Vk::DescriptorSet descriptorSet = pool.descriptorPool->AllocateDescriptorSet(m_descriptorSetLayout);
|
||||||
if (!descriptorSet)
|
if (!descriptorSet)
|
||||||
{
|
{
|
||||||
NazaraWarning("Failed to allocate descriptor set: " + TranslateVulkanError(pool.descriptorPool.GetLastErrorCode()));
|
NazaraWarning("Failed to allocate descriptor set: " + TranslateVulkanError(pool.descriptorPool->GetLastErrorCode()));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue