Skip to content

Commit e8532a5

Browse files
SuperResolution: use public GraphicsEngine interfaces
1 parent a19144b commit e8532a5

File tree

8 files changed

+192
-170
lines changed

8 files changed

+192
-170
lines changed

Graphics/GraphicsEngineD3DBase/include/D3DErrors.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2025 Diligent Graphics LLC
2+
* Copyright 2019-2026 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -124,3 +124,14 @@ class ComErrorDesc
124124
LOG_ERROR_MESSAGE(Message, "\nHRESULT Desc: ", ErrDesc.Get()); \
125125
} \
126126
} while (false)
127+
128+
#define LOG_D3D_WARNING(Expr, Message) \
129+
do \
130+
{ \
131+
HRESULT _hr_ = Expr; \
132+
if (FAILED(_hr_)) \
133+
{ \
134+
ComErrorDesc ErrDesc(_hr_); \
135+
LOG_WARNING_MESSAGE(Message, "\nHRESULT Desc: ", ErrDesc.Get()); \
136+
} \
137+
} while (false)

Graphics/SuperResolution/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,23 +143,19 @@ PRIVATE
143143

144144
if(DILIGENT_DSR_SUPPORTED)
145145
target_link_libraries(Diligent-SuperResolution-static PRIVATE Diligent-GraphicsEngineD3D12-static DirectSR-Headers)
146-
target_include_directories(Diligent-SuperResolution-static PRIVATE ../GraphicsEngineD3D12/include)
147146
endif()
148147

149148
if(DILIGENT_DLSS_SUPPORTED)
150149
target_link_libraries(Diligent-SuperResolution-static PRIVATE DLSS-Headers DLSS-NGX)
151150

152151
if(D3D12_SUPPORTED)
153-
target_link_libraries(Diligent-SuperResolution-static PRIVATE Diligent-GraphicsEngineD3D12-static)
154-
target_include_directories(Diligent-SuperResolution-static PRIVATE ../GraphicsEngineD3D12/include)
152+
target_link_libraries(Diligent-SuperResolution-static PRIVATE Diligent-GraphicsEngineD3D12Interface)
155153
endif()
156154
if(D3D11_SUPPORTED)
157-
target_link_libraries(Diligent-SuperResolution-static PRIVATE Diligent-GraphicsEngineD3D11-static)
158-
target_include_directories(Diligent-SuperResolution-static PRIVATE ../GraphicsEngineD3D11/include)
155+
target_link_libraries(Diligent-SuperResolution-static PRIVATE Diligent-GraphicsEngineD3D11Interface)
159156
endif()
160157
if(VULKAN_SUPPORTED)
161158
target_link_libraries(Diligent-SuperResolution-static PRIVATE Diligent-GraphicsEngineVk-static Vulkan::Headers)
162-
target_include_directories(Diligent-SuperResolution-static PRIVATE ../GraphicsEngineVulkan/include)
163159
endif()
164160
endif()
165161

Graphics/SuperResolution/include/SuperResolutionProvider.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ class SuperResolutionProvider
5555
switch (Attribs.OptimizationType)
5656
{
5757
// clang-format off
58-
case SUPER_RESOLUTION_OPTIMIZATION_TYPE_MAX_QUALITY: ScaleFactor = 1.0f / 1.3f; break;
59-
case SUPER_RESOLUTION_OPTIMIZATION_TYPE_HIGH_QUALITY: ScaleFactor = 1.0f / 1.5f; break;
60-
case SUPER_RESOLUTION_OPTIMIZATION_TYPE_BALANCED: ScaleFactor = 1.0f / 1.7f; break;
61-
case SUPER_RESOLUTION_OPTIMIZATION_TYPE_HIGH_PERFORMANCE: ScaleFactor = 0.5f; break;
62-
case SUPER_RESOLUTION_OPTIMIZATION_TYPE_MAX_PERFORMANCE: ScaleFactor = 1.0f / 3.0f; break;
63-
default: ScaleFactor = 1.0f / 1.7f; break;
58+
case SUPER_RESOLUTION_OPTIMIZATION_TYPE_MAX_QUALITY: ScaleFactor = 12.f / 16.f; break;
59+
case SUPER_RESOLUTION_OPTIMIZATION_TYPE_HIGH_QUALITY: ScaleFactor = 11.f / 16.f; break;
60+
case SUPER_RESOLUTION_OPTIMIZATION_TYPE_BALANCED: ScaleFactor = 9.f / 16.f; break;
61+
case SUPER_RESOLUTION_OPTIMIZATION_TYPE_HIGH_PERFORMANCE: ScaleFactor = 8.f / 16.f; break;
62+
case SUPER_RESOLUTION_OPTIMIZATION_TYPE_MAX_PERFORMANCE: ScaleFactor = 5.f / 16.f; break;
63+
default: ScaleFactor = 9.f / 16.f; break;
6464
// clang-format on
6565
}
6666

