diff --git a/source_common/trackers/command_buffer.hpp b/source_common/trackers/command_buffer.hpp index 69ba601..827694e 100644 --- a/source_common/trackers/command_buffer.hpp +++ b/source_common/trackers/command_buffer.hpp @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: MIT * ---------------------------------------------------------------------------- - * Copyright (c) 2022-2024 Arm Limited + * Copyright (c) 2022-2026 Arm Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -240,6 +240,8 @@ class CommandBuffer */ class CommandPool { + using CommandBufferMap = std::unordered_map>; + public: /** * @brief Construct a new command pool wrapping a Vulkan allocation. @@ -264,6 +266,16 @@ class CommandPool */ void freeCommandBuffer(VkCommandBuffer commandBuffer); + /** + * @brief Return view onto the allocated command buffers in the pool. + * + * @return A read-only view of the command buffer mapping. + */ + const CommandBufferMap& getCommandBuffers() + { + return commandBuffers; + } + /** * @brief Reset all allocated command buffers into the @a Initial state. */ @@ -278,7 +290,7 @@ class CommandPool /** * @brief The command buffers currently allocated in this command pool. */ - std::unordered_map> commandBuffers; + CommandBufferMap commandBuffers; }; } diff --git a/source_common/trackers/device.cpp b/source_common/trackers/device.cpp index bc65eaa..3e734e8 100644 --- a/source_common/trackers/device.cpp +++ b/source_common/trackers/device.cpp @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: MIT * ---------------------------------------------------------------------------- - * Copyright (c) 2022-2024 Arm Limited + * Copyright (c) 2022-2026 Arm Limited * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -46,6 +46,15 @@ CommandPool& Device::getCommandPool(VkCommandPool commandPool) /* See header for documentation. */ void Device::destroyCommandPool(VkCommandPool commandPool) { + auto& pool = getCommandPool(commandPool); + + // Release command buffer trackers for command buffers still allocated + for (auto& cb : pool.getCommandBuffers()) + { + commandBuffers.erase(cb.first); + } + + // Release the pool itself commandPools.erase(commandPool); } diff --git a/source_common/utils/misc.hpp b/source_common/utils/misc.hpp index 8cb4ffb..ae0aa59 100644 --- a/source_common/utils/misc.hpp +++ b/source_common/utils/misc.hpp @@ -163,7 +163,7 @@ static inline bool isInExtensionList( uint32_t extensionCount, const char* const* extensionList ) { - for(uint32_t i = 0; i < extensionCount; i++) + for (uint32_t i = 0; i < extensionCount; i++) { if (target == extensionList[i]) {