Skip to content

Commit eedebec

Browse files
Add DirectSR (D3D12) super resolution implementation
1 parent 65bacb2 commit eedebec

7 files changed

Lines changed: 965 additions & 3 deletions

File tree

.github/workflows/msvc_analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
# Ruleset file that will determine what checks will be run
6161
ruleset: NativeRecommendedRules.ruleset
6262
# Paths to ignore analysis of CMake targets and includes
63-
ignoredPaths: '${{ github.workspace }}/ThirdParty'
63+
ignoredPaths: '${{ github.workspace }}/ThirdParty;${{ env.DILIGENT_BUILD_DIR }}/_deps'
6464

6565
# Upload SARIF file to GitHub Code Scanning Alerts
6666
- name: Upload SARIF to GitHub

Graphics/SuperResolution/CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ include(../../BuildTools/CMake/BuildUtils.cmake)
44

55
project(Diligent-SuperResolution CXX)
66

7+
if(D3D12_SUPPORTED)
8+
# Fetch DirectSR headers
9+
FetchContent_DeclareShallowGit(DirectSR-Headers
10+
GIT_REPOSITORY https://github.com/MikhailGorobets/DirectSR-Headers.git
11+
GIT_TAG dev
12+
)
13+
FetchContent_MakeAvailable(DirectSR-Headers)
14+
if(TARGET DirectSR-AgilitySDK)
15+
set_target_properties(DirectSR-AgilitySDK PROPERTIES FOLDER DiligentCore/ThirdParty)
16+
endif()
17+
endif()
18+
719
set(INCLUDE
820
include/SuperResolutionBase.hpp
921
include/SuperResolutionInternal.hpp
@@ -20,6 +32,7 @@ set(SOURCE
2032
)
2133

2234
if(D3D12_SUPPORTED)
35+
list(APPEND INCLUDE include/SuperResolution_D3D12.hpp)
2336
list(APPEND SOURCE src/SuperResolution_D3D12.cpp)
2437
endif()
2538

@@ -66,7 +79,7 @@ PRIVATE
6679
)
6780

6881
if(D3D12_SUPPORTED)
69-
target_link_libraries(Diligent-SuperResolution-static PRIVATE Diligent-GraphicsEngineD3D12-static)
82+
target_link_libraries(Diligent-SuperResolution-static PRIVATE Diligent-GraphicsEngineD3D12-static DirectSR-Headers)
7083
target_include_directories(Diligent-SuperResolution-static PRIVATE ../GraphicsEngineD3D12/include)
7184
endif()
7285

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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 "SuperResolutionInternal.hpp"
30+
31+
#include "../../GraphicsEngineD3D12/include/pch.h"
32+
#include <directsr.h>
33+
34+
namespace Diligent
35+
{
36+
37+
CComPtr<IDSRDevice> CreateDSRDeviceD3D12(IRenderDevice* pDevice);
38+
39+
void EnumerateVariantsD3D12(IDSRDevice* pDSRDevice,
40+
std::vector<SuperResolutionInfo>& Variants);
41+
42+
void GetSourceSettingsD3D12(IDSRDevice* pDSRDevice,
43+
const SuperResolutionSourceSettingsAttribs& Attribs,
44+
SuperResolutionSourceSettings& Settings);
45+
46+
void CreateSuperResolutionD3D12(IRenderDevice* pDevice,
47+
IDSRDevice* pDSRDevice,
48+
const SuperResolutionDesc& Desc,
49+
ISuperResolution** ppUpscaler);
50+
51+
} // namespace Diligent

Graphics/SuperResolution/src/SuperResolutionFactory.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
#include "DebugUtilities.hpp"
3434
#include "SuperResolutionInternal.hpp"
3535

36+
#if D3D12_SUPPORTED
37+
# include "SuperResolution_D3D12.hpp"
38+
#endif
39+
3640
namespace Diligent
3741
{
3842

@@ -68,18 +72,31 @@ class SuperResolutionFactoryImpl final : public ObjectBase<ISuperResolutionFacto
6872

6973
RefCntAutoPtr<IRenderDevice> m_pDevice;
7074
SuperResolutionVariants m_Variants{};
75+
76+
#if D3D12_SUPPORTED
77+
CComPtr<IDSRDevice> m_pDSRDevice;
78+
#endif
7179
};
7280

7381

7482
SuperResolutionFactoryImpl::SuperResolutionFactoryImpl(IReferenceCounters* pRefCounters, IRenderDevice* pDevice) :
7583
TBase{pRefCounters},
7684
m_pDevice{pDevice}
7785
{
86+
#if D3D12_SUPPORTED
87+
if (m_pDevice != nullptr && m_pDevice->GetDeviceInfo().Type == RENDER_DEVICE_TYPE_D3D12)
88+
m_pDSRDevice = CreateDSRDeviceD3D12(m_pDevice);
89+
#endif
90+
7891
PopulateVariants();
7992
}
8093

8194
void SuperResolutionFactoryImpl::PopulateVariants()
8295
{
96+
#if D3D12_SUPPORTED
97+
if (m_pDSRDevice)
98+
EnumerateVariantsD3D12(m_pDSRDevice, m_Variants[SUPER_RESOLUTION_BACKEND_D3D12_DSR]);
99+
#endif
83100
}
84101

85102
SUPER_RESOLUTION_BACKEND SuperResolutionFactoryImpl::FindVariant(const INTERFACE_ID& VariantId) const
@@ -133,6 +150,11 @@ void SuperResolutionFactoryImpl::GetSourceSettings(const SuperResolutionSourceSe
133150

134151
switch (Backend)
135152
{
153+
#if D3D12_SUPPORTED
154+
case SUPER_RESOLUTION_BACKEND_D3D12_DSR:
155+
GetSourceSettingsD3D12(m_pDSRDevice, Attribs, Settings);
156+
break;
157+
#endif
136158
default:
137159
LOG_WARNING_MESSAGE("Unknown super resolution backend");
138160
break;
@@ -158,6 +180,11 @@ void SuperResolutionFactoryImpl::CreateSuperResolution(const SuperResolutionDesc
158180
{
159181
switch (Backend)
160182
{
183+
#if D3D12_SUPPORTED
184+
case SUPER_RESOLUTION_BACKEND_D3D12_DSR:
185+
CreateSuperResolutionD3D12(m_pDevice, m_pDSRDevice, Desc, ppUpscaler);
186+
break;
187+
#endif
161188
default:
162189
LOG_ERROR_MESSAGE("Unknown super resolution backend");
163190
break;

0 commit comments

Comments
 (0)