Graphics/SuperResolution/src/DLSSProviderD3D11.cpp

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@
3030
#include "SuperResolutionBase.hpp"
3131
#include "SuperResolutionVariants.hpp"
3232

33+
#include <d3d11.h>
34+
#include <atlbase.h>
3335
#include <nvsdk_ngx_helpers.h>
3436

35-
#include "../../GraphicsEngineD3D11/include/pch.h"
36-
#include "RenderDeviceD3D11Impl.hpp"
37-
#include "DeviceContextD3D11Impl.hpp"
38-
#include "TextureBaseD3D11.hpp"
37+
#include "RenderDeviceD3D11.h"
38+
#include "DeviceContextD3D11.h"
39+
#include "TextureD3D11.h"
40+
#include "EngineMemory.h"
3941

4042
namespace Diligent
4143
{
@@ -47,12 +49,10 @@ class SuperResolutionD3D11_DLSS final : public SuperResolutionBase
4749
{
4850
public:
4951
SuperResolutionD3D11_DLSS(IReferenceCounters* pRefCounters,
50-
IRenderDevice* pDevice,
5152
const SuperResolutionDesc& Desc,
5253
const SuperResolutionInfo& Info,
5354
NVSDK_NGX_Parameter* pNGXParams) :
5455
SuperResolutionBase{pRefCounters, Desc, Info},
55-
m_pDevice{pDevice},
5656
m_pNGXParams{pNGXParams}
5757
{
5858
PopulateHaltonJitterPattern(m_JitterPattern, 64);
@@ -72,17 +72,15 @@ class SuperResolutionD3D11_DLSS final : public SuperResolutionBase
7272
if (pDLSSFeature == nullptr)
7373
return;
7474

75-
DeviceContextD3D11Impl* pCtxImpl = ClassPtrCast<DeviceContextD3D11Impl>(Attribs.pContext);
76-
7775
auto GetD3D11Resource = [](ITextureView* pView) -> ID3D11Resource* {
78-
if (pView != nullptr)
79-
return ClassPtrCast<TextureBaseD3D11>(pView->GetTexture())->GetD3D11Texture();
80-
return nullptr;
76+
return pView != nullptr ?
77+
ClassPtrCast<ITextureD3D11>(pView->GetTexture())->GetD3D11Texture() :
78+
nullptr;
8179
};
8280

83-
ID3D11DeviceContext* pd3d11DeviceContext = pCtxImpl->GetD3D11DeviceContext();
81+
ID3D11DeviceContext* pd3d11Ctx = ClassPtrCast<IDeviceContextD3D11>(Attribs.pContext)->GetD3D11DeviceContext();
8482

85-
NVSDK_NGX_D3D11_DLSS_Eval_Params EvalParams = {};
83+
NVSDK_NGX_D3D11_DLSS_Eval_Params EvalParams{};
8684
EvalParams.Feature.pInColor = GetD3D11Resource(Attribs.pColorTextureSRV);
8785
EvalParams.Feature.pInOutput = GetD3D11Resource(Attribs.pOutputTextureView);
8886
EvalParams.pInDepth = GetD3D11Resource(Attribs.pDepthTextureSRV);
@@ -101,7 +99,7 @@ class SuperResolutionD3D11_DLSS final : public SuperResolutionBase
10199
EvalParams.InPreExposure = Attribs.PreExposure;
102100
EvalParams.InExposureScale = Attribs.ExposureScale;
103101

104-
NVSDK_NGX_Result Result = NGX_D3D11_EVALUATE_DLSS_EXT(pd3d11DeviceContext, pDLSSFeature, m_pNGXParams, &EvalParams);
102+
NVSDK_NGX_Result Result = NGX_D3D11_EVALUATE_DLSS_EXT(pd3d11Ctx, pDLSSFeature, m_pNGXParams, &EvalParams);
105103
if (NVSDK_NGX_FAILED(Result))
106104
LOG_ERROR_MESSAGE("DLSS D3D11 evaluation failed. NGX Result: ", static_cast<Uint32>(Result));
107105
}
@@ -120,15 +118,15 @@ class SuperResolutionD3D11_DLSS final : public SuperResolutionBase
120118
}
121119
m_DLSSFeatureFlags = DLSSCreateFeatureFlags;
122120

123-
NVSDK_NGX_DLSS_Create_Params DLSSCreateParams = {};
124-
DLSSCreateParams.Feature.InWidth = m_Desc.InputWidth;
125-
DLSSCreateParams.Feature.InHeight = m_Desc.InputHeight;
126-
DLSSCreateParams.Feature.InTargetWidth = m_Desc.OutputWidth;
127-
DLSSCreateParams.Feature.InTargetHeight = m_Desc.OutputHeight;
128-
DLSSCreateParams.InFeatureCreateFlags = DLSSCreateFeatureFlags;
121+
NVSDK_NGX_DLSS_Create_Params DLSSCreateParams{};
122+
DLSSCreateParams.Feature.InWidth = m_Desc.InputWidth;
123+
DLSSCreateParams.Feature.InHeight = m_Desc.InputHeight;
124+
DLSSCreateParams.Feature.InTargetWidth = m_Desc.OutputWidth;
125+
DLSSCreateParams.Feature.InTargetHeight = m_Desc.OutputHeight;
126+
DLSSCreateParams.InFeatureCreateFlags = DLSSCreateFeatureFlags;
129127

130128
NVSDK_NGX_Handle* pFeature = nullptr;
131-
ID3D11DeviceContext* pd3d11Ctx = ClassPtrCast<DeviceContextD3D11Impl>(Attribs.pContext)->GetD3D11DeviceContext();
129+
ID3D11DeviceContext* pd3d11Ctx = ClassPtrCast<IDeviceContextD3D11>(Attribs.pContext)->GetD3D11DeviceContext();
132130
NVSDK_NGX_Result Result = NGX_D3D11_CREATE_DLSS_EXT(pd3d11Ctx, &pFeature, m_pNGXParams, &DLSSCreateParams);
133131

134132
if (NVSDK_NGX_FAILED(Result))
@@ -140,20 +138,28 @@ class SuperResolutionD3D11_DLSS final : public SuperResolutionBase
140138
return m_pDLSSFeature;
141139
}
142140

