From 4c7bfc0a0cc481e83bd8aa2f1bea3d5779f97bf6 Mon Sep 17 00:00:00 2001 From: cdozdil Date: Wed, 20 Aug 2025 23:35:22 +0300 Subject: [PATCH] Added FidelityFX 2.0 amd_fidelityfx_loader_dx12.dll support --- OptiScaler/DllNames.h | 2 +- OptiScaler/proxies/FfxApi_Proxy.h | 54 +++++++++++++++++++------------ 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/OptiScaler/DllNames.h b/OptiScaler/DllNames.h index da6fe888..33c61cfa 100644 --- a/OptiScaler/DllNames.h +++ b/OptiScaler/DllNames.h @@ -158,7 +158,7 @@ DEFINE_NAME_VECTORS(fsr2BE, "ffx_fsr2_api_dx12_x64"); DEFINE_NAME_VECTORS(fsr3, "ffx_fsr3upscaler_x64"); DEFINE_NAME_VECTORS(fsr3BE, "ffx_backend_dx12_x64"); -DEFINE_NAME_VECTORS(ffxDx12, "amd_fidelityfx_dx12"); +DEFINE_NAME_VECTORS(ffxDx12, "amd_fidelityfx_dx12", "amd_fidelityfx_loader_dx12"); DEFINE_NAME_VECTORS(ffxVk, "amd_fidelityfx_vk"); inline static bool CheckDllName(std::string* dllName, std::vector* namesList) diff --git a/OptiScaler/proxies/FfxApi_Proxy.h b/OptiScaler/proxies/FfxApi_Proxy.h index 43be7887..c98de53a 100644 --- a/OptiScaler/proxies/FfxApi_Proxy.h +++ b/OptiScaler/proxies/FfxApi_Proxy.h @@ -64,30 +64,42 @@ class FfxApiProxy if (module != nullptr) _dllDx12 = module; - LOG_DEBUG("Loading amd_fidelityfx_dx12.dll methods"); - - if (_dllDx12 == nullptr && Config::Instance()->FfxDx12Path.has_value()) - { - std::filesystem::path libPath(Config::Instance()->FfxDx12Path.value().c_str()); - - if (libPath.has_filename()) - _dllDx12 = KernelBaseProxy::LoadLibraryExW_()(libPath.c_str(), NULL, 0); - else - _dllDx12 = KernelBaseProxy::LoadLibraryExW_()((libPath / L"amd_fidelityfx_dx12.dll").c_str(), NULL, 0); - - if (_dllDx12 != nullptr) - { - LOG_INFO("amd_fidelityfx_dx12.dll loaded from {0}", - wstring_to_string(Config::Instance()->FfxDx12Path.value())); - } - } - if (_dllDx12 == nullptr) { - _dllDx12 = KernelBaseProxy::LoadLibraryExW_()(L"amd_fidelityfx_dx12.dll", NULL, 0); + std::vector dllNames = { L"amd_fidelityfx_dx12.dll", L"amd_fidelityfx_loader_dx12.dll" }; - if (_dllDx12 != nullptr) - LOG_INFO("amd_fidelityfx_dx12.dll loaded from exe folder"); + for (size_t i = 0; i < dllNames.size(); i++) + { + LOG_DEBUG("Trying to load {}", wstring_to_string(dllNames[i])); + + if (_dllDx12 == nullptr && Config::Instance()->FfxDx12Path.has_value()) + { + std::filesystem::path libPath(Config::Instance()->FfxDx12Path.value().c_str()); + + if (libPath.has_filename()) + _dllDx12 = KernelBaseProxy::LoadLibraryExW_()(libPath.c_str(), NULL, 0); + else + _dllDx12 = KernelBaseProxy::LoadLibraryExW_()((libPath / dllNames[i]).c_str(), NULL, 0); + + if (_dllDx12 != nullptr) + { + LOG_INFO("{} loaded from {}", wstring_to_string(dllNames[i]), + wstring_to_string(Config::Instance()->FfxDx12Path.value())); + break; + } + } + + if (_dllDx12 == nullptr) + { + _dllDx12 = KernelBaseProxy::LoadLibraryExW_()(dllNames[i].c_str(), NULL, 0); + + if (_dllDx12 != nullptr) + { + LOG_INFO("{} loaded from exe folder", wstring_to_string(dllNames[i])); + break; + } + } + } } if (_dllDx12 != nullptr && _D3D12_Configure == nullptr)