Skip to content

Commit 0323e60

Browse files
Implement SuperResolution stubs in D3D11, D3D12, Vulkan, OpenGL, and WebGPU backends
1 parent b9e176c commit 0323e60

32 files changed

+209
-14
lines changed

Graphics/GraphicsEngine/include/RenderDeviceBase.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include "IndexWrapper.hpp"
5353
#include "ThreadPool.hpp"
5454
#include "SpinLock.hpp"
55+
#include "SuperResolution.h"
5556

5657
namespace Diligent
5758
{
@@ -119,6 +120,7 @@ class RenderDeviceBase : public ObjectBase<typename EngineImplTraits::RenderDevi
119120
using PipelineResourceSignatureImplType = typename EngineImplTraits::PipelineResourceSignatureImplType;
120121
using DeviceMemoryImplType = typename EngineImplTraits::DeviceMemoryImplType;
121122
using PipelineStateCacheImplType = typename EngineImplTraits::PipelineStateCacheImplType;
123+
using SuperResolutionImplType = typename EngineImplTraits::SuperResolutionImplType;
122124

123125
/// \param pRefCounters - Reference counters object that controls the lifetime of this render device
124126
/// \param RawMemAllocator - Allocator that will be used to allocate memory for all device objects (including render device itself)
@@ -638,6 +640,17 @@ class RenderDeviceBase : public ObjectBase<typename EngineImplTraits::RenderDevi
638640
});
639641
}
640642

643+
template <typename... ExtraArgsType>
644+
void CreateSuperResolutionImpl(ISuperResolution** ppUpscaler, const SuperResolutionDesc& Desc, const ExtraArgsType&... ExtraArgs)
645+
{
646+
CreateDeviceObject("Super Resolution Upscaler", Desc, ppUpscaler,
647+
[&]() //
648+
{
649+
SuperResolutionImplType* pUpscalerImpl = NEW_RC_OBJ(GetRawAllocator(), "SuperResolution instance", SuperResolutionImplType)(static_cast<RenderDeviceImplType*>(this), Desc, ExtraArgs...);
650+
pUpscalerImpl->QueryInterface(IID_SuperResolution, reinterpret_cast<IObject**>(ppUpscaler));
651+
});
652+
}
653+
641654
template <typename... ExtraArgsType>
642655
void CreateDeferredContextImpl(IDeviceContext** ppContext, const ExtraArgsType&... ExtraArgs)
643656
{

Graphics/GraphicsEngine/src/RenderDeviceBase.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ DeviceFeatures EnableDeviceFeatures(const DeviceFeatures& SupportedFeatures,
120120
ENABLE_FEATURE(NativeMultiDraw, "Native multi-draw commands are");
121121
ENABLE_FEATURE(AsyncShaderCompilation, "Async shader compilation is");
122122
ENABLE_FEATURE(FormattedBuffers, "Formatted buffers are");
123+
ENABLE_FEATURE(SuperResolution, "Super resolution is");
123124
// clang-format on
124125

125-
ASSERT_SIZEOF(DeviceFeatures, 47, "Did you add a new feature to DeviceFeatures? Please handle its status here (if necessary).");
126+
ASSERT_SIZEOF(DeviceFeatures, 48, "Did you add a new feature to DeviceFeatures? Please handle its status here (if necessary).");
126127

127128
return EnabledFeatures;
128129
}

Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ class DeviceContextD3D11Impl final : public DeviceContextBase<EngineD3D11ImplTra
284284
SHADING_RATE_COMBINER PrimitiveCombiner,
285285
SHADING_RATE_COMBINER TextureCombiner) override final;
286286

287+
/// Implementation of IDeviceContext::ExecuteSuperResolution() in Direct3D11 backend.
288+
virtual void DILIGENT_CALL_TYPE ExecuteSuperResolution(const ExecuteSuperResolutionAttribs& Attribs,
289+
ISuperResolution* pUpscaler) override final;
287290
/// Implementation of IDeviceContext::BindSparseResourceMemory() in Direct3D11 backend.
288291
virtual void DILIGENT_CALL_TYPE BindSparseResourceMemory(const BindSparseResourceMemoryAttribs& Attribs) override final;
289292

Graphics/GraphicsEngineD3D11/include/EngineD3D11ImplTraits.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ class TopLevelASD3D11Impl;
7171
class ShaderBindingTableD3D11Impl;
7272
class PipelineResourceSignatureD3D11Impl;
7373
class DeviceMemoryD3D11Impl;
74-
class PipelineStateCacheD3D11Impl
75-
{};
74+
class PipelineStateCacheD3D11Impl;
75+
class SuperResolutionD3D11Impl;
7676

7777
class FixedBlockMemoryAllocator;
7878

@@ -127,7 +127,7 @@ struct EngineD3D11ImplTraits
127127
using PipelineResourceSignatureImplType = PipelineResourceSignatureD3D11Impl;
128128
using DeviceMemoryImplType = DeviceMemoryD3D11Impl;
129129
using PipelineStateCacheImplType = PipelineStateCacheD3D11Impl;
130-
130+
using SuperResolutionImplType = SuperResolutionD3D11Impl;
131131

132132
using BuffViewObjAllocatorType = FixedBlockMemoryAllocator;
133133
using TexViewObjAllocatorType = FixedBlockMemoryAllocator;

Graphics/GraphicsEngineD3D11/include/RenderDeviceD3D11Impl.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ class RenderDeviceD3D11Impl final : public RenderDeviceD3DBase<EngineD3D11ImplTr
111111
virtual void DILIGENT_CALL_TYPE CreateSBT(const ShaderBindingTableDesc& Desc,
112112
IShaderBindingTable** ppSBT) override final;
113113

