From 9482f46fff421d99b26ceeaf9b58bfd3e23aee93 Mon Sep 17 00:00:00 2001 From: Astyyyyy Date: Sun, 26 Apr 2026 21:26:11 +0930 Subject: [PATCH 1/3] Fix gpu detection on native vulkan games --- OptiScaler/misc/IdentifyGpu.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/OptiScaler/misc/IdentifyGpu.cpp b/OptiScaler/misc/IdentifyGpu.cpp index b38b623f..6d0f8c2a 100644 --- a/OptiScaler/misc/IdentifyGpu.cpp +++ b/OptiScaler/misc/IdentifyGpu.cpp @@ -41,6 +41,8 @@ std::vector IdentifyGpu::checkGpuInfo() { auto localCachedInfo = std::vector {}; + ScopedSkipSpoofing skipSpoofing {}; + DxgiProxy::Init(); ComPtr factory = nullptr; @@ -71,10 +73,7 @@ std::vector IdentifyGpu::checkGpuInfo() continue; } - { - ScopedSkipSpoofing skipSpoofing {}; - result = adapter->GetDesc1(&adapterDesc); - } + result = adapter->GetDesc1(&adapterDesc); if (result == S_OK) { @@ -328,6 +327,8 @@ void IdentifyGpu::updateD3d12Capabilities(D3d12Proxy::PFN_D3D12CreateDevice o_D3 pD3D12CreateDevice = D3d12Proxy::D3D12CreateDevice_(); // D3D12 device is needed to be able to query amdxc and check for vkd3d-proton + ScopedCreatingD3DDevice scopedCreating {}; + ScopedSkipVulkanHooks skipVulkanHooks {}; mutex.unlock(); // To avoid VK hooks, not ideal auto createResult = pD3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_12_0, IID_PPV_ARGS(&gpuInfo.d3d12device)); From 9c673d380630a284dbe38418e5f27f47cd011dc1 Mon Sep 17 00:00:00 2001 From: Astyyyyy Date: Sun, 26 Apr 2026 21:26:14 +0930 Subject: [PATCH 2/3] Fix reflex timings overlay on native vulkan games --- OptiScaler/hooks/Reflex_Hooks.cpp | 56 ++++++++++++++++--------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/OptiScaler/hooks/Reflex_Hooks.cpp b/OptiScaler/hooks/Reflex_Hooks.cpp index e0adaf89..cebb47d3 100644 --- a/OptiScaler/hooks/Reflex_Hooks.cpp +++ b/OptiScaler/hooks/Reflex_Hooks.cpp @@ -383,6 +383,7 @@ NvAPI_Status ReflexHooks::hkNvAPI_Vulkan_SetLatencyMarker(HANDLE vkDevice, #endif _updatesWithoutMarker = 0; + State::Instance().reflexFrameId = pSetLatencyMarkerParams->frameID; return o_NvAPI_Vulkan_SetLatencyMarker(vkDevice, pSetLatencyMarkerParams); } @@ -532,41 +533,42 @@ bool ReflexHooks::updateTimingData() UPDATE_TIMING_ENTRY(osRenderQueue, OsRenderQueue) UPDATE_TIMING_ENTRY(gpuRender, GpuRender) + if (frameReport.frameID != 0) + State::Instance().reflexFrameId = frameReport.frameID; + return true; }; - if (_lastSleepDev) + if (_lastSleepDev && o_NvAPI_D3D_GetLatency) { - if (o_NvAPI_D3D_GetLatency) + // Not calling free on this but it's static so hopefully fine + static NV_LATENCY_RESULT_PARAMS* results = new NV_LATENCY_RESULT_PARAMS(); + results->version = NV_LATENCY_RESULT_PARAMS_VER; + + if (auto result = hkNvAPI_D3D_GetLatency(_lastSleepDev, results); result != NVAPI_OK) { - // Not calling free on this but it's static so hopefully fine - static NV_LATENCY_RESULT_PARAMS* results = new NV_LATENCY_RESULT_PARAMS(); - results->version = NV_LATENCY_RESULT_PARAMS_VER; - - if (auto result = hkNvAPI_D3D_GetLatency(_lastSleepDev, results); result != NVAPI_OK) - { - LOG_WARN("NvAPI_D3D_GetLatency failed: {}", magic_enum::enum_name(result)); - return false; - } - - // 64th element has the latest data - return processFrameReport(results->frameReport[63]); + LOG_WARN("NvAPI_D3D_GetLatency failed: {}", magic_enum::enum_name(result)); + return false; } - else if (o_NvAPI_Vulkan_GetLatency) + + // 64th element has the latest data + return processFrameReport(results->frameReport[63]); + } + + if (_lastVkSleepDev && o_NvAPI_Vulkan_GetLatency) + { + // Not calling free on this but it's static so hopefully fine + static NV_VULKAN_LATENCY_RESULT_PARAMS* results = new NV_VULKAN_LATENCY_RESULT_PARAMS(); + results->version = NV_VULKAN_LATENCY_RESULT_PARAMS_VER; + + if (auto result = hkNvAPI_Vulkan_GetLatency(_lastVkSleepDev, results); result != NVAPI_OK) { - // Not calling free on this but it's static so hopefully fine - static NV_VULKAN_LATENCY_RESULT_PARAMS* results = new NV_VULKAN_LATENCY_RESULT_PARAMS(); - results->version = NV_VULKAN_LATENCY_RESULT_PARAMS_VER; - - if (auto result = hkNvAPI_Vulkan_GetLatency(_lastVkSleepDev, results); result != NVAPI_OK) - { - LOG_WARN("NvAPI_Vulkan_GetLatency failed: {}", magic_enum::enum_name(result)); - return false; - } - - // 64th element has the latest data - return processFrameReport(results->frameReport[63]); + LOG_WARN("NvAPI_Vulkan_GetLatency failed: {}", magic_enum::enum_name(result)); + return false; } + + // 64th element has the latest data + return processFrameReport(results->frameReport[63]); } return false; From 804243ef8f638d0a41d5c017d667674111f29572 Mon Sep 17 00:00:00 2001 From: Astyyyyy Date: Sun, 26 Apr 2026 21:26:21 +0930 Subject: [PATCH 3/3] fix crash with vk/w dx12 --- OptiScaler/hooks/VulkanwDx12_Hooks.cpp | 32 ++++++++------------------ 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/OptiScaler/hooks/VulkanwDx12_Hooks.cpp b/OptiScaler/hooks/VulkanwDx12_Hooks.cpp index 969a0ff8..29d7b6f7 100644 --- a/OptiScaler/hooks/VulkanwDx12_Hooks.cpp +++ b/OptiScaler/hooks/VulkanwDx12_Hooks.cpp @@ -6223,17 +6223,11 @@ VkResult Vulkan_wDx12::hk_vkQueueSubmit(VkQueue queue, uint32_t submitCount, VkS syncSubmitInfo.pSignalSemaphores = signals; // move signal values to new submit - if (signalValues.size() > 0) - { - syncTimelineInfo.signalSemaphoreValueCount = - static_cast(signalValues.size()) + signalCount; - syncTimelineInfo.pSignalSemaphoreValues = signalValues.data(); - } - else - { - syncTimelineInfo.signalSemaphoreValueCount = signalCount; - syncTimelineInfo.pSignalSemaphoreValues = nullptr; - } + for (uint32_t z = 0; z < signalCount; z++) + signalValues.push_back(0); + + syncTimelineInfo.signalSemaphoreValueCount = static_cast(signalValues.size()); + syncTimelineInfo.pSignalSemaphoreValues = signalValues.data(); // prepare new submit infos list submitInfos.reserve(submitCount + 2); @@ -6614,17 +6608,11 @@ VkResult Vulkan_wDx12::hk_vkQueueSubmit(VkQueue queue, uint32_t submitCount, con syncSubmitInfo.pSignalSemaphores = signals; // move signal values to new submit - if (signalValues.size() > 0) - { - syncTimelineInfo.signalSemaphoreValueCount = - static_cast(signalValues.size()) + signalCount; - syncTimelineInfo.pSignalSemaphoreValues = signalValues.data(); - } - else - { - syncTimelineInfo.signalSemaphoreValueCount = signalCount; - syncTimelineInfo.pSignalSemaphoreValues = nullptr; - } + for (uint32_t z = 0; z < signalCount; z++) + signalValues.push_back(0); + + syncTimelineInfo.signalSemaphoreValueCount = static_cast(signalValues.size()); + syncTimelineInfo.pSignalSemaphoreValues = signalValues.data(); // prepare new submit infos list finalSubmits.reserve(submitCount + 2);