Skip to content

Commit d3fb0c3

Browse files
committed
Prevent a loop where getPrimaryGpuVulkan calls itself
1 parent 500369e commit d3fb0c3

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

OptiScaler/spoofing/Vulkan_Spoofing.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,18 +229,10 @@ VkResult VulkanSpoofing::hkvkCreateInstance(VkInstanceCreateInfo* pCreateInfo, c
229229
if (pCreateInfo == nullptr)
230230
return VK_ERROR_INITIALIZATION_FAILED;
231231

232-
bool skipExtensions = false;
232+
thread_local bool skipExtensions = false;
233233
if (pCreateInfo->pApplicationInfo != nullptr && pCreateInfo->pApplicationInfo->pApplicationName != nullptr)
234234
{
235235
LOG_DEBUG("ApplicationName: {}", pCreateInfo->pApplicationInfo->pApplicationName);
236-
237-
// WAR: Something gets stuck trying to create instance with this name
238-
// probably doesn't need extension changes anyway as enabledExtensionCount == 0
239-
if (pCreateInfo->enabledExtensionCount == 0 &&
240-
std::string(pCreateInfo->pApplicationInfo->pApplicationName).contains("AdapterQuery"))
241-
{
242-
skipExtensions = true;
243-
}
244236
}
245237

246238
static std::vector<const char*> newExtensionList;
@@ -255,7 +247,18 @@ VkResult VulkanSpoofing::hkvkCreateInstance(VkInstanceCreateInfo* pCreateInfo, c
255247
newExtensionList.push_back(pCreateInfo->ppEnabledExtensionNames[i]);
256248
}
257249

250+
// To prevent a loop
251+
// Applies to hooked:
252+
// vkCreateInstance
253+
// vkGetInstanceProcAddr
254+
// vkEnumeratePhysicalDevices
255+
// vkGetPhysicalDeviceProperties2
256+
// vkGetPhysicalDeviceMemoryProperties
257+
// vkDestroyInstance
258+
skipExtensions = true;
258259
static auto primaryGpu = IdentifyGpu::getPrimaryGpuVulkan();
260+
skipExtensions = false;
261+
259262
if (primaryGpu.dlssCapable && Config::Instance()->DLSSEnabled.value_or_default())
260263
{
261264
LOG_INFO("Adding NVNGX Vulkan extensions");

0 commit comments

Comments
 (0)