114+
/// Implementation of IRenderDevice::CreateSuperResolution() in Direct3D11 backend.
115+
virtual void DILIGENT_CALL_TYPE CreateSuperResolution(const SuperResolutionDesc& Desc,
116+
ISuperResolution** ppUpscaler) override final;
117+
118+
/// Implementation of IRenderDevice::GetSuperResolutionSourceSettings() in Direct3D11 backend.
119+
virtual void DILIGENT_CALL_TYPE GetSuperResolutionSourceSettings(const SuperResolutionSourceSettingsAttribs& Attribs,
120+
SuperResolutionSourceSettings& Settings) const override final;
121+
114122
/// Implementation of IRenderDevice::CreatePipelineResourceSignature() in Direct3D11 backend.
115123
virtual void DILIGENT_CALL_TYPE CreatePipelineResourceSignature(const PipelineResourceSignatureDesc& Desc,
116124
IPipelineResourceSignature** ppSignature) override final;

Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,6 +2466,12 @@ void DeviceContextD3D11Impl::SetShadingRate(SHADING_RATE BaseRate, SHADING_RATE_
24662466
UNSUPPORTED("SetShadingRate is not supported in DirectX 11");
24672467
}
24682468

2469+
void DeviceContextD3D11Impl::ExecuteSuperResolution(const ExecuteSuperResolutionAttribs& Attribs,
2470+
ISuperResolution* pUpscaler)
2471+
{
2472+
UNSUPPORTED("ExecuteSuperResolution is not supported in DirectX 11");
2473+
}
2474+
24692475
void DeviceContextD3D11Impl::BindSparseResourceMemory(const BindSparseResourceMemoryAttribs& Attribs)
24702476
{
24712477
TDeviceContextBase::BindSparseResourceMemory(Attribs, 0);

Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ GraphicsAdapterInfo EngineFactoryD3D11Impl::GetGraphicsAdapterInfo(void*
490490
Features.ShaderFloat16 = ShaderFloat16Supported ? DEVICE_FEATURE_STATE_ENABLED : DEVICE_FEATURE_STATE_DISABLED;
491491
}
492492

493-
ASSERT_SIZEOF(Features, 47, "Did you add a new feature to DeviceFeatures? Please handle its status here.");
493+
ASSERT_SIZEOF(Features, 48, "Did you add a new feature to DeviceFeatures? Please handle its status here.");
494494

495495
// Texture properties
496496
{

Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ class TopLevelASD3D11Impl
5858
{};
5959
class ShaderBindingTableD3D11Impl
6060
{};
61+
class PipelineStateCacheD3D11Impl
62+
{};
63+
class SuperResolutionD3D11Impl
64+
{};
6165

6266
RenderDeviceD3D11Impl::RenderDeviceD3D11Impl(IReferenceCounters* pRefCounters,
6367
IMemoryAllocator& RawMemAllocator,
@@ -355,6 +359,20 @@ void RenderDeviceD3D11Impl::CreateSBT(const ShaderBindingTableDesc& Desc,
355359
*ppSBT = nullptr;
356360
}
357361

362+
void RenderDeviceD3D11Impl::CreateSuperResolution(const SuperResolutionDesc& Desc,
363+
ISuperResolution** ppUpscaler)
364+
{
365+
UNSUPPORTED("CreateSuperResolution is not supported in DirectX 11");
366+
*ppUpscaler = nullptr;
367+
}
368+
369+
void RenderDeviceD3D11Impl::GetSuperResolutionSourceSettings(const SuperResolutionSourceSettingsAttribs& Attribs,
370+
SuperResolutionSourceSettings& Settings) const
371+
{
372+
UNSUPPORTED("GetSuperResolutionSourceSettings is not supported in DirectX 11");
373+
Settings = {};
374+
}
375+
358376
void RenderDeviceD3D11Impl::CreatePipelineResourceSignature(const PipelineResourceSignatureDesc& Desc,
359377
IPipelineResourceSignature** ppSignature)
360378
{

Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ class DeviceContextD3D12Impl final : public DeviceContextNextGenBase<EngineD3D12
299299
SHADING_RATE_COMBINER PrimitiveCombiner,
300300
SHADING_RATE_COMBINER TextureCombiner) override final;
301301

302+
/// Implementation of IDeviceContext::ExecuteSuperResolution() in Direct3D12 backend.
303+
virtual void DILIGENT_CALL_TYPE ExecuteSuperResolution(const ExecuteSuperResolutionAttribs& Attribs,
304+
ISuperResolution* pUpscaler) override final;
302305
/// Implementation of IDeviceContext::BindSparseResourceMemory() in Direct3D12 backend.
303306
virtual void DILIGENT_CALL_TYPE BindSparseResourceMemory(const BindSparseResourceMemoryAttribs& Attribs) override final;
304307

Graphics/GraphicsEngineD3D12/include/EngineD3D12ImplTraits.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class ShaderBindingTableD3D12Impl;
7777
class PipelineResourceSignatureD3D12Impl;
7878
class DeviceMemoryD3D12Impl;
7979
class PipelineStateCacheD3D12Impl;
80+
class SuperResolutionD3D12Impl;
8081

8182
class FixedBlockMemoryAllocator;
8283

@@ -138,6 +139,7 @@ struct EngineD3D12ImplTraits
138139
using PipelineResourceSignatureImplType = PipelineResourceSignatureD3D12Impl;
139140
using DeviceMemoryImplType = DeviceMemoryD3D12Impl;
140141
using PipelineStateCacheImplType = PipelineStateCacheD3D12Impl;
142+
using SuperResolutionImplType = SuperResolutionD3D12Impl;
141143

142144
using BuffViewObjAllocatorType = FixedBlockMemoryAllocator;
143145
using TexViewObjAllocatorType = FixedBlockMemoryAllocator;

0 commit comments

Comments
 (0)