Skip to content

Commit 73b09a8

Browse files
committed
Mutex the access to commandPoolToQueueFamilyMap
1 parent 80aecc5 commit 73b09a8

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
@@ -315,7 +315,7 @@ class Config
315315
L"idtechlauncher.exe|cefviewwing.exe|ace-setup64.exe|ace-service64.exe|qtwebengineprocess.exe|"
316316
L"platformprocess.exe|bugsplathd64.exe|bssndrpt64.exe|pspcsdkappmgr.exe|pspcsdkcore.exe|pspcsdkstttts.exe|"
317317
L"pspcsdktelemetry.exe|pspcsdkui.exe|pspcsdkupdatechecker.exe|pspcsdkvoicechat.exe|pspcsdkwebview.exe|windhawk."
318-
L"exe|vscodium.exe|crash_reporter.exe|steamerrorreporter64.exe"
318+
L"exe|vscodium.exe|crash_reporter.exe|steamerrorreporter64.exe|crashreportclient.exe"
319319
};
320320

321321
// Hotfixes

OptiScaler/hooks/VulkanwDx12_Hooks.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ static PFN_vkAllocateCommandBuffers o_vkAllocateCommandBuffers = nullptr;
2525
static PFN_vkDestroyCommandPool o_vkDestroyCommandPool = nullptr;
2626
static PFN_vkCreateCommandPool o_vkCreateCommandPool = nullptr;
2727

28+
static std::mutex mutexCommandPoolToQueueFamilyMap;
2829
static 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

Comments
 (0)