mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
Fix crash in CreateDescriptorSetGroup
Signed-off-by: renderexpert <expert@renderconsulting.co.uk>
This commit is contained in:
committed by
Konstantin Pastbin
parent
01c2f02c86
commit
36f123ef25
@@ -202,8 +202,7 @@ VulkanObject VulkanObjectManager::CreateImage(VkImageUsageFlags usageFlags, VkFo
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
DescriptorSetGroup VulkanObjectManager::CreateDescriptorSetGroup(ref_ptr<VulkanGpuProgram> program)
|
DescriptorSetGroup VulkanObjectManager::CreateDescriptorSetGroup(ref_ptr<VulkanGpuProgram> program) {
|
||||||
{
|
|
||||||
CHECK(std::this_thread::get_id() == m_renderers[ThreadType::Frontend], ());
|
CHECK(std::this_thread::get_id() == m_renderers[ThreadType::Frontend], ());
|
||||||
|
|
||||||
DescriptorSetGroup s;
|
DescriptorSetGroup s;
|
||||||
@@ -212,14 +211,17 @@ DescriptorSetGroup VulkanObjectManager::CreateDescriptorSetGroup(ref_ptr<VulkanG
|
|||||||
|
|
||||||
// Find a pool with available sets.
|
// Find a pool with available sets.
|
||||||
uint32_t poolIndex = 0;
|
uint32_t poolIndex = 0;
|
||||||
while (poolIndex < m_descriptorPools.size() && m_descriptorPools[poolIndex].m_availableSetsCount == 0)
|
while (poolIndex <= m_descriptorPools.size())
|
||||||
++poolIndex;
|
{
|
||||||
|
|
||||||
// No such a pool, create one.
|
// No such a pool, create one.
|
||||||
if (poolIndex == m_descriptorPools.size())
|
if (poolIndex == m_descriptorPools.size())
|
||||||
{
|
|
||||||
CreateDescriptorPool();
|
CreateDescriptorPool();
|
||||||
poolIndex = m_descriptorPools.size() - 1;
|
|
||||||
|
// No available sets in the pool, try next one.
|
||||||
|
if (m_descriptorPools[poolIndex].m_availableSetsCount == 0)
|
||||||
|
{
|
||||||
|
poolIndex++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate a descriptor set.
|
// Allocate a descriptor set.
|
||||||
@@ -232,6 +234,22 @@ DescriptorSetGroup VulkanObjectManager::CreateDescriptorSetGroup(ref_ptr<VulkanG
|
|||||||
// Decrease the available sets count.
|
// Decrease the available sets count.
|
||||||
m_descriptorPools[poolIndex].m_availableSetsCount--;
|
m_descriptorPools[poolIndex].m_availableSetsCount--;
|
||||||
|
|
||||||
|
auto const r = vkAllocateDescriptorSets(m_device, &allocInfo, &s.m_descriptorSet);
|
||||||
|
if (r == VK_ERROR_FRAGMENTED_POOL || r == VK_ERROR_OUT_OF_POOL_MEMORY)
|
||||||
|
{
|
||||||
|
poolIndex++;
|
||||||
|
m_descriptorPools[poolIndex].m_availableSetsCount++;
|
||||||
|
}
|
||||||
|
else if (r != VK_SUCCESS)
|
||||||
|
{
|
||||||
|
CHECK_VK_CALL(r);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TRACE_COUNTER("[drape][vulkan] Descriptor pools", static_cast<int64_t>(m_descriptorPools.size()));
|
TRACE_COUNTER("[drape][vulkan] Descriptor pools", static_cast<int64_t>(m_descriptorPools.size()));
|
||||||
#ifdef ENABLE_TRACE
|
#ifdef ENABLE_TRACE
|
||||||
int64_t usedDescriptorsSets = 0;
|
int64_t usedDescriptorsSets = 0;
|
||||||
@@ -240,7 +258,6 @@ DescriptorSetGroup VulkanObjectManager::CreateDescriptorSetGroup(ref_ptr<VulkanG
|
|||||||
TRACE_COUNTER("[drape][vulkan] Descriptor sets", usedDescriptorsSets);
|
TRACE_COUNTER("[drape][vulkan] Descriptor sets", usedDescriptorsSets);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CHECK_VK_CALL(vkAllocateDescriptorSets(m_device, &allocInfo, &s.m_descriptorSet));
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user