Skip to content

Commit e5bfc09

Browse files
MikhailGorobetsTheMostDiligent
authored andcommitted
Add super-resolution support: DLSS (D3D11/D3D12/Vulkan), DirectSR (D3D12), MetalFX (Metal)
1 parent baab22d commit e5bfc09

24 files changed

+2658
-129
lines changed

.github/workflows/msvc_analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
platform: "Win32"
1212
toolset: "x64"
1313
build_type: "Debug"
14-
cmake_args: "-DDILIGENT_NO_GLSLANG=ON -DDILIGENT_NO_HLSL=ON"
14+
cmake_args: "-DDILIGENT_NO_GLSLANG=ON -DDILIGENT_NO_HLSL=ON -DDILIGENT_NO_DLSS=ON -DDILIGENT_NO_DSR=ON"
1515
cmake_generator: "Visual Studio 17 2022"
1616

1717
runs-on: windows-2022

Graphics/SuperResolution/CMakeLists.txt

Lines changed: 88 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,50 @@ include(../../BuildTools/CMake/BuildUtils.cmake)
44

55
project(Diligent-SuperResolution CXX)
66

7+
set(DILIGENT_DLSS_SUPPORTED FALSE CACHE INTERNAL "DLSS is not supported")
8+
set(DILIGENT_DSR_SUPPORTED FALSE CACHE INTERNAL "DirectSR is not supported")
9+
10+
if(PLATFORM_WIN32)
11+
set(DILIGENT_DLSS_SUPPORTED TRUE CACHE INTERNAL "DLSS is supported on Win32 platform")
12+
set(DILIGENT_DSR_SUPPORTED TRUE CACHE INTERNAL "DirectSR is supported on Win32 platform")
13+
endif()
14+
15+
if(${DILIGENT_NO_DLSS})
16+
set(DILIGENT_DLSS_SUPPORTED FALSE CACHE INTERNAL "DLSS is forcibly disabled")
17+
endif()
18+
if(${DILIGENT_NO_DSR})
19+
set(DILIGENT_DSR_SUPPORTED FALSE CACHE INTERNAL "DirectSR is forcibly disabled")
20+
endif()
21+
22+
if(DILIGENT_DSR_SUPPORTED)
23+
# Fetch DirectSR headers
24+
FetchContent_DeclareShallowGit(DirectSR-Headers
25+
GIT_REPOSITORY https://github.com/MikhailGorobets/DirectSR-Headers.git
26+
GIT_TAG master
27+
)
28+
FetchContent_MakeAvailable(DirectSR-Headers)
29+
if(TARGET DirectSR-AgilitySDK)
30+
set_target_properties(DirectSR-AgilitySDK PROPERTIES FOLDER DiligentCore/ThirdParty)
31+
endif()
32+
endif()
33+
34+
if(DILIGENT_DLSS_SUPPORTED)
35+
# Fetch NVIDIA DLSS SDK headers
36+
FetchContent_DeclareShallowGit(DLSS-Headers
37+
GIT_REPOSITORY https://github.com/NVIDIA/DLSS.git
38+
GIT_TAG main
39+
)
40+
FetchContent_MakeAvailable(DLSS-Headers)
41+
endif()
42+
743
set(INCLUDE
844
include/SuperResolutionBase.hpp
945
include/SuperResolutionFactoryBase.hpp
46+
include/SuperResolutionVariants.hpp
47+
include/DLSSProviderD3D12.hpp
48+
include/DLSSProviderD3D11.hpp
49+
include/DLSSProviderVk.hpp
50+
include/DSRProviderD3D12.hpp
1051
)
1152

