From 0c8a55f22b4e0ce4fd623a9f75b99ef7bed7ea0d Mon Sep 17 00:00:00 2001 From: FakeMichau <49685661+FakeMichau@users.noreply.github.com> Date: Tue, 30 Sep 2025 15:50:56 +0200 Subject: [PATCH] Prevent Fsr4Update from being reset on cards that support FSR 4 --- OptiScaler/Config.cpp | 3 ++- OptiScaler/Config.h | 12 ++++++++++++ OptiScaler/hooks/Kernel_Hooks.h | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/OptiScaler/Config.cpp b/OptiScaler/Config.cpp index 12d173aa..2d7e769a 100644 --- a/OptiScaler/Config.cpp +++ b/OptiScaler/Config.cpp @@ -764,7 +764,8 @@ bool Config::SaveIni() GetBoolValue(Instance()->FsrUseMaskForTransparency.value_for_config()).c_str()); ini.SetValue("FSR", "DlssReactiveMaskBias", GetFloatValue(Instance()->DlssReactiveMaskBias.value_for_config()).c_str()); - ini.SetValue("FSR", "Fsr4Update", GetBoolValue(Instance()->Fsr4Update.value_for_config()).c_str()); + ini.SetValue("FSR", "Fsr4Update", + GetBoolValue(Instance()->Fsr4Update.value_for_config_ignore_default()).c_str()); ini.SetValue("FSR", "Fsr4Model", GetIntValue(Instance()->Fsr4Model.value_for_config()).c_str()); ini.SetValue("FSR", "FsrNonLinearColorSpace", GetBoolValue(Instance()->FsrNonLinearColorSpace.value_for_config()).c_str()); diff --git a/OptiScaler/Config.h b/OptiScaler/Config.h index 40d6d76a..f5b7e75a 100644 --- a/OptiScaler/Config.h +++ b/OptiScaler/Config.h @@ -121,6 +121,18 @@ template class CustomOptio return this->value(); } + constexpr std::optional value_for_config_ignore_default() + requires(defaultState == WithDefault) + { + if (_volatile) + return _configIni; + + if (this->has_value()) + return this->value(); + + return std::nullopt; + } + constexpr std::optional value_for_config() requires(defaultState != WithDefault) { diff --git a/OptiScaler/hooks/Kernel_Hooks.h b/OptiScaler/hooks/Kernel_Hooks.h index 1a94278a..bc009109 100644 --- a/OptiScaler/hooks/Kernel_Hooks.h +++ b/OptiScaler/hooks/Kernel_Hooks.h @@ -139,7 +139,7 @@ class KernelHooks // FSR 4 Init in case of missing amdxc64.dll // 2nd check is amdxcffx64.dll trying to queue amdxc64 but amdxc64 not being loaded if (lpProcName != nullptr && (hModule == amdxc64Mark || hModule == nullptr) && - lstrcmpA(lpProcName, "AmdExtD3DCreateInterface") == 0 && Config::Instance()->Fsr4Update.value_for_config()) + lstrcmpA(lpProcName, "AmdExtD3DCreateInterface") == 0 && Config::Instance()->Fsr4Update.value_or_default()) { return (FARPROC) &hkAmdExtD3DCreateInterface; }