@@ -33,6 +33,7 @@ static PFN_vkAllocateCommandBuffers o_vkAllocateCommandBuffers = nullptr;
3333static PFN_vkDestroyCommandPool o_vkDestroyCommandPool = nullptr ;
3434static PFN_vkCreateCommandPool o_vkCreateCommandPool = nullptr ;
3535
36+ static std::mutex mutexCommandPoolToQueueFamilyMap;
3637static std::unordered_map<VkCommandPool, uint32_t > commandPoolToQueueFamilyMap;
3738
3839// #define LOG_ALL_RECORDS
@@ -6055,7 +6056,10 @@ VkResult hk_vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo*
60556056
60566057 if (result == VK_SUCCESS && pCommandPool && *pCommandPool != VK_NULL_HANDLE && pCreateInfo)
60576058 {
6058- commandPoolToQueueFamilyMap[*pCommandPool] = pCreateInfo->queueFamilyIndex ;
6059+ {
6060+ std::scoped_lock lock (mutexCommandPoolToQueueFamilyMap);
6061+ commandPoolToQueueFamilyMap[*pCommandPool] = pCreateInfo->queueFamilyIndex ;
6062+ }
60596063
60606064 LOG_DEBUG (" Command pool {:X} created for queue family {}" , (size_t ) *pCommandPool,
60616065 pCreateInfo->queueFamilyIndex );
@@ -7179,8 +7183,13 @@ VkResult Vulkan_wDx12::hk_vkAllocateCommandBuffers(VkDevice device, const VkComm
71797183
71807184 if (result == VK_SUCCESS && pAllocateInfo != nullptr && pCommandBuffers != nullptr )
71817185 {
7182- auto it = commandPoolToQueueFamilyMap.find (pAllocateInfo->commandPool );
7183- uint32_t queueFamily = (it != commandPoolToQueueFamilyMap.end ()) ? it->second : 0 ;
7186+ uint32_t queueFamily = 0 ;
7187+
7188+ {
7189+ std::scoped_lock lock (mutexCommandPoolToQueueFamilyMap);
7190+ auto it = commandPoolToQueueFamilyMap.find (pAllocateInfo->commandPool );
7191+ queueFamily = (it != commandPoolToQueueFamilyMap.end ()) ? it->second : 0 ;
7192+ }
71847193
71857194 // Notify state tracker about new command buffers
71867195 cmdBufferStateTracker.OnAllocateCommandBuffers (pAllocateInfo->commandPool , pAllocateInfo->commandBufferCount ,
0 commit comments