From 29f3eec957ae2ab48c417a2d1189a876253d25d7 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Mon, 12 Jun 2023 23:48:21 +0300 Subject: [PATCH] vk: On pool recovery, rescan the subpool table in case a new pool really cannot be created --- rpcs3/Emu/RSX/VK/vkutils/descriptors.cpp | 29 +++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/rpcs3/Emu/RSX/VK/vkutils/descriptors.cpp b/rpcs3/Emu/RSX/VK/vkutils/descriptors.cpp index d9d4101eee..d7ec16a58a 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/descriptors.cpp +++ b/rpcs3/Emu/RSX/VK/vkutils/descriptors.cpp @@ -228,23 +228,28 @@ namespace vk m_current_subpool_offset = 0; m_current_subpool_index = umax; - for (u32 index = 0; index < m_device_subpools.size(); ++index) + // 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) { - if (!m_device_subpools[index].busy) + for (u32 index = 0; index < m_device_subpools.size(); ++index) { - m_current_subpool_index = index; + if (!m_device_subpools[index].busy) + { + m_current_subpool_index = index; + break; + } + } + + if (m_current_subpool_index != umax) + { + // We found something, exit early break; } - } - if (m_current_subpool_index == umax) - { VkDescriptorPool subpool = VK_NULL_HANDLE; - - // 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 (VkResult result = vkCreateDescriptorPool(*m_owner, &m_create_info, nullptr, &subpool)) { if (retries-- && (result == VK_ERROR_FRAGMENTATION_EXT)) { @@ -254,8 +259,10 @@ namespace vk } vk::die_with_error(result); + break; } + // New subpool created successfully std::lock_guard lock(m_subpool_lock); m_device_subpools.push_back(