@@ -25,6 +25,7 @@ static PFN_vkAllocateCommandBuffers o_vkAllocateCommandBuffers = nullptr;
2525static PFN_vkDestroyCommandPool o_vkDestroyCommandPool = nullptr ;
2626static PFN_vkCreateCommandPool o_vkCreateCommandPool = nullptr ;
2727
28+ static std::mutex mutexCommandPoolToQueueFamilyMap;
2829static std::unordered_map<VkCommandPool, uint32_t > commandPoolToQueueFamilyMap;
2930
3031// #define LOG_ALL_RECORDS
@@ -6048,7 +6049,10 @@ VkResult Vulkan_wDx12::hk_vkCreateCommandPool(VkDevice device, const VkCommandPo
60486049
60496050 if (result == VK_SUCCESS && pCommandPool && *pCommandPool != VK_NULL_HANDLE && pCreateInfo)
60506051 {
6051- commandPoolToQueueFamilyMap[*pCommandPool] = pCreateInfo->queueFamilyIndex ;
6052+ {
6053+ std::scoped_lock lock (mutexCommandPoolToQueueFamilyMap);
6054+ commandPoolToQueueFamilyMap[*pCommandPool] = pCreateInfo->queueFamilyIndex ;
6055+ }
60526056
60536057 LOG_DEBUG (" Command pool {:X} created for queue family {}" , (size_t ) *pCommandPool,
60546058 pCreateInfo->queueFamilyIndex );
@@ -7195,8 +7199,13 @@ VkResult Vulkan_wDx12::hk_vkAllocateCommandBuffers(VkDevice device, const VkComm
71957199
71967200 if (result == VK_SUCCESS && pAllocateInfo != nullptr && pCommandBuffers != nullptr )
71977201 {
7198- auto it = commandPoolToQueueFamilyMap.find (pAllocateInfo->commandPool );
7199- uint32_t queueFamily = (it != commandPoolToQueueFamilyMap.end ()) ? it->second : 0 ;
7202+ uint32_t queueFamily = 0 ;
7203+
7204+ {
7205+ std::scoped_lock lock (mutexCommandPoolToQueueFamilyMap);
7206+ auto it = commandPoolToQueueFamilyMap.find (pAllocateInfo->commandPool );
7207+ queueFamily = (it != commandPoolToQueueFamilyMap.end ()) ? it->second : 0 ;
7208+ }
72007209
72017210 // Notify state tracker about new command buffers
72027211 cmdBufferStateTracker.OnAllocateCommandBuffers (pAllocateInfo->commandPool , pAllocateInfo->commandBufferCount ,
0 commit comments