mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-08-23 22:56:52 +00:00
Fix Nvidia NVSDK init path order so dll overrides are now working again
This commit is contained in:
+28
-3
@@ -1738,6 +1738,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
||||
HMODULE handle = nullptr;
|
||||
OSVERSIONINFOW winVer { 0 };
|
||||
auto exePath = Util::ExePath().remove_filename();
|
||||
std::filesystem::path optiDllPath;
|
||||
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
@@ -1848,9 +1849,33 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
||||
|
||||
spdlog::info("");
|
||||
spdlog::info("Check for DLSS files");
|
||||
State::Instance().NVNGX_DLSS_Path = Util::FindFilePath(exePath, "nvngx_dlss.dll");
|
||||
State::Instance().NVNGX_DLSSD_Path = Util::FindFilePath(exePath, "nvngx_dlssd.dll");
|
||||
State::Instance().NVNGX_DLSSG_Path = Util::FindFilePath(exePath, "nvngx_dlssg.dll");
|
||||
|
||||
optiDllPath = std::filesystem::path(Config::Instance()->MainDllPath.value());
|
||||
|
||||
if (Config::Instance()->NVNGX_DLSS_Library.has_value())
|
||||
{
|
||||
std::filesystem::path dlssPath(Config::Instance()->NVNGX_DLSS_Library.value());
|
||||
|
||||
if (std::filesystem::is_directory(dlssPath) && std::filesystem::exists(dlssPath))
|
||||
{
|
||||
State::Instance().NVNGX_DLSS_Path = dlssPath;
|
||||
LOG_DEBUG("nvngx_dlss.dll found at {}", dlssPath.string());
|
||||
}
|
||||
}
|
||||
|
||||
if (!State::Instance().NVNGX_DLSS_Path.has_value())
|
||||
State::Instance().NVNGX_DLSS_Path = Util::FindFilePath(optiDllPath, "nvngx_dlss.dll");
|
||||
|
||||
if (!State::Instance().NVNGX_DLSS_Path.has_value())
|
||||
State::Instance().NVNGX_DLSS_Path = Util::FindFilePath(exePath, "nvngx_dlss.dll");
|
||||
|
||||
State::Instance().NVNGX_DLSSD_Path = Util::FindFilePath(optiDllPath, "nvngx_dlssd.dll");
|
||||
if (!State::Instance().NVNGX_DLSSD_Path.has_value())
|
||||
State::Instance().NVNGX_DLSSD_Path = Util::FindFilePath(exePath, "nvngx_dlssd.dll");
|
||||
|
||||
State::Instance().NVNGX_DLSSG_Path = Util::FindFilePath(optiDllPath, "nvngx_dlssg.dll");
|
||||
if (!State::Instance().NVNGX_DLSSG_Path.has_value())
|
||||
State::Instance().NVNGX_DLSSG_Path = Util::FindFilePath(exePath, "nvngx_dlssg.dll");
|
||||
|
||||
// Check if real DLSS available
|
||||
if (Config::Instance()->DLSSEnabled.value_or_default())
|
||||
|
||||
@@ -499,34 +499,6 @@ static Fsr212::FfxErrorCode ffxFsr2ContextCreate_Pattern_Dx12(Fsr212::FfxFsr2Con
|
||||
NVSDK_NGX_FeatureCommonInfo fcInfo {};
|
||||
|
||||
auto exePath = Util::ExePath().remove_filename();
|
||||
auto nvngxDlssPath = Util::FindFilePath(exePath, "nvngx_dlss.dll");
|
||||
auto nvngxDlssDPath = Util::FindFilePath(exePath, "nvngx_dlssd.dll");
|
||||
auto nvngxDlssGPath = Util::FindFilePath(exePath, "nvngx_dlssg.dll");
|
||||
|
||||
std::vector<std::wstring> pathStorage;
|
||||
|
||||
pathStorage.push_back(exePath.wstring());
|
||||
if (nvngxDlssPath.has_value())
|
||||
pathStorage.push_back(nvngxDlssPath.value().parent_path().wstring());
|
||||
|
||||
if (nvngxDlssDPath.has_value())
|
||||
pathStorage.push_back(nvngxDlssDPath.value().parent_path().wstring());
|
||||
|
||||
if (nvngxDlssGPath.has_value())
|
||||
pathStorage.push_back(nvngxDlssGPath.value().parent_path().wstring());
|
||||
|
||||
if (Config::Instance()->DLSSFeaturePath.has_value())
|
||||
pathStorage.push_back(Config::Instance()->DLSSFeaturePath.value());
|
||||
|
||||
// Build pointer array
|
||||
wchar_t const** paths = new const wchar_t*[pathStorage.size()];
|
||||
for (size_t i = 0; i < pathStorage.size(); ++i)
|
||||
{
|
||||
paths[i] = pathStorage[i].c_str();
|
||||
}
|
||||
|
||||
fcInfo.PathListInfo.Path = paths;
|
||||
fcInfo.PathListInfo.Length = (int) pathStorage.size();
|
||||
|
||||
auto nvResult = NVSDK_NGX_D3D12_Init_with_ProjectID(
|
||||
OPTI_GUID, state.NVNGX_Engine, OPTI_VERSION, exePath.c_str(), _d3d12Device, &fcInfo,
|
||||
|
||||
@@ -464,35 +464,6 @@ ffxFsr3ContextCreate_Pattern_Dx12(Fsr3::FfxFsr3UpscalerContext* pContext,
|
||||
NVSDK_NGX_FeatureCommonInfo fcInfo {};
|
||||
|
||||
auto exePath = Util::ExePath().remove_filename();
|
||||
auto nvngxDlssPath = Util::FindFilePath(exePath, "nvngx_dlss.dll");
|
||||
auto nvngxDlssDPath = Util::FindFilePath(exePath, "nvngx_dlssd.dll");
|
||||
auto nvngxDlssGPath = Util::FindFilePath(exePath, "nvngx_dlssg.dll");
|
||||
|
||||
std::vector<std::wstring> pathStorage;
|
||||
|
||||
pathStorage.push_back(exePath.wstring());
|
||||
|
||||
if (nvngxDlssPath.has_value())
|
||||
pathStorage.push_back(nvngxDlssPath.value().parent_path().wstring());
|
||||
|
||||
if (nvngxDlssDPath.has_value())
|
||||
pathStorage.push_back(nvngxDlssDPath.value().parent_path().wstring());
|
||||
|
||||
if (nvngxDlssGPath.has_value())
|
||||
pathStorage.push_back(nvngxDlssGPath.value().parent_path().wstring());
|
||||
|
||||
if (Config::Instance()->DLSSFeaturePath.has_value())
|
||||
pathStorage.push_back(Config::Instance()->DLSSFeaturePath.value());
|
||||
|
||||
// Build pointer array
|
||||
wchar_t const** paths = new const wchar_t*[pathStorage.size()];
|
||||
for (size_t i = 0; i < pathStorage.size(); ++i)
|
||||
{
|
||||
paths[i] = pathStorage[i].c_str();
|
||||
}
|
||||
|
||||
fcInfo.PathListInfo.Path = paths;
|
||||
fcInfo.PathListInfo.Length = (int) pathStorage.size();
|
||||
|
||||
auto nvResult = NVSDK_NGX_D3D12_Init_with_ProjectID(
|
||||
OPTI_GUID, state.NVNGX_Engine, OPTI_VERSION, exePath.c_str(), _d3d12Device, &fcInfo,
|
||||
|
||||
@@ -41,12 +41,6 @@ static void UpdateInitPaths(NVSDK_NGX_FeatureCommonInfo* InFeatureInfo)
|
||||
|
||||
if (InFeatureInfo != nullptr)
|
||||
{
|
||||
for (size_t i = 0; i < InFeatureInfo->PathListInfo.Length; i++)
|
||||
{
|
||||
const wchar_t* path = InFeatureInfo->PathListInfo.Path[i];
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(std::wstring(path));
|
||||
}
|
||||
|
||||
auto exePath = Util::ExePath().remove_filename();
|
||||
|
||||
std::optional<std::filesystem::path> nvngxDlssPath = std::nullopt;
|
||||
@@ -92,20 +86,38 @@ static void UpdateInitPaths(NVSDK_NGX_FeatureCommonInfo* InFeatureInfo)
|
||||
nvngxDlssGPath = path.value();
|
||||
}
|
||||
|
||||
// Add found locations
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(exePath.wstring());
|
||||
if (nvngxDlssPath.has_value())
|
||||
// Override locations
|
||||
if (Config::Instance()->DLSSFeaturePath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(Config::Instance()->DLSSFeaturePath.value());
|
||||
|
||||
// If DLSS path is overriden
|
||||
if (Config::Instance()->NVNGX_DLSS_Library.has_value() && nvngxDlssPath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(nvngxDlssPath.value().parent_path().wstring());
|
||||
|
||||
// OptiDll Path
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(Config::Instance()->MainDllPath.value());
|
||||
|
||||
// Original paths from NVNGX
|
||||
for (size_t i = 0; i < InFeatureInfo->PathListInfo.Length; i++)
|
||||
{
|
||||
const wchar_t* path = InFeatureInfo->PathListInfo.Path[i];
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(std::wstring(path));
|
||||
}
|
||||
|
||||
// Exe path
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(exePath.wstring());
|
||||
|
||||
// If DLSS path is not overriden
|
||||
if (!Config::Instance()->NVNGX_DLSS_Library.has_value() && nvngxDlssPath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(nvngxDlssPath.value().parent_path().wstring());
|
||||
|
||||
// Add found locations
|
||||
if (nvngxDlssDPath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(nvngxDlssDPath.value().parent_path().wstring());
|
||||
|
||||
if (nvngxDlssGPath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(nvngxDlssGPath.value().parent_path().wstring());
|
||||
|
||||
if (Config::Instance()->DLSSFeaturePath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(Config::Instance()->DLSSFeaturePath.value());
|
||||
|
||||
// Build pointer array
|
||||
paths = new const wchar_t*[State::Instance().NVNGX_FeatureInfo_Paths.size()];
|
||||
for (size_t i = 0; i < State::Instance().NVNGX_FeatureInfo_Paths.size(); ++i)
|
||||
|
||||
@@ -52,12 +52,6 @@ static void UpdateInitPaths(NVSDK_NGX_FeatureCommonInfo* InFeatureInfo)
|
||||
|
||||
if (InFeatureInfo != nullptr)
|
||||
{
|
||||
for (size_t i = 0; i < InFeatureInfo->PathListInfo.Length; i++)
|
||||
{
|
||||
const wchar_t* path = InFeatureInfo->PathListInfo.Path[i];
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(std::wstring(path));
|
||||
}
|
||||
|
||||
auto exePath = Util::ExePath().remove_filename();
|
||||
|
||||
std::optional<std::filesystem::path> nvngxDlssPath = std::nullopt;
|
||||
@@ -103,20 +97,38 @@ static void UpdateInitPaths(NVSDK_NGX_FeatureCommonInfo* InFeatureInfo)
|
||||
nvngxDlssGPath = path.value();
|
||||
}
|
||||
|
||||
// Add found locations
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(exePath.wstring());
|
||||
if (nvngxDlssPath.has_value())
|
||||
// Override locations
|
||||
if (Config::Instance()->DLSSFeaturePath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(Config::Instance()->DLSSFeaturePath.value());
|
||||
|
||||
// If DLSS path is overriden
|
||||
if (Config::Instance()->NVNGX_DLSS_Library.has_value() && nvngxDlssPath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(nvngxDlssPath.value().parent_path().wstring());
|
||||
|
||||
// OptiDll Path
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(Config::Instance()->MainDllPath.value());
|
||||
|
||||
// Original paths from NVNGX
|
||||
for (size_t i = 0; i < InFeatureInfo->PathListInfo.Length; i++)
|
||||
{
|
||||
const wchar_t* path = InFeatureInfo->PathListInfo.Path[i];
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(std::wstring(path));
|
||||
}
|
||||
|
||||
// Exe path
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(exePath.wstring());
|
||||
|
||||
// If DLSS path is not overriden
|
||||
if (!Config::Instance()->NVNGX_DLSS_Library.has_value() && nvngxDlssPath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(nvngxDlssPath.value().parent_path().wstring());
|
||||
|
||||
// Add found locations
|
||||
if (nvngxDlssDPath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(nvngxDlssDPath.value().parent_path().wstring());
|
||||
|
||||
if (nvngxDlssGPath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(nvngxDlssGPath.value().parent_path().wstring());
|
||||
|
||||
if (Config::Instance()->DLSSFeaturePath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(Config::Instance()->DLSSFeaturePath.value());
|
||||
|
||||
// Build pointer array
|
||||
paths = new const wchar_t*[State::Instance().NVNGX_FeatureInfo_Paths.size()];
|
||||
for (size_t i = 0; i < State::Instance().NVNGX_FeatureInfo_Paths.size(); ++i)
|
||||
|
||||
@@ -47,12 +47,6 @@ static void UpdateInitPaths(NVSDK_NGX_FeatureCommonInfo* InFeatureInfo)
|
||||
|
||||
if (InFeatureInfo != nullptr)
|
||||
{
|
||||
for (size_t i = 0; i < InFeatureInfo->PathListInfo.Length; i++)
|
||||
{
|
||||
const wchar_t* path = InFeatureInfo->PathListInfo.Path[i];
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(std::wstring(path));
|
||||
}
|
||||
|
||||
auto exePath = Util::ExePath().remove_filename();
|
||||
|
||||
std::optional<std::filesystem::path> nvngxDlssPath = std::nullopt;
|
||||
@@ -98,20 +92,38 @@ static void UpdateInitPaths(NVSDK_NGX_FeatureCommonInfo* InFeatureInfo)
|
||||
nvngxDlssGPath = path.value();
|
||||
}
|
||||
|
||||
// Add found locations
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(exePath.wstring());
|
||||
if (nvngxDlssPath.has_value())
|
||||
// Override locations
|
||||
if (Config::Instance()->DLSSFeaturePath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(Config::Instance()->DLSSFeaturePath.value());
|
||||
|
||||
// If DLSS path is overriden
|
||||
if (Config::Instance()->NVNGX_DLSS_Library.has_value() && nvngxDlssPath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(nvngxDlssPath.value().parent_path().wstring());
|
||||
|
||||
// OptiDll Path
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(Config::Instance()->MainDllPath.value());
|
||||
|
||||
// Original paths from NVNGX
|
||||
for (size_t i = 0; i < InFeatureInfo->PathListInfo.Length; i++)
|
||||
{
|
||||
const wchar_t* path = InFeatureInfo->PathListInfo.Path[i];
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(std::wstring(path));
|
||||
}
|
||||
|
||||
// Exe path
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(exePath.wstring());
|
||||
|
||||
// If DLSS path is not overriden
|
||||
if (!Config::Instance()->NVNGX_DLSS_Library.has_value() && nvngxDlssPath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(nvngxDlssPath.value().parent_path().wstring());
|
||||
|
||||
// Add found locations
|
||||
if (nvngxDlssDPath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(nvngxDlssDPath.value().parent_path().wstring());
|
||||
|
||||
if (nvngxDlssGPath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(nvngxDlssGPath.value().parent_path().wstring());
|
||||
|
||||
if (Config::Instance()->DLSSFeaturePath.has_value())
|
||||
State::Instance().NVNGX_FeatureInfo_Paths.push_back(Config::Instance()->DLSSFeaturePath.value());
|
||||
|
||||
// Build pointer array
|
||||
paths = new const wchar_t*[State::Instance().NVNGX_FeatureInfo_Paths.size()];
|
||||
for (size_t i = 0; i < State::Instance().NVNGX_FeatureInfo_Paths.size(); ++i)
|
||||
|
||||
@@ -105,34 +105,6 @@ xess_result_t hk_xessD3D11CreateContext(ID3D11Device* device, xess_context_handl
|
||||
NVSDK_NGX_FeatureCommonInfo fcInfo {};
|
||||
|
||||
auto exePath = Util::ExePath().remove_filename();
|
||||
// auto nvngxDlssPath = Util::FindFilePath(exePath, "nvngx_dlss.dll");
|
||||
// auto nvngxDlssDPath = Util::FindFilePath(exePath, "nvngx_dlssd.dll");
|
||||
// auto nvngxDlssGPath = Util::FindFilePath(exePath, "nvngx_dlssg.dll");
|
||||
|
||||
// std::vector<std::wstring> pathStorage;
|
||||
|
||||
// pathStorage.push_back(exePath.wstring());
|
||||
// if (nvngxDlssPath.has_value())
|
||||
// pathStorage.push_back(nvngxDlssPath.value().parent_path().wstring());
|
||||
|
||||
// if (nvngxDlssDPath.has_value())
|
||||
// pathStorage.push_back(nvngxDlssDPath.value().parent_path().wstring());
|
||||
|
||||
// if (nvngxDlssGPath.has_value())
|
||||
// pathStorage.push_back(nvngxDlssGPath.value().parent_path().wstring());
|
||||
|
||||
// if (Config::Instance()->DLSSFeaturePath.has_value())
|
||||
// pathStorage.push_back(Config::Instance()->DLSSFeaturePath.value());
|
||||
|
||||
//// Build pointer array
|
||||
// wchar_t const** paths = new const wchar_t*[pathStorage.size()];
|
||||
// for (size_t i = 0; i < pathStorage.size(); ++i)
|
||||
//{
|
||||
// paths[i] = pathStorage[i].c_str();
|
||||
// }
|
||||
|
||||
// fcInfo.PathListInfo.Path = paths;
|
||||
// fcInfo.PathListInfo.Length = (int) pathStorage.size();
|
||||
|
||||
auto nvResult = NVSDK_NGX_D3D11_Init_with_ProjectID(
|
||||
OPTI_GUID, NVSDK_NGX_ENGINE_TYPE_CUSTOM, OPTI_VERSION, exePath.c_str(), device, &fcInfo,
|
||||
|
||||
@@ -106,34 +106,6 @@ xess_result_t hk_xessD3D12CreateContext(ID3D12Device* pDevice, xess_context_hand
|
||||
NVSDK_NGX_FeatureCommonInfo fcInfo {};
|
||||
|
||||
auto exePath = Util::ExePath().remove_filename();
|
||||
// auto nvngxDlssPath = Util::FindFilePath(exePath, "nvngx_dlss.dll");
|
||||
// auto nvngxDlssDPath = Util::FindFilePath(exePath, "nvngx_dlssd.dll");
|
||||
// auto nvngxDlssGPath = Util::FindFilePath(exePath, "nvngx_dlssg.dll");
|
||||
|
||||
// std::vector<std::wstring> pathStorage;
|
||||
|
||||
// pathStorage.push_back(exePath.wstring());
|
||||
// if (nvngxDlssPath.has_value())
|
||||
// pathStorage.push_back(nvngxDlssPath.value().parent_path().wstring());
|
||||
|
||||
// if (nvngxDlssDPath.has_value())
|
||||
// pathStorage.push_back(nvngxDlssDPath.value().parent_path().wstring());
|
||||
|
||||
// if (nvngxDlssGPath.has_value())
|
||||
// pathStorage.push_back(nvngxDlssGPath.value().parent_path().wstring());
|
||||
|
||||
// if (Config::Instance()->DLSSFeaturePath.has_value())
|
||||
// pathStorage.push_back(Config::Instance()->DLSSFeaturePath.value());
|
||||
|
||||
//// Build pointer array
|
||||
// wchar_t const** paths = new const wchar_t*[pathStorage.size()];
|
||||
// for (size_t i = 0; i < pathStorage.size(); ++i)
|
||||
//{
|
||||
// paths[i] = pathStorage[i].c_str();
|
||||
// }
|
||||
|
||||
// fcInfo.PathListInfo.Path = paths;
|
||||
// fcInfo.PathListInfo.Length = (int) pathStorage.size();
|
||||
|
||||
auto nvResult = NVSDK_NGX_D3D12_Init_with_ProjectID(
|
||||
OPTI_GUID, NVSDK_NGX_ENGINE_TYPE_CUSTOM, OPTI_VERSION, exePath.c_str(), pDevice, &fcInfo,
|
||||
|
||||
Reference in New Issue
Block a user