vk: On pool recovery, rescan the subpool table in case a new pool really cannot be created

This commit is contained in:
kd-11 2023-06-12 23:48:21 +03:00 committed by kd-11
parent c1d875d841
commit 29f3eec957
1 changed files with 18 additions and 11 deletions

View File

@ -228,6 +228,11 @@ namespace vk
m_current_subpool_offset = 0; m_current_subpool_offset = 0;
m_current_subpool_index = umax; m_current_subpool_index = umax;
// Only attempt recovery once. Can be bumped up if we have a more complex setup in future.
int retries = 1;
while (m_current_subpool_index == umax)
{
for (u32 index = 0; index < m_device_subpools.size(); ++index) for (u32 index = 0; index < m_device_subpools.size(); ++index)
{ {
if (!m_device_subpools[index].busy) if (!m_device_subpools[index].busy)
@ -237,14 +242,14 @@ namespace vk
} }
} }
if (m_current_subpool_index == umax) if (m_current_subpool_index != umax)
{ {
// We found something, exit early
break;
}
VkDescriptorPool subpool = VK_NULL_HANDLE; VkDescriptorPool subpool = VK_NULL_HANDLE;
if (VkResult result = vkCreateDescriptorPool(*m_owner, &m_create_info, nullptr, &subpool))
// Only attempt recovery once. Can be bumped up if we have a more complex setup in future.
int retries = 1;
while (VkResult result = vkCreateDescriptorPool(*m_owner, &m_create_info, nullptr, &subpool))
{ {
if (retries-- && (result == VK_ERROR_FRAGMENTATION_EXT)) if (retries-- && (result == VK_ERROR_FRAGMENTATION_EXT))
{ {
@ -254,8 +259,10 @@ namespace vk
} }
vk::die_with_error(result); vk::die_with_error(result);
break;
} }
// New subpool created successfully
std::lock_guard lock(m_subpool_lock); std::lock_guard lock(m_subpool_lock);
m_device_subpools.push_back( m_device_subpools.push_back(