Skip to content

Commit a2c8ef1

Browse files
committed
Mutex the access to commandPoolToQueueFamilyMap
1 parent f73a2f9 commit a2c8ef1

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

OptiScaler/Config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ class Config
310310
L"idtechlauncher.exe|cefviewwing.exe|ace-setup64.exe|ace-service64.exe|qtwebengineprocess.exe|"
311311
L"platformprocess.exe|bugsplathd64.exe|bssndrpt64.exe|pspcsdkappmgr.exe|pspcsdkcore.exe|pspcsdkstttts.exe|"
312312
L"pspcsdktelemetry.exe|pspcsdkui.exe|pspcsdkupdatechecker.exe|pspcsdkvoicechat.exe|pspcsdkwebview.exe|windhawk."
313-
L"exe|vscodium.exe|crash_reporter.exe|steamerrorreporter64.exe"
313+
L"exe|vscodium.exe|crash_reporter.exe|steamerrorreporter64.exe|crashreportclient.exe"
314314
};
315315

316316
// Hotfixes

OptiScaler/hooks/VulkanwDx12_Hooks.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static PFN_vkAllocateCommandBuffers o_vkAllocateCommandBuffers = nullptr;
3333
static PFN_vkDestroyCommandPool o_vkDestroyCommandPool = nullptr;
3434
static PFN_vkCreateCommandPool o_vkCreateCommandPool = nullptr;
3535

36+
static std::mutex mutexCommandPoolToQueueFamilyMap;
3637
static 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

Comments
 (0)