From 62e282246efb7d9811bc275e79ffbd8e2fab9399 Mon Sep 17 00:00:00 2001 From: FakeMichau <49685661+FakeMichau@users.noreply.github.com> Date: Sat, 14 Jun 2025 15:20:06 +0200 Subject: [PATCH] Fix fps cap, add warning, only apply to Vulkan --- OptiScaler/hooks/Streamline_Hooks.cpp | 8 +++++- OptiScaler/menu/menu_common.cpp | 36 +++++++++++++++------------ OptiScaler/nvapi/ReflexHooks.cpp | 2 ++ OptiScaler/nvapi/ReflexHooks.h | 1 + 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/OptiScaler/hooks/Streamline_Hooks.cpp b/OptiScaler/hooks/Streamline_Hooks.cpp index 65d9d4b1..a4f76d22 100644 --- a/OptiScaler/hooks/Streamline_Hooks.cpp +++ b/OptiScaler/hooks/Streamline_Hooks.cpp @@ -7,6 +7,7 @@ #include #include #include +#include // interposer decltype(&slInit) StreamlineHooks::o_slInit = nullptr; @@ -169,7 +170,10 @@ bool StreamlineHooks::hkdlssg_slOnPluginLoad(void* params, const char* loaderJSO sl::Result StreamlineHooks::hkslDLSSGSetOptions(const sl::ViewportHandle& viewport, const sl::DLSSGOptions& options) { + if (State::Instance().api != API::Vulkan) + return o_slDLSSGSetOptions(viewport, options); + // Only matters for Vulkan, DX doesn't use this delay if (options.mode != sl::DLSSGMode::eOff && !MenuOverlayBase::IsVisible()) State::Instance().delayMenuRenderBy = 10; @@ -180,10 +184,12 @@ sl::Result StreamlineHooks::hkslDLSSGSetOptions(const sl::ViewportHandle& viewpo newOptions.flags |= sl::DLSSGFlags::eRetainResourcesWhenOff; LOG_TRACE("DLSSG Modified Mode: {}", (uint32_t) newOptions.mode); + ReflexHooks::setDlssgDetectedState(false); return o_slDLSSGSetOptions(viewport, newOptions); } - LOG_TRACE("DLSSG Mode: {}", (uint32_t) options.mode); + // Can't tell if eAuto means enabled or disabled + ReflexHooks::setDlssgDetectedState(options.mode == sl::DLSSGMode::eOn); return o_slDLSSGSetOptions(viewport, options); } diff --git a/OptiScaler/menu/menu_common.cpp b/OptiScaler/menu/menu_common.cpp index 7b937f2a..f9705d16 100644 --- a/OptiScaler/menu/menu_common.cpp +++ b/OptiScaler/menu/menu_common.cpp @@ -2361,27 +2361,31 @@ bool MenuCommon::RenderMenu() Config::Instance()->MakeDepthCopy = makeDepthCopy; ShowHelpMarker("Makes a copy of the depth buffer\nCan fix broken visuals in some games on AMD " "GPUs under Windows\nCan cause stutters so best to use only when necessary"); + } + else if (State::Instance().api == Vulkan) + { + ImGui::TextColored(ImVec4(1.f, 0.8f, 0.f, 1.f), "DLSSG is purposefully disabled when this menu is visible"); + ImGui::Spacing(); + } - if (DLSSGMod::isLoaded()) + if (DLSSGMod::isLoaded()) + { + if (DLSSGMod::is120orNewer()) { - if (DLSSGMod::is120orNewer()) + if (ImGui::Checkbox("Enable Debug View", &State::Instance().DLSSGDebugView)) { - if (ImGui::Checkbox("Enable Debug View", &State::Instance().DLSSGDebugView)) - { - DLSSGMod::setDebugView(State::Instance().DLSSGDebugView); - } - if (ImGui::Checkbox("Interpolated frames only", - &State::Instance().DLSSGInterpolatedOnly)) - { - DLSSGMod::setInterpolatedOnly(State::Instance().DLSSGInterpolatedOnly); - } + DLSSGMod::setDebugView(State::Instance().DLSSGDebugView); } - else if (DLSSGMod::FSRDebugView() != nullptr) + if (ImGui::Checkbox("Interpolated frames only", &State::Instance().DLSSGInterpolatedOnly)) { - if (ImGui::Checkbox("Enable Debug View", &State::Instance().DLSSGDebugView)) - { - DLSSGMod::FSRDebugView()(State::Instance().DLSSGDebugView); - } + DLSSGMod::setInterpolatedOnly(State::Instance().DLSSGInterpolatedOnly); + } + } + else if (DLSSGMod::FSRDebugView() != nullptr) + { + if (ImGui::Checkbox("Enable Debug View", &State::Instance().DLSSGDebugView)) + { + DLSSGMod::FSRDebugView()(State::Instance().DLSSGDebugView); } } } diff --git a/OptiScaler/nvapi/ReflexHooks.cpp b/OptiScaler/nvapi/ReflexHooks.cpp index 572de1f3..ca023b41 100644 --- a/OptiScaler/nvapi/ReflexHooks.cpp +++ b/OptiScaler/nvapi/ReflexHooks.cpp @@ -151,6 +151,8 @@ void ReflexHooks::hookReflex(PFN_NvApi_QueryInterface& queryInterface) bool ReflexHooks::isDlssgDetected() { return _dlssgDetected; } +void ReflexHooks::setDlssgDetectedState(bool state) { _dlssgDetected = state; } + bool ReflexHooks::isReflexHooked() { return _inited; } void* ReflexHooks::getHookedReflex(unsigned int InterfaceId) diff --git a/OptiScaler/nvapi/ReflexHooks.h b/OptiScaler/nvapi/ReflexHooks.h index 7b9f0857..98d31dec 100644 --- a/OptiScaler/nvapi/ReflexHooks.h +++ b/OptiScaler/nvapi/ReflexHooks.h @@ -42,6 +42,7 @@ class ReflexHooks public: static void hookReflex(PFN_NvApi_QueryInterface& queryInterface); static bool isDlssgDetected(); + static void setDlssgDetectedState(bool state); static bool isReflexHooked(); static void* getHookedReflex(unsigned int InterfaceId);