Skip to content

Commit

Permalink
rendervulkan: Fix a CVulkanCmdBuffer leak that could result in screen…
Browse files Browse the repository at this point in the history
…shot 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.
  • Loading branch information
lostgoat authored Oct 29, 2024
1 parent 056b79e commit 7dd1bcd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/rendervulkan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <atomic>
#include <stdint.h>
#include <memory>
#include <map>
#include <unordered_map>
#include <array>
#include <bitset>
Expand Down Expand Up @@ -863,7 +864,7 @@ class CVulkanDevice
VkSemaphore m_scratchTimelineSemaphore;
std::atomic<uint64_t> m_submissionSeqNo = { 0 };
std::vector<std::unique_ptr<CVulkanCmdBuffer>> m_unusedCmdBufs;
std::unordered_map<uint64_t, std::unique_ptr<CVulkanCmdBuffer>> m_pendingCmdBufs;
std::map<uint64_t, std::unique_ptr<CVulkanCmdBuffer>> m_pendingCmdBufs;
};

struct TextureState
Expand Down

0 comments on commit 7dd1bcd

Please sign in to comment.