diff options
| author | Nicolas James <nj3ahxac@gmail.com> | 2026-03-12 23:37:18 +1100 |
|---|---|---|
| committer | Nicolas James <nj3ahxac@gmail.com> | 2026-03-12 23:37:18 +1100 |
| commit | 0d8a1a411ad53f36157354d3a9001f3994876bc0 (patch) | |
| tree | 27054ee9d95cb0d971f9f159bc538b44cd32da90 /src/queue_context.hh | |
| parent | 8ea01a571be073be00f8a77150f3d62ef5600b52 (diff) | |
Fix leaks via owner class wrappers on some vulkan objects
Diffstat (limited to 'src/queue_context.hh')
| -rw-r--r-- | src/queue_context.hh | 20 |
1 files changed, 18 insertions, 2 deletions
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<CommandPoolOwner> command_pool; std::unique_ptr<TimestampPool> timestamp_pool; |
