Go to the documentation of this file.
49 #ifndef D3D12_RAYTRACING_MAX_RAY_GENERATION_SHADER_THREADS
50 # define D3D12_RAYTRACING_MAX_RAY_GENERATION_SHADER_THREADS (1073741824)
52 #ifndef D3D12_RAYTRACING_MAX_SHADER_RECORD_STRIDE
53 # define D3D12_RAYTRACING_MAX_SHADER_RECORD_STRIDE (4096)
55 #ifndef D3D12_RAYTRACING_MAX_INSTANCES_PER_TOP_LEVEL_ACCELERATION_STRUCTURE
56 # define D3D12_RAYTRACING_MAX_INSTANCES_PER_TOP_LEVEL_ACCELERATION_STRUCTURE (16777216)
58 #ifndef D3D12_RAYTRACING_MAX_PRIMITIVES_PER_BOTTOM_LEVEL_ACCELERATION_STRUCTURE
59 # define D3D12_RAYTRACING_MAX_PRIMITIVES_PER_BOTTOM_LEVEL_ACCELERATION_STRUCTURE (536870912)
61 #ifndef D3D12_RAYTRACING_MAX_GEOMETRIES_PER_BOTTOM_LEVEL_ACCELERATION_STRUCTURE
62 # define D3D12_RAYTRACING_MAX_GEOMETRIES_PER_BOTTOM_LEVEL_ACCELERATION_STRUCTURE (16777216)
80 ID3D12Device* pD3D12Device,
81 size_t CommandQueueCount,
99 IBuffer** ppBuffer)
override final;
107 ITexture** ppTexture)
override final;
110 ID3D12Resource* pd3d12Texture,
116 ISampler** ppSampler)
override final;
150 bool IsDeviceInternal);
158 ITexture** ppTexture)
override final;
164 IBuffer** ppBuffer)
override final;
196 bool DiscardStaleObjects,
213 VERIFY_EXPR(
Type == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV ||
Type == D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
214 return m_GPUDescriptorHeaps[
Type];
222 #define GET_D3D12_DEVICE(Version) \
223 ID3D12Device##Version* GetD3D12Device##Version() \
225 DEV_CHECK_ERR(m_MaxD3D12DeviceVersion >= Version, "ID3D12Device", Version, \
226 " is not supported. Maximum supported version: ", \
227 m_MaxD3D12DeviceVersion); \
228 return static_cast<ID3D12Device##Version*>(m_pd3d12Device.p); \
235 #undef GET_D3D12_DEVICE
261 CComPtr<ID3D12Device> m_pd3d12Device;
271 std::mutex m_ContextPoolMutex;
272 std::vector<PooledCommandContext, STDAllocatorRawMem<PooledCommandContext>> m_ContextPool;
273 #ifdef DILIGENT_DEVELOPMENT
274 std::atomic_int m_AllocatedCtxCounter{0};
277 D3D12DynamicMemoryManager m_DynamicMemoryManager;
280 GenerateMipsHelper m_MipsGenerator;
282 QueryManagerD3D12 m_QueryMgr;
284 Properties m_Properties;
286 std::unique_ptr<IDXCompiler> m_pDxCompiler;
288 FixedBlockMemoryAllocator m_RootSignatureAllocator;
289 RootSignatureCacheD3D12 m_RootSignatureCache;
291 #ifdef DILIGENT_DEVELOPMENT
292 Uint32 m_MaxD3D12DeviceVersion = 0;
const Uint32 MaxShaderRecordStride
Definition: RenderDeviceD3D12Impl.hpp:240
#define D3D12_RAYTRACING_MAX_SHADER_RECORD_STRIDE
Definition: RenderDeviceD3D12Impl.hpp:53
Exposes Direct3D12-specific functionality of a render device.
Definition: RenderDeviceD3D12.h:51
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
Graphics pipeline state creation attributes.
Definition: PipelineState.h:397
char Char
Definition: BasicTypes.h:64
virtual void CreateFramebuffer(const FramebufferDesc &Desc, IFramebuffer **ppFramebuffer) override final
Implementation of IRenderDevice::CreateFramebuffer() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:662
Sampler description.
Definition: Sampler.h:58
Texture sampler interface.
Definition: Sampler.h:192
Ray tracing pipeline state description.
Definition: PipelineState.h:443
D3D12DynamicMemoryManager & GetDynamicMemoryManager()
Definition: RenderDeviceD3D12Impl.hpp:209
Pipeline resource signature interface.
Definition: PipelineResourceSignature.h:226
const Uint32 ShaderGroupHandleSize
Definition: RenderDeviceD3D12Impl.hpp:239
Pipeline resource signature description.
Definition: PipelineResourceSignature.h:166
Shader binding table interface.
Definition: ShaderBindingTable.h:93
void SignalFences(Uint32 QueueIndex, std::vector< std::pair< Uint64, RefCntAutoPtr< IFence >>> &SignalFences)
Definition: RenderDeviceD3D12Impl.cpp:483
virtual void CreateRenderPass(const RenderPassDesc &Desc, IRenderPass **ppRenderPass) override final
Implementation of IRenderDevice::CreateRenderPass() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:657
Shader version.
Definition: Shader.h:177
Top-level AS description.
Definition: TopLevelAS.h:49
const Properties & GetProperties() const
Definition: RenderDeviceD3D12Impl.hpp:252
Pipeline state interface.
Definition: PipelineState.h:505
Implementation of the Diligent::RootSignature class.
Definition: RootSignature.hpp:67
Query description.
Definition: Query.h:150
RenderDeviceD3D12Impl(IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator, IEngineFactory *pEngineFactory, const EngineD3D12CreateInfo &EngineCI, ID3D12Device *pD3D12Device, size_t CommandQueueCount, ICommandQueueD3D12 **ppCmdQueues) noexcept(false)
Definition: RenderDeviceD3D12Impl.cpp:98
Shader interface.
Definition: Shader.h:428
uint64_t Uint64
64-bit unsigned integer
Definition: BasicTypes.h:50
Top-level AS interface.
Definition: TopLevelAS.h:151
DescriptorHeapAllocation AllocateDescriptors(D3D12_DESCRIPTOR_HEAP_TYPE Type, UINT Count=1)
Definition: RenderDeviceD3D12Impl.cpp:714
const Uint32 MaxInstancesPerTLAS
Definition: RenderDeviceD3D12Impl.hpp:245
const GenerateMipsHelper & GetMipsGenerator() const
Definition: RenderDeviceD3D12Impl.hpp:217
Uint64 CloseAndExecuteCommandContexts(Uint32 QueueIndex, Uint32 NumContexts, PooledCommandContext pContexts[], bool DiscardStaleObjects, std::vector< std::pair< Uint64, RefCntAutoPtr< IFence >>> *pSignalFences)
Definition: RenderDeviceD3D12Impl.cpp:423
Framebuffer interface.
Definition: Framebuffer.h:73
const Uint32 MaxGeometriesPerBLAS
Definition: RenderDeviceD3D12Impl.hpp:247
const Uint32 MaxDrawMeshTasksCount
Definition: RenderDeviceD3D12Impl.hpp:242
Render pass description.
Definition: RenderPass.h:341
PooledCommandContext AllocateCommandContext(const Char *ID="")
Definition: RenderDeviceD3D12Impl.cpp:512
Definition: RenderDeviceD3D12Impl.hpp:237
Shader creation attributes.
Definition: Shader.h:241
Implementation of a texture object in Direct3D12 backend.
Definition: TextureD3D12Impl.hpp:42
Buffer interface.
Definition: Buffer.h:187
virtual void IdleGPU() override final
Implementation of IRenderDevice::IdleGPU() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:493
Definition: CommandContext.hpp:66
Definition: D3D12DynamicHeap.hpp:122
const Uint32 MaxPrimitivesPerBLAS
Definition: RenderDeviceD3D12Impl.hpp:246
Definition: DescriptorHeap.hpp:473
Definition: GenerateMips.hpp:55
Base implementation of the render device for next-generation backends.
Definition: RenderDeviceNextGenBase.hpp:49
GPUDescriptorHeap & GetGPUDescriptorHeap(D3D12_DESCRIPTOR_HEAP_TYPE Type)
Definition: RenderDeviceD3D12Impl.hpp:211
Shader binding table description.
Definition: ShaderBindingTable.h:50
Command queue interface.
Definition: CommandQueueD3D12.h:51
Texture description.
Definition: Texture.h:47
Render device implementation in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.hpp:70
Root signature cache that deduplicates RootSignatureD3D12 objects.
Definition: RootSignature.hpp:168
virtual void CreateFence(const FenceDesc &Desc, IFence **ppFence) override final
Implementation of IRenderDevice::CreateFence() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:647
DXC compiler interface.
Definition: DXCompiler.hpp:55
virtual void CreateTLASFromD3DResource(ID3D12Resource *pd3d12TLAS, const TopLevelASDesc &Desc, RESOURCE_STATE InitialState, ITopLevelAS **ppTLAS) override final
Implementation of IRenderDeviceD3D12::CreateTLASFromD3DResource().
Definition: RenderDeviceD3D12Impl.cpp:681
virtual void CreateQuery(const QueryDesc &Desc, IQuery **ppQuery) override final
Implementation of IRenderDevice::CreateQuery() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:652
#define IMPLEMENT_QUERY_INTERFACE_IN_PLACE(InterfaceID, ParentClassName)
Definition: ObjectBase.hpp:59
Template class that implements reference counting.
Definition: RefCntAutoPtr.hpp:73
Attributes specific to D3D12 engine.
Definition: GraphicsTypes.h:2099
virtual void TestTextureFormat(TEXTURE_FORMAT TexFormat) override final
Definition: RenderDeviceD3D12Impl.cpp:540
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
Describes the initial data to store in the texture.
Definition: Texture.h:221
const D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type
Definition: PipelineStateD3D12Impl.cpp:69
Compute pipeline state description.
Definition: PipelineState.h:427
DescriptorHeapAllocation AllocateGPUDescriptors(D3D12_DESCRIPTOR_HEAP_TYPE Type, UINT Count=1)
Definition: RenderDeviceD3D12Impl.cpp:720
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
const Uint32 ShaderGroupBaseAlignment
Definition: RenderDeviceD3D12Impl.hpp:241
virtual void CreateBuffer(const BufferDesc &BuffDesc, const BufferData *pBuffData, IBuffer **ppBuffer) override final
Implementation of IRenderDevice::CreateBuffer() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:609
ShaderVersion MaxShaderVersion
Definition: RenderDeviceD3D12Impl.hpp:249
virtual void CreateSBT(const ShaderBindingTableDesc &Desc, IShaderBindingTable **ppSBT) override final
Implementation of IRenderDevice::CreateSBT() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:695
Definition: STDAllocator.hpp:182
#define D3D12_RAYTRACING_MAX_GEOMETRIES_PER_BOTTOM_LEVEL_ACCELERATION_STRUCTURE
Definition: RenderDeviceD3D12Impl.hpp:62
TEXTURE_FORMAT
Texture formats.
Definition: GraphicsTypes.h:328
void DisposeCommandContext(PooledCommandContext &&Ctx)
Definition: RenderDeviceD3D12Impl.cpp:389
#define D3D12_RAYTRACING_MAX_RAY_GENERATION_SHADER_THREADS
Definition: RenderDeviceD3D12Impl.hpp:50
virtual void CreatePipelineResourceSignature(const PipelineResourceSignatureDesc &Desc, IPipelineResourceSignature **ppSignature) override final
Implementation of IRenderDevice::CreatePipelineResourceSignature() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:701
Buffer description.
Definition: Buffer.h:74
virtual void CreateTextureFromD3DResource(ID3D12Resource *pd3d12Texture, RESOURCE_STATE InitialState, ITexture **ppTexture) override final
Implementation of IRenderDeviceD3D12::CreateTextureFromD3DResource().
Definition: RenderDeviceD3D12Impl.cpp:620
void FlushStaleResources(Uint32 CmdQueueIndex)
Definition: RenderDeviceD3D12Impl.cpp:499
Definition: DescriptorHeap.hpp:387
Base interface for a raw memory allocator.
Definition: MemoryAllocator.h:41
virtual void CreateTexture(const TextureDesc &TexDesc, const TextureData *pData, ITexture **ppTexture) override final
Implementation of IRenderDevice::CreateTexture() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:637
Fence interface.
Definition: Fence.h:62
Definition: AdvancedMath.hpp:979
virtual void CreateShader(const ShaderCreateInfo &ShaderCreateInfo, IShader **ppShader) override final
Implementation of IRenderDevice::CreateShader() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:615
virtual void CreateComputePipelineState(const ComputePipelineStateCreateInfo &PSOCreateInfo, IPipelineState **ppPipelineState) override final
Implementation of IRenderDevice::CreateComputePipelineState() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:594
Query interface.
Definition: Query.h:177
const Uint32 MaxRayGenThreads
Definition: RenderDeviceD3D12Impl.hpp:244
virtual void CreateSampler(const SamplerDesc &SamplerDesc, ISampler **ppSampler) override final
Implementation of IRenderDevice::CreateSampler() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:642
#define D3D12_RAYTRACING_MAX_INSTANCES_PER_TOP_LEVEL_ACCELERATION_STRUCTURE
Definition: RenderDeviceD3D12Impl.hpp:56
~RenderDeviceD3D12Impl()
Definition: RenderDeviceD3D12Impl.cpp:363
virtual void CreateBLAS(const BottomLevelASDesc &Desc, IBottomLevelAS **ppBLAS) override final
Implementation of IRenderDevice::CreateBLAS() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:675
#define VERIFY_EXPR(...)
Definition: DebugUtilities.hpp:79
Framebuffer description.
Definition: Framebuffer.h:46
Bottom-level AS interface.
Definition: BottomLevelAS.h:207
Definition: QueryManagerD3D12.hpp:44
virtual void CreateTLAS(const TopLevelASDesc &Desc, ITopLevelAS **ppTLAS) override final
Implementation of IRenderDevice::CreateTLAS() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:689
virtual void CreateBLASFromD3DResource(ID3D12Resource *pd3d12BLAS, const BottomLevelASDesc &Desc, RESOURCE_STATE InitialState, IBottomLevelAS **ppBLAS) override final
Implementation of IRenderDeviceD3D12::CreateBLASFromD3DResource().
Definition: RenderDeviceD3D12Impl.cpp:667
#define GET_D3D12_DEVICE(Version)
Definition: RenderDeviceD3D12Impl.hpp:222
void CloseAndExecuteTransientCommandContext(Uint32 CommandQueueIndex, PooledCommandContext &&Ctx)
Definition: RenderDeviceD3D12Impl.cpp:407
virtual void CreateGraphicsPipelineState(const GraphicsPipelineStateCreateInfo &PSOCreateInfo, IPipelineState **ppPipelineState) override final
Implementation of IRenderDevice::CreateGraphicsPipelineState() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:589
#define D3D12_RAYTRACING_MAX_PRIMITIVES_PER_BOTTOM_LEVEL_ACCELERATION_STRUCTURE
Definition: RenderDeviceD3D12Impl.hpp:59
virtual void ReleaseStaleResources(bool ForceRelease=false) override final
Implementation of IRenderDevice::() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:506
RESOURCE_STATE
Resource usage state.
Definition: GraphicsTypes.h:2814
virtual ID3D12Device * GetD3D12Device() override final
Implementation of IRenderDeviceD3D12::GetD3D12Device().
Definition: RenderDeviceD3D12Impl.hpp:153
std::unique_ptr< CommandContext, STDDeleterRawMem< CommandContext > > PooledCommandContext
Definition: RenderDeviceD3D12Impl.hpp:188
void CreateRootSignature(const RefCntAutoPtr< class PipelineResourceSignatureD3D12Impl > *ppSignatures, Uint32 SignatureCount, size_t Hash, RootSignatureD3D12 **ppRootSig)
Definition: RenderDeviceD3D12Impl.cpp:726
Describes the buffer initial data.
Definition: Buffer.h:155
virtual void CreateBufferFromD3DResource(ID3D12Resource *pd3d12Buffer, const BufferDesc &BuffDesc, RESOURCE_STATE InitialState, IBuffer **ppBuffer) override final
Implementation of IRenderDeviceD3D12::CreateBufferFromD3DResource().
Definition: RenderDeviceD3D12Impl.cpp:604
Bottom-level AS description.
Definition: BottomLevelAS.h:145
Engine factory base interface.
Definition: EngineFactory.h:60
Definition: DescriptorHeap.hpp:67
Fence description.
Definition: Fence.h:43
Texture inteface.
Definition: Texture.h:273
Definition: CommandListManager.hpp:39
QueryManagerD3D12 & GetQueryManager()
Definition: RenderDeviceD3D12Impl.hpp:218
Render pass interface.
Definition: RenderPass.h:369
virtual void CreateRayTracingPipelineState(const RayTracingPipelineStateCreateInfo &PSOCreateInfo, IPipelineState **ppPipelineState) override final
Implementation of IRenderDevice::CreateRayTracingPipelineState() in Direct3D12 backend.
Definition: RenderDeviceD3D12Impl.cpp:599
const Uint32 MaxRayTracingRecursionDepth
Definition: RenderDeviceD3D12Impl.hpp:243
IDXCompiler * GetDxCompiler() const
Definition: RenderDeviceD3D12Impl.hpp:220
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
RootSignatureCacheD3D12 & GetRootSignatureCache()
Definition: RenderDeviceD3D12Impl.hpp:180