@@ -45,23 +45,24 @@ namespace Diligent
4545namespace
4646{
4747
48- class SuperResolutionD3D12_DLSS final : public SuperResolutionBase
48+ NVSDK_NGX_Result CreateDLSSFeatureD3D12 (IDeviceContext* pContext,
49+ NVSDK_NGX_Parameter* pNGXParams,
50+ NVSDK_NGX_DLSS_Create_Params& DLSSCreateParams,
51+ NVSDK_NGX_Handle** ppFeature)
52+ {
53+ ID3D12GraphicsCommandList* pCmdList = ClassPtrCast<IDeviceContextD3D12>(pContext)->GetD3D12CommandList ();
54+ return NGX_D3D12_CREATE_DLSS_EXT (pCmdList, 1 , 1 , ppFeature, pNGXParams, &DLSSCreateParams);
55+ }
56+
57+ class SuperResolutionD3D12_DLSS final : public SuperResolutionDLSS<CreateDLSSFeatureD3D12, NVSDK_NGX_D3D12_ReleaseFeature>
4958{
5059public:
5160 SuperResolutionD3D12_DLSS (IReferenceCounters* pRefCounters,
5261 const SuperResolutionDesc& Desc,
5362 const SuperResolutionInfo& Info,
5463 NVSDK_NGX_Parameter* pNGXParams) :
55- SuperResolutionBase{pRefCounters, Desc, Info},
56- m_pNGXParams{pNGXParams}
64+ SuperResolutionDLSS{pRefCounters, Desc, Info, pNGXParams}
5765 {
58- PopulateHaltonJitterPattern (m_JitterPattern, 64 );
59- }
60-
61- ~SuperResolutionD3D12_DLSS ()
62- {
63- if (m_pDLSSFeature != nullptr )
64- NVSDK_NGX_D3D12_ReleaseFeature (m_pDLSSFeature);
6566 }
6667
6768 virtual void DILIGENT_CALL_TYPE Execute (const ExecuteSuperResolutionAttribs& Attribs) override final
@@ -119,61 +120,23 @@ class SuperResolutionD3D12_DLSS final : public SuperResolutionBase
119120 pCtxImpl->TransitionTextureState (Attribs.pOutputTextureView ->GetTexture (), D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE);
120121 pCtxImpl->Flush ();
121122 }
122-
123- private:
124- NVSDK_NGX_Handle* AcquireFeature (const ExecuteSuperResolutionAttribs& Attribs)
125- {
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;
136-
137- NVSDK_NGX_DLSS_Create_Params DLSSCreateParams{};
138- DLSSCreateParams.Feature .InWidth = m_Desc.InputWidth ;
139- DLSSCreateParams.Feature .InHeight = m_Desc.InputHeight ;
140- DLSSCreateParams.Feature .InTargetWidth = m_Desc.OutputWidth ;
141- DLSSCreateParams.Feature .InTargetHeight = m_Desc.OutputHeight ;
142- DLSSCreateParams.InFeatureCreateFlags = DLSSCreateFeatureFlags;
143-
144- NVSDK_NGX_Handle* pFeature = nullptr ;
145- ID3D12GraphicsCommandList* pCmdList = ClassPtrCast<IDeviceContextD3D12>(Attribs.pContext )->GetD3D12CommandList ();
146- NVSDK_NGX_Result Result = NGX_D3D12_CREATE_DLSS_EXT (pCmdList, 1 , 1 , &pFeature, m_pNGXParams, &DLSSCreateParams);
147-
148- if (NVSDK_NGX_FAILED (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;
155- }
156-
157- NVSDK_NGX_Handle* m_pDLSSFeature = nullptr ;
158- NVSDK_NGX_Parameter* m_pNGXParams = nullptr ;
159- Int32 m_DLSSFeatureFlags = 0 ;
160123};
161124
162125
163- class DLSSProviderD3D12 final : public SuperResolutionProvider
126+ class DLSSProviderD3D12 final : public DLSSProviderBase
164127{
165128public:
166129 DLSSProviderD3D12 (IRenderDevice* pDevice)
167130 {
168131 if (pDevice == nullptr )
169132 LOG_ERROR_AND_THROW (" Device must not be null" );
170- if (RefCntAutoPtr<IRenderDeviceD3D12> pDeviceD3D11 {pDevice, IID_RenderDeviceD3D12})
133+ if (RefCntAutoPtr<IRenderDeviceD3D12> pDeviceD3D12 {pDevice, IID_RenderDeviceD3D12})
171134 {
172- m_pd3d12Device = pDeviceD3D11 ->GetD3D12Device ();
135+ m_pd3d12Device = pDeviceD3D12 ->GetD3D12Device ();
173136 }
174137 else
175138 {
176- LOG_ERROR_AND_THROW (" Device must be of type RENDER_DEVICE_TYPE_D3D11 " );
139+ LOG_ERROR_AND_THROW (" Device must be of type RENDER_DEVICE_TYPE_D3D12 " );
177140 }
178141
179142 NVSDK_NGX_Result Result = NVSDK_NGX_D3D12_Init_with_ProjectID (DLSSProjectId, NVSDK_NGX_ENGINE_TYPE_CUSTOM, " 0" , DLSSAppDataPath, m_pd3d12Device);
@@ -201,16 +164,6 @@ class DLSSProviderD3D12 final : public SuperResolutionProvider
201164 }
202165 }
203166
204- virtual void EnumerateVariants (std::vector<SuperResolutionInfo>& Variants) override final
205- {
206- EnumerateDLSSVariants (m_pNGXParams, Variants);
207- }
208-
209- virtual void GetSourceSettings (const SuperResolutionSourceSettingsAttribs& Attribs, SuperResolutionSourceSettings& Settings) override final
210- {
211- GetDLSSSourceSettings (m_pNGXParams, Attribs, Settings);
212- }
213-
214167 virtual void CreateSuperResolution (const SuperResolutionDesc& Desc, const SuperResolutionInfo& Info, ISuperResolution** ppUpscaler) override final
215168 {
216169 DEV_CHECK_ERR (ppUpscaler != nullptr , " ppUpscaler must not be null" );
@@ -221,7 +174,6 @@ class DLSSProviderD3D12 final : public SuperResolutionProvider
221174
222175private:
223176 CComPtr<ID3D12Device> m_pd3d12Device;
224- NVSDK_NGX_Parameter* m_pNGXParams = nullptr ;
225177};
226178
227179} // anonymous namespace
0 commit comments