From a3e474a17bdfafb3e18b47ecf31058873996ac2d Mon Sep 17 00:00:00 2001 From: Andres Rodriguez Date: Tue, 29 Oct 2024 16:27:16 -0700 Subject: [PATCH] Fix a CVulkanCmdBuffer leak that could result in screenshot request failures CVulkanDevice::resetCmdBuffers expects m_pendingCmdBufs to be sorted. Using an unordered_map can result in cases where we eagerly exit out of the loop without fully cleaning all the relevant resources. This will result in leaking the command buffer and any resources it transitively references. This can be a problem for screenshots as there are only two screenshot image slots available. If we leak references to these images, at some point we won't be able to allocate new images for screenshot capture and the operation will fail. --- src/rendervulkan.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rendervulkan.hpp b/src/rendervulkan.hpp index b967e849f..b5371703c 100644 --- a/src/rendervulkan.hpp +++ b/src/rendervulkan.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -863,7 +864,7 @@ class CVulkanDevice VkSemaphore m_scratchTimelineSemaphore; std::atomic m_submissionSeqNo = { 0 }; std::vector> m_unusedCmdBufs; - std::unordered_map> m_pendingCmdBufs; + std::map> m_pendingCmdBufs; }; struct TextureState