diff --git a/OptiScaler/OptiScaler.vcxproj b/OptiScaler/OptiScaler.vcxproj
index c4e09143..5d090a3a 100644
--- a/OptiScaler/OptiScaler.vcxproj
+++ b/OptiScaler/OptiScaler.vcxproj
@@ -370,6 +370,7 @@ copy NUL "$(SolutionDir)x64\Release\a\!! EXTRACT ALL FILES TO GAME FOLDER !!" /Y
+
@@ -511,6 +512,7 @@ copy NUL "$(SolutionDir)x64\Release\a\!! EXTRACT ALL FILES TO GAME FOLDER !!" /Y
+
diff --git a/OptiScaler/inputs/NVNGX_DLSS_Dx11.cpp b/OptiScaler/inputs/NVNGX_DLSS_Dx11.cpp
index 95d1eac7..ee4ff226 100644
--- a/OptiScaler/inputs/NVNGX_DLSS_Dx11.cpp
+++ b/OptiScaler/inputs/NVNGX_DLSS_Dx11.cpp
@@ -3,19 +3,12 @@
#include "Config.h"
#include "Util.h"
+#include
+#include
+
+#include "NVNGX_DLSS.h"
#include "NVNGX_Parameter.h"
#include "proxies/NVNGX_Proxy.h"
-#include "NVNGX_DLSS.h"
-
-#include "upscalers/dlss/DLSSFeature_Dx11.h"
-#include "upscalers/dlssd/DLSSDFeature_Dx11.h"
-#include "upscalers/fsr2/FSR2Feature_Dx11.h"
-#include "upscalers/fsr2/FSR2Feature_Dx11On12.h"
-#include "upscalers/fsr2_212/FSR2Feature_Dx11On12_212.h"
-#include "upscalers/fsr31/FSR31Feature_Dx11.h"
-#include "upscalers/fsr31/FSR31Feature_Dx11On12.h"
-#include "upscalers/xess/XeSSFeature_Dx11.h"
-#include "upscalers/xess/XeSSFeature_Dx11on12.h"
#include "hooks/HooksDx.h"
@@ -222,8 +215,6 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_Shutdown()
D3D11Device = nullptr;
State::Instance().currentFeature = nullptr;
- DLSSFeatureDx11::Shutdown(D3D11Device);
-
if (Config::Instance()->DLSSEnabled.value_or_default() && NVNGXProxy::IsDx11Inited() &&
NVNGXProxy::D3D11_Shutdown() != nullptr)
{
@@ -407,129 +398,36 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_CreateFeature(ID3D11DeviceContext
if (InFeatureID == NVSDK_NGX_Feature_SuperSampling)
{
- std::string defaultUpscaler = "fsr22";
+ std::string upscalerChoice = "fsr22"; // Default FSR 2.2.1
// If original NVNGX available use DLSS as base upscaler
- if (NVNGXProxy::IsDx11Inited())
- defaultUpscaler = "dlss";
+ if (Config::Instance()->DLSSEnabled.value_or_default() && NVNGXProxy::IsDx11Inited())
+ upscalerChoice = "dlss";
- if (Config::Instance()->Dx11Upscaler.value_or(defaultUpscaler) == "xess")
+ if (Config::Instance()->Dx11Upscaler.has_value())
+ upscalerChoice = Config::Instance()->Dx11Upscaler.value();
+
+ LOG_INFO("Creating new {} feature", upscalerChoice);
+
+ Dx11Contexts[handleId] = {};
+
+ if (!FeatureProvider_Dx11::GetFeature(upscalerChoice, handleId, InParameters, &Dx11Contexts[handleId].feature))
{
- Dx11Contexts[handleId].feature = std::make_unique(handleId, InParameters);
-
- if (!Dx11Contexts[handleId].feature->ModuleLoaded())
- {
- LOG_ERROR("can't create new XeSS feature, Fallback to FSR2.2!");
-
- Dx11Contexts[handleId].feature.reset();
- Dx11Contexts[handleId].feature = nullptr;
-
- Config::Instance()->Dx11Upscaler = "fsr22";
- }
- else
- {
- LOG_INFO("creating new XeSS feature");
- }
+ LOG_ERROR("Can't create {} feature", upscalerChoice);
+ return NVSDK_NGX_Result_Fail;
}
-
- if (Config::Instance()->Dx11Upscaler.value_or(defaultUpscaler) == "xess_12")
- {
- Dx11Contexts[handleId].feature = std::make_unique(handleId, InParameters);
-
- if (!Dx11Contexts[handleId].feature->ModuleLoaded())
- {
- LOG_ERROR("can't create new XeSS with Dx12 feature, Fallback to FSR2.2!");
-
- Dx11Contexts[handleId].feature.reset();
- Dx11Contexts[handleId].feature = nullptr;
-
- Config::Instance()->Dx11Upscaler = "fsr22";
- }
- else
- {
- LOG_INFO("creating new XeSS with Dx12 feature");
- }
- }
-
- if (Config::Instance()->Dx11Upscaler.value_or(defaultUpscaler) == "dlss")
- {
- if (Config::Instance()->DLSSEnabled.value_or_default())
- {
- Dx11Contexts[handleId].feature = std::make_unique(handleId, InParameters);
-
- if (!Dx11Contexts[handleId].feature->ModuleLoaded())
- {
- LOG_ERROR("can't create new DLSS feature, Fallback to FSR2.2!");
-
- Dx11Contexts[handleId].feature.reset();
- Dx11Contexts[handleId].feature = nullptr;
- // auto it = std::find_if(Dx11Contexts.begin(), Dx11Contexts.end(), [&handleId](const auto& p) {
- // return p.first == handleId; }); Dx11Contexts.erase(it);
-
- Config::Instance()->Dx11Upscaler = "fsr22";
- }
- else
- {
- LOG_INFO("creating new DLSS feature");
- }
- }
- else
- {
- Config::Instance()->Dx11Upscaler.reset();
- }
- }
-
- if (Config::Instance()->Dx11Upscaler.value_or(defaultUpscaler) == "fsr31_12")
- {
- Dx11Contexts[handleId].feature = std::make_unique(handleId, InParameters);
-
- if (!Dx11Contexts[handleId].feature->ModuleLoaded())
- {
- LOG_ERROR("can't create new FSR 3.1 feature, Fallback to FSR2.2!");
-
- Dx11Contexts[handleId].feature.reset();
- Dx11Contexts[handleId].feature = nullptr;
- // auto it = std::find_if(Dx11Contexts.begin(), Dx11Contexts.end(), [&handleId](const auto& p) { return
- // p.first == handleId; }); Dx11Contexts.erase(it);
-
- Config::Instance()->Dx11Upscaler = "fsr22";
- }
- else
- {
- LOG_INFO("creating new FSR 3.1 feature");
- }
- }
-
- if (Config::Instance()->Dx11Upscaler.value_or(defaultUpscaler) == "fsr22_12")
- {
- LOG_INFO("creating new FSR 2.2.1 with Dx12 feature");
- Dx11Contexts[handleId].feature = std::make_unique(handleId, InParameters);
- }
- else if (Config::Instance()->Dx11Upscaler.value_or(defaultUpscaler) == "fsr21_12")
- {
- LOG_INFO("creating new FSR 2.1.2 with Dx12 feature");
- Dx11Contexts[handleId].feature = std::make_unique(handleId, InParameters);
- }
- else if (Config::Instance()->Dx11Upscaler.value_or(defaultUpscaler) == "fsr22")
- {
- LOG_INFO("creating new native FSR 2.2.1 feature");
- Dx11Contexts[handleId].feature = std::make_unique(handleId, InParameters);
- }
- else if (Config::Instance()->Dx11Upscaler.value_or(defaultUpscaler) == "fsr31")
- {
- LOG_INFO("creating new native FSR 3.1.0 feature");
- Dx11Contexts[handleId].feature = std::make_unique(handleId, InParameters);
- }
- // else if (Config::Instance()->Dx11Upscaler.value_or(defaultUpscaler) == "fsr304")
- //{
- // LOG_INFO("creating new native FSR 3.1.0 feature");
- // Dx11Contexts[handleId].feature = std::make_unique(handleId, InParameters);
- // }
}
- else
+ else if (InFeatureID == NVSDK_NGX_Feature_RayReconstruction)
{
- LOG_INFO("creating new DLSSD feature");
- Dx11Contexts[handleId].feature = std::make_unique(handleId, InParameters);
+ LOG_INFO("Creating new DLSSD feature");
+
+ Dx11Contexts[handleId] = {};
+
+ if (!FeatureProvider_Dx11::GetFeature("dlssd", handleId, InParameters, &Dx11Contexts[handleId].feature))
+ {
+ LOG_ERROR("Can't create DLSSD feature");
+ return NVSDK_NGX_Result_Fail;
+ }
}
auto deviceContext = Dx11Contexts[handleId].feature.get();
@@ -699,205 +597,18 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D11_EvaluateFeature(ID3D11DeviceConte
LOG_INFO("callback exist");
IFeature_Dx11* deviceContext = nullptr;
+ auto activeContext = &Dx11Contexts[handleId];
if (State::Instance().changeBackend[handleId])
{
- if (State::Instance().newBackend == "" ||
- (!Config::Instance()->DLSSEnabled.value_or_default() && State::Instance().newBackend == "dlss"))
- State::Instance().newBackend = Config::Instance()->Dx11Upscaler.value_or_default();
+ FeatureProvider_Dx11::ChangeFeature(State::Instance().newBackend, D3D11Device, InDevCtx, handleId, InParameters,
+ activeContext);
- Dx11Contexts[handleId].changeBackendCounter++;
-
- // first release everything
- if (Dx11Contexts[handleId].changeBackendCounter == 1)
- {
- if (Dx11Contexts.contains(handleId) && Dx11Contexts[handleId].feature != nullptr)
- {
- LOG_INFO("changing backend to {0}", State::Instance().newBackend);
-
- auto dc = Dx11Contexts[handleId].feature.get();
-
- if (State::Instance().newBackend != "dlssd" && State::Instance().newBackend != "dlss")
- Dx11Contexts[handleId].createParams = GetNGXParameters("OptiDx11");
- else
- Dx11Contexts[handleId].createParams = InParameters;
-
- Dx11Contexts[handleId].createParams->Set(NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags,
- dc->GetFeatureFlags());
- Dx11Contexts[handleId].createParams->Set(NVSDK_NGX_Parameter_Width, dc->RenderWidth());
- Dx11Contexts[handleId].createParams->Set(NVSDK_NGX_Parameter_Height, dc->RenderHeight());
- Dx11Contexts[handleId].createParams->Set(NVSDK_NGX_Parameter_OutWidth, dc->DisplayWidth());
- Dx11Contexts[handleId].createParams->Set(NVSDK_NGX_Parameter_OutHeight, dc->DisplayHeight());
- Dx11Contexts[handleId].createParams->Set(NVSDK_NGX_Parameter_PerfQualityValue, dc->PerfQualityValue());
-
- LOG_TRACE("sleeping before reset of current feature for 1000ms");
- std::this_thread::sleep_for(std::chrono::milliseconds(1000));
-
- Dx11Contexts[handleId].feature.reset();
- Dx11Contexts[handleId].feature = nullptr;
- // auto it = std::find_if(Dx11Contexts.begin(), Dx11Contexts.end(), [&handleId](const auto& p) { return
- // p.first == handleId; }); Dx11Contexts.erase(it);
-
- State::Instance().currentFeature = nullptr;
- }
- else
- {
- LOG_ERROR("can't find handle {0} in Dx11Contexts!", handleId);
-
- State::Instance().newBackend = "";
- State::Instance().changeBackend[handleId] = false;
-
- if (Dx11Contexts[handleId].createParams != nullptr)
- {
- free(Dx11Contexts[handleId].createParams);
- Dx11Contexts[handleId].createParams = nullptr;
- }
-
- Dx11Contexts[handleId].changeBackendCounter = 0;
- }
-
- return NVSDK_NGX_Result_Success;
- }
-
- if (Dx11Contexts[handleId].changeBackendCounter == 2)
- {
- // next frame prepare stuff
- if (State::Instance().newBackend == "xess")
- {
- Config::Instance()->Dx11Upscaler = "xess";
- LOG_INFO("creating new XeSS feature");
- Dx11Contexts[handleId].feature =
- std::make_unique(handleId, Dx11Contexts[handleId].createParams);
- }
- else if (State::Instance().newBackend == "xess_12")
- {
- Config::Instance()->Dx11Upscaler = "xess_12";
- LOG_INFO("creating new XeSS with Dx12 feature");
- Dx11Contexts[handleId].feature =
- std::make_unique(handleId, Dx11Contexts[handleId].createParams);
- }
- else if (State::Instance().newBackend == "dlss")
- {
- Config::Instance()->Dx11Upscaler = "dlss";
- LOG_INFO("creating new DLSS feature");
- Dx11Contexts[handleId].feature =
- std::make_unique(handleId, Dx11Contexts[handleId].createParams);
- }
- else if (State::Instance().newBackend == "dlssd")
- {
- LOG_INFO("creating new DLSSD feature");
- Dx11Contexts[handleId].feature = std::make_unique(handleId, InParameters);
- }
- else if (State::Instance().newBackend == "fsr21_12")
- {
- Config::Instance()->Dx11Upscaler = "fsr21_12";
- LOG_INFO("creating new FSR 2.1.2 with Dx12 feature");
- Dx11Contexts[handleId].feature =
- std::make_unique(handleId, Dx11Contexts[handleId].createParams);
- }
- else if (State::Instance().newBackend == "fsr31_12")
- {
- Config::Instance()->Dx11Upscaler = "fsr31_12";
- LOG_INFO("creating new FSR 3.1 with Dx12 feature");
- Dx11Contexts[handleId].feature =
- std::make_unique(handleId, Dx11Contexts[handleId].createParams);
- }
- else if (State::Instance().newBackend == "fsr22_12")
- {
- Config::Instance()->Dx11Upscaler = "fsr22_12";
- LOG_INFO("creating new FSR 2.2.1 with Dx12 feature");
- Dx11Contexts[handleId].feature =
- std::make_unique(handleId, Dx11Contexts[handleId].createParams);
- }
- else if (State::Instance().newBackend == "fsr22")
- {
- Config::Instance()->Dx11Upscaler = "fsr22";
- LOG_INFO("creating new native FSR 2.2.1 feature");
- Dx11Contexts[handleId].feature =
- std::make_unique(handleId, Dx11Contexts[handleId].createParams);
- }
- else if (State::Instance().newBackend == "fsr31")
- {
- Config::Instance()->Dx11Upscaler = "fsr31";
- LOG_INFO("creating new native FSR 3.1.0 feature");
- Dx11Contexts[handleId].feature =
- std::make_unique(handleId, Dx11Contexts[handleId].createParams);
- }
- // else if (State::Instance().newBackend == "fsr304")
- //{
- // Config::Instance()->Dx11Upscaler = "fsr31";
- // LOG_INFO("creating new native FSR 3.1.0 feature");
- // Dx11Contexts[handleId].feature = std::make_unique(handleId,
- // Dx11Contexts[handleId].createParams);
- // }
-
- if (Config::Instance()->Dx11DelayedInit.value_or_default() && State::Instance().newBackend != "fsr22" &&
- State::Instance().newBackend != "dlss" && State::Instance().newBackend != "dlssd")
- {
- LOG_TRACE("sleeping after new creation of new feature for 1000ms");
- std::this_thread::sleep_for(std::chrono::milliseconds(1000));
- }
-
- return NVSDK_NGX_Result_Success;
- }
-
- if (Dx11Contexts[handleId].changeBackendCounter == 3)
- {
- // then init and continue
- auto initResult =
- Dx11Contexts[handleId].feature->Init(D3D11Device, InDevCtx, Dx11Contexts[handleId].createParams);
-
- if (Config::Instance()->Dx11DelayedInit.value_or_default())
- {
- LOG_TRACE("sleeping after new Init of new feature for 1000ms");
- std::this_thread::sleep_for(std::chrono::milliseconds(1000));
- }
-
- Dx11Contexts[handleId].changeBackendCounter = 0;
-
- if (!initResult || !Dx11Contexts[handleId].feature->ModuleLoaded())
- {
- LOG_ERROR("init failed with {0} feature", State::Instance().newBackend);
-
- if (State::Instance().newBackend != "dlssd")
- {
- State::Instance().newBackend = "fsr22";
- State::Instance().changeBackend[handleId] = true;
- }
- else
- {
- State::Instance().newBackend = "";
- State::Instance().changeBackend[handleId] = false;
- return NVSDK_NGX_Result_Fail;
- }
- }
- else
- {
- LOG_INFO("init successful for {0}, upscaler changed", State::Instance().newBackend);
-
- State::Instance().newBackend = "";
- State::Instance().changeBackend[handleId] = false;
- evalCounter = 0;
- }
-
- // if opti nvparam release it
- int optiParam = 0;
- if (Dx11Contexts[handleId].createParams->Get("OptiScaler", &optiParam) == NVSDK_NGX_Result_Success &&
- optiParam == 1)
- {
- free(Dx11Contexts[handleId].createParams);
- Dx11Contexts[handleId].createParams = nullptr;
- }
- }
-
- // if initial feature can't be inited
- State::Instance().currentFeature = Dx11Contexts[handleId].feature.get();
+ evalCounter = 0;
return NVSDK_NGX_Result_Success;
}
- auto activeContext = &Dx11Contexts[handleId];
-
if (activeContext->feature == nullptr) // prevent source api name flicker when dlssg is active
{
State::Instance().setInputApiName = State::Instance().currentInputApiName;
diff --git a/OptiScaler/inputs/NVNGX_DLSS_Dx12.cpp b/OptiScaler/inputs/NVNGX_DLSS_Dx12.cpp
index 943471ab..8f66d04c 100644
--- a/OptiScaler/inputs/NVNGX_DLSS_Dx12.cpp
+++ b/OptiScaler/inputs/NVNGX_DLSS_Dx12.cpp
@@ -1012,6 +1012,8 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCom
FeatureProvider_Dx12::ChangeFeature(State::Instance().newBackend, D3D12Device, InCmdList, handleId,
InParameters, deviceContext);
+ evalCounter = 0;
+
return NVSDK_NGX_Result_Success;
}
diff --git a/OptiScaler/upscalers/FeatureProvider_Dx11.cpp b/OptiScaler/upscalers/FeatureProvider_Dx11.cpp
new file mode 100644
index 00000000..85e81a46
--- /dev/null
+++ b/OptiScaler/upscalers/FeatureProvider_Dx11.cpp
@@ -0,0 +1,218 @@
+#include "FeatureProvider_Dx11.h"
+
+#include "Util.h"
+#include "Config.h"
+
+#include "NVNGX_Parameter.h"
+
+#include "upscalers/dlss/DLSSFeature_Dx11.h"
+#include "upscalers/dlssd/DLSSDFeature_Dx11.h"
+#include "upscalers/fsr2/FSR2Feature_Dx11.h"
+#include "upscalers/fsr2/FSR2Feature_Dx11On12.h"
+#include "upscalers/fsr2_212/FSR2Feature_Dx11On12_212.h"
+#include "upscalers/fsr31/FSR31Feature_Dx11.h"
+#include "upscalers/fsr31/FSR31Feature_Dx11On12.h"
+#include "upscalers/xess/XeSSFeature_Dx11.h"
+#include "upscalers/xess/XeSSFeature_Dx11on12.h"
+
+bool FeatureProvider_Dx11::GetFeature(std::string upscalerName, UINT handleId, NVSDK_NGX_Parameter* parameters,
+ std::unique_ptr* feature)
+{
+ do
+ {
+ if (upscalerName == "xess")
+ {
+ *feature = std::make_unique(handleId, parameters);
+ break;
+ }
+ else if (upscalerName == "xess_12")
+ {
+ *feature = std::make_unique(handleId, parameters);
+ break;
+ }
+ else if (upscalerName == "fsr21_12")
+ {
+ *feature = std::make_unique(handleId, parameters);
+ break;
+ }
+ else if (upscalerName == "fsr22")
+ {
+ *feature = std::make_unique(handleId, parameters);
+ break;
+ }
+ else if (upscalerName == "fsr22_12")
+ {
+ *feature = std::make_unique(handleId, parameters);
+ break;
+ }
+ else if (upscalerName == "fsr31")
+ {
+ *feature = std::make_unique(handleId, parameters);
+ break;
+ }
+ else if (upscalerName == "fsr31_12")
+ {
+ *feature = std::make_unique(handleId, parameters);
+ break;
+ }
+
+ if (Config::Instance()->DLSSEnabled.value_or_default())
+ {
+ if (upscalerName == "dlss")
+ {
+ *feature = std::make_unique(handleId, parameters);
+ break;
+ }
+ else if (upscalerName == "dlssd")
+ {
+ *feature = std::make_unique(handleId, parameters);
+ break;
+ }
+ }
+
+ } while (false);
+
+ if (!(*feature)->ModuleLoaded())
+ {
+ (*feature).reset();
+ *feature = std::make_unique(handleId, parameters);
+ upscalerName = "fsr22";
+ }
+
+ auto result = (*feature)->ModuleLoaded();
+
+ if (result)
+ {
+ if (upscalerName == "dlssd")
+ upscalerName = "dlss";
+
+ Config::Instance()->Dx11Upscaler = upscalerName;
+ }
+
+ return result;
+}
+
+bool FeatureProvider_Dx11::ChangeFeature(std::string upscalerName, ID3D11Device* device,
+ ID3D11DeviceContext* devContext, UINT handleId,
+ NVSDK_NGX_Parameter* parameters, ContextData* contextData)
+{
+ if (State::Instance().newBackend == "" ||
+ (!Config::Instance()->DLSSEnabled.value_or_default() && State::Instance().newBackend == "dlss"))
+ State::Instance().newBackend = Config::Instance()->Dx11Upscaler.value_or_default();
+
+ contextData->changeBackendCounter++;
+
+ // first release everything
+ if (contextData->changeBackendCounter == 1)
+ {
+ if (contextData->feature != nullptr)
+ {
+ LOG_INFO("changing backend to {0}", State::Instance().newBackend);
+
+ auto dc = contextData->feature.get();
+
+ if (State::Instance().newBackend != "dlssd" && State::Instance().newBackend != "dlss")
+ contextData->createParams = GetNGXParameters("OptiDx11");
+ else
+ contextData->createParams = parameters;
+
+ contextData->createParams->Set(NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags, dc->GetFeatureFlags());
+ contextData->createParams->Set(NVSDK_NGX_Parameter_Width, dc->RenderWidth());
+ contextData->createParams->Set(NVSDK_NGX_Parameter_Height, dc->RenderHeight());
+ contextData->createParams->Set(NVSDK_NGX_Parameter_OutWidth, dc->DisplayWidth());
+ contextData->createParams->Set(NVSDK_NGX_Parameter_OutHeight, dc->DisplayHeight());
+ contextData->createParams->Set(NVSDK_NGX_Parameter_PerfQualityValue, dc->PerfQualityValue());
+
+ LOG_TRACE("sleeping before reset of current feature for 1000ms");
+ std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+
+ contextData->feature.reset();
+ contextData->feature = nullptr;
+
+ State::Instance().currentFeature = nullptr;
+ }
+ else
+ {
+ LOG_ERROR("can't find handle {0} in Dx11Contexts!", handleId);
+
+ State::Instance().newBackend = "";
+ State::Instance().changeBackend[handleId] = false;
+
+ if (contextData->createParams != nullptr)
+ {
+ free(contextData->createParams);
+ contextData->createParams = nullptr;
+ }
+
+ contextData->changeBackendCounter = 0;
+ }
+
+ return NVSDK_NGX_Result_Success;
+ }
+
+ if (contextData->changeBackendCounter == 2)
+ {
+ LOG_INFO("Creating new {} upscaler", State::Instance().newBackend);
+
+ contextData->feature.reset();
+
+ if (!GetFeature(State::Instance().newBackend, handleId, parameters, &contextData->feature))
+ {
+ LOG_ERROR("Upscaler can't created");
+ return NVSDK_NGX_Result_Fail;
+ }
+
+ return NVSDK_NGX_Result_Success;
+ }
+
+ if (contextData->changeBackendCounter == 3)
+ {
+ // then init and continue
+ auto initResult = contextData->feature->Init(device, devContext, contextData->createParams);
+
+ if (Config::Instance()->Dx11DelayedInit.value_or_default())
+ {
+ LOG_TRACE("sleeping after new Init of new feature for 1000ms");
+ std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+ }
+
+ contextData->changeBackendCounter = 0;
+
+ if (!initResult || !contextData->feature->ModuleLoaded())
+ {
+ LOG_ERROR("init failed with {0} feature", State::Instance().newBackend);
+
+ if (State::Instance().newBackend != "dlssd")
+ {
+ State::Instance().newBackend = "fsr22";
+ State::Instance().changeBackend[handleId] = true;
+ }
+ else
+ {
+ State::Instance().newBackend = "";
+ State::Instance().changeBackend[handleId] = false;
+ return NVSDK_NGX_Result_Fail;
+ }
+ }
+ else
+ {
+ LOG_INFO("init successful for {0}, upscaler changed", State::Instance().newBackend);
+
+ State::Instance().newBackend = "";
+ State::Instance().changeBackend[handleId] = false;
+ }
+
+ // if opti nvparam release it
+ int optiParam = 0;
+ if (contextData->createParams->Get("OptiScaler", &optiParam) == NVSDK_NGX_Result_Success && optiParam == 1)
+ {
+ free(contextData->createParams);
+ contextData->createParams = nullptr;
+ }
+ }
+
+ // if initial feature can't be inited
+ State::Instance().currentFeature = contextData->feature.get();
+
+ return true;
+}
diff --git a/OptiScaler/upscalers/FeatureProvider_Dx11.h b/OptiScaler/upscalers/FeatureProvider_Dx11.h
new file mode 100644
index 00000000..ae800212
--- /dev/null
+++ b/OptiScaler/upscalers/FeatureProvider_Dx11.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include
+
+#include "IFeature_Dx11.h"
+
+#include
+
+class FeatureProvider_Dx11
+{
+ public:
+ static bool GetFeature(std::string upscalerName, UINT handleId, NVSDK_NGX_Parameter* parameters,
+ std::unique_ptr* feature);
+
+ static bool ChangeFeature(std::string upscalerName, ID3D11Device* device, ID3D11DeviceContext* cmdList,
+ UINT handleId, NVSDK_NGX_Parameter* parameters, ContextData* contextData);
+};
diff --git a/OptiScaler/upscalers/FeatureProvider_Dx12.cpp b/OptiScaler/upscalers/FeatureProvider_Dx12.cpp
index 374cbd5b..cb5228d4 100644
--- a/OptiScaler/upscalers/FeatureProvider_Dx12.cpp
+++ b/OptiScaler/upscalers/FeatureProvider_Dx12.cpp
@@ -11,6 +11,7 @@
#include "upscalers/fsr2_212/FSR2Feature_Dx12_212.h"
#include "upscalers/fsr31/FSR31Feature_Dx12.h"
#include "upscalers/xess/XeSSFeature_Dx12.h"
+#include "FeatureProvider_Dx11.h"
bool FeatureProvider_Dx12::GetFeature(std::string upscalerName, UINT handleId, NVSDK_NGX_Parameter* parameters,
std::unique_ptr* feature)
@@ -161,8 +162,7 @@ bool FeatureProvider_Dx12::ChangeFeature(std::string upscalerName, ID3D12Device*
contextData->feature.reset();
- if (!FeatureProvider_Dx12::GetFeature(State::Instance().newBackend, handleId, parameters,
- &contextData->feature))
+ if (!GetFeature(State::Instance().newBackend, handleId, parameters, &contextData->feature))
{
LOG_ERROR("Upscaler can't created");
return NVSDK_NGX_Result_Fail;