From d619b2249ab8f4543b1d2e1f8bf59b09ef582f03 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 19 Jun 2018 17:35:16 -0700 Subject: Improved code formatting of D3D12 backend headers --- .../GraphicsEngineD3D12/include/BufferD3D12Impl.h | 20 +- .../include/BufferViewD3D12Impl.h | 10 +- .../include/CommandListD3D12Impl.h | 4 +- .../GraphicsEngineD3D12/include/DescriptorHeap.h | 220 +++++++++++---------- .../include/DeviceContextD3D12Impl.h | 8 +- .../include/DynamicUploadHeap.h | 59 +++--- .../GraphicsEngineD3D12/include/GenerateMips.h | 2 - .../include/PipelineStateD3D12Impl.h | 12 +- .../include/RenderDeviceD3D12Impl.h | 7 +- .../GraphicsEngineD3D12/include/RootSignature.h | 194 +++++++++++------- .../GraphicsEngineD3D12/include/SamplerD3D12Impl.h | 4 +- .../GraphicsEngineD3D12/include/ShaderD3D12Impl.h | 6 +- .../include/ShaderResourceBindingD3D12Impl.h | 4 +- .../include/ShaderResourceCacheD3D12.h | 38 ++-- .../include/ShaderResourceLayoutD3D12.h | 121 ++++++------ .../include/SwapChainD3D12Impl.h | 8 +- .../GraphicsEngineD3D12/include/TextureD3D12Impl.h | 40 ++-- .../include/TextureViewD3D12Impl.h | 12 +- .../interface/DeviceContextD3D12.h | 4 +- .../interface/RenderDeviceD3D12.h | 4 +- .../interface/RenderDeviceFactoryD3D12.h | 46 ++--- .../GraphicsEngineD3D12/interface/SwapChainD3D12.h | 2 +- 22 files changed, 450 insertions(+), 375 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h index 5a0be377..51ac7489 100644 --- a/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h @@ -43,16 +43,16 @@ class BufferD3D12Impl : public BufferBase TBufferBase; - BufferD3D12Impl(IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator &BuffViewObjMemAllocator, - class RenderDeviceD3D12Impl *pDeviceD3D12, - const BufferDesc& BuffDesc, - const BufferData &BuffData = BufferData()); - BufferD3D12Impl(IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator &BuffViewObjMemAllocator, - class RenderDeviceD3D12Impl *pDeviceD3D12, - const BufferDesc& BuffDesc, - ID3D12Resource *pd3d12Buffer); + BufferD3D12Impl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& BuffViewObjMemAllocator, + class RenderDeviceD3D12Impl* pDeviceD3D12, + const BufferDesc& BuffDesc, + const BufferData& BuffData = BufferData()); + BufferD3D12Impl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& BuffViewObjMemAllocator, + class RenderDeviceD3D12Impl* pDeviceD3D12, + const BufferDesc& BuffDesc, + ID3D12Resource* pd3d12Buffer); ~BufferD3D12Impl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override; diff --git a/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h index 705997fc..7a8336d6 100644 --- a/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h @@ -41,11 +41,11 @@ class BufferViewD3D12Impl : public BufferViewBase public: typedef BufferViewBase TBufferViewBase; - BufferViewD3D12Impl( IReferenceCounters *pRefCounters, - IRenderDevice *pDevice, - const BufferViewDesc& ViewDesc, - class IBuffer *pBuffer, - DescriptorHeapAllocation &&HandleAlloc, + BufferViewD3D12Impl( IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + const BufferViewDesc& ViewDesc, + class IBuffer* pBuffer, + DescriptorHeapAllocation&& HandleAlloc, bool bIsDefaultView); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ); diff --git a/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h index d42700d8..bf97df8c 100644 --- a/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h @@ -36,7 +36,9 @@ class CommandListD3D12Impl : public CommandListBase { public: typedef CommandListBase TCommandListBase; - CommandListD3D12Impl(IReferenceCounters *pRefCounters, IRenderDevice *pDevice, class CommandContext* pCmdContext) : + CommandListD3D12Impl(IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + class CommandContext* pCmdContext) : TCommandListBase(pRefCounters, pDevice), m_pCmdContext(pCmdContext) { diff --git a/Graphics/GraphicsEngineD3D12/include/DescriptorHeap.h b/Graphics/GraphicsEngineD3D12/include/DescriptorHeap.h index 59fe85b5..859b0cad 100644 --- a/Graphics/GraphicsEngineD3D12/include/DescriptorHeap.h +++ b/Graphics/GraphicsEngineD3D12/include/DescriptorHeap.h @@ -63,28 +63,28 @@ class DescriptorHeapAllocation { public: // Creates null allocation - DescriptorHeapAllocation() : - m_NumHandles(1), // One null descriptor handle - m_pDescriptorHeap(nullptr), - m_DescriptorSize(0) + DescriptorHeapAllocation()noexcept : + m_NumHandles (1), // One null descriptor handle + m_pDescriptorHeap (nullptr), + m_DescriptorSize (0) { m_FirstCpuHandle.ptr = 0; m_FirstGpuHandle.ptr = 0; } // Initializes non-null allocation - DescriptorHeapAllocation( IDescriptorAllocator *pAllocator, - ID3D12DescriptorHeap *pHeap, + DescriptorHeapAllocation( IDescriptorAllocator* pAllocator, + ID3D12DescriptorHeap* pHeap, D3D12_CPU_DESCRIPTOR_HANDLE CpuHandle, D3D12_GPU_DESCRIPTOR_HANDLE GpuHandle, - Uint32 NHandles, - Uint16 AllocationManagerId = static_cast(-1) ) : - m_FirstCpuHandle(CpuHandle), - m_FirstGpuHandle(GpuHandle), - m_pAllocator(pAllocator), - m_NumHandles(NHandles), - m_pDescriptorHeap(pHeap), - m_AllocationManagerId(AllocationManagerId) + Uint32 NHandles, + Uint16 AllocationManagerId = static_cast(-1) )noexcept : + m_FirstCpuHandle (CpuHandle), + m_FirstGpuHandle (GpuHandle), + m_pAllocator (pAllocator), + m_NumHandles (NHandles), + m_pDescriptorHeap (pHeap), + m_AllocationManagerId (AllocationManagerId) { VERIFY_EXPR(m_pAllocator != nullptr && m_pDescriptorHeap != nullptr); auto DescriptorSize = m_pAllocator->GetDescriptorSize(); @@ -93,46 +93,51 @@ public: } // Move constructor (copy is not allowed) - DescriptorHeapAllocation(DescriptorHeapAllocation &&Allocation) : - m_FirstCpuHandle(Allocation.m_FirstCpuHandle), - m_FirstGpuHandle(Allocation.m_FirstGpuHandle), - m_NumHandles(Allocation.m_NumHandles), - m_pAllocator(std::move(Allocation.m_pAllocator)), - m_AllocationManagerId(std::move(Allocation.m_AllocationManagerId)), - m_pDescriptorHeap(std::move(Allocation.m_pDescriptorHeap) ), - m_DescriptorSize(std::move(Allocation.m_DescriptorSize) ) + DescriptorHeapAllocation(DescriptorHeapAllocation&& Allocation)noexcept : + m_FirstCpuHandle (Allocation.m_FirstCpuHandle), + m_FirstGpuHandle (Allocation.m_FirstGpuHandle), + m_NumHandles (Allocation.m_NumHandles), + m_pAllocator (std::move(Allocation.m_pAllocator)), + m_AllocationManagerId (std::move(Allocation.m_AllocationManagerId)), + m_pDescriptorHeap (std::move(Allocation.m_pDescriptorHeap) ), + m_DescriptorSize (std::move(Allocation.m_DescriptorSize) ) { - Allocation.m_pAllocator = nullptr; - Allocation.m_FirstCpuHandle.ptr = 0; - Allocation.m_FirstGpuHandle.ptr = 0; - Allocation.m_NumHandles = 0; - Allocation.m_pDescriptorHeap = nullptr; - Allocation.m_DescriptorSize = 0; + Allocation.m_pAllocator = nullptr; + Allocation.m_FirstCpuHandle.ptr = 0; + Allocation.m_FirstGpuHandle.ptr = 0; + Allocation.m_NumHandles = 0; + Allocation.m_pDescriptorHeap = nullptr; + Allocation.m_DescriptorSize = 0; Allocation.m_AllocationManagerId = static_cast(-1); } // Move assignment (assignment is not allowed) - DescriptorHeapAllocation& operator = (DescriptorHeapAllocation &&Allocation) + DescriptorHeapAllocation& operator = (DescriptorHeapAllocation&& Allocation)noexcept { - m_FirstCpuHandle = Allocation.m_FirstCpuHandle; - m_FirstGpuHandle = Allocation.m_FirstGpuHandle; - m_NumHandles = Allocation.m_NumHandles; - m_pAllocator = std::move(Allocation.m_pAllocator); + m_FirstCpuHandle = Allocation.m_FirstCpuHandle; + m_FirstGpuHandle = Allocation.m_FirstGpuHandle; + m_NumHandles = Allocation.m_NumHandles; + m_pAllocator = std::move(Allocation.m_pAllocator); m_AllocationManagerId = std::move(Allocation.m_AllocationManagerId); - m_pDescriptorHeap = std::move(Allocation.m_pDescriptorHeap); - m_DescriptorSize = std::move(Allocation.m_DescriptorSize); - - Allocation.m_FirstCpuHandle.ptr = 0; - Allocation.m_FirstGpuHandle.ptr = 0; - Allocation.m_NumHandles = 0; - Allocation.m_pAllocator = nullptr; - Allocation.m_pDescriptorHeap = nullptr; - Allocation.m_DescriptorSize = 0; + m_pDescriptorHeap = std::move(Allocation.m_pDescriptorHeap); + m_DescriptorSize = std::move(Allocation.m_DescriptorSize); + + Allocation.m_FirstCpuHandle.ptr = 0; + Allocation.m_FirstGpuHandle.ptr = 0; + Allocation.m_NumHandles = 0; + Allocation.m_pAllocator = nullptr; + Allocation.m_pDescriptorHeap = nullptr; + Allocation.m_DescriptorSize = 0; Allocation.m_AllocationManagerId = static_cast(-1); return *this; } + // No copies, only moves are allowed + DescriptorHeapAllocation (const DescriptorHeapAllocation&) = delete; + DescriptorHeapAllocation& operator= (const DescriptorHeapAllocation&) = delete; + + // Destructor automatically releases this allocation through the allocator ~DescriptorHeapAllocation() { @@ -172,15 +177,12 @@ public: size_t GetNumHandles()const{return m_NumHandles;} - bool IsNull() const { return m_FirstCpuHandle.ptr == 0; } - bool IsShaderVisible() const { return m_FirstGpuHandle.ptr != 0; } - size_t GetAllocationManagerId(){return m_AllocationManagerId;} - UINT GetDescriptorSize()const{return m_DescriptorSize;} + bool IsNull() const { return m_FirstCpuHandle.ptr == 0; } + bool IsShaderVisible() const { return m_FirstGpuHandle.ptr != 0; } + size_t GetAllocationManagerId()const { return m_AllocationManagerId; } + UINT GetDescriptorSize() const { return m_DescriptorSize; } private: - // No copies, only moves are allowed - DescriptorHeapAllocation(const DescriptorHeapAllocation&) = delete; - DescriptorHeapAllocation& operator= (const DescriptorHeapAllocation&) = delete; // First CPU descriptor handle in this allocation D3D12_CPU_DESCRIPTOR_HANDLE m_FirstCpuHandle = {0}; @@ -223,51 +225,51 @@ class DescriptorHeapAllocationManager { public: // Creates a new D3D12 descriptor heap - DescriptorHeapAllocationManager(IMemoryAllocator &Allocator, - RenderDeviceD3D12Impl *pDeviceD3D12Impl, - IDescriptorAllocator *pParentAllocator, - size_t ThisManagerId, - const D3D12_DESCRIPTOR_HEAP_DESC &HeapDesc); + DescriptorHeapAllocationManager(IMemoryAllocator& Allocator, + RenderDeviceD3D12Impl* pDeviceD3D12Impl, + IDescriptorAllocator* pParentAllocator, + size_t ThisManagerId, + const D3D12_DESCRIPTOR_HEAP_DESC& HeapDesc); // Uses subrange of descriptors in the existing D3D12 descriptor heap // that starts at offset FirstDescriptor and uses NumDescriptors descriptors - DescriptorHeapAllocationManager(IMemoryAllocator &Allocator, - RenderDeviceD3D12Impl *pDeviceD3D12Impl, - IDescriptorAllocator *pParentAllocator, - size_t ThisManagerId, - ID3D12DescriptorHeap *pd3d12DescriptorHeap, - Uint32 FirstDescriptor, - Uint32 NumDescriptors); + DescriptorHeapAllocationManager(IMemoryAllocator& Allocator, + RenderDeviceD3D12Impl* pDeviceD3D12Impl, + IDescriptorAllocator* pParentAllocator, + size_t ThisManagerId, + ID3D12DescriptorHeap* pd3d12DescriptorHeap, + Uint32 FirstDescriptor, + Uint32 NumDescriptors); // = default causes compiler error when instantiating std::vector::emplace_back() in Visual Studio 2015 (Version 14.0.23107.0 D14REL) - DescriptorHeapAllocationManager(DescriptorHeapAllocationManager&& rhs) : - m_FreeBlockManager(std::move(rhs.m_FreeBlockManager)), - m_HeapDesc(rhs.m_HeapDesc), - m_pd3d12DescriptorHeap(std::move(rhs.m_pd3d12DescriptorHeap)), - m_FirstCPUHandle(rhs.m_FirstCPUHandle), - m_FirstGPUHandle(rhs.m_FirstGPUHandle), - m_DescriptorSize(rhs.m_DescriptorSize), + DescriptorHeapAllocationManager(DescriptorHeapAllocationManager&& rhs)noexcept : + m_FreeBlockManager (std::move(rhs.m_FreeBlockManager)), + m_HeapDesc (rhs.m_HeapDesc), + m_pd3d12DescriptorHeap (std::move(rhs.m_pd3d12DescriptorHeap)), + m_FirstCPUHandle (rhs.m_FirstCPUHandle), + m_FirstGPUHandle (rhs.m_FirstGPUHandle), + m_DescriptorSize (rhs.m_DescriptorSize), m_NumDescriptorsInAllocation(rhs.m_NumDescriptorsInAllocation), // Mutex is not movable //m_AllocationMutex(std::move(rhs.m_AllocationMutex)) - m_pDeviceD3D12Impl(rhs.m_pDeviceD3D12Impl), - m_pParentAllocator(rhs.m_pParentAllocator), - m_ThisManagerId(rhs.m_ThisManagerId) + m_pDeviceD3D12Impl (rhs.m_pDeviceD3D12Impl), + m_pParentAllocator (rhs.m_pParentAllocator), + m_ThisManagerId (rhs.m_ThisManagerId) { - rhs.m_FirstCPUHandle.ptr = 0; - rhs.m_FirstGPUHandle.ptr = 0; - rhs.m_DescriptorSize = 0; + rhs.m_FirstCPUHandle.ptr = 0; + rhs.m_FirstGPUHandle.ptr = 0; + rhs.m_DescriptorSize = 0; rhs.m_NumDescriptorsInAllocation = 0; - rhs.m_HeapDesc.NumDescriptors = 0; - rhs.m_pDeviceD3D12Impl = nullptr; - rhs.m_pParentAllocator = nullptr; - rhs.m_ThisManagerId = static_cast(-1); + rhs.m_HeapDesc.NumDescriptors = 0; + rhs.m_pDeviceD3D12Impl = nullptr; + rhs.m_pParentAllocator = nullptr; + rhs.m_ThisManagerId = static_cast(-1); } // No copies or move-assignments - DescriptorHeapAllocationManager& operator = (DescriptorHeapAllocationManager&& rhs) = delete; - DescriptorHeapAllocationManager(const DescriptorHeapAllocationManager&) = delete; + DescriptorHeapAllocationManager& operator = (DescriptorHeapAllocationManager&&) = delete; + DescriptorHeapAllocationManager (const DescriptorHeapAllocationManager&) = delete; DescriptorHeapAllocationManager& operator = (const DescriptorHeapAllocationManager&) = delete; ~DescriptorHeapAllocationManager(); @@ -285,9 +287,9 @@ public: // and releases all allocations whose associated fence value n <= N void ReleaseStaleAllocations(Uint64 LastCompletedFenceValue); - size_t GetNumAvailableDescriptors()const{return m_FreeBlockManager.GetFreeSize();} - size_t GetNumStaleDescriptors()const { return m_FreeBlockManager.GetStaleAllocationsSize(); } - Uint32 GetMaxDescriptors()const { return m_NumDescriptorsInAllocation; } + size_t GetNumAvailableDescriptors()const { return m_FreeBlockManager.GetFreeSize(); } + size_t GetNumStaleDescriptors() const { return m_FreeBlockManager.GetStaleAllocationsSize(); } + Uint32 GetMaxDescriptors() const { return m_NumDescriptorsInAllocation; } private: // Allocations manager used to handle descriptor allocations within the heap @@ -313,8 +315,8 @@ private: Uint32 m_NumDescriptorsInAllocation = 0; std::mutex m_AllocationMutex; - RenderDeviceD3D12Impl *m_pDeviceD3D12Impl = nullptr; - IDescriptorAllocator *m_pParentAllocator = nullptr; + RenderDeviceD3D12Impl* m_pDeviceD3D12Impl = nullptr; + IDescriptorAllocator* m_pParentAllocator = nullptr; // External ID assigned to this descriptor allocations manager size_t m_ThisManagerId = static_cast(-1); @@ -341,16 +343,16 @@ class CPUDescriptorHeap : public IDescriptorAllocator { public: // Initializes the heap - CPUDescriptorHeap(IMemoryAllocator &Allocator, - RenderDeviceD3D12Impl *pDeviceD3D12Impl, - Uint32 NumDescriptorsInHeap, - D3D12_DESCRIPTOR_HEAP_TYPE Type, + CPUDescriptorHeap(IMemoryAllocator& Allocator, + RenderDeviceD3D12Impl* pDeviceD3D12Impl, + Uint32 NumDescriptorsInHeap, + D3D12_DESCRIPTOR_HEAP_TYPE Type, D3D12_DESCRIPTOR_HEAP_FLAGS Flags); - CPUDescriptorHeap(const CPUDescriptorHeap&) = delete; - CPUDescriptorHeap(CPUDescriptorHeap&&) = delete; + CPUDescriptorHeap (const CPUDescriptorHeap&) = delete; + CPUDescriptorHeap (CPUDescriptorHeap&&) = delete; CPUDescriptorHeap& operator = (const CPUDescriptorHeap&) = delete; - CPUDescriptorHeap& operator = (CPUDescriptorHeap&&) = delete; + CPUDescriptorHeap& operator = (CPUDescriptorHeap&&) = delete; ~CPUDescriptorHeap(); @@ -425,17 +427,17 @@ protected: class GPUDescriptorHeap : public IDescriptorAllocator { public: - GPUDescriptorHeap(IMemoryAllocator &Allocator, - RenderDeviceD3D12Impl *pDevice, - Uint32 NumDescriptorsInHeap, - Uint32 NumDynamicDescriptors, - D3D12_DESCRIPTOR_HEAP_TYPE Type, + GPUDescriptorHeap(IMemoryAllocator& Allocator, + RenderDeviceD3D12Impl* pDevice, + Uint32 NumDescriptorsInHeap, + Uint32 NumDynamicDescriptors, + D3D12_DESCRIPTOR_HEAP_TYPE Type, D3D12_DESCRIPTOR_HEAP_FLAGS Flags); - GPUDescriptorHeap(const GPUDescriptorHeap&) = delete; - GPUDescriptorHeap(GPUDescriptorHeap&&) = delete; + GPUDescriptorHeap (const GPUDescriptorHeap&) = delete; + GPUDescriptorHeap (GPUDescriptorHeap&&) = delete; GPUDescriptorHeap& operator = (const GPUDescriptorHeap&) = delete; - GPUDescriptorHeap& operator = (GPUDescriptorHeap&&) = delete; + GPUDescriptorHeap& operator = (GPUDescriptorHeap&&) = delete; ~GPUDescriptorHeap(); @@ -451,7 +453,7 @@ public: void ReleaseStaleAllocations(Uint64 LastCompletedFenceValue); const D3D12_DESCRIPTOR_HEAP_DESC &GetHeapDesc()const{return m_HeapDesc;} - Uint32 GetMaxStaticDescriptors()const { return m_HeapAllocationManager.GetMaxDescriptors(); } + Uint32 GetMaxStaticDescriptors() const { return m_HeapAllocationManager.GetMaxDescriptors(); } Uint32 GetMaxDynamicDescriptors()const { return m_DynamicAllocationsManager.GetMaxDescriptors(); } protected: @@ -471,11 +473,11 @@ protected: RenderDeviceD3D12Impl *m_pDeviceD3D12; Uint32 m_CurrentSize = 0; // Maximum static/mutable part size during the application lifetime - for statistic purposes - Uint32 m_MaxHeapSize = 0; - Uint32 m_MaxStaleSize = 0; + Uint32 m_MaxHeapSize = 0; + Uint32 m_MaxStaleSize = 0; Uint32 m_CurrentDynamicSize = 0; // Maximum dynamic part size during the application lifetime - for statistic purposes - Uint32 m_MaxDynamicSize = 0; + Uint32 m_MaxDynamicSize = 0; Uint32 m_MaxDynamicStaleSize = 0; }; @@ -495,14 +497,14 @@ class DynamicSuballocationsManager : public IDescriptorAllocator public: DynamicSuballocationsManager(IMemoryAllocator &Allocator, GPUDescriptorHeap& ParentGPUHeap, Uint32 DynamicChunkSize); - DynamicSuballocationsManager(const DynamicSuballocationsManager&) = delete; - DynamicSuballocationsManager(DynamicSuballocationsManager&&) = delete; + DynamicSuballocationsManager (const DynamicSuballocationsManager&) = delete; + DynamicSuballocationsManager (DynamicSuballocationsManager&&) = delete; DynamicSuballocationsManager& operator = (const DynamicSuballocationsManager&) = delete; - DynamicSuballocationsManager& operator = (DynamicSuballocationsManager&&) = delete; + DynamicSuballocationsManager& operator = (DynamicSuballocationsManager&&) = delete; void DiscardAllocations(Uint64 /*FenceValue*/); - virtual DescriptorHeapAllocation Allocate( Uint32 Count )override; + virtual DescriptorHeapAllocation Allocate(Uint32 Count)override; virtual void Free(DescriptorHeapAllocation&& Allocation)override; virtual Uint32 GetDescriptorSize()const override{return m_ParentGPUHeap.GetDescriptorSize();} @@ -513,7 +515,7 @@ private: std::vector > m_Suballocations; Uint32 m_CurrentSuballocationOffset = 0; - Uint32 m_DynamicChunkSize = 0; + Uint32 m_DynamicChunkSize = 0; // Parent GPU descriptor heap that is used to allocate chunks GPUDescriptorHeap &m_ParentGPUHeap; diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h index b4ae5de5..bf072f78 100644 --- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h @@ -43,7 +43,11 @@ class DeviceContextD3D12Impl : public DeviceContextBase public: typedef DeviceContextBase TDeviceContextBase; - DeviceContextD3D12Impl(IReferenceCounters *pRefCounters, class RenderDeviceD3D12Impl *pDevice, bool bIsDeferred, const EngineD3D12Attribs &Attribs, Uint32 ContextId); + DeviceContextD3D12Impl(IReferenceCounters* pRefCounters, + class RenderDeviceD3D12Impl* pDevice, + bool bIsDeferred, + const EngineD3D12Attribs& Attribs, + Uint32 ContextId); ~DeviceContextD3D12Impl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; @@ -129,7 +133,7 @@ private: return m_pCurrCmdCtx; } size_t m_NumCommandsInCurCtx = 0; - const Uint32 m_NumCommandsToFlush = 192; + const Uint32 m_NumCommandsToFlush = 192; CommandContext* m_pCurrCmdCtx = nullptr; CComPtr m_CommittedD3D12IndexBuffer; diff --git a/Graphics/GraphicsEngineD3D12/include/DynamicUploadHeap.h b/Graphics/GraphicsEngineD3D12/include/DynamicUploadHeap.h index 8a3525b4..8edc4c57 100644 --- a/Graphics/GraphicsEngineD3D12/include/DynamicUploadHeap.h +++ b/Graphics/GraphicsEngineD3D12/include/DynamicUploadHeap.h @@ -33,15 +33,21 @@ namespace Diligent struct DynamicAllocation { - DynamicAllocation(ID3D12Resource *pBuff = nullptr, size_t ThisOffset = 0, size_t ThisSize = 0) - : pBuffer(pBuff), Offset(ThisOffset), Size(ThisSize) {} - - //CComPtr pBuffer; // The D3D buffer associated with this memory. - ID3D12Resource *pBuffer = nullptr; // The D3D buffer associated with this memory. - size_t Offset = 0; // Offset from start of buffer resource - size_t Size = 0; // Reserved size of this allocation - void* CPUAddress = 0; // The CPU-writeable address - D3D12_GPU_VIRTUAL_ADDRESS GPUAddress = 0; // The GPU-visible address + DynamicAllocation()noexcept{} + DynamicAllocation(ID3D12Resource* pBuff, + size_t _Offset, + size_t _Size)noexcept : + pBuffer(pBuff), + Offset (_Offset), + Size (_Size) + {} + + //CComPtr pBuffer; // The D3D buffer associated with this memory. + ID3D12Resource* pBuffer = nullptr; // The D3D buffer associated with this memory. + size_t Offset = 0; // Offset from start of buffer resource + size_t Size = 0; // Reserved size of this allocation + void* CPUAddress = nullptr; // The CPU-writeable address + D3D12_GPU_VIRTUAL_ADDRESS GPUAddress = 0; // The GPU-visible address #ifdef _DEBUG Uint64 FrameNum = static_cast(-1); #endif @@ -52,25 +58,26 @@ class GPURingBuffer : public RingBuffer public: GPURingBuffer(size_t MaxSize, IMemoryAllocator &Allocator, ID3D12Device *pd3d12Device, bool AllowCPUAccess); - GPURingBuffer(GPURingBuffer&& rhs) : - RingBuffer(std::move(rhs)), - m_CpuVirtualAddress(rhs.m_CpuVirtualAddress), - m_GpuVirtualAddress(rhs.m_GpuVirtualAddress), - m_pBuffer(std::move(rhs.m_pBuffer)) + GPURingBuffer(GPURingBuffer&& rhs)noexcept : + RingBuffer (std::move(rhs)), + m_CpuVirtualAddress (rhs.m_CpuVirtualAddress), + m_GpuVirtualAddress (rhs.m_GpuVirtualAddress), + m_pBuffer (std::move(rhs.m_pBuffer)) { rhs.m_CpuVirtualAddress = nullptr; rhs.m_GpuVirtualAddress = 0; rhs.m_pBuffer.Release(); } - GPURingBuffer& operator =(GPURingBuffer&& rhs) + GPURingBuffer& operator =(GPURingBuffer&& rhs)noexcept { Destroy(); static_cast(*this) = std::move(rhs); - m_CpuVirtualAddress = rhs.m_CpuVirtualAddress; - m_GpuVirtualAddress = rhs.m_GpuVirtualAddress; - m_pBuffer = std::move(rhs.m_pBuffer); + m_CpuVirtualAddress = rhs.m_CpuVirtualAddress; + m_GpuVirtualAddress = rhs.m_GpuVirtualAddress; + m_pBuffer = std::move(rhs.m_pBuffer); + rhs.m_CpuVirtualAddress = 0; rhs.m_GpuVirtualAddress = 0; @@ -103,8 +110,8 @@ public: private: void Destroy(); - void* m_CpuVirtualAddress; - D3D12_GPU_VIRTUAL_ADDRESS m_GpuVirtualAddress; + void* m_CpuVirtualAddress; + D3D12_GPU_VIRTUAL_ADDRESS m_GpuVirtualAddress; CComPtr m_pBuffer; }; @@ -112,14 +119,14 @@ class DynamicUploadHeap { public: - DynamicUploadHeap(IMemoryAllocator &Allocator, bool bIsCPUAccessible, class RenderDeviceD3D12Impl* pDevice, size_t InitialSize); + DynamicUploadHeap(IMemoryAllocator &Allocator, bool bIsCPUAccessible, class RenderDeviceD3D12Impl* pDevice, size_t InitialSize); - DynamicUploadHeap(const DynamicUploadHeap&)=delete; - DynamicUploadHeap(DynamicUploadHeap&&)=delete; - DynamicUploadHeap& operator=(const DynamicUploadHeap&)=delete; - DynamicUploadHeap& operator=(DynamicUploadHeap&&)=delete; + DynamicUploadHeap (const DynamicUploadHeap&)= delete; + DynamicUploadHeap (DynamicUploadHeap&&) = delete; + DynamicUploadHeap& operator=(const DynamicUploadHeap&)= delete; + DynamicUploadHeap& operator=(DynamicUploadHeap&&) = delete; - DynamicAllocation Allocate( size_t SizeInBytes, size_t Alignment = DEFAULT_ALIGN ); + DynamicAllocation Allocate( size_t SizeInBytes, size_t Alignment = DEFAULT_ALIGN ); void FinishFrame(Uint64 FenceValue, Uint64 LastCompletedFenceValue); diff --git a/Graphics/GraphicsEngineD3D12/include/GenerateMips.h b/Graphics/GraphicsEngineD3D12/include/GenerateMips.h index 6e858082..8bb1266a 100644 --- a/Graphics/GraphicsEngineD3D12/include/GenerateMips.h +++ b/Graphics/GraphicsEngineD3D12/include/GenerateMips.h @@ -59,6 +59,4 @@ namespace Diligent CComPtr m_pGenerateMipsLinearPSO[4]; CComPtr m_pGenerateMipsGammaPSO[4]; }; - - } diff --git a/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h index 9813ed59..a248ccf3 100644 --- a/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h @@ -59,10 +59,10 @@ public: virtual ID3D12RootSignature *GetD3D12RootSignature()const override final{return m_RootSig.GetD3D12RootSignature(); } - ShaderResourceCacheD3D12* CommitAndTransitionShaderResources(IShaderResourceBinding *pShaderResourceBinding, - class CommandContext &Ctx, - bool CommitResources, - bool TransitionResources)const; + ShaderResourceCacheD3D12* CommitAndTransitionShaderResources(IShaderResourceBinding* pShaderResourceBinding, + class CommandContext& Ctx, + bool CommitResources, + bool TransitionResources)const; const RootSignature& GetRootSignature()const{return m_RootSig;} @@ -70,8 +70,8 @@ public: bool dbgContainsShaderResources()const; - IMemoryAllocator &GetResourceCacheDataAllocator(){return m_ResourceCacheDataAllocator;} - IMemoryAllocator &GetShaderResourceLayoutDataAllocator(Uint32 ActiveShaderInd) + IMemoryAllocator& GetResourceCacheDataAllocator(){return m_ResourceCacheDataAllocator;} + IMemoryAllocator& GetShaderResourceLayoutDataAllocator(Uint32 ActiveShaderInd) { VERIFY_EXPR(ActiveShaderInd < m_NumShaders); auto *pAllocator = m_ResLayoutDataAllocators.GetAllocator(ActiveShaderInd); diff --git a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h index e750a624..47c58d99 100644 --- a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.h @@ -46,7 +46,12 @@ class RenderDeviceD3D12Impl : public RenderDeviceD3DBase public: typedef RenderDeviceD3DBase TRenderDeviceBase; - RenderDeviceD3D12Impl( IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator, const EngineD3D12Attribs &CreationAttribs, ID3D12Device *pD3D12Device, ICommandQueueD3D12 *pCmdQueue, Uint32 NumDeferredContexts ); + RenderDeviceD3D12Impl( IReferenceCounters* pRefCounters, + IMemoryAllocator& RawMemAllocator, + const EngineD3D12Attribs& CreationAttribs, + ID3D12Device* pD3D12Device, + ICommandQueueD3D12* pCmdQueue, + Uint32 NumDeferredContexts ); ~RenderDeviceD3D12Impl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; diff --git a/Graphics/GraphicsEngineD3D12/include/RootSignature.h b/Graphics/GraphicsEngineD3D12/include/RootSignature.h index 46e4fc1c..9d3fd016 100644 --- a/Graphics/GraphicsEngineD3D12/include/RootSignature.h +++ b/Graphics/GraphicsEngineD3D12/include/RootSignature.h @@ -39,65 +39,83 @@ class RootParameter { public: - RootParameter(D3D12_ROOT_PARAMETER_TYPE ParameterType, Uint32 RootIndex, UINT Register, UINT RegisterSpace, D3D12_SHADER_VISIBILITY Visibility, SHADER_VARIABLE_TYPE VarType) : - m_RootIndex(RootIndex), + RootParameter(D3D12_ROOT_PARAMETER_TYPE ParameterType, + Uint32 RootIndex, + UINT Register, + UINT RegisterSpace, + D3D12_SHADER_VISIBILITY Visibility, + SHADER_VARIABLE_TYPE VarType)noexcept : + m_RootIndex (RootIndex), m_ShaderVarType(VarType) { VERIFY(ParameterType == D3D12_ROOT_PARAMETER_TYPE_CBV || ParameterType == D3D12_ROOT_PARAMETER_TYPE_SRV || ParameterType == D3D12_ROOT_PARAMETER_TYPE_UAV, "Unexpected parameter type - verify argument list"); - m_RootParam.ParameterType = ParameterType; - m_RootParam.ShaderVisibility = Visibility; + m_RootParam.ParameterType = ParameterType; + m_RootParam.ShaderVisibility = Visibility; m_RootParam.Descriptor.ShaderRegister = Register; - m_RootParam.Descriptor.RegisterSpace = RegisterSpace; + m_RootParam.Descriptor.RegisterSpace = RegisterSpace; } - RootParameter( D3D12_ROOT_PARAMETER_TYPE ParameterType, Uint32 RootIndex, UINT Register, UINT RegisterSpace, UINT NumDwords, D3D12_SHADER_VISIBILITY Visibility, SHADER_VARIABLE_TYPE VarType) : - m_RootIndex(RootIndex), + RootParameter(D3D12_ROOT_PARAMETER_TYPE ParameterType, + Uint32 RootIndex, + UINT Register, + UINT RegisterSpace, + UINT NumDwords, + D3D12_SHADER_VISIBILITY Visibility, + SHADER_VARIABLE_TYPE VarType)noexcept : + m_RootIndex (RootIndex), m_ShaderVarType(VarType) { VERIFY(ParameterType == D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS, "Unexpected parameter type - verify argument list"); - m_RootParam.ParameterType = ParameterType; - m_RootParam.ShaderVisibility = Visibility; + m_RootParam.ParameterType = ParameterType; + m_RootParam.ShaderVisibility = Visibility; m_RootParam.Constants.Num32BitValues = NumDwords; m_RootParam.Constants.ShaderRegister = Register; - m_RootParam.Constants.RegisterSpace = RegisterSpace; + m_RootParam.Constants.RegisterSpace = RegisterSpace; } - RootParameter( D3D12_ROOT_PARAMETER_TYPE ParameterType, Uint32 RootIndex, UINT NumRanges, D3D12_DESCRIPTOR_RANGE *pRanges, D3D12_SHADER_VISIBILITY Visibility, SHADER_VARIABLE_TYPE VarType) : - m_RootIndex(RootIndex), + RootParameter(D3D12_ROOT_PARAMETER_TYPE ParameterType, + Uint32 RootIndex, + UINT NumRanges, + D3D12_DESCRIPTOR_RANGE* pRanges, + D3D12_SHADER_VISIBILITY Visibility, + SHADER_VARIABLE_TYPE VarType)noexcept : + m_RootIndex (RootIndex), m_ShaderVarType(VarType) { VERIFY(ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, "Unexpected parameter type - verify argument list"); VERIFY_EXPR(pRanges != nullptr); - m_RootParam.ParameterType = ParameterType; + m_RootParam.ParameterType = ParameterType; m_RootParam.ShaderVisibility = Visibility; m_RootParam.DescriptorTable.NumDescriptorRanges = NumRanges; - m_RootParam.DescriptorTable.pDescriptorRanges = pRanges; + m_RootParam.DescriptorTable.pDescriptorRanges = pRanges; #ifdef _DEBUG for(Uint32 r=0; r < NumRanges; ++r) pRanges[r].RangeType = static_cast(-1); #endif } - RootParameter(const RootParameter &RP): - m_RootParam( RP.m_RootParam), + RootParameter(const RootParameter& RP)noexcept : + m_RootParam (RP.m_RootParam), m_DescriptorTableSize(RP.m_DescriptorTableSize), - m_ShaderVarType(RP.m_ShaderVarType), - m_RootIndex(RP.m_RootIndex) + m_ShaderVarType (RP.m_ShaderVarType), + m_RootIndex (RP.m_RootIndex) { VERIFY(m_RootParam.ParameterType != D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, "Use another constructor to copy descriptor table"); } - RootParameter(const RootParameter &RP, UINT NumRanges, D3D12_DESCRIPTOR_RANGE *pRanges): - m_RootParam( RP.m_RootParam), + RootParameter(const RootParameter& RP, + UINT NumRanges, + D3D12_DESCRIPTOR_RANGE* pRanges)noexcept : + m_RootParam (RP.m_RootParam), m_DescriptorTableSize(RP.m_DescriptorTableSize), - m_ShaderVarType(RP.m_ShaderVarType), - m_RootIndex(RP.m_RootIndex) + m_ShaderVarType (RP.m_ShaderVarType), + m_RootIndex (RP.m_RootIndex) { VERIFY(m_RootParam.ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, "Root parameter is expected to be a descriptor table"); VERIFY(NumRanges >= m_RootParam.DescriptorTable.NumDescriptorRanges, "New table must be larger than source one"); auto &DstTbl = m_RootParam.DescriptorTable; DstTbl.NumDescriptorRanges = NumRanges; - DstTbl.pDescriptorRanges = pRanges; + DstTbl.pDescriptorRanges = pRanges; const auto &SrcTbl = RP.m_RootParam.DescriptorTable; memcpy(pRanges, SrcTbl.pDescriptorRanges, SrcTbl.NumDescriptorRanges * sizeof(D3D12_DESCRIPTOR_RANGE)); #ifdef _DEBUG @@ -116,20 +134,25 @@ public: #endif } - RootParameter& operator = (const RootParameter &RP) = delete; - RootParameter& operator = (RootParameter &&RP) = delete; + RootParameter& operator = (const RootParameter&) = delete; + RootParameter& operator = (RootParameter&&) = delete; - void SetDescriptorRange( UINT RangeIndex, D3D12_DESCRIPTOR_RANGE_TYPE Type, UINT Register, UINT Count, UINT Space = 0, UINT OffsetFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) + void SetDescriptorRange(UINT RangeIndex, + D3D12_DESCRIPTOR_RANGE_TYPE Type, + UINT Register, + UINT Count, + UINT Space = 0, + UINT OffsetFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) { VERIFY(m_RootParam.ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, "Incorrect parameter table: descriptor table is expected"); auto &Tbl = m_RootParam.DescriptorTable; VERIFY(RangeIndex < Tbl.NumDescriptorRanges, "Invalid descriptor range index"); D3D12_DESCRIPTOR_RANGE &range = const_cast(Tbl.pDescriptorRanges[RangeIndex]); VERIFY(range.RangeType == static_cast(-1), "Descriptor range has already been initialized. m_DescriptorTableSize may be updated incorrectly"); - range.RangeType = Type; - range.NumDescriptors = Count; + range.RangeType = Type; + range.NumDescriptors = Count; range.BaseShaderRegister = Register; - range.RegisterSpace = Space; + range.RegisterSpace = Space; range.OffsetInDescriptorsFromTableStart = OffsetFromTableStart; m_DescriptorTableSize = std::max(m_DescriptorTableSize, OffsetFromTableStart + Count); } @@ -140,12 +163,12 @@ public: VERIFY(m_RootParam.ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, "Incorrect parameter table: descriptor table is expected"); return m_DescriptorTableSize; } - D3D12_SHADER_VISIBILITY GetShaderVisibility()const{return m_RootParam.ShaderVisibility;} - D3D12_ROOT_PARAMETER_TYPE GetParameterType()const{return m_RootParam.ParameterType;} + D3D12_SHADER_VISIBILITY GetShaderVisibility()const { return m_RootParam.ShaderVisibility; } + D3D12_ROOT_PARAMETER_TYPE GetParameterType() const { return m_RootParam.ParameterType; } - Uint32 GetRootIndex()const{return m_RootIndex;} + Uint32 GetRootIndex()const { return m_RootIndex; } - operator const D3D12_ROOT_PARAMETER&()const{return m_RootParam;} + operator const D3D12_ROOT_PARAMETER&()const { return m_RootParam; } bool operator == (const RootParameter&rhs)const { @@ -271,28 +294,34 @@ public: ID3D12RootSignature* GetD3D12RootSignature()const{return m_pd3d12RootSignature;} void InitResourceCache(class RenderDeviceD3D12Impl *pDeviceD3D12Impl, class ShaderResourceCacheD3D12& ResourceCache, IMemoryAllocator &CacheMemAllocator)const; - void InitStaticSampler(SHADER_TYPE ShaderType, const String &TextureName, const D3DShaderResourceAttribs &ShaderResAttribs); + void InitStaticSampler(SHADER_TYPE ShaderType, + const String& TextureName, + const D3DShaderResourceAttribs& ShaderResAttribs); - void AllocateResourceSlot(SHADER_TYPE ShaderType, const D3DShaderResourceAttribs &ShaderResAttribs, D3D12_DESCRIPTOR_RANGE_TYPE RangeType, Uint32 &RootIndex, Uint32 &OffsetFromTableStart); + void AllocateResourceSlot(SHADER_TYPE ShaderType, + const D3DShaderResourceAttribs& ShaderResAttribs, + D3D12_DESCRIPTOR_RANGE_TYPE RangeType, + Uint32& RootIndex, + Uint32& OffsetFromTableStart); // This method should be thread-safe as it does not modify any object state - void (RootSignature::*CommitDescriptorHandles)(class RenderDeviceD3D12Impl *pRenderDeviceD3D12, - ShaderResourceCacheD3D12& ResourceCache, - class CommandContext &Ctx, - bool IsCompute)const = nullptr; + void (RootSignature::*CommitDescriptorHandles)(class RenderDeviceD3D12Impl* pRenderDeviceD3D12, + ShaderResourceCacheD3D12& ResourceCache, + class CommandContext& Ctx, + bool IsCompute)const = nullptr; - void (RootSignature::*TransitionAndCommitDescriptorHandles)(class RenderDeviceD3D12Impl *pRenderDeviceD3D12, - ShaderResourceCacheD3D12& ResourceCache, - class CommandContext &Ctx, - bool IsCompute)const = nullptr; + void (RootSignature::*TransitionAndCommitDescriptorHandles)(class RenderDeviceD3D12Impl* pRenderDeviceD3D12, + ShaderResourceCacheD3D12& ResourceCache, + class CommandContext& Ctx, + bool IsCompute)const = nullptr; - void TransitionResources(ShaderResourceCacheD3D12& ResourceCache, - class CommandContext &Ctx)const; + void TransitionResources(ShaderResourceCacheD3D12& ResourceCache, + class CommandContext& Ctx)const; - void CommitRootViews(ShaderResourceCacheD3D12& ResourceCache, - class CommandContext &Ctx, - bool IsCompute, - Uint32 ContextId)const; + void CommitRootViews(ShaderResourceCacheD3D12& ResourceCache, + class CommandContext& Ctx, + bool IsCompute, + Uint32 ContextId)const; Uint32 GetTotalSrvCbvUavSlots(SHADER_VARIABLE_TYPE VarType)const { @@ -329,13 +358,13 @@ private: public: RootParamsManager(IMemoryAllocator &MemAllocator); - RootParamsManager(const RootParamsManager&) = delete; + RootParamsManager (const RootParamsManager&) = delete; RootParamsManager& operator= (const RootParamsManager&) = delete; - RootParamsManager(RootParamsManager&&) = delete; - RootParamsManager& operator= (RootParamsManager&&) = delete; + RootParamsManager (RootParamsManager&&) = delete; + RootParamsManager& operator= (RootParamsManager&&) = delete; - Uint32 GetNumRootTables()const{return m_NumRootTables;} - Uint32 GetNumRootViews()const{return m_NumRootViews;} + Uint32 GetNumRootTables()const { return m_NumRootTables; } + Uint32 GetNumRootViews() const { return m_NumRootViews; } const RootParameter& GetRootTable(Uint32 TableInd)const { @@ -361,8 +390,17 @@ private: return m_pRootViews[ViewInd]; } - void AddRootView(D3D12_ROOT_PARAMETER_TYPE ParameterType, Uint32 RootIndex, UINT Register, D3D12_SHADER_VISIBILITY Visibility, SHADER_VARIABLE_TYPE VarType); - void AddRootTable(Uint32 RootIndex, D3D12_SHADER_VISIBILITY Visibility, SHADER_VARIABLE_TYPE VarType, Uint32 NumRangesInNewTable = 1); + void AddRootView(D3D12_ROOT_PARAMETER_TYPE ParameterType, + Uint32 RootIndex, + UINT Register, + D3D12_SHADER_VISIBILITY Visibility, + SHADER_VARIABLE_TYPE VarType); + + void AddRootTable(Uint32 RootIndex, + D3D12_SHADER_VISIBILITY Visibility, + SHADER_VARIABLE_TYPE VarType, + Uint32 NumRangesInNewTable = 1); + void AddDescriptorRanges(Uint32 RootTableInd, Uint32 NumExtraRanges = 1); template @@ -372,16 +410,22 @@ private: size_t GetHash()const; private: - size_t GetRequiredMemorySize(Uint32 NumExtraRootTables, Uint32 NumExtraRootViews, Uint32 NumExtraDescriptorRanges)const; - D3D12_DESCRIPTOR_RANGE* Extend(Uint32 NumExtraRootTables, Uint32 NumExtraRootViews, Uint32 NumExtraDescriptorRanges, Uint32 RootTableToAddRanges = static_cast(-1)); + size_t GetRequiredMemorySize(Uint32 NumExtraRootTables, + Uint32 NumExtraRootViews, + Uint32 NumExtraDescriptorRanges)const; + + D3D12_DESCRIPTOR_RANGE* Extend(Uint32 NumExtraRootTables, + Uint32 NumExtraRootViews, + Uint32 NumExtraDescriptorRanges, + Uint32 RootTableToAddRanges = static_cast(-1)); IMemoryAllocator &m_MemAllocator; std::unique_ptr> m_pMemory; - Uint32 m_NumRootTables = 0; - Uint32 m_NumRootViews = 0; + Uint32 m_NumRootTables = 0; + Uint32 m_NumRootViews = 0; Uint32 m_TotalDescriptorRanges = 0; - RootParameter *m_pRootTables = nullptr; - RootParameter *m_pRootViews = nullptr; + RootParameter* m_pRootTables = nullptr; + RootParameter* m_pRootViews = nullptr; }; static constexpr Uint8 InvalidRootTableIndex = static_cast(-1); @@ -400,13 +444,13 @@ private: { StaticSamplerDesc SamplerDesc; UINT ShaderRegister = static_cast(-1); - UINT ArraySize = 0; - UINT RegisterSpace = 0; + UINT ArraySize = 0; + UINT RegisterSpace = 0; D3D12_SHADER_VISIBILITY ShaderVisibility = static_cast(-1); - StaticSamplerAttribs(){} - StaticSamplerAttribs(const StaticSamplerDesc& SamDesc, D3D12_SHADER_VISIBILITY Visibility) : - SamplerDesc(SamDesc), + StaticSamplerAttribs()noexcept{} + StaticSamplerAttribs(const StaticSamplerDesc& SamDesc, D3D12_SHADER_VISIBILITY Visibility)noexcept : + SamplerDesc (SamDesc), ShaderVisibility(Visibility) {} }; @@ -417,16 +461,16 @@ private: // Commits descriptor handles for static and mutable variables template - void CommitDescriptorHandlesInternal_SM(class RenderDeviceD3D12Impl *pRenderDeviceD3D12, - ShaderResourceCacheD3D12& ResourceCache, - class CommandContext &Ctx, - bool IsCompute)const; + void CommitDescriptorHandlesInternal_SM(class RenderDeviceD3D12Impl* pRenderDeviceD3D12, + ShaderResourceCacheD3D12& ResourceCache, + class CommandContext& Ctx, + bool IsCompute)const; template // Commits descriptor handles for static, mutable, and dynamic variables - void CommitDescriptorHandlesInternal_SMD(class RenderDeviceD3D12Impl *pRenderDeviceD3D12, - ShaderResourceCacheD3D12& ResourceCache, - class CommandContext &Ctx, - bool IsCompute)const; + void CommitDescriptorHandlesInternal_SMD(class RenderDeviceD3D12Impl* pRenderDeviceD3D12, + ShaderResourceCacheD3D12& ResourceCache, + class CommandContext& Ctx, + bool IsCompute)const; }; } diff --git a/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h index dd5a9ddd..0c34888c 100644 --- a/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h @@ -41,7 +41,9 @@ class SamplerD3D12Impl : public SamplerBase public: typedef SamplerBase TSamplerBase; - SamplerD3D12Impl(IReferenceCounters *pRefCounters, class RenderDeviceD3D12Impl *pRenderDeviceD3D12, const SamplerDesc& SamplerDesc); + SamplerD3D12Impl(IReferenceCounters* pRefCounters, + class RenderDeviceD3D12Impl* pRenderDeviceD3D12, + const SamplerDesc& SamplerDesc); ~SamplerD3D12Impl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override; diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h index 4ee98ae6..fc61928b 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h @@ -48,7 +48,9 @@ class ShaderD3D12Impl : public ShaderBase, pub public: typedef ShaderBase TShaderBase; - ShaderD3D12Impl(IReferenceCounters *pRefCounters, class RenderDeviceD3D12Impl *pRenderDeviceD3D12, const ShaderCreationAttribs &ShaderCreationAttribs); + ShaderD3D12Impl(IReferenceCounters* pRefCounters, + class RenderDeviceD3D12Impl* pRenderDeviceD3D12, + const ShaderCreationAttribs& ShaderCreationAttribs); ~ShaderD3D12Impl(); //virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override; @@ -73,7 +75,7 @@ private: // it is referenced by ShaderResourceLayoutD3D12 class instances std::shared_ptr m_pShaderResources; ShaderResourceLayoutD3D12 m_StaticResLayout; - ShaderResourceCacheD3D12 m_ConstResCache; + ShaderResourceCacheD3D12 m_ConstResCache; }; } diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.h index 4b3e366c..cf88a372 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.h @@ -42,7 +42,9 @@ class ShaderResourceBindingD3D12Impl : public ShaderResourceBindingBase TBase; - ShaderResourceBindingD3D12Impl(IReferenceCounters *pRefCounters, class PipelineStateD3D12Impl *pPSO, bool IsPSOInternal); + ShaderResourceBindingD3D12Impl(IReferenceCounters* pRefCounters, + class PipelineStateD3D12Impl* pPSO, + bool IsPSOInternal); ~ShaderResourceBindingD3D12Impl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override; diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.h b/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.h index 1230b8c1..98bc4112 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.h +++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.h @@ -115,7 +115,9 @@ public: ~ShaderResourceCacheD3D12(); - void Initialize(IMemoryAllocator &MemAllocator, Uint32 NumTables, Uint32 TableSizes[]); + void Initialize(IMemoryAllocator& MemAllocator, + Uint32 NumTables, + Uint32 TableSizes[]); static constexpr Uint32 InvalidDescriptorOffset = static_cast(-1); @@ -132,17 +134,17 @@ public: class RootTable { public: - RootTable(Uint32 NumResources, Resource *pResources) : + RootTable(Uint32 NumResources, Resource *pResources)noexcept : m_NumResources(NumResources), - m_pResources(pResources) + m_pResources (pResources) {} - inline Resource& GetResource(Uint32 OffsetFromTableStart, + inline Resource& GetResource(Uint32 OffsetFromTableStart, const D3D12_DESCRIPTOR_HEAP_TYPE dbgDescriptorHeapType, - const SHADER_TYPE dbgRefShaderType) + const SHADER_TYPE dbgRefShaderType) { - VERIFY(m_dbgHeapType == dbgDescriptorHeapType, "Incosistent descriptor heap type" ); - VERIFY(m_dbgShaderType == dbgRefShaderType, "Incosistent shader type" ); + VERIFY(m_dbgHeapType == dbgDescriptorHeapType, "Incosistent descriptor heap type" ); + VERIFY(m_dbgShaderType == dbgRefShaderType, "Incosistent shader type" ); VERIFY(OffsetFromTableStart < m_NumResources, "Root table at index is not large enough to store descriptor at offset ", OffsetFromTableStart ); return m_pResources[OffsetFromTableStart]; @@ -154,12 +156,12 @@ public: Uint32 m_TableStartOffset = InvalidDescriptorOffset; #ifdef _DEBUG - void SetDebugAttribs(Uint32 MaxOffset, + void SetDebugAttribs(Uint32 MaxOffset, const D3D12_DESCRIPTOR_HEAP_TYPE dbgDescriptorHeapType, - const SHADER_TYPE dbgRefShaderType) + const SHADER_TYPE dbgRefShaderType) { VERIFY_EXPR(m_NumResources == MaxOffset); - m_dbgHeapType = dbgDescriptorHeapType; + m_dbgHeapType = dbgDescriptorHeapType; m_dbgShaderType = dbgRefShaderType; } @@ -170,8 +172,8 @@ public: private: #ifdef _DEBUG - D3D12_DESCRIPTOR_HEAP_TYPE m_dbgHeapType = D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES; - SHADER_TYPE m_dbgShaderType = SHADER_TYPE_UNKNOWN; + D3D12_DESCRIPTOR_HEAP_TYPE m_dbgHeapType = D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES; + SHADER_TYPE m_dbgShaderType = SHADER_TYPE_UNKNOWN; #endif Resource* const m_pResources = nullptr; @@ -185,7 +187,7 @@ public: inline Uint32 GetNumRootTables()const{return m_NumTables; } - void SetDescriptorHeapSpace(DescriptorHeapAllocation &&CbcSrvUavHeapSpace, DescriptorHeapAllocation &&SamplerHeapSpace) + void SetDescriptorHeapSpace(DescriptorHeapAllocation&& CbcSrvUavHeapSpace, DescriptorHeapAllocation&& SamplerHeapSpace) { VERIFY(m_SamplerHeapSpace.GetCpuHandle().ptr == 0 && m_CbvSrvUavHeapSpace.GetCpuHandle().ptr == 0, "Space has already been allocated in GPU descriptor heaps"); #ifdef _DEBUG @@ -215,8 +217,8 @@ public: m_SamplerHeapSpace = std::move(SamplerHeapSpace); } - ID3D12DescriptorHeap* GetSrvCbvUavDescriptorHeap(){return m_CbvSrvUavHeapSpace.GetDescriptorHeap();} - ID3D12DescriptorHeap* GetSamplerDescriptorHeap() {return m_SamplerHeapSpace.GetDescriptorHeap();} + ID3D12DescriptorHeap* GetSrvCbvUavDescriptorHeap() { return m_CbvSrvUavHeapSpace.GetDescriptorHeap(); } + ID3D12DescriptorHeap* GetSamplerDescriptorHeap() { return m_SamplerHeapSpace.GetDescriptorHeap(); } // Returns CPU descriptor handle of a shader visible descriptor heap allocation template @@ -285,10 +287,10 @@ public: #endif private: - ShaderResourceCacheD3D12(const ShaderResourceCacheD3D12&) = delete; - ShaderResourceCacheD3D12(ShaderResourceCacheD3D12&&) = delete; + ShaderResourceCacheD3D12 (const ShaderResourceCacheD3D12&) = delete; + ShaderResourceCacheD3D12 (ShaderResourceCacheD3D12&&) = delete; ShaderResourceCacheD3D12& operator = (const ShaderResourceCacheD3D12&) = delete; - ShaderResourceCacheD3D12& operator = (ShaderResourceCacheD3D12&&) = delete; + ShaderResourceCacheD3D12& operator = (ShaderResourceCacheD3D12&&) = delete; // Allocation in a GPU-visible sampler descriptor heap DescriptorHeapAllocation m_SamplerHeapSpace; diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.h b/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.h index af54a6ba..19520669 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.h +++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourceLayoutD3D12.h @@ -125,21 +125,21 @@ namespace Diligent class ShaderResourceLayoutD3D12 { public: - ShaderResourceLayoutD3D12(IObject &Owner, IMemoryAllocator &ResourceLayoutDataAllocator); + ShaderResourceLayoutD3D12(IObject& Owner, IMemoryAllocator& ResourceLayoutDataAllocator); // This constructor is used by ShaderResourceBindingD3D12Impl to clone layout from the reference layout in PipelineStateD3D12Impl. // Root indices and descriptor table offsets must be correct. Resource cache is assigned, but not initialized. - ShaderResourceLayoutD3D12(IObject &Owner, + ShaderResourceLayoutD3D12(IObject& Owner, const ShaderResourceLayoutD3D12& SrcLayout, - IMemoryAllocator &ResourceLayoutDataAllocator, - const SHADER_VARIABLE_TYPE *AllowedVarTypes, - Uint32 NumAllowedTypes, - ShaderResourceCacheD3D12 &ResourceCache); + IMemoryAllocator& ResourceLayoutDataAllocator, + const SHADER_VARIABLE_TYPE* AllowedVarTypes, + Uint32 NumAllowedTypes, + ShaderResourceCacheD3D12& ResourceCache); - ShaderResourceLayoutD3D12(const ShaderResourceLayoutD3D12&) = delete; - ShaderResourceLayoutD3D12(ShaderResourceLayoutD3D12&&) = delete; + ShaderResourceLayoutD3D12 (const ShaderResourceLayoutD3D12&) = delete; + ShaderResourceLayoutD3D12 (ShaderResourceLayoutD3D12&&) = delete; ShaderResourceLayoutD3D12& operator =(const ShaderResourceLayoutD3D12&) = delete; - ShaderResourceLayoutD3D12& operator =(ShaderResourceLayoutD3D12&&) = delete; + ShaderResourceLayoutD3D12& operator =(ShaderResourceLayoutD3D12&&) = delete; ~ShaderResourceLayoutD3D12(); @@ -149,19 +149,19 @@ public: // - PipelineStateD3D12Impl class instance to reference all types of resources (static, mutable, dynamic). // Root indices and descriptor table offsets are assigned during the initialization; // no shader resource cache is provided - void Initialize(ID3D12Device *pd3d12Device, + void Initialize(ID3D12Device* pd3d12Device, const std::shared_ptr& pSrcResources, - IMemoryAllocator &LayoutDataAllocator, - const SHADER_VARIABLE_TYPE *VarTypes, - Uint32 NumAllowedTypes, - ShaderResourceCacheD3D12 *pResourceCache, - class RootSignature *pRootSig); + IMemoryAllocator& LayoutDataAllocator, + const SHADER_VARIABLE_TYPE* VarTypes, + Uint32 NumAllowedTypes, + ShaderResourceCacheD3D12* pResourceCache, + class RootSignature* pRootSig); // sizeof(SRV_CBV_UAV) == 32 (x64) struct SRV_CBV_UAV : ShaderVariableD3DBase { - SRV_CBV_UAV(const SRV_CBV_UAV&) = delete; - SRV_CBV_UAV(SRV_CBV_UAV&&) = delete; + SRV_CBV_UAV (const SRV_CBV_UAV&) = delete; + SRV_CBV_UAV (SRV_CBV_UAV&&) = delete; SRV_CBV_UAV& operator = (const SRV_CBV_UAV&) = delete; SRV_CBV_UAV& operator = (SRV_CBV_UAV&&) = delete; @@ -183,11 +183,13 @@ public: // Special copy constructor. Note that sampler ID refers to the ID of the sampler // within THIS layout, and may not be the same as in original layout - SRV_CBV_UAV(ShaderResourceLayoutD3D12 &ParentLayout, const SRV_CBV_UAV &rhs, Uint32 SamId ) : - ResType_RootIndex(rhs.ResType_RootIndex), - SamplerId(static_cast(SamId)), - OffsetFromTableStart(rhs.OffsetFromTableStart), - ShaderVariableD3DBase(ParentLayout, rhs.Attribs) + SRV_CBV_UAV(ShaderResourceLayoutD3D12& ParentLayout, + const SRV_CBV_UAV& rhs, + Uint32 SamId)noexcept : + ShaderVariableD3DBase(ParentLayout, rhs.Attribs), + ResType_RootIndex (rhs.ResType_RootIndex), + SamplerId (static_cast(SamId)), + OffsetFromTableStart(rhs.OffsetFromTableStart) { VERIFY(SamId == InvalidSamplerId || SamId <= MaxSamplerId, "Sampler id exceeds max allowed value (", MaxSamplerId, ")" ); VERIFY(rhs.m_ParentResLayout.m_pResources == m_ParentResLayout.m_pResources, "Incosistent resource references"); @@ -195,23 +197,23 @@ public: VERIFY(IsValidRootIndex(), "Root index must be valid" ); } - SRV_CBV_UAV(ShaderResourceLayoutD3D12 &ParentLayout, - const D3DShaderResourceAttribs &_Attribs, - CachedResourceType ResType, - Uint32 RootIndex, - Uint32 _OffsetFromTableStart, - Uint32 _SamplerId) : - ResType_RootIndex( (static_cast(ResType) << RootIndBits) | (RootIndex & RootIndMask)), - SamplerId( static_cast(_SamplerId) ), - OffsetFromTableStart(_OffsetFromTableStart), - ShaderVariableD3DBase(ParentLayout, _Attribs) + SRV_CBV_UAV(ShaderResourceLayoutD3D12& ParentLayout, + const D3DShaderResourceAttribs& _Attribs, + CachedResourceType ResType, + Uint32 RootIndex, + Uint32 _OffsetFromTableStart, + Uint32 _SamplerId)noexcept : + ShaderVariableD3DBase(ParentLayout, _Attribs), + ResType_RootIndex ( (static_cast(ResType) << RootIndBits) | (RootIndex & RootIndMask)), + SamplerId ( static_cast(_SamplerId) ), + OffsetFromTableStart( _OffsetFromTableStart ) { VERIFY(RootIndex == InvalidRootIndex || RootIndex <= MaxRootIndex, "Root index exceeds max allowed value (", MaxRootIndex, ")" ); VERIFY(IsValidOffset(), "Offset must be valid" ); VERIFY(SamplerId == InvalidSamplerId || SamplerId <= MaxSamplerId, "Sampler id exceeds max allowed value (", MaxSamplerId, ")" ); } - bool IsBound(Uint32 ArrayIndex); + bool IsBound(Uint32 ArrayIndex)const; // Non-virtual function void BindResource(IDeviceObject *pObject, Uint32 ArrayIndex, const ShaderResourceLayoutD3D12 *dbgResLayout); @@ -223,9 +225,9 @@ public: BindResource(ppObjects[Elem], FirstElement+Elem, nullptr); } - bool IsValidSampler() const{return GetSamplerId() != InvalidSamplerId;} - bool IsValidRootIndex()const{return GetRootIndex() != InvalidRootIndex;} - bool IsValidOffset() const{return OffsetFromTableStart != InvalidOffset; } + bool IsValidSampler() const { return GetSamplerId() != InvalidSamplerId; } + bool IsValidRootIndex()const { return GetRootIndex() != InvalidRootIndex; } + bool IsValidOffset() const { return OffsetFromTableStart != InvalidOffset; } CachedResourceType GetResType()const { @@ -248,32 +250,32 @@ public: // | Root index | ResType | const Uint16 SamplerId; - void CacheCB(IDeviceObject *pBuffer, + void CacheCB(IDeviceObject* pBuffer, ShaderResourceCacheD3D12::Resource& DstRes, - Uint32 ArrayInd, - D3D12_CPU_DESCRIPTOR_HANDLE ShdrVisibleHeapCPUDescriptorHandle); + Uint32 ArrayInd, + D3D12_CPU_DESCRIPTOR_HANDLE ShdrVisibleHeapCPUDescriptorHandle); template - void CacheResourceView(IDeviceObject *pView, + void CacheResourceView(IDeviceObject* pView, ShaderResourceCacheD3D12::Resource& DstRes, - Uint32 ArrayIndex, - D3D12_CPU_DESCRIPTOR_HANDLE ShdrVisibleHeapCPUDescriptorHandle, - TViewTypeEnum dbgExpectedViewType, - TBindSamplerProcType BindSamplerProc); + Uint32 ArrayIndex, + D3D12_CPU_DESCRIPTOR_HANDLE ShdrVisibleHeapCPUDescriptorHandle, + TViewTypeEnum dbgExpectedViewType, + TBindSamplerProcType BindSamplerProc); }; // sizeof(Sampler) == 24 (x64) struct Sampler { - Sampler(const Sampler&) = delete; - Sampler(Sampler&&) = delete; + Sampler (const Sampler&) = delete; + Sampler (Sampler&&) = delete; Sampler& operator = (const Sampler&) = delete; Sampler& operator = (Sampler&&) = delete; - const D3DShaderResourceAttribs &Attribs; - ShaderResourceLayoutD3D12 &m_ParentResLayout; + const D3DShaderResourceAttribs& Attribs; + ShaderResourceLayoutD3D12& m_ParentResLayout; static constexpr Uint32 InvalidRootIndex = static_cast(-1); static constexpr Uint32 InvalidOffset = static_cast(-1); @@ -281,10 +283,10 @@ public: const Uint32 RootIndex; const Uint32 OffsetFromTableStart; - Sampler(ShaderResourceLayoutD3D12 &ParentLayout, const Sampler& Sam): - Attribs(Sam.Attribs), - m_ParentResLayout(ParentLayout), - RootIndex(Sam.RootIndex), + Sampler(ShaderResourceLayoutD3D12 &ParentLayout, const Sampler& Sam)noexcept : + Attribs (Sam.Attribs), + m_ParentResLayout (ParentLayout), + RootIndex (Sam.RootIndex), OffsetFromTableStart(Sam.OffsetFromTableStart) { VERIFY(Sam.m_ParentResLayout.m_pResources == m_ParentResLayout.m_pResources, "Incosistent resource references"); @@ -292,18 +294,21 @@ public: VERIFY(IsValidOffset(), "Offset must be valid" ); } - Sampler(ShaderResourceLayoutD3D12 &ParentResLayout, const D3DShaderResourceAttribs &_Attribs, Uint32 _RootIndex, Uint32 _OffsetFromTableStart) : - RootIndex(_RootIndex), + Sampler(ShaderResourceLayoutD3D12& ParentResLayout, + const D3DShaderResourceAttribs& _Attribs, + Uint32 _RootIndex, + Uint32 _OffsetFromTableStart)noexcept : + RootIndex (_RootIndex), OffsetFromTableStart(_OffsetFromTableStart), - Attribs(_Attribs), - m_ParentResLayout(ParentResLayout) + Attribs (_Attribs), + m_ParentResLayout (ParentResLayout) { VERIFY(IsValidRootIndex(), "Root index must be valid" ); VERIFY(IsValidOffset(), "Offset must be valid" ); } - bool IsValidRootIndex()const{return RootIndex != InvalidRootIndex;} - bool IsValidOffset() const{return OffsetFromTableStart != InvalidOffset; } + bool IsValidRootIndex()const { return RootIndex != InvalidRootIndex; } + bool IsValidOffset() const { return OffsetFromTableStart != InvalidOffset; } void CacheSampler(class ITextureViewD3D12 *pTexViewD3D12, Uint32 ArrayIndex, D3D12_CPU_DESCRIPTOR_HANDLE ShdrVisibleHeapCPUDescriptorHandle); }; diff --git a/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h index 3b1f21a1..c186ff28 100644 --- a/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h @@ -40,10 +40,10 @@ class SwapChainD3D12Impl : public SwapChainD3DBase; - SwapChainD3D12Impl(IReferenceCounters *pRefCounters, - const SwapChainDesc& SwapChainDesc, - const FullScreenModeDesc& FSDesc, - class RenderDeviceD3D12Impl* pRenderDeviceD3D12, + SwapChainD3D12Impl(IReferenceCounters* pRefCounters, + const SwapChainDesc& SwapChainDesc, + const FullScreenModeDesc& FSDesc, + class RenderDeviceD3D12Impl* pRenderDeviceD3D12, class DeviceContextD3D12Impl* pDeviceContextD3D12, void* pNativeWndHandle); ~SwapChainD3D12Impl(); diff --git a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h index bb3861c9..86cc6f0e 100644 --- a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h @@ -45,17 +45,17 @@ public: typedef TextureBase TTextureBase; // Creates a new D3D12 resource - TextureD3D12Impl(IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator &TexViewObjAllocator, - class RenderDeviceD3D12Impl *pDeviceD3D12, - const TextureDesc& TexDesc, - const TextureData &InitData = TextureData()); + TextureD3D12Impl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceD3D12Impl* pDeviceD3D12, + const TextureDesc& TexDesc, + const TextureData& InitData = TextureData()); // Attaches to an existing D3D12 resource - TextureD3D12Impl(IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator &TexViewObjAllocator, - class RenderDeviceD3D12Impl *pDeviceD3D12, - const TextureDesc& TexDesc, - ID3D12Resource *pTexture); + TextureD3D12Impl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + class RenderDeviceD3D12Impl* pDeviceD3D12, + const TextureDesc& TexDesc, + ID3D12Resource* pTexture); ~TextureD3D12Impl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override; @@ -72,16 +72,16 @@ public: virtual void SetD3D12ResourceState(D3D12_RESOURCE_STATES state)override final{ SetState(state); } - void CopyData(IDeviceContext *pContext, - ITexture *pSrcTexture, - Uint32 SrcMipLevel, - Uint32 SrcSlice, - const Box *pSrcBox, - Uint32 DstMipLevel, - Uint32 DstSlice, - Uint32 DstX, - Uint32 DstY, - Uint32 DstZ); + void CopyData(IDeviceContext* pContext, + ITexture* pSrcTexture, + Uint32 SrcMipLevel, + Uint32 SrcSlice, + const Box* pSrcBox, + Uint32 DstMipLevel, + Uint32 DstSlice, + Uint32 DstX, + Uint32 DstY, + Uint32 DstZ); D3D12_CPU_DESCRIPTOR_HANDLE GetMipLevelUAV(Uint32 Mip) { diff --git a/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h index d8704683..072446d9 100644 --- a/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h @@ -41,12 +41,12 @@ class TextureViewD3D12Impl : public TextureViewBase public: typedef TextureViewBase TTextureViewBase; - TextureViewD3D12Impl( IReferenceCounters *pRefCounters, - IRenderDevice *pDevice, - const TextureViewDesc& ViewDesc, - class ITexture *pTexture, - DescriptorHeapAllocation &&HandleAlloc, - bool bIsDefaultView); + TextureViewD3D12Impl( IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + const TextureViewDesc& ViewDesc, + class ITexture* pTexture, + DescriptorHeapAllocation&& HandleAlloc, + bool bIsDefaultView); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override; diff --git a/Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h b/Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h index 19b96a10..107de833 100644 --- a/Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/DeviceContextD3D12.h @@ -44,13 +44,13 @@ public: /// \param [in] pTexture - texture to transition /// \param [in] State - D3D12 resource state this texture to transition to - virtual void TransitionTextureState(ITexture *pTexture, D3D12_RESOURCE_STATES State) = 0; + virtual void TransitionTextureState(ITexture* pTexture, D3D12_RESOURCE_STATES State) = 0; /// Transitions internal D3D12 buffer object to a specified state /// \param [in] pBuffer - Buffer to transition /// \param [in] State - D3D12 resource state this buffer to transition to - virtual void TransitionBufferState(IBuffer *pBuffer, D3D12_RESOURCE_STATES State) = 0; + virtual void TransitionBufferState(IBuffer* pBuffer, D3D12_RESOURCE_STATES State) = 0; }; } diff --git a/Graphics/GraphicsEngineD3D12/interface/RenderDeviceD3D12.h b/Graphics/GraphicsEngineD3D12/interface/RenderDeviceD3D12.h index d4fb6513..70d111cb 100644 --- a/Graphics/GraphicsEngineD3D12/interface/RenderDeviceD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/RenderDeviceD3D12.h @@ -63,7 +63,7 @@ public: /// texture interface will be stored. /// The function calls AddRef(), so that the new object will contain /// one refernce. - virtual void CreateTextureFromD3DResource(ID3D12Resource *pd3d12Texture, ITexture **ppTexture) = 0; + virtual void CreateTextureFromD3DResource(ID3D12Resource* pd3d12Texture, ITexture** ppTexture) = 0; /// Creates a buffer object from native d3d12 resoruce @@ -75,7 +75,7 @@ public: /// buffer interface will be stored. /// The function calls AddRef(), so that the new object will contain /// one reference. - virtual void CreateBufferFromD3DResource(ID3D12Resource *pd3d12Buffer, const BufferDesc& BuffDesc, IBuffer **ppBuffer) = 0; + virtual void CreateBufferFromD3DResource(ID3D12Resource* pd3d12Buffer, const BufferDesc& BuffDesc, IBuffer** ppBuffer) = 0; }; } diff --git a/Graphics/GraphicsEngineD3D12/interface/RenderDeviceFactoryD3D12.h b/Graphics/GraphicsEngineD3D12/interface/RenderDeviceFactoryD3D12.h index e8b7cdb4..67d994c4 100644 --- a/Graphics/GraphicsEngineD3D12/interface/RenderDeviceFactoryD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/RenderDeviceFactoryD3D12.h @@ -43,32 +43,32 @@ class IEngineFactoryD3D12 { public: virtual void CreateDeviceAndContextsD3D12( const EngineD3D12Attribs& CreationAttribs, - IRenderDevice **ppDevice, - IDeviceContext **ppContexts, - Uint32 NumDeferredContexts) = 0; - - virtual void AttachToD3D12Device(void *pd3d12NativeDevice, - class ICommandQueueD3D12 *pCommandQueue, - const EngineD3D12Attribs& EngineAttribs, - IRenderDevice **ppDevice, - IDeviceContext **ppContexts, - Uint32 NumDeferredContexts) = 0; - - virtual void CreateSwapChainD3D12( IRenderDevice *pDevice, - IDeviceContext *pImmediateContext, - const SwapChainDesc& SwapChainDesc, + IRenderDevice** ppDevice, + IDeviceContext** ppContexts, + Uint32 NumDeferredContexts) = 0; + + virtual void AttachToD3D12Device(void* pd3d12NativeDevice, + class ICommandQueueD3D12* pCommandQueue, + const EngineD3D12Attribs& EngineAttribs, + IRenderDevice** ppDevice, + IDeviceContext** ppContexts, + Uint32 NumDeferredContexts) = 0; + + virtual void CreateSwapChainD3D12( IRenderDevice* pDevice, + IDeviceContext* pImmediateContext, + const SwapChainDesc& SwapChainDesc, const FullScreenModeDesc& FSDesc, - void* pNativeWndHandle, - ISwapChain **ppSwapChain ) = 0; + void* pNativeWndHandle, + ISwapChain** ppSwapChain ) = 0; - virtual void EnumerateHardwareAdapters(Uint32 &NumAdapters, - HardwareAdapterAttribs *Adapters) = 0; + virtual void EnumerateHardwareAdapters(Uint32& NumAdapters, + HardwareAdapterAttribs* Adapters) = 0; - virtual void EnumerateDisplayModes(Uint32 AdapterId, - Uint32 OutputId, - TEXTURE_FORMAT Format, - Uint32 &NumDisplayModes, - DisplayModeAttribs *DisplayModes) = 0; + virtual void EnumerateDisplayModes(Uint32 AdapterId, + Uint32 OutputId, + TEXTURE_FORMAT Format, + Uint32& NumDisplayModes, + DisplayModeAttribs* DisplayModes) = 0; }; diff --git a/Graphics/GraphicsEngineD3D12/interface/SwapChainD3D12.h b/Graphics/GraphicsEngineD3D12/interface/SwapChainD3D12.h index d65478ef..b6a64831 100644 --- a/Graphics/GraphicsEngineD3D12/interface/SwapChainD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/SwapChainD3D12.h @@ -47,7 +47,7 @@ public: /// The method does *NOT* call AddRef() on the returned interface, /// so Release() must not be called. - virtual IDXGISwapChain *GetDXGISwapChain() = 0; + virtual IDXGISwapChain* GetDXGISwapChain() = 0; /// Returns a pointer to the render target view of the current back buffer in the swap chain -- cgit v1.2.3