1253
set(INTERFACE
@@ -16,15 +57,22 @@ set(INTERFACE
1657
)
1758

1859
set(SOURCE
60+
src/SuperResolutionBase.cpp
1961
src/SuperResolutionFactoryBase.cpp
62+
src/SuperResolutionFactory.cpp
63+
src/SuperResolutionFactoryD3D12.cpp
64+
src/SuperResolutionFactoryD3D11.cpp
65+
src/SuperResolutionFactoryVk.cpp
66+
src/SuperResolutionFactoryMtl.cpp
67+
src/DLSSProviderD3D12.cpp
68+
src/DLSSProviderD3D11.cpp
69+
src/DLSSProviderVk.cpp
70+
src/DSRProviderD3D12.cpp
2071
)
2172

22-
if(D3D12_SUPPORTED)
23-
list(APPEND
24-
SOURCE
25-
src/SuperResolutionD3D12.cpp
26-
src/SuperResolutionFactoryD3D12.cpp
27-
)
73+
if(DILIGENT_DLSS_SUPPORTED)
74+
list(APPEND INCLUDE include/SuperResolutionDLSS.hpp)
75+
list(APPEND SOURCE src/SuperResolutionDLSS.cpp)
2876
endif()
2977

3078
set(DLL_SOURCE
@@ -57,6 +105,14 @@ PRIVATE
57105
../GraphicsEngineNextGenBase/include
58106
)
59107

108+
if(DILIGENT_DLSS_SUPPORTED)
109+
target_compile_definitions(Diligent-SuperResolution-static PRIVATE DILIGENT_DLSS_SUPPORTED=1)
110+
endif()
111+
112+
if(DILIGENT_DSR_SUPPORTED)
113+
target_compile_definitions(Diligent-SuperResolution-static PRIVATE DILIGENT_DSR_SUPPORTED=1)
114+
endif()
115+
60116
target_compile_definitions(Diligent-SuperResolution-shared PUBLIC DILIGENT_SUPER_RESOLUTION_SHARED=1)
61117

62118
target_link_libraries(Diligent-SuperResolution-static
@@ -69,11 +125,35 @@ PRIVATE
69125
Diligent-ShaderTools
70126
)
71127

72-
if(D3D12_SUPPORTED)
73-
target_link_libraries(Diligent-SuperResolution-static PRIVATE Diligent-GraphicsEngineD3D12-static)
128+
if(DILIGENT_DSR_SUPPORTED)
129+
target_link_libraries(Diligent-SuperResolution-static PRIVATE Diligent-GraphicsEngineD3D12-static DirectSR-Headers)
74130
target_include_directories(Diligent-SuperResolution-static PRIVATE ../GraphicsEngineD3D12/include)
75131
endif()
76132

133+
if(DILIGENT_DLSS_SUPPORTED)
134+
set(DLSS_SDK_DIR ${FETCHCONTENT_BASE_DIR}/dlss-headers-src)
135+
target_include_directories(Diligent-SuperResolution-static PRIVATE ${DLSS_SDK_DIR}/include)
136+
137+
# Link NGX static library (dynamic CRT /MD variant)
138+
target_link_libraries(Diligent-SuperResolution-static PRIVATE
139+
debug ${DLSS_SDK_DIR}/lib/Windows_x86_64/x64/nvsdk_ngx_d_dbg.lib
140+
optimized ${DLSS_SDK_DIR}/lib/Windows_x86_64/x64/nvsdk_ngx_d.lib
141+
)
142+
143+
if(D3D12_SUPPORTED)
144+
target_link_libraries(Diligent-SuperResolution-static PRIVATE Diligent-GraphicsEngineD3D12-static)
145+
target_include_directories(Diligent-SuperResolution-static PRIVATE ../GraphicsEngineD3D12/include)
146+
endif()
147+
if(D3D11_SUPPORTED)
148+
target_link_libraries(Diligent-SuperResolution-static PRIVATE Diligent-GraphicsEngineD3D11-static)
149+
target_include_directories(Diligent-SuperResolution-static PRIVATE ../GraphicsEngineD3D11/include)
150+
endif()
151+
if(VULKAN_SUPPORTED)
152+
target_link_libraries(Diligent-SuperResolution-static PRIVATE Diligent-GraphicsEngineVk-static Vulkan::Headers)
153+
target_include_directories(Diligent-SuperResolution-static PRIVATE ../GraphicsEngineVulkan/include)
154+
endif()
155+
endif()
156+
77157
target_link_libraries(Diligent-SuperResolution-shared
78158
PUBLIC
79159
Diligent-SuperResolutionInterface
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2026 Diligent Graphics LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* In no event and under no legal theory, whether in tort (including negligence),
17+
* contract, or otherwise, unless required by applicable law (such as deliberate
18+
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
19+
* liable for any damages, including any direct, indirect, special, incidental,
20+
* or consequential damages of any character arising as a result of this License or
21+
* out of the use or inability to use the software (including but not limited to damages
22+
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
23+
* all other commercial damages or losses), even if such Contributor has been advised
24+
* of the possibility of such damages.
25+
*/
26+
27+
#pragma once
28+
29+
#include "SuperResolutionFactory.h"
30+
#include "SuperResolution.h"
31+
#include "RefCntAutoPtr.hpp"
32+
33+
#include <vector>
34+
35+
struct NVSDK_NGX_Parameter;
36+
37+
namespace Diligent
38+
{
39+
40+
class DLSSProviderD3D11 final
41+
{
42+
public:
43+
DLSSProviderD3D11(IRenderDevice* pDevice);
44+
45+
~DLSSProviderD3D11();
46+
47+
void EnumerateVariants(std::vector<SuperResolutionInfo>& Variants);
48+
49+
void GetSourceSettings(const SuperResolutionSourceSettingsAttribs& Attribs, SuperResolutionSourceSettings& Settings);
50+
51+
void CreateSuperResolution(const SuperResolutionDesc& Desc, ISuperResolution** ppUpscaler);
52+
53+
private:
54+
RefCntAutoPtr<IRenderDevice> m_pDevice;
55+
NVSDK_NGX_Parameter* m_pNGXParams = nullptr;
56+
};
57+
58+
} // namespace Diligent
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2026 Diligent Graphics LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* In no event and under no legal theory, whether in tort (including negligence),
17+
* contract, or otherwise, unless required by applicable law (such as deliberate
18+
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
19+
* liable for any damages, including any direct, indirect, special, incidental,
20+
* or consequential damages of any character arising as a result of this License or
21+
* out of the use or inability to use the software (including but not limited to damages
22+
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
23+
* all other commercial damages or losses), even if such Contributor has been advised
24+
* of the possibility of such damages.
25+
*/
26+
27+
#pragma once
28+
29+
#include "SuperResolutionFactory.h"
30+
#include "SuperResolution.h"
31+
#include "RefCntAutoPtr.hpp"
32+
33+
#include <vector>
34+
35+
struct NVSDK_NGX_Parameter;
36+
37+
namespace Diligent
38+
{
39+
40+
class DLSSProviderD3D12 final
41+
{
42+
public:
43+
DLSSProviderD3D12(IRenderDevice* pDevice);
44+
45+
~DLSSProviderD3D12();
46+
47+
void EnumerateVariants(std::vector<SuperResolutionInfo>& Variants);
48+
49+
void GetSourceSettings(const SuperResolutionSourceSettingsAttribs& Attribs, SuperResolutionSourceSettings& Settings);
50+
51+
void CreateSuperResolution(const SuperResolutionDesc& Desc, ISuperResolution** ppUpscaler);
52+
53+
private:
54+
RefCntAutoPtr<IRenderDevice> m_pDevice;
55+
NVSDK_NGX_Parameter* m_pNGXParams = nullptr;
56+
};
57+
58+
} // namespace Diligent
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2026 Diligent Graphics LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* In no event and under no legal theory, whether in tort (including negligence),
17+
* contract, or otherwise, unless required by applicable law (such as deliberate
18+
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
19+
* liable for any damages, including any direct, indirect, special, incidental,
20+
* or consequential damages of any character arising as a result of this License or
21+
* out of the use or inability to use the software (including but not limited to damages
22+
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
23+
* all other commercial damages or losses), even if such Contributor has been advised
24+
* of the possibility of such damages.
25+
*/
26+
27+
#pragma once
28+
29+
#include "SuperResolutionFactory.h"
30+
#include "SuperResolution.h"
31+
#include "RefCntAutoPtr.hpp"
32+
33+
#include <vector>
34+
35+
struct NVSDK_NGX_Parameter;
36+
37+
namespace Diligent
38+
{
39+
40+
class DLSSProviderVk final
41+
{
42+
public:
43+
DLSSProviderVk(IRenderDevice* pDevice);
44+
45+
~DLSSProviderVk();
46+
47+
void EnumerateVariants(std::vector<SuperResolutionInfo>& Variants);
48+
49+
void GetSourceSettings(const SuperResolutionSourceSettingsAttribs& Attribs, SuperResolutionSourceSettings& Settings);
50+
51+
void CreateSuperResolution(const SuperResolutionDesc& Desc, ISuperResolution** ppUpscaler);
52+
53+
private:
54+
RefCntAutoPtr<IRenderDevice> m_pDevice;
55+
NVSDK_NGX_Parameter* m_pNGXParams = nullptr;
56+
};
57+
58+
} // namespace Diligent
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright 2026 Diligent Graphics LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* In no event and under no legal theory, whether in tort (including negligence),
17+
* contract, or otherwise, unless required by applicable law (such as deliberate
18+
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
19+
* liable for any damages, including any direct, indirect, special, incidental,
20+
* or consequential damages of any character arising as a result of this License or
21+
* out of the use or inability to use the software (including but not limited to damages
22+
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
23+
* all other commercial damages or losses), even if such Contributor has been advised
24+
* of the possibility of such damages.
25+
*/
26+
27+
#pragma once
28+
29+
#include "SuperResolutionFactory.h"
30+
#include "SuperResolution.h"
31+
#include "RefCntAutoPtr.hpp"
32+
33+
#include <vector>
34+
35+
struct IDSRDevice;
36+
37+
namespace Diligent
38+
{
39+
40+
class DSRProviderD3D12 final
41+
{
42+
public:
43+
DSRProviderD3D12(IRenderDevice* pDevice);
44+
45+
~DSRProviderD3D12();
46+
47+
void EnumerateVariants(std::vector<SuperResolutionInfo>& Variants);
48+
49+
void GetSourceSettings(const SuperResolutionSourceSettingsAttribs& Attribs,
50+
SuperResolutionSourceSettings& Settings);
51+
52+
void CreateSuperResolution(const SuperResolutionDesc& Desc,
53+
ISuperResolution** ppUpscaler);
54+
55+
private:
56+
RefCntAutoPtr<IRenderDevice> m_pDevice;
57+
IDSRDevice* m_pDSRDevice = nullptr;
58+
};
59+
60+
} // namespace Diligent

0 commit comments

Comments
 (0)