@@ -68,8 +68,9 @@ class SuperResolutionD3D12_DLSS final : public SuperResolutionBase
6868 {
6969 ValidateTemporalExecuteSuperResolutionAttribs (m_Desc, Attribs);
7070
71- if (m_pDLSSFeature == nullptr )
72- CreateFeature (Attribs);
71+ NVSDK_NGX_Handle* pDLSSFeature = AcquireFeature (Attribs);
72+ if (pDLSSFeature == nullptr )
73+ return ;
7374
7475 DeviceContextD3D12Impl* pCtxImpl = ClassPtrCast<DeviceContextD3D12Impl>(Attribs.pContext );
7576
@@ -111,7 +112,7 @@ class SuperResolutionD3D12_DLSS final : public SuperResolutionBase
111112 EvalParams.InPreExposure = Attribs.PreExposure ;
112113 EvalParams.InExposureScale = Attribs.ExposureScale ;
113114
114- NVSDK_NGX_Result Result = NGX_D3D12_EVALUATE_DLSS_EXT (pCmdList, m_pDLSSFeature , m_pNGXParams, &EvalParams);
115+ NVSDK_NGX_Result Result = NGX_D3D12_EVALUATE_DLSS_EXT (pCmdList, pDLSSFeature , m_pNGXParams, &EvalParams);
115116 if (NVSDK_NGX_FAILED (Result))
116117 LOG_ERROR_MESSAGE (" DLSS D3D12 evaluation failed. NGX Result: " , static_cast <Uint32>(Result));
117118
@@ -120,11 +121,18 @@ class SuperResolutionD3D12_DLSS final : public SuperResolutionBase
120121 }
121122
122123private:
123- void CreateFeature (const ExecuteSuperResolutionAttribs& Attribs)
124+ NVSDK_NGX_Handle* AcquireFeature (const ExecuteSuperResolutionAttribs& Attribs)
124125 {
125- Int32 DLSSCreateFeatureFlags = SuperResolutionFlagsToDLSSFeatureFlags (m_Desc.Flags );
126- if (Attribs.CameraNear > Attribs.CameraFar )
127- DLSSCreateFeatureFlags |= NVSDK_NGX_DLSS_Feature_Flags_DepthInverted;
126+ const Int32 DLSSCreateFeatureFlags = ComputeDLSSFeatureFlags (m_Desc.Flags , Attribs);
127+ if (m_pDLSSFeature != nullptr && m_DLSSFeatureFlags == DLSSCreateFeatureFlags)
128+ return m_pDLSSFeature;
129+
130+ if (m_pDLSSFeature != nullptr )
131+ {
132+ NVSDK_NGX_D3D12_ReleaseFeature (m_pDLSSFeature);
133+ m_pDLSSFeature = nullptr ;
134+ }
135+ m_DLSSFeatureFlags = DLSSCreateFeatureFlags;
128136
129137 NVSDK_NGX_DLSS_Create_Params DLSSCreateParams = {};
130138 DLSSCreateParams.Feature .InWidth = m_Desc.InputWidth ;
@@ -133,16 +141,23 @@ class SuperResolutionD3D12_DLSS final : public SuperResolutionBase
133141 DLSSCreateParams.Feature .InTargetHeight = m_Desc.OutputHeight ;
134142 DLSSCreateParams.InFeatureCreateFlags = DLSSCreateFeatureFlags;
135143
144+ NVSDK_NGX_Handle* pFeature = nullptr ;
136145 ID3D12GraphicsCommandList* pCmdList = ClassPtrCast<DeviceContextD3D12Impl>(Attribs.pContext )->GetD3D12CommandList ();
137- NVSDK_NGX_Result Result = NGX_D3D12_CREATE_DLSS_EXT (pCmdList, 1 , 1 , &m_pDLSSFeature , m_pNGXParams, &DLSSCreateParams);
146+ NVSDK_NGX_Result Result = NGX_D3D12_CREATE_DLSS_EXT (pCmdList, 1 , 1 , &pFeature , m_pNGXParams, &DLSSCreateParams);
138147
139148 if (NVSDK_NGX_FAILED (Result))
140- LOG_ERROR_AND_THROW (" Failed to create DLSS D3D12 feature. NGX Result: " , static_cast <Uint32>(Result));
149+ {
150+ LOG_ERROR_MESSAGE (" Failed to create DLSS D3D12 feature. NGX Result: " , static_cast <Uint32>(Result));
151+ return nullptr ;
152+ }
153+ m_pDLSSFeature = pFeature;
154+ return m_pDLSSFeature;
141155 }
142156
143157 RefCntAutoPtr<IRenderDevice> m_pDevice;
144- NVSDK_NGX_Handle* m_pDLSSFeature = nullptr ;
145- NVSDK_NGX_Parameter* m_pNGXParams = nullptr ;
158+ NVSDK_NGX_Handle* m_pDLSSFeature = nullptr ;
159+ NVSDK_NGX_Parameter* m_pNGXParams = nullptr ;
160+ Int32 m_DLSSFeatureFlags = 0 ;
146161};
147162
148163
@@ -155,18 +170,27 @@ class DLSSProviderD3D12 final : public SuperResolutionProvider
155170 ID3D12Device* pd3d12Device = ClassPtrCast<RenderDeviceD3D12Impl>(pDevice)->GetD3D12Device ();
156171 NVSDK_NGX_Result Result = NVSDK_NGX_D3D12_Init_with_ProjectID (DLSSProjectId, NVSDK_NGX_ENGINE_TYPE_CUSTOM, " 0" , DLSSAppDataPath, pd3d12Device);
157172 if (NVSDK_NGX_FAILED (Result))
158- LOG_ERROR_AND_THROW (" NVIDIA NGX D3D12 initialization failed. Result: " , static_cast <Uint32>(Result));
173+ {
174+ LOG_WARNING_MESSAGE (" NVIDIA NGX D3D12 initialization failed. DLSS will not be available. Result: " , static_cast <Uint32>(Result));
175+ return ;
176+ }
159177
160178 Result = NVSDK_NGX_D3D12_GetCapabilityParameters (&m_pNGXParams);
161179 if (NVSDK_NGX_FAILED (Result) || m_pNGXParams == nullptr )
162- LOG_ERROR_AND_THROW (" Failed to get NGX D3D12 capability parameters. Result: " , static_cast <Uint32>(Result));
180+ {
181+ LOG_WARNING_MESSAGE (" Failed to get NGX D3D12 capability parameters. DLSS will not be available. Result: " , static_cast <Uint32>(Result));
182+ m_pNGXParams = nullptr ;
183+ NVSDK_NGX_D3D12_Shutdown1 (pd3d12Device);
184+ }
163185 }
164186
165187 ~DLSSProviderD3D12 ()
166188 {
167189 if (m_pNGXParams != nullptr )
190+ {
168191 NVSDK_NGX_D3D12_DestroyParameters (m_pNGXParams);
169- NVSDK_NGX_D3D12_Shutdown1 (ClassPtrCast<RenderDeviceD3D12Impl>(m_pDevice.RawPtr ())->GetD3D12Device ());
192+ NVSDK_NGX_D3D12_Shutdown1 (ClassPtrCast<RenderDeviceD3D12Impl>(m_pDevice.RawPtr ())->GetD3D12Device ());
193+ }
170194 }
171195
172196 virtual void EnumerateVariants (std::vector<SuperResolutionInfo>& Variants) override final
0 commit comments