143-
RefCntAutoPtr<IRenderDevice> m_pDevice;
144-
NVSDK_NGX_Handle* m_pDLSSFeature = nullptr;
145-
NVSDK_NGX_Parameter* m_pNGXParams = nullptr;
146-
Int32 m_DLSSFeatureFlags = 0;
141+
NVSDK_NGX_Handle* m_pDLSSFeature = nullptr;
142+
NVSDK_NGX_Parameter* m_pNGXParams = nullptr;
143+
Int32 m_DLSSFeatureFlags = 0;
147144
};
148145

149146
class DLSSProviderD3D11 final : public SuperResolutionProvider
150147
{
151148
public:
152-
DLSSProviderD3D11(IRenderDevice* pDevice) :
153-
m_pDevice{pDevice}
149+
DLSSProviderD3D11(IRenderDevice* pDevice)
154150
{
155-
ID3D11Device* pd3d11Device = ClassPtrCast<RenderDeviceD3D11Impl>(pDevice)->GetD3D11Device();
156-
NVSDK_NGX_Result Result = NVSDK_NGX_D3D11_Init_with_ProjectID(DLSSProjectId, NVSDK_NGX_ENGINE_TYPE_CUSTOM, "0", DLSSAppDataPath, pd3d11Device);
151+
if (pDevice == nullptr)
152+
LOG_ERROR_AND_THROW("Device must not be null");
153+
if (RefCntAutoPtr<IRenderDeviceD3D11> pDeviceD3D11{pDevice, IID_RenderDeviceD3D11})
154+
{
155+
m_pd3d11Device = pDeviceD3D11->GetD3D11Device();
156+
}
157+
else
158+
{
159+
LOG_ERROR_AND_THROW("Device must be of type RENDER_DEVICE_TYPE_D3D11");
160+
}
161+
162+
NVSDK_NGX_Result Result = NVSDK_NGX_D3D11_Init_with_ProjectID(DLSSProjectId, NVSDK_NGX_ENGINE_TYPE_CUSTOM, "0", DLSSAppDataPath, m_pd3d11Device);
157163
if (NVSDK_NGX_FAILED(Result))
158164
{
159165
LOG_WARNING_MESSAGE("NVIDIA NGX D3D11 initialization failed. DLSS will not be available. Result: ", static_cast<Uint32>(Result));
@@ -165,7 +171,7 @@ class DLSSProviderD3D11 final : public SuperResolutionProvider
165171
{
166172
LOG_WARNING_MESSAGE("Failed to get NGX D3D11 capability parameters. DLSS will not be available. Result: ", static_cast<Uint32>(Result));
167173
m_pNGXParams = nullptr;
168-
NVSDK_NGX_D3D11_Shutdown1(pd3d11Device);
174+
NVSDK_NGX_D3D11_Shutdown1(m_pd3d11Device);
169175
}
170176
}
171177

@@ -174,7 +180,7 @@ class DLSSProviderD3D11 final : public SuperResolutionProvider
174180
if (m_pNGXParams != nullptr)
175181
{
176182
NVSDK_NGX_D3D11_DestroyParameters(m_pNGXParams);
177-
NVSDK_NGX_D3D11_Shutdown1(ClassPtrCast<RenderDeviceD3D11Impl>(m_pDevice.RawPtr())->GetD3D11Device());
183+
NVSDK_NGX_D3D11_Shutdown1(m_pd3d11Device);
178184
}
179185
}
180186

@@ -190,16 +196,15 @@ class DLSSProviderD3D11 final : public SuperResolutionProvider
190196

191197
virtual void CreateSuperResolution(const SuperResolutionDesc& Desc, const SuperResolutionInfo& Info, ISuperResolution** ppUpscaler) override final
192198
{
193-
DEV_CHECK_ERR(m_pDevice != nullptr, "Render device must not be null");
194199
DEV_CHECK_ERR(ppUpscaler != nullptr, "ppUpscaler must not be null");
195200

196-
SuperResolutionD3D11_DLSS* pUpscaler = NEW_RC_OBJ(GetRawAllocator(), "SuperResolutionD3D11_DLSS instance", SuperResolutionD3D11_DLSS)(m_pDevice, Desc, Info, m_pNGXParams);
201+
SuperResolutionD3D11_DLSS* pUpscaler = NEW_RC_OBJ(GetRawAllocator(), "SuperResolutionD3D11_DLSS instance", SuperResolutionD3D11_DLSS)(Desc, Info, m_pNGXParams);
197202
pUpscaler->QueryInterface(IID_SuperResolution, reinterpret_cast<IObject**>(ppUpscaler));
198203
}
199204

200205
private:
201-
RefCntAutoPtr<IRenderDevice> m_pDevice;
202-
NVSDK_NGX_Parameter* m_pNGXParams = nullptr;
206+
CComPtr<ID3D11Device> m_pd3d11Device;
207+
NVSDK_NGX_Parameter* m_pNGXParams = nullptr;
203208
};
204209

