From 0d8a1a411ad53f36157354d3a9001f3994876bc0 Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Thu, 12 Mar 2026 23:37:18 +1100 Subject: Fix leaks via owner class wrappers on some vulkan objects --- src/queue_context.hh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/queue_context.hh') diff --git a/src/queue_context.hh b/src/queue_context.hh index 0e6441e..701fc0d 100644 --- a/src/queue_context.hh +++ b/src/queue_context.hh @@ -24,7 +24,7 @@ class QueueContext final : public Context { // The amount of queue submissions we allow tracked per queue before // we give up tracking them. For a queue that is presented to, // these submissions will be constantly moved to Frame structs so - // it's not an issue that we only track so many - unless it just + // it's not an issue that we only track so many - unless it just // happens that an application makes an unexpectedly large // amount of vkQueueSubmit's per frame. For queues which don't // present, this limit stops them from growing limitlessly in memory @@ -37,7 +37,23 @@ class QueueContext final : public Context { const VkQueue queue; const std::uint32_t queue_family_index; - VkCommandPool command_pool; + struct CommandPoolOwner final { + private: + const QueueContext& queue_context; + VkCommandPool command_pool; + + public: + CommandPoolOwner(const QueueContext& queue_context); + CommandPoolOwner(const CommandPoolOwner&) = delete; + CommandPoolOwner(CommandPoolOwner&&) = delete; + CommandPoolOwner operator=(const CommandPoolOwner&) = delete; + CommandPoolOwner operator=(CommandPoolOwner&&) = delete; + ~CommandPoolOwner(); + + public: + operator const VkCommandPool&() const { return this->command_pool; } + }; + const std::unique_ptr command_pool; std::unique_ptr timestamp_pool; -- cgit v1.2.3