aboutsummaryrefslogtreecommitdiff
path: root/icd
diff options
context:
space:
mode:
authorDaniel Rakos <daniel.rakos@rastergrid.com>2023-06-22 11:20:54 +0200
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2023-06-22 11:07:13 -0600
commit8cf2cdd2c9d53cb26a4e32b7e677bf7e37900cfc (patch)
tree6e0967140e0bb201ffbe4fc142a0750f099d4999 /icd
parent41c8e28fe2db3ea620c85804492fdecd287d4b87 (diff)
downloadusermoji-8cf2cdd2c9d53cb26a4e32b7e677bf7e37900cfc.tar.xz
mock: Fix memory leak issue
Diffstat (limited to 'icd')
-rw-r--r--icd/generated/function_definitions.h10
-rw-r--r--icd/mock_icd.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/icd/generated/function_definitions.h b/icd/generated/function_definitions.h
index 5eb09156..d5a7a343 100644
--- a/icd/generated/function_definitions.h
+++ b/icd/generated/function_definitions.h
@@ -250,6 +250,14 @@ static VKAPI_ATTR void VKAPI_CALL DestroyDevice(
}
}
+ for (auto& cp : command_pool_map[device]) {
+ for (auto& cb : command_pool_buffer_map[cp]) {
+ DestroyDispObjHandle((void*) cb);
+ }
+ command_pool_buffer_map.erase(cp);
+ }
+ command_pool_map[device].clear();
+
queue_map.erase(device);
buffer_map.erase(device);
image_memory_size_map.erase(device);
@@ -1095,6 +1103,7 @@ static VKAPI_ATTR VkResult VKAPI_CALL CreateCommandPool(
{
unique_lock_t lock(global_lock);
*pCommandPool = (VkCommandPool)global_unique_handle++;
+ command_pool_map[device].insert(*pCommandPool);
return VK_SUCCESS;
}
@@ -1113,6 +1122,7 @@ static VKAPI_ATTR void VKAPI_CALL DestroyCommandPool(
}
command_pool_buffer_map.erase(it);
}
+ command_pool_map[device].erase(commandPool);
}
static VKAPI_ATTR VkResult VKAPI_CALL ResetCommandPool(
diff --git a/icd/mock_icd.h b/icd/mock_icd.h
index dd712bcd..4210ed30 100644
--- a/icd/mock_icd.h
+++ b/icd/mock_icd.h
@@ -22,6 +22,7 @@
#include <algorithm>
#include <array>
#include <mutex>
+#include <unordered_set>
#include <unordered_map>
#include <string>
#include <vector>
@@ -64,6 +65,7 @@ struct BufferState {
};
static std::unordered_map<VkDevice, std::unordered_map<VkBuffer, BufferState>> buffer_map;
static std::unordered_map<VkDevice, std::unordered_map<VkImage, VkDeviceSize>> image_memory_size_map;
+static std::unordered_map<VkDevice, std::unordered_set<VkCommandPool>> command_pool_map;
static std::unordered_map<VkCommandPool, std::vector<VkCommandBuffer>> command_pool_buffer_map;
static constexpr uint32_t icd_swapchain_image_count = 1;