205210
} // anonymous namespace

Graphics/SuperResolution/src/DLSSProviderD3D12.cpp

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@
3030
#include "SuperResolutionBase.hpp"
3131
#include "SuperResolutionVariants.hpp"
3232

33+
#include <d3d12.h>
34+
#include <atlbase.h>
3335
#include <nvsdk_ngx_helpers.h>
3436

35-
#include "../../GraphicsEngineD3D12/include/pch.h"
36-
#include "RenderDeviceD3D12Impl.hpp"
37-
#include "DeviceContextD3D12Impl.hpp"
38-
#include "TextureD3D12Impl.hpp"
37+
#include "RenderDeviceD3D12.h"
38+
#include "DeviceContextD3D12.h"
39+
#include "TextureD3D12.h"
40+
#include "EngineMemory.h"
3941

4042
namespace Diligent
4143
{
@@ -47,12 +49,10 @@ class SuperResolutionD3D12_DLSS final : public SuperResolutionBase
4749
{
4850
public:
4951
SuperResolutionD3D12_DLSS(IReferenceCounters* pRefCounters,
50-
IRenderDevice* pDevice,
5152
const SuperResolutionDesc& Desc,
5253
const SuperResolutionInfo& Info,
5354
NVSDK_NGX_Parameter* pNGXParams) :
5455
SuperResolutionBase{pRefCounters, Desc, Info},
55-
m_pDevice{pDevice},
5656
m_pNGXParams{pNGXParams}
5757
{
5858
PopulateHaltonJitterPattern(m_JitterPattern, 64);
@@ -72,12 +72,12 @@ class SuperResolutionD3D12_DLSS final : public SuperResolutionBase
7272
if (pDLSSFeature == nullptr)
7373
return;
7474

75-
DeviceContextD3D12Impl* pCtxImpl = ClassPtrCast<DeviceContextD3D12Impl>(Attribs.pContext);
75+
IDeviceContextD3D12* pCtxImpl = ClassPtrCast<IDeviceContextD3D12>(Attribs.pContext);
7676

7777
auto GetD3D12Resource = [](ITextureView* pView) -> ID3D12Resource* {
78-
if (pView != nullptr)
79-
return ClassPtrCast<TextureD3D12Impl>(pView->GetTexture())->GetD3D12Resource();
80-
return nullptr;
78+
return pView != nullptr ?
79+
ClassPtrCast<ITextureD3D12>(pView->GetTexture())->GetD3D12Texture() :
80+
nullptr;
8181
};
8282

8383
pCtxImpl->TransitionTextureState(Attribs.pColorTextureSRV->GetTexture(), D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
@@ -93,7 +93,7 @@ class SuperResolutionD3D12_DLSS final : public SuperResolutionBase
9393

9494
ID3D12GraphicsCommandList* pCmdList = pCtxImpl->GetD3D12CommandList();
9595

96-
NVSDK_NGX_D3D12_DLSS_Eval_Params EvalParams = {};
96+
NVSDK_NGX_D3D12_DLSS_Eval_Params EvalParams{};
9797
EvalParams.Feature.pInColor = GetD3D12Resource(Attribs.pColorTextureSRV);
9898
EvalParams.Feature.pInOutput = GetD3D12Resource(Attribs.pOutputTextureView);
9999
EvalParams.pInDepth = GetD3D12Resource(Attribs.pDepthTextureSRV);
@@ -134,15 +134,15 @@ class SuperResolutionD3D12_DLSS final : public SuperResolutionBase
134134
}
135135
m_DLSSFeatureFlags = DLSSCreateFeatureFlags;
136136

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;
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;
143143

144144
NVSDK_NGX_Handle* pFeature = nullptr;
145-
ID3D12GraphicsCommandList* pCmdList = ClassPtrCast<DeviceContextD3D12Impl>(Attribs.pContext)->GetD3D12CommandList();
145+
ID3D12GraphicsCommandList* pCmdList = ClassPtrCast<IDeviceContextD3D12>(Attribs.pContext)->GetD3D12CommandList();
146146
NVSDK_NGX_Result Result = NGX_D3D12_CREATE_DLSS_EXT(pCmdList, 1, 1, &pFeature, m_pNGXParams, &DLSSCreateParams);
147147

148148
if (NVSDK_NGX_FAILED(Result))
@@ -154,21 +154,29 @@ class SuperResolutionD3D12_DLSS final : public SuperResolutionBase
154154
return m_pDLSSFeature;
155155
}
156156

157-
RefCntAutoPtr<IRenderDevice> m_pDevice;
158-
NVSDK_NGX_Handle* m_pDLSSFeature = nullptr;
159-
NVSDK_NGX_Parameter* m_pNGXParams = nullptr;
160-
Int32 m_DLSSFeatureFlags = 0;
157+
NVSDK_NGX_Handle* m_pDLSSFeature = nullptr;
158+
NVSDK_NGX_Parameter* m_pNGXParams = nullptr;
159+
Int32 m_DLSSFeatureFlags = 0;
161160
};
162161

163162

164163
class DLSSProviderD3D12 final : public SuperResolutionProvider
165164
{
166165
public:
167-
DLSSProviderD3D12(IRenderDevice* pDevice) :
168-
m_pDevice{pDevice}
166+
DLSSProviderD3D12(IRenderDevice* pDevice)
169167
{
170-
ID3D12Device* pd3d12Device = ClassPtrCast<RenderDeviceD3D12Impl>(pDevice)->GetD3D12Device();
171-
NVSDK_NGX_Result Result = NVSDK_NGX_D3D12_Init_with_ProjectID(DLSSProjectId, NVSDK_NGX_ENGINE_TYPE_CUSTOM, "0", DLSSAppDataPath, pd3d12Device);
168+
if (pDevice == nullptr)
169+
LOG_ERROR_AND_THROW("Device must not be null");
170+
if (RefCntAutoPtr<IRenderDeviceD3D12> pDeviceD3D11{pDevice, IID_RenderDeviceD3D12})
171+
{
172+
m_pd3d12Device = pDeviceD3D11->GetD3D12Device();
173+
}
174+
else
175+
{
176+
LOG_ERROR_AND_THROW("Device must be of type RENDER_DEVICE_TYPE_D3D11");
177+
}
178+
179+
NVSDK_NGX_Result Result = NVSDK_NGX_D3D12_Init_with_ProjectID(DLSSProjectId, NVSDK_NGX_ENGINE_TYPE_CUSTOM, "0", DLSSAppDataPath, m_pd3d12Device);
172180
if (NVSDK_NGX_FAILED(Result))
173181
{
174182
LOG_WARNING_MESSAGE("NVIDIA NGX D3D12 initialization failed. DLSS will not be available. Result: ", static_cast<Uint32>(Result));
@@ -180,7 +188,7 @@ class DLSSProviderD3D12 final : public SuperResolutionProvider
180188
{
181189
LOG_WARNING_MESSAGE("Failed to get NGX D3D12 capability parameters. DLSS will not be available. Result: ", static_cast<Uint32>(Result));
182190
m_pNGXParams = nullptr;
183-
NVSDK_NGX_D3D12_Shutdown1(pd3d12Device);
191+
NVSDK_NGX_D3D12_Shutdown1(m_pd3d12Device);
184192
}
185193
}
186194

@@ -189,7 +197,7 @@ class DLSSProviderD3D12 final : public SuperResolutionProvider
189197
if (m_pNGXParams != nullptr)
190198
{
191199
NVSDK_NGX_D3D12_DestroyParameters(m_pNGXParams);
192-
NVSDK_NGX_D3D12_Shutdown1(ClassPtrCast<RenderDeviceD3D12Impl>(m_pDevice.RawPtr())->GetD3D12Device());
200+
NVSDK_NGX_D3D12_Shutdown1(m_pd3d12Device);
193201
}
194202
}
195203

@@ -205,16 +213,15 @@ class DLSSProviderD3D12 final : public SuperResolutionProvider
205213

206214
virtual void CreateSuperResolution(const SuperResolutionDesc& Desc, const SuperResolutionInfo& Info, ISuperResolution** ppUpscaler) override final
207215
{
208-
DEV_CHECK_ERR(m_pDevice != nullptr, "Render device must not be null");
209216
DEV_CHECK_ERR(ppUpscaler != nullptr, "ppUpscaler must not be null");
210217

211-
SuperResolutionD3D12_DLSS* pUpscaler = NEW_RC_OBJ(GetRawAllocator(), "SuperResolutionD3D12_DLSS instance", SuperResolutionD3D12_DLSS)(m_pDevice, Desc, Info, m_pNGXParams);
218+
SuperResolutionD3D12_DLSS* pUpscaler = NEW_RC_OBJ(GetRawAllocator(), "SuperResolutionD3D12_DLSS instance", SuperResolutionD3D12_DLSS)(Desc, Info, m_pNGXParams);
212219
pUpscaler->QueryInterface(IID_SuperResolution, reinterpret_cast<IObject**>(ppUpscaler));
213220
}
214221

215222
private:
216-
RefCntAutoPtr<IRenderDevice> m_pDevice;
217-
NVSDK_NGX_Parameter* m_pNGXParams = nullptr;
223+
CComPtr<ID3D12Device> m_pd3d12Device;
224+
NVSDK_NGX_Parameter* m_pNGXParams = nullptr;
218225
};
219226

220227
} // anonymous namespace

0 commit comments

Comments
 (0)