Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions source_common/trackers/command_buffer.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -240,6 +240,8 @@ class CommandBuffer
*/
class CommandPool
{
using CommandBufferMap = std::unordered_map<VkCommandBuffer, std::unique_ptr<CommandBuffer>>;

public:
/**
* @brief Construct a new command pool wrapping a Vulkan allocation.
Expand All @@ -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.
*/
Expand All @@ -278,7 +290,7 @@ class CommandPool
/**
* @brief The command buffers currently allocated in this command pool.
*/
std::unordered_map<VkCommandBuffer, std::unique_ptr<CommandBuffer>> commandBuffers;
CommandBufferMap commandBuffers;
};

}
11 changes: 10 additions & 1 deletion source_common/trackers/device.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion source_common/utils/misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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])
{
Expand Down
Loading