diff --git a/OptiScaler/inputs/NVNGX_DLSS_Dx12.cpp b/OptiScaler/inputs/NVNGX_DLSS_Dx12.cpp index 72ae3f15..e6552b52 100644 --- a/OptiScaler/inputs/NVNGX_DLSS_Dx12.cpp +++ b/OptiScaler/inputs/NVNGX_DLSS_Dx12.cpp @@ -6,6 +6,7 @@ #include "proxies/NVNGX_Proxy.h" #include +#include "upscalers/dlss/DLSSFeature_Dx12.h" #include "FG/DLSSG_Mod.h" #include "FG/FSR3_Dx12_FG.h" @@ -360,6 +361,7 @@ NVSDK_NGX_API NVSDK_NGX_Result NVSDK_NGX_D3D12_Shutdown(void) // Unhooking and cleaning stuff causing issues during shutdown. // Disabled for now to check if it cause any issues // UnhookAll(); + DLSSFeatureDx12::Shutdown(D3D12Device); // Added `&& !State::Instance().isShuttingDown` hack for crash on exit if (Config::Instance()->DLSSEnabled.value_or_default() && NVNGXProxy::IsDx12Inited() && diff --git a/OptiScaler/upscalers/dlss/DLSSFeature.cpp b/OptiScaler/upscalers/dlss/DLSSFeature.cpp index 6a288fc3..c33bedfb 100644 --- a/OptiScaler/upscalers/dlss/DLSSFeature.cpp +++ b/OptiScaler/upscalers/dlss/DLSSFeature.cpp @@ -215,6 +215,16 @@ DLSSFeature::DLSSFeature(unsigned int handleId, NVSDK_NGX_Parameter* InParameter DLSSFeature::~DLSSFeature() {} +void DLSSFeature::Shutdown() +{ + LOG_FUNC(); + + if (NVNGXProxy::NVNGXModule() != nullptr) + UnhookApis(); + + LOG_FUNC_RESULT(0); +} + float DLSSFeature::GetSharpness(const NVSDK_NGX_Parameter* InParameters) { if (Config::Instance()->OverrideSharpness.value_or_default()) diff --git a/OptiScaler/upscalers/dlss/DLSSFeature.h b/OptiScaler/upscalers/dlss/DLSSFeature.h index 99d23692..2aa040d9 100644 --- a/OptiScaler/upscalers/dlss/DLSSFeature.h +++ b/OptiScaler/upscalers/dlss/DLSSFeature.h @@ -18,6 +18,7 @@ class DLSSFeature : public virtual IFeature void ProcessInitParams(NVSDK_NGX_Parameter* InParameters); void ReadVersion(); + static void Shutdown(); float GetSharpness(const NVSDK_NGX_Parameter* InParameters); public: diff --git a/OptiScaler/upscalers/dlss/DLSSFeature_Dx12.cpp b/OptiScaler/upscalers/dlss/DLSSFeature_Dx12.cpp index 9cb7454a..09673aa7 100644 --- a/OptiScaler/upscalers/dlss/DLSSFeature_Dx12.cpp +++ b/OptiScaler/upscalers/dlss/DLSSFeature_Dx12.cpp @@ -265,6 +265,19 @@ bool DLSSFeatureDx12::Evaluate(ID3D12GraphicsCommandList* InCommandList, NVSDK_N return true; } +void DLSSFeatureDx12::Shutdown(ID3D12Device* InDevice) +{ + if (_dlssInited) + { + if (NVNGXProxy::D3D12_Shutdown() != nullptr) + NVNGXProxy::D3D12_Shutdown()(); + else if (NVNGXProxy::D3D12_Shutdown1() != nullptr) + NVNGXProxy::D3D12_Shutdown1()(InDevice); + } + + DLSSFeature::Shutdown(); +} + DLSSFeatureDx12::DLSSFeatureDx12(unsigned int InHandleId, NVSDK_NGX_Parameter* InParameters) : IFeature(InHandleId, InParameters), IFeature_Dx12(InHandleId, InParameters), DLSSFeature(InHandleId, InParameters) { diff --git a/OptiScaler/upscalers/dlss/DLSSFeature_Dx12.h b/OptiScaler/upscalers/dlss/DLSSFeature_Dx12.h index e85f08cc..ec3c2231 100644 --- a/OptiScaler/upscalers/dlss/DLSSFeature_Dx12.h +++ b/OptiScaler/upscalers/dlss/DLSSFeature_Dx12.h @@ -13,6 +13,8 @@ class DLSSFeatureDx12 : public DLSSFeature, public IFeature_Dx12 NVSDK_NGX_Parameter* InParameters) override; bool Evaluate(ID3D12GraphicsCommandList* InCommandList, NVSDK_NGX_Parameter* InParameters) override; + static void Shutdown(ID3D12Device* InDevice); + feature_version Version() override { return DLSSFeature::Version(); } std::string Name() const override { return DLSSFeature::Name(); }