From e6265b06115bc7dbb719abfe6e81c90ffbb3a3c2 Mon Sep 17 00:00:00 2001 From: cdozdil Date: Wed, 29 Jan 2025 13:57:23 +0300 Subject: [PATCH] revise menu for DLSS, DLSS-G & FSR-FG options --- OptiScaler/State.h | 3 ++ OptiScaler/dllmain.cpp | 6 +++ OptiScaler/menu/menu_common.cpp | 65 +++++++++++++++++++++++++++++---- 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/OptiScaler/State.h b/OptiScaler/State.h index 030f2b43..09c0c95f 100644 --- a/OptiScaler/State.h +++ b/OptiScaler/State.h @@ -28,6 +28,8 @@ public: // DLSSG GameQuirk gameQuirk = GameQuirk::Other; + bool NukemsFilesAvailable = false; + bool DlssGIsActive = false; // FSR Common float lastFsrCameraNear = 0.0f; @@ -39,6 +41,7 @@ public: bool SCchanged = false; bool skipHeapCapture = false; bool useThreadingForHeaps = false; + bool FsrFgIsActive = false; bool FGcaptureResources = false; int FGcapturedResourceCount = false; diff --git a/OptiScaler/dllmain.cpp b/OptiScaler/dllmain.cpp index ce2c5e6c..8e8229ae 100644 --- a/OptiScaler/dllmain.cpp +++ b/OptiScaler/dllmain.cpp @@ -2275,6 +2275,8 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv HookFSR2ExeInputs(); + spdlog::info(""); + CheckQuirks(); spdlog::info(""); CheckQuirks(); @@ -2290,6 +2292,10 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv State::Instance().skipDllLoadChecks = false; + // Initial state of FSR-FG + State::Instance().FsrFgIsActive = Config::Instance()->FGUseFGSwapChain.value_or_default(); + State::Instance().DlssGIsActive = Config::Instance()->DLSSGMod.value_or_default(); + for (size_t i = 0; i < 300; i++) { State::Instance().frameTimes.push_back(0.0f); diff --git a/OptiScaler/menu/menu_common.cpp b/OptiScaler/menu/menu_common.cpp index 00f0538f..5a960a97 100644 --- a/OptiScaler/menu/menu_common.cpp +++ b/OptiScaler/menu/menu_common.cpp @@ -3,6 +3,7 @@ #include "font/Hack_Compressed.h" #include #include +#include #include @@ -778,6 +779,8 @@ bool MenuCommon::RenderMenu() if (_isVisible) { Config::Instance()->ReloadFakenvapi(); + auto dllPath = Util::DllPath().parent_path() / "dlssg_to_fsr3_amd_is_better.dll"; + State::Instance().NukemsFilesAvailable = std::filesystem::exists(dllPath); if (pfn_ClipCursor_hooked) { @@ -1201,17 +1204,29 @@ bool MenuCommon::RenderMenu() if (ImGui::Button("Revert")) State::Instance().newBackend = ""; } - - // DYNAMIC PROPERTIES ----------------------------- + } // Frame Generation - if (Config::Instance()->FGUseFGSwapChain.value_or_default() && Config::Instance()->OverlayMenu.value_or_default() && - State::Instance().api == DX12 && !State::Instance().isWorkingAsNvngx) + if (Config::Instance()->OverlayMenu.value_or_default() && State::Instance().api == DX12 && !State::Instance().isWorkingAsNvngx) { - ImGui::SeparatorText("Frame Generation (Dx12)"); + ImGui::SeparatorText("Frame Generation (OptiFG)"); + auto fsrFgActive = Config::Instance()->FGUseFGSwapChain.value_or_default(); + if (ImGui::Checkbox("Frame Generation Enabled", &fsrFgActive)) + { + Config::Instance()->FGUseFGSwapChain = fsrFgActive; + + if (fsrFgActive) + Config::Instance()->DLSSGMod = false; + else + Config::Instance()->DLSSGMod.reset(); + } + ShowHelpMarker("These settings will become active on next boot!"); + + if (State::Instance().FsrFgIsActive && currentFeature != nullptr && FfxApiProxy::InitFfxDx12()) + { bool fgActive = Config::Instance()->FGEnabled.value_or_default(); - if (ImGui::Checkbox("Frame Generation", &fgActive)) + if (ImGui::Checkbox("FG Active", &fgActive)) { Config::Instance()->FGEnabled = fgActive; LOG_DEBUG("Enabled set FGEnabled: {}", fgActive); @@ -1220,7 +1235,7 @@ bool MenuCommon::RenderMenu() State::Instance().FGchanged = true; } - ShowHelpMarker("Enable FSR frame generation"); + ShowHelpMarker("Enable frame generation (OptiFG)"); bool fgHudfix = Config::Instance()->FGHUDFix.value_or_default(); if (ImGui::Checkbox("FG HUD Fix", &fgHudfix)) @@ -1420,9 +1435,33 @@ bool MenuCommon::RenderMenu() } // DLSSG Mod - if (Config::Instance()->DLSSGMod.value_or_default() && State::Instance().api != DX11 && !State::Instance().isWorkingAsNvngx) { + if (State::Instance().api != DX11 && !State::Instance().isWorkingAsNvngx) + { ImGui::SeparatorText("Frame Generation (DLSSG)"); + auto dlssgEnabled = Config::Instance()->DLSSGMod.value_or_default(); + if (ImGui::Checkbox("DLSSG Enabled", &dlssgEnabled)) + { + Config::Instance()->DLSSGMod = dlssgEnabled; + + if (dlssgEnabled) + Config::Instance()->FGUseFGSwapChain = false; + else + Config::Instance()->FGUseFGSwapChain.reset(); + } + ShowHelpMarker("These settings will become active on next boot!"); + + if(Config::Instance()->DLSSGMod.value_or_default() && !State::Instance().NukemsFilesAvailable) + ImGui::TextColored(ImVec4(1.f, 0.f, 0.f, 1.f), "Please put dlssg_to_fsr3_amd_is_better.dll next to OptiScaler"); + + if (Config::Instance()->AdvancedSettings.value_or_default()) + { + auto hagsSpoofing = Config::Instance()->SpoofHAGS.value_or(dlssgEnabled); + if (ImGui::Checkbox("HAGS Spoofing Enabled", &hagsSpoofing)) + Config::Instance()->SpoofHAGS = hagsSpoofing; + } + + if (State::Instance().DlssGIsActive) { if (!ReflexHooks::isReflexHooked()) { ImGui::TextColored(ImVec4(1.f, 0.f, 0.f, 1.f), "Reflex not hooked"); ImGui::Text("If you are using an AMD/Intel GPU then make sure you have fakenvapi"); @@ -1444,6 +1483,7 @@ bool MenuCommon::RenderMenu() 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"); } } + } if (currentFeature != nullptr) { // Dx11 with Dx12 @@ -1621,6 +1661,7 @@ bool MenuCommon::RenderMenu() } } + // FSR Common ----------------- if (Config::Instance()->FGUseFGSwapChain.value_or_default() || currentBackend.rfind("fsr", 0) == 0) { SeparatorWithHelpMarker("FSR Common Settings", "Affects both FSR-FG & Upscalers"); @@ -1729,6 +1770,14 @@ bool MenuCommon::RenderMenu() AddRenderPreset("Balanced Preset", &Config::Instance()->RenderPresetBalanced); AddRenderPreset("Perf Preset", &Config::Instance()->RenderPresetPerformance); AddRenderPreset("UltraP Preset", &Config::Instance()->RenderPresetUltraPerformance); + + bool appIdOverride = Config::Instance()->UseGenericAppIdWithDlss.value_or_default(); + if (ImGui::Checkbox("Use Generic App Id with DLSS", &appIdOverride)) + Config::Instance()->UseGenericAppIdWithDlss = appIdOverride; + + ShowHelpMarker("Use generic appid with NGX\n" + "Fixes OptiScaler preset override not working with certain games\n" + "Requires a game restart."); } // RCAS -----------------