diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-06-20 03:23:58 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-06-20 03:23:58 +0000 |
| commit | 437895eae2866946b005d17c45c9893c71a6b2be (patch) | |
| tree | 8d20a0a3586176d66b9ee5f6cd7352f8c35d1a38 /Graphics/GraphicsEngineD3D12 | |
| parent | Improved ShaderResourceLayoutD3D12 (replaced num CbvSrvUav/Samplers with offs... (diff) | |
| download | DiligentCore-437895eae2866946b005d17c45c9893c71a6b2be.tar.gz DiligentCore-437895eae2866946b005d17c45c9893c71a6b2be.zip | |
Improved formatting of D3D12 backend source
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
19 files changed, 372 insertions, 284 deletions
diff --git a/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp index b2077fe0..4a5df652 100644 --- a/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/BufferD3D12Impl.cpp @@ -35,16 +35,33 @@ namespace Diligent { -BufferD3D12Impl :: BufferD3D12Impl(IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator &BuffViewObjMemAllocator, - RenderDeviceD3D12Impl *pRenderDeviceD3D12, - const BufferDesc& BuffDesc, - const BufferData &BuffData /*= BufferData()*/) : - TBufferBase(pRefCounters, BuffViewObjMemAllocator, pRenderDeviceD3D12, BuffDesc, false), +BufferD3D12Impl :: BufferD3D12Impl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& BuffViewObjMemAllocator, + RenderDeviceD3D12Impl* pRenderDeviceD3D12, + const BufferDesc& BuffDesc, + const BufferData& BuffData /*= BufferData()*/) : + TBufferBase + { + pRefCounters, + BuffViewObjMemAllocator, + pRenderDeviceD3D12, + BuffDesc, + false + }, #ifdef _DEBUG - m_DbgMapType(1 + pRenderDeviceD3D12->GetNumDeferredContexts(), std::make_pair(static_cast<MAP_TYPE>(-1), static_cast<Uint32>(-1)), STD_ALLOCATOR_RAW_MEM(DynamicAllocation, GetRawAllocator(), "Allocator for vector<pair<MAP_TYPE,Uint32>>")), + m_DbgMapType + { + 1 + pRenderDeviceD3D12->GetNumDeferredContexts(), + std::make_pair(static_cast<MAP_TYPE>(-1), static_cast<Uint32>(-1)), + STD_ALLOCATOR_RAW_MEM(DynamicAllocation, GetRawAllocator(), "Allocator for vector<pair<MAP_TYPE,Uint32>>") + }, #endif - m_DynamicData(BuffDesc.Usage == USAGE_DYNAMIC ? (1 + pRenderDeviceD3D12->GetNumDeferredContexts()) : 0, DynamicAllocation(), STD_ALLOCATOR_RAW_MEM(DynamicAllocation, GetRawAllocator(), "Allocator for vector<DynamicAllocation>")) + m_DynamicData + { + BuffDesc.Usage == USAGE_DYNAMIC ? (1 + pRenderDeviceD3D12->GetNumDeferredContexts()) : 0, + DynamicAllocation(), + STD_ALLOCATOR_RAW_MEM(DynamicAllocation, GetRawAllocator(), "Allocator for vector<DynamicAllocation>") + } { #define LOG_BUFFER_ERROR_AND_THROW(...) LOG_ERROR_AND_THROW("Buffer \"", BuffDesc.Name ? BuffDesc.Name : "", "\": ", ##__VA_ARGS__); @@ -87,14 +104,14 @@ BufferD3D12Impl :: BufferD3D12Impl(IReferenceCounters *pRefCounters, else { D3D12_RESOURCE_DESC D3D12BuffDesc = {}; - D3D12BuffDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; - D3D12BuffDesc.Alignment = 0; - D3D12BuffDesc.Width = m_Desc.uiSizeInBytes; - D3D12BuffDesc.Height = 1; - D3D12BuffDesc.DepthOrArraySize = 1; - D3D12BuffDesc.MipLevels = 1; - D3D12BuffDesc.Format = DXGI_FORMAT_UNKNOWN; - D3D12BuffDesc.SampleDesc.Count = 1; + D3D12BuffDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; + D3D12BuffDesc.Alignment = 0; + D3D12BuffDesc.Width = m_Desc.uiSizeInBytes; + D3D12BuffDesc.Height = 1; + D3D12BuffDesc.DepthOrArraySize = 1; + D3D12BuffDesc.MipLevels = 1; + D3D12BuffDesc.Format = DXGI_FORMAT_UNKNOWN; + D3D12BuffDesc.SampleDesc.Count = 1; D3D12BuffDesc.SampleDesc.Quality = 0; // Layout must be D3D12_TEXTURE_LAYOUT_ROW_MAJOR, as buffer memory layouts are // understood by applications and row-major texture data is commonly marshaled through buffers. @@ -120,7 +137,7 @@ BufferD3D12Impl :: BufferD3D12Impl(IReferenceCounters *pRefCounters, HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; HeapProps.CreationNodeMask = 1; - HeapProps.VisibleNodeMask = 1; + HeapProps.VisibleNodeMask = 1; bool bInitializeBuffer = (BuffData.pData != nullptr && BuffData.DataSize > 0); if(bInitializeBuffer) @@ -137,11 +154,11 @@ BufferD3D12Impl :: BufferD3D12Impl(IReferenceCounters *pRefCounters, if( bInitializeBuffer ) { D3D12_HEAP_PROPERTIES UploadHeapProps; - UploadHeapProps.Type = D3D12_HEAP_TYPE_UPLOAD; - UploadHeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; + UploadHeapProps.Type = D3D12_HEAP_TYPE_UPLOAD; + UploadHeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; UploadHeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - UploadHeapProps.CreationNodeMask = 1; - UploadHeapProps.VisibleNodeMask = 1; + UploadHeapProps.CreationNodeMask = 1; + UploadHeapProps.VisibleNodeMask = 1; D3D12BuffDesc.Flags = D3D12_RESOURCE_FLAG_NONE; CComPtr<ID3D12Resource> UploadBuffer; @@ -200,7 +217,7 @@ BufferD3D12Impl :: BufferD3D12Impl(IReferenceCounters *pRefCounters, } } -static BufferDesc BufferDescFromD3D12Resource(BufferDesc BuffDesc, ID3D12Resource *pd3d12Buffer) +static BufferDesc BufferDescFromD3D12Resource(BufferDesc BuffDesc, ID3D12Resource* pd3d12Buffer) { VERIFY(BuffDesc.Usage != USAGE_DYNAMIC, "Dynamic buffers cannot be attached to native d3d12 resource"); @@ -241,16 +258,28 @@ static BufferDesc BufferDescFromD3D12Resource(BufferDesc BuffDesc, ID3D12Resourc return BuffDesc; } -BufferD3D12Impl :: BufferD3D12Impl(IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator &BuffViewObjMemAllocator, - RenderDeviceD3D12Impl *pRenderDeviceD3D12, - const BufferDesc& BuffDesc, - ID3D12Resource *pd3d12Buffer) : - TBufferBase(pRefCounters, BuffViewObjMemAllocator, pRenderDeviceD3D12, BufferDescFromD3D12Resource(BuffDesc, pd3d12Buffer), false), +BufferD3D12Impl :: BufferD3D12Impl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& BuffViewObjMemAllocator, + RenderDeviceD3D12Impl* pRenderDeviceD3D12, + const BufferDesc& BuffDesc, + ID3D12Resource* pd3d12Buffer) : + TBufferBase + { + pRefCounters, + BuffViewObjMemAllocator, + pRenderDeviceD3D12, + BufferDescFromD3D12Resource(BuffDesc, pd3d12Buffer), + false + }, #ifdef _DEBUG m_DbgMapType(1 + pRenderDeviceD3D12->GetNumDeferredContexts(), std::make_pair(static_cast<MAP_TYPE>(-1), static_cast<Uint32>(-1)), STD_ALLOCATOR_RAW_MEM(DynamicAllocation, GetRawAllocator(), "Allocator for vector<pair<MAP_TYPE,Uint32>>")), #endif - m_DynamicData(BuffDesc.Usage == USAGE_DYNAMIC ? (1 + pRenderDeviceD3D12->GetNumDeferredContexts()) : 0, DynamicAllocation(), STD_ALLOCATOR_RAW_MEM(DynamicAllocation, GetRawAllocator(), "Allocator for vector<DynamicAllocation>")) + m_DynamicData + { + BuffDesc.Usage == USAGE_DYNAMIC ? (1 + pRenderDeviceD3D12->GetNumDeferredContexts()) : 0, + DynamicAllocation(), + STD_ALLOCATOR_RAW_MEM(DynamicAllocation, GetRawAllocator(), "Allocator for vector<DynamicAllocation>") + } { m_pd3d12Resource = pd3d12Buffer; @@ -269,7 +298,7 @@ BufferD3D12Impl :: ~BufferD3D12Impl() IMPLEMENT_QUERY_INTERFACE( BufferD3D12Impl, IID_BufferD3D12, TBufferBase ) -void BufferD3D12Impl::UpdateData( IDeviceContext *pContext, Uint32 Offset, Uint32 Size, const PVoid pData ) +void BufferD3D12Impl::UpdateData( IDeviceContext* pContext, Uint32 Offset, Uint32 Size, const PVoid pData ) { TBufferBase::UpdateData( pContext, Offset, Size, pData ); @@ -279,14 +308,14 @@ void BufferD3D12Impl::UpdateData( IDeviceContext *pContext, Uint32 Offset, Uint3 pDeviceContextD3D12->UpdateBufferRegion(this, pData, Offset, Size); } -void BufferD3D12Impl :: CopyData(IDeviceContext *pContext, IBuffer *pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size) +void BufferD3D12Impl :: CopyData(IDeviceContext* pContext, IBuffer *pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size) { TBufferBase::CopyData( pContext, pSrcBuffer, SrcOffset, DstOffset, Size ); auto *pDeviceContextD3D12 = ValidatedCast<DeviceContextD3D12Impl>(pContext); pDeviceContextD3D12->CopyBufferRegion(ValidatedCast<BufferD3D12Impl>(pSrcBuffer), this, SrcOffset, DstOffset, Size); } -void BufferD3D12Impl :: Map(IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData) +void BufferD3D12Impl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData) { TBufferBase::Map( pContext, MapType, MapFlags, pMappedData ); auto *pDeviceContextD3D12 = ValidatedCast<DeviceContextD3D12Impl>(pContext); @@ -341,7 +370,7 @@ void BufferD3D12Impl :: Map(IDeviceContext *pContext, MAP_TYPE MapType, Uint32 M } } -void BufferD3D12Impl::Unmap( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags ) +void BufferD3D12Impl::Unmap( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags ) { TBufferBase::Unmap( pContext, MapType, MapFlags ); auto *pDeviceContextD3D12 = ValidatedCast<DeviceContextD3D12Impl>(pContext); @@ -386,7 +415,7 @@ void BufferD3D12Impl::Unmap( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 #endif } -void BufferD3D12Impl::CreateViewInternal( const BufferViewDesc &OrigViewDesc, IBufferView **ppView, bool bIsDefaultView ) +void BufferD3D12Impl::CreateViewInternal( const BufferViewDesc& OrigViewDesc, IBufferView** ppView, bool bIsDefaultView ) { VERIFY( ppView != nullptr, "Null pointer provided" ); if( !ppView )return; @@ -426,7 +455,7 @@ void BufferD3D12Impl::CreateViewInternal( const BufferViewDesc &OrigViewDesc, IB } } -void BufferD3D12Impl::CreateUAV( BufferViewDesc &UAVDesc, D3D12_CPU_DESCRIPTOR_HANDLE UAVDescriptor ) +void BufferD3D12Impl::CreateUAV( BufferViewDesc& UAVDesc, D3D12_CPU_DESCRIPTOR_HANDLE UAVDescriptor ) { CorrectBufferViewDesc( UAVDesc ); @@ -437,7 +466,7 @@ void BufferD3D12Impl::CreateUAV( BufferViewDesc &UAVDesc, D3D12_CPU_DESCRIPTOR_H pDeviceD3D12->CreateUnorderedAccessView( m_pd3d12Resource, nullptr, &D3D12_UAVDesc, UAVDescriptor ); } -void BufferD3D12Impl::CreateSRV( struct BufferViewDesc &SRVDesc, D3D12_CPU_DESCRIPTOR_HANDLE SRVDescriptor ) +void BufferD3D12Impl::CreateSRV( struct BufferViewDesc& SRVDesc, D3D12_CPU_DESCRIPTOR_HANDLE SRVDescriptor ) { CorrectBufferViewDesc( SRVDesc ); @@ -468,5 +497,4 @@ void BufferD3D12Impl::DbgVerifyDynamicAllocation(Uint32 ContextId)const } #endif - } diff --git a/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp index d56844ef..2f9a0661 100644 --- a/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp @@ -27,12 +27,12 @@ namespace Diligent { -BufferViewD3D12Impl::BufferViewD3D12Impl( IReferenceCounters *pRefCounters, - IRenderDevice *pDevice, - const BufferViewDesc& ViewDesc, - IBuffer *pBuffer, - DescriptorHeapAllocation &&HandleAlloc, - bool bIsDefaultView ) : +BufferViewD3D12Impl::BufferViewD3D12Impl( IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + const BufferViewDesc& ViewDesc, + IBuffer* pBuffer, + DescriptorHeapAllocation&& HandleAlloc, + bool bIsDefaultView ) : TBufferViewBase( pRefCounters, pDevice, ViewDesc, pBuffer, bIsDefaultView ), m_DescriptorHandle( std::move(HandleAlloc) ) { diff --git a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp index 00b79965..4217b0c0 100644 --- a/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp +++ b/Graphics/GraphicsEngineD3D12/src/CommandContext.cpp @@ -30,13 +30,13 @@ namespace Diligent { -CommandContext::CommandContext( IMemoryAllocator &MemAllocator, - CommandListManager &CmdListManager, - GPUDescriptorHeap GPUDescriptorHeaps[], - const Uint32 DynamicDescriptorAllocationChunkSize[]) : - m_pCurGraphicsRootSignature( nullptr), - m_pCurPipelineState( nullptr), - m_pCurComputeRootSignature( nullptr), +CommandContext::CommandContext( IMemoryAllocator& MemAllocator, + CommandListManager& CmdListManager, + GPUDescriptorHeap GPUDescriptorHeaps[], + const Uint32 DynamicDescriptorAllocationChunkSize[]) : + m_pCurGraphicsRootSignature (nullptr), + m_pCurPipelineState (nullptr), + m_pCurComputeRootSignature (nullptr), m_DynamicGPUDescriptorAllocator { {MemAllocator, GPUDescriptorHeaps[0], DynamicDescriptorAllocationChunkSize[0]}, @@ -82,7 +82,7 @@ void CommandContext::Reset( CommandListManager& CmdListManager ) #endif } -ID3D12GraphicsCommandList* CommandContext::Close(ID3D12CommandAllocator **ppAllocator) +ID3D12GraphicsCommandList* CommandContext::Close(ID3D12CommandAllocator** ppAllocator) { FlushResourceBarriers(); @@ -138,7 +138,7 @@ void GraphicsContext::SetRenderTargets( UINT NumRTVs, ITextureViewD3D12** ppRTVs } } -void CommandContext::ClearUAVFloat( ITextureViewD3D12 *pTexView, const float* Color ) +void CommandContext::ClearUAVFloat( ITextureViewD3D12* pTexView, const float* Color ) { auto *pTexture = ValidatedCast<TextureD3D12Impl>( pTexView->GetTexture() ); TransitionResource(pTexture, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, true); @@ -150,7 +150,7 @@ void CommandContext::ClearUAVFloat( ITextureViewD3D12 *pTexView, const float* Co m_pCommandList->ClearUnorderedAccessViewFloat(GpuVisibleHandle, pTexView->GetCPUDescriptorHandle(), pTexture->GetD3D12Resource(), Color, 0, nullptr); } -void CommandContext::ClearUAVUint( ITextureViewD3D12 *pTexView, const UINT *Color ) +void CommandContext::ClearUAVUint( ITextureViewD3D12* pTexView, const UINT* Color ) { auto *pTexture = ValidatedCast<TextureD3D12Impl>( pTexView->GetTexture() ); TransitionResource(pTexture, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, true); @@ -166,14 +166,14 @@ void CommandContext::ClearUAVUint( ITextureViewD3D12 *pTexView, const UINT *Colo } -void GraphicsContext::ClearRenderTarget( ITextureViewD3D12 *pRTV, const float *Color ) +void GraphicsContext::ClearRenderTarget( ITextureViewD3D12* pRTV, const float* Color ) { auto *pTexture = ValidatedCast<TextureD3D12Impl>( pRTV->GetTexture() ); TransitionResource(pTexture, D3D12_RESOURCE_STATE_RENDER_TARGET, true); m_pCommandList->ClearRenderTargetView(pRTV->GetCPUDescriptorHandle(), Color, 0, nullptr); } -void GraphicsContext::ClearDepthStencil( ITextureViewD3D12 *pDSV, D3D12_CLEAR_FLAGS ClearFlags, float Depth, UINT8 Stencil ) +void GraphicsContext::ClearDepthStencil( ITextureViewD3D12* pDSV, D3D12_CLEAR_FLAGS ClearFlags, float Depth, UINT8 Stencil ) { auto *pTexture = ValidatedCast<TextureD3D12Impl>( pDSV->GetTexture() ); TransitionResource( pTexture, D3D12_RESOURCE_STATE_DEPTH_WRITE, true); @@ -181,14 +181,14 @@ void GraphicsContext::ClearDepthStencil( ITextureViewD3D12 *pDSV, D3D12_CLEAR_FL } -void CommandContext::TransitionResource(ITextureD3D12 *pTexture, D3D12_RESOURCE_STATES NewState, bool FlushImmediate) +void CommandContext::TransitionResource(ITextureD3D12* pTexture, D3D12_RESOURCE_STATES NewState, bool FlushImmediate) { VERIFY_EXPR( pTexture != nullptr ); auto *pTexD3D12 = ValidatedCast<TextureD3D12Impl>(pTexture); TransitionResource(*pTexD3D12, *pTexD3D12, NewState, FlushImmediate); } -void CommandContext::TransitionResource(IBufferD3D12 *pBuffer, D3D12_RESOURCE_STATES NewState, bool FlushImmediate) +void CommandContext::TransitionResource(IBufferD3D12* pBuffer, D3D12_RESOURCE_STATES NewState, bool FlushImmediate) { VERIFY_EXPR( pBuffer != nullptr ); auto *pBuffD3D12 = ValidatedCast<BufferD3D12Impl>(pBuffer); @@ -212,7 +212,7 @@ void CommandContext::TransitionResource(IBufferD3D12 *pBuffer, D3D12_RESOURCE_ST #endif } -void CommandContext::TransitionResource(D3D12ResourceBase& Resource, IDeviceObject &Object, D3D12_RESOURCE_STATES NewState, bool FlushImmediate) +void CommandContext::TransitionResource(D3D12ResourceBase& Resource, IDeviceObject& Object, D3D12_RESOURCE_STATES NewState, bool FlushImmediate) { D3D12_RESOURCE_STATES OldState = Resource.GetState(); @@ -268,7 +268,7 @@ void CommandContext::FlushResourceBarriers() } -void CommandContext::InsertUAVBarrier(D3D12ResourceBase& Resource, IDeviceObject &Object, bool FlushImmediate) +void CommandContext::InsertUAVBarrier(D3D12ResourceBase& Resource, IDeviceObject& Object, bool FlushImmediate) { m_PendingResourceBarriers.emplace_back(); m_PendingBarrierObjects.emplace_back(&Object); @@ -282,7 +282,7 @@ void CommandContext::InsertUAVBarrier(D3D12ResourceBase& Resource, IDeviceObject FlushResourceBarriers(); } -void CommandContext::InsertAliasBarrier(D3D12ResourceBase& Before, D3D12ResourceBase& After, IDeviceObject &BeforeObj, IDeviceObject &AfterObj, bool FlushImmediate) +void CommandContext::InsertAliasBarrier(D3D12ResourceBase& Before, D3D12ResourceBase& After, IDeviceObject& BeforeObj, IDeviceObject& AfterObj, bool FlushImmediate) { m_PendingResourceBarriers.emplace_back(); m_PendingBarrierObjects.emplace_back(&BeforeObj); diff --git a/Graphics/GraphicsEngineD3D12/src/CommandQueueD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/CommandQueueD3D12Impl.cpp index 7e931404..89e70d37 100644 --- a/Graphics/GraphicsEngineD3D12/src/CommandQueueD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/CommandQueueD3D12Impl.cpp @@ -27,7 +27,9 @@ namespace Diligent { -CommandQueueD3D12Impl::CommandQueueD3D12Impl(IReferenceCounters *pRefCounters, ID3D12CommandQueue *pd3d12NativeCmdQueue, ID3D12Fence *pd3d12Fence) : +CommandQueueD3D12Impl::CommandQueueD3D12Impl(IReferenceCounters* pRefCounters, + ID3D12CommandQueue* pd3d12NativeCmdQueue, + ID3D12Fence* pd3d12Fence) : TBase(pRefCounters), m_pd3d12CmdQueue(pd3d12NativeCmdQueue), m_d3d12Fence(pd3d12Fence), diff --git a/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp b/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp index c9053465..9437281e 100644 --- a/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp +++ b/Graphics/GraphicsEngineD3D12/src/D3D12TypeConversions.cpp @@ -47,12 +47,12 @@ D3D12_TEXTURE_ADDRESS_MODE TexAddressModeToD3D12AddressMode(TEXTURE_ADDRESS_MODE return TexAddressModeToD3DAddressMode<D3D12_TEXTURE_ADDRESS_MODE>(Mode); } -void DepthStencilStateDesc_To_D3D12_DEPTH_STENCIL_DESC(const DepthStencilStateDesc &DepthStencilDesc, D3D12_DEPTH_STENCIL_DESC &d3d12DSSDesc) +void DepthStencilStateDesc_To_D3D12_DEPTH_STENCIL_DESC(const DepthStencilStateDesc& DepthStencilDesc, D3D12_DEPTH_STENCIL_DESC& d3d12DSSDesc) { DepthStencilStateDesc_To_D3D_DEPTH_STENCIL_DESC<D3D12_DEPTH_STENCIL_DESC, D3D12_DEPTH_STENCILOP_DESC, D3D12_STENCIL_OP, D3D12_COMPARISON_FUNC>(DepthStencilDesc, d3d12DSSDesc); } -void RasterizerStateDesc_To_D3D12_RASTERIZER_DESC(const RasterizerStateDesc &RasterizerDesc, D3D12_RASTERIZER_DESC &d3d12RSDesc) +void RasterizerStateDesc_To_D3D12_RASTERIZER_DESC(const RasterizerStateDesc& RasterizerDesc, D3D12_RASTERIZER_DESC& d3d12RSDesc) { RasterizerStateDesc_To_D3D_RASTERIZER_DESC<D3D12_RASTERIZER_DESC, D3D12_FILL_MODE, D3D12_CULL_MODE>(RasterizerDesc, d3d12RSDesc); @@ -109,7 +109,7 @@ D3D12_LOGIC_OP LogicOperationToD3D12LogicOp( LOGIC_OPERATION lo ) } -void BlendStateDesc_To_D3D12_BLEND_DESC(const BlendStateDesc &BSDesc, D3D12_BLEND_DESC &d3d12BlendDesc) +void BlendStateDesc_To_D3D12_BLEND_DESC(const BlendStateDesc& BSDesc, D3D12_BLEND_DESC& d3d12BlendDesc) { BlendStateDescToD3DBlendDesc<D3D12_BLEND_DESC, D3D12_BLEND, D3D12_BLEND_OP>(BSDesc, d3d12BlendDesc); @@ -190,7 +190,7 @@ void TextureViewDesc_to_D3D12_SRV_DESC(const TextureViewDesc& SRVDesc, D3D12_SHA } } -void TextureViewDesc_to_D3D12_RTV_DESC(const TextureViewDesc& RTVDesc, D3D12_RENDER_TARGET_VIEW_DESC &D3D12RTVDesc, Uint32 SampleCount) +void TextureViewDesc_to_D3D12_RTV_DESC(const TextureViewDesc& RTVDesc, D3D12_RENDER_TARGET_VIEW_DESC& D3D12RTVDesc, Uint32 SampleCount) { TextureViewDesc_to_D3D_RTV_DESC(RTVDesc, D3D12RTVDesc, SampleCount); switch (RTVDesc.TextureDim) @@ -229,13 +229,13 @@ void TextureViewDesc_to_D3D12_RTV_DESC(const TextureViewDesc& RTVDesc, D3D12_REN } } -void TextureViewDesc_to_D3D12_DSV_DESC(const TextureViewDesc& DSVDesc, D3D12_DEPTH_STENCIL_VIEW_DESC &D3D12DSVDesc, Uint32 SampleCount) +void TextureViewDesc_to_D3D12_DSV_DESC(const TextureViewDesc& DSVDesc, D3D12_DEPTH_STENCIL_VIEW_DESC& D3D12DSVDesc, Uint32 SampleCount) { TextureViewDesc_to_D3D_DSV_DESC(DSVDesc, D3D12DSVDesc, SampleCount); D3D12DSVDesc.Flags = D3D12_DSV_FLAG_NONE; } -void TextureViewDesc_to_D3D12_UAV_DESC(const TextureViewDesc& UAVDesc, D3D12_UNORDERED_ACCESS_VIEW_DESC &D3D12UAVDesc) +void TextureViewDesc_to_D3D12_UAV_DESC(const TextureViewDesc& UAVDesc, D3D12_UNORDERED_ACCESS_VIEW_DESC& D3D12UAVDesc) { TextureViewDesc_to_D3D_UAV_DESC(UAVDesc, D3D12UAVDesc); switch (UAVDesc.TextureDim) @@ -263,7 +263,7 @@ void TextureViewDesc_to_D3D12_UAV_DESC(const TextureViewDesc& UAVDesc, D3D12_UNO } -void BufferViewDesc_to_D3D12_SRV_DESC(const BufferDesc &BuffDesc, const BufferViewDesc& SRVDesc, D3D12_SHADER_RESOURCE_VIEW_DESC &D3D12SRVDesc) +void BufferViewDesc_to_D3D12_SRV_DESC(const BufferDesc &BuffDesc, const BufferViewDesc& SRVDesc, D3D12_SHADER_RESOURCE_VIEW_DESC& D3D12SRVDesc) { BufferViewDesc_to_D3D_SRV_DESC(BuffDesc, SRVDesc, D3D12SRVDesc); D3D12SRVDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; @@ -273,7 +273,7 @@ void BufferViewDesc_to_D3D12_SRV_DESC(const BufferDesc &BuffDesc, const BufferVi D3D12SRVDesc.Buffer.StructureByteStride = BuffDesc.ElementByteStride; } -void BufferViewDesc_to_D3D12_UAV_DESC(const BufferDesc &BuffDesc, const BufferViewDesc& UAVDesc, D3D12_UNORDERED_ACCESS_VIEW_DESC &D3D12UAVDesc) +void BufferViewDesc_to_D3D12_UAV_DESC(const BufferDesc& BuffDesc, const BufferViewDesc& UAVDesc, D3D12_UNORDERED_ACCESS_VIEW_DESC& D3D12UAVDesc) { BufferViewDesc_to_D3D_UAV_DESC(BuffDesc, UAVDesc, D3D12UAVDesc); D3D12UAVDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE; diff --git a/Graphics/GraphicsEngineD3D12/src/DescriptorHeap.cpp b/Graphics/GraphicsEngineD3D12/src/DescriptorHeap.cpp index ba279db8..6815b112 100644 --- a/Graphics/GraphicsEngineD3D12/src/DescriptorHeap.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DescriptorHeap.cpp @@ -30,17 +30,17 @@ namespace Diligent { // Creates a new descriptor heap and reference the entire heap -DescriptorHeapAllocationManager::DescriptorHeapAllocationManager(IMemoryAllocator &Allocator, - RenderDeviceD3D12Impl *pDeviceD3D12Impl, - IDescriptorAllocator *pParentAllocator, - size_t ThisManagerId, - const D3D12_DESCRIPTOR_HEAP_DESC &HeapDesc) : - m_FreeBlockManager(HeapDesc.NumDescriptors, Allocator), - m_NumDescriptorsInAllocation(HeapDesc.NumDescriptors), - m_HeapDesc(HeapDesc), - m_pDeviceD3D12Impl(pDeviceD3D12Impl), - m_pParentAllocator(pParentAllocator), - m_ThisManagerId(ThisManagerId) +DescriptorHeapAllocationManager::DescriptorHeapAllocationManager(IMemoryAllocator& Allocator, + RenderDeviceD3D12Impl* pDeviceD3D12Impl, + IDescriptorAllocator* pParentAllocator, + size_t ThisManagerId, + const D3D12_DESCRIPTOR_HEAP_DESC& HeapDesc) : + m_FreeBlockManager (HeapDesc.NumDescriptors, Allocator), + m_NumDescriptorsInAllocation (HeapDesc.NumDescriptors), + m_HeapDesc (HeapDesc), + m_pDeviceD3D12Impl (pDeviceD3D12Impl), + m_pParentAllocator (pParentAllocator), + m_ThisManagerId (ThisManagerId) { auto pDevice = pDeviceD3D12Impl->GetD3D12Device(); @@ -48,32 +48,32 @@ DescriptorHeapAllocationManager::DescriptorHeapAllocationManager(IMemoryAllocato m_FirstGPUHandle.ptr = 0; m_DescriptorSize = pDevice->GetDescriptorHandleIncrementSize(HeapDesc.Type); - pDevice->CreateDescriptorHeap(&m_HeapDesc, __uuidof(m_pd3d12DescriptorHeap), reinterpret_cast<void**>(static_cast<ID3D12DescriptorHeap**>(&m_pd3d12DescriptorHeap))); - m_FirstCPUHandle = m_pd3d12DescriptorHeap->GetCPUDescriptorHandleForHeapStart(); + pDevice->CreateDescriptorHeap(&m_HeapDesc, __uuidof(m_pd3d12DescriptorHeap), reinterpret_cast<void**>(static_cast<ID3D12DescriptorHeap**>(&m_pd3d12DescriptorHeap))); + m_FirstCPUHandle = m_pd3d12DescriptorHeap->GetCPUDescriptorHandleForHeapStart(); if(m_HeapDesc.Flags & D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE) m_FirstGPUHandle = m_pd3d12DescriptorHeap->GetGPUDescriptorHandleForHeapStart(); } // Uses subrange of descriptors in the existing D3D12 descriptor heap // that starts at offset FirstDescriptor and uses NumDescriptors descriptors -DescriptorHeapAllocationManager::DescriptorHeapAllocationManager(IMemoryAllocator &Allocator, - RenderDeviceD3D12Impl *pDeviceD3D12Impl, - IDescriptorAllocator *pParentAllocator, - size_t ThisManagerId, - ID3D12DescriptorHeap *pd3d12DescriptorHeap, - Uint32 FirstDescriptor, - Uint32 NumDescriptors): - m_FreeBlockManager(NumDescriptors, Allocator), - m_NumDescriptorsInAllocation(NumDescriptors), - m_pDeviceD3D12Impl(pDeviceD3D12Impl), - m_pParentAllocator(pParentAllocator), - m_ThisManagerId(ThisManagerId), - m_pd3d12DescriptorHeap(pd3d12DescriptorHeap) +DescriptorHeapAllocationManager::DescriptorHeapAllocationManager(IMemoryAllocator& Allocator, + RenderDeviceD3D12Impl* pDeviceD3D12Impl, + IDescriptorAllocator* pParentAllocator, + size_t ThisManagerId, + ID3D12DescriptorHeap* pd3d12DescriptorHeap, + Uint32 FirstDescriptor, + Uint32 NumDescriptors): + m_FreeBlockManager (NumDescriptors, Allocator), + m_NumDescriptorsInAllocation (NumDescriptors), + m_pDeviceD3D12Impl (pDeviceD3D12Impl), + m_pParentAllocator (pParentAllocator), + m_ThisManagerId (ThisManagerId), + m_pd3d12DescriptorHeap (pd3d12DescriptorHeap) { m_HeapDesc = m_pd3d12DescriptorHeap->GetDesc(); m_DescriptorSize = pDeviceD3D12Impl->GetD3D12Device()->GetDescriptorHandleIncrementSize(m_HeapDesc.Type); - m_FirstCPUHandle = pd3d12DescriptorHeap->GetCPUDescriptorHandleForHeapStart(); + m_FirstCPUHandle = pd3d12DescriptorHeap->GetCPUDescriptorHandleForHeapStart(); m_FirstCPUHandle.ptr += m_DescriptorSize * FirstDescriptor; if (m_HeapDesc.Flags & D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE) @@ -111,7 +111,7 @@ DescriptorHeapAllocation DescriptorHeapAllocationManager::Allocate(uint32_t Coun GPUHandle.ptr += DescriptorHandleOffset * m_DescriptorSize; VERIFY(m_ThisManagerId < std::numeric_limits<Uint16>::max(), "ManagerID exceeds 16-bit range"); - return DescriptorHeapAllocation( m_pParentAllocator, m_pd3d12DescriptorHeap, CPUHandle, GPUHandle, Count, static_cast<Uint16>(m_ThisManagerId)); + return DescriptorHeapAllocation( m_pParentAllocator, m_pd3d12DescriptorHeap, CPUHandle, GPUHandle, Count, static_cast<Uint16>(m_ThisManagerId)); } void DescriptorHeapAllocationManager::Free(DescriptorHeapAllocation&& Allocation) @@ -123,8 +123,8 @@ void DescriptorHeapAllocationManager::Free(DescriptorHeapAllocation&& Allocation auto DescriptorOffset = (Allocation.GetCpuHandle().ptr - m_FirstCPUHandle.ptr) / m_DescriptorSize; - // Note that the allocation is not released immediately, but added to the release queue in the allocations manager - + // Note that the allocation is not released immediately, but added to the release queue in the allocations manager + // The following basic requirement guarantees correctness of resource deallocation: // // A resource is never released before the last draw command referencing it is invoked on the immediate context @@ -135,7 +135,7 @@ void DescriptorHeapAllocationManager::Free(DescriptorHeapAllocation&& Allocation // associated with the last command list that references descriptors from the allocation m_FreeBlockManager.Free(DescriptorOffset, Allocation.GetNumHandles(), m_pDeviceD3D12Impl->GetNextFenceValue()); - // Clear the allocation + // Clear the allocation Allocation = DescriptorHeapAllocation(); } @@ -153,16 +153,20 @@ void DescriptorHeapAllocationManager::ReleaseStaleAllocations(Uint64 LastComplet // // CPUDescriptorHeap implementation // -CPUDescriptorHeap::CPUDescriptorHeap(IMemoryAllocator &Allocator, RenderDeviceD3D12Impl *pDeviceD3D12Impl, Uint32 NumDescriptorsInHeap, D3D12_DESCRIPTOR_HEAP_TYPE Type, D3D12_DESCRIPTOR_HEAP_FLAGS Flags) : +CPUDescriptorHeap::CPUDescriptorHeap(IMemoryAllocator& Allocator, + RenderDeviceD3D12Impl* pDeviceD3D12Impl, + Uint32 NumDescriptorsInHeap, + D3D12_DESCRIPTOR_HEAP_TYPE Type, + D3D12_DESCRIPTOR_HEAP_FLAGS Flags) : m_pDeviceD3D12Impl(pDeviceD3D12Impl), - m_MemAllocator(Allocator), + m_MemAllocator (Allocator), m_HeapPool(STD_ALLOCATOR_RAW_MEM(DescriptorHeapAllocationManager, GetRawAllocator(), "Allocator for vector<DescriptorHeapAllocationManager>")), m_AvailableHeaps(STD_ALLOCATOR_RAW_MEM(size_t, GetRawAllocator(), "Allocator for set<size_t>")) { - m_HeapDesc.Type = Type; - m_HeapDesc.NodeMask = 1; + m_HeapDesc.Type = Type; + m_HeapDesc.NodeMask = 1; m_HeapDesc.NumDescriptors = NumDescriptorsInHeap; - m_HeapDesc.Flags = Flags; + m_HeapDesc.Flags = Flags; m_DescriptorSize = m_pDeviceD3D12Impl->GetD3D12Device()->GetDescriptorHandleIncrementSize(Type); } @@ -172,16 +176,16 @@ CPUDescriptorHeap::~CPUDescriptorHeap() VERIFY(m_CurrentSize == 0, "Not all allocations released" ); VERIFY(m_AvailableHeaps.size() == m_HeapPool.size(), "Not all descriptor heap pools are released"); - Uint32 TotalDescriptors = 0; + Uint32 TotalDescriptors = 0; for (auto HeapPoolIt = m_HeapPool.begin(); HeapPoolIt != m_HeapPool.end(); ++HeapPoolIt) { VERIFY(HeapPoolIt->GetNumAvailableDescriptors() == HeapPoolIt->GetMaxDescriptors(), "Not all descriptors in the descriptor pool are released"); - TotalDescriptors += HeapPoolIt->GetMaxDescriptors(); - } + TotalDescriptors += HeapPoolIt->GetMaxDescriptors(); + } TotalDescriptors = std::max(TotalDescriptors, 1u); LOG_INFO_MESSAGE(GetD3D12DescriptorHeapTypeLiteralName(m_HeapDesc.Type), " CPU heap max size: ", m_MaxHeapSize, " (", m_MaxHeapSize*100/ TotalDescriptors, "%) " - ". Max stale size: ", m_MaxStaleSize, " (", m_MaxStaleSize * 100 / TotalDescriptors, "%)"); + ". Max stale size: ", m_MaxStaleSize, " (", m_MaxStaleSize * 100 / TotalDescriptors, "%)"); } DescriptorHeapAllocation CPUDescriptorHeap::Allocate( uint32_t Count ) @@ -247,28 +251,28 @@ void CPUDescriptorHeap::Free(DescriptorHeapAllocation&& Allocation) void CPUDescriptorHeap::ReleaseStaleAllocations(Uint64 LastCompletedFenceValue) { std::lock_guard<std::mutex> LockGuard(m_AllocationMutex); - size_t StaleSize = 0; + size_t StaleSize = 0; for (size_t HeapManagerInd = 0; HeapManagerInd < m_HeapPool.size(); ++HeapManagerInd) { - // Update size before releasing stale allocations - StaleSize += m_HeapPool[HeapManagerInd].GetNumStaleDescriptors(); + // Update size before releasing stale allocations + StaleSize += m_HeapPool[HeapManagerInd].GetNumStaleDescriptors(); m_HeapPool[HeapManagerInd].ReleaseStaleAllocations(LastCompletedFenceValue); // Return the manager to the pool of available managers if it has available descriptors if(m_HeapPool[HeapManagerInd].GetNumAvailableDescriptors() > 0) m_AvailableHeaps.insert(HeapManagerInd); } - m_MaxStaleSize = std::max(m_MaxStaleSize, static_cast<Uint32>(StaleSize)); + m_MaxStaleSize = std::max(m_MaxStaleSize, static_cast<Uint32>(StaleSize)); } -GPUDescriptorHeap::GPUDescriptorHeap(IMemoryAllocator &Allocator, - RenderDeviceD3D12Impl *pDevice, - Uint32 NumDescriptorsInHeap, - Uint32 NumDynamicDescriptors, - D3D12_DESCRIPTOR_HEAP_TYPE Type, +GPUDescriptorHeap::GPUDescriptorHeap(IMemoryAllocator& Allocator, + RenderDeviceD3D12Impl* pDevice, + Uint32 NumDescriptorsInHeap, + Uint32 NumDynamicDescriptors, + D3D12_DESCRIPTOR_HEAP_TYPE Type, D3D12_DESCRIPTOR_HEAP_FLAGS Flags) : m_pDeviceD3D12(pDevice), m_HeapDesc @@ -291,13 +295,13 @@ GPUDescriptorHeap::GPUDescriptorHeap(IMemoryAllocator &Allocator, GPUDescriptorHeap::~GPUDescriptorHeap() { - auto StaticSize = m_HeapAllocationManager.GetMaxDescriptors(); - auto DynamicSize = m_DynamicAllocationsManager.GetMaxDescriptors(); + auto StaticSize = m_HeapAllocationManager.GetMaxDescriptors(); + auto DynamicSize = m_DynamicAllocationsManager.GetMaxDescriptors(); LOG_INFO_MESSAGE(GetD3D12DescriptorHeapTypeLiteralName(m_HeapDesc.Type), " GPU heap max allocated size (static|dynamic): ", - m_MaxHeapSize, " (", m_MaxHeapSize * 100 / StaticSize,"%) | ", - m_MaxDynamicSize, " (", m_MaxDynamicSize * 100 / DynamicSize, "%). Max stale size (static|dynamic): ", - m_MaxStaleSize, " (", m_MaxStaleSize * 100 / StaticSize, "%) | ", - m_MaxDynamicStaleSize, " (", m_MaxDynamicStaleSize * 100 / DynamicSize, "%)"); + m_MaxHeapSize, " (", m_MaxHeapSize * 100 / StaticSize,"%) | ", + m_MaxDynamicSize, " (", m_MaxDynamicSize * 100 / DynamicSize, "%). Max stale size (static|dynamic): ", + m_MaxStaleSize, " (", m_MaxStaleSize * 100 / StaticSize, "%) | ", + m_MaxDynamicStaleSize, " (", m_MaxDynamicStaleSize * 100 / DynamicSize, "%)"); } DescriptorHeapAllocation GPUDescriptorHeap::Allocate(uint32_t Count) @@ -352,13 +356,13 @@ void GPUDescriptorHeap::ReleaseStaleAllocations(Uint64 LastCompletedFenceValue) { { std::lock_guard<std::mutex> LockGuard(m_AllocMutex); - m_MaxStaleSize = std::max(m_MaxStaleSize, static_cast<Uint32>(m_HeapAllocationManager.GetNumStaleDescriptors())); + m_MaxStaleSize = std::max(m_MaxStaleSize, static_cast<Uint32>(m_HeapAllocationManager.GetNumStaleDescriptors())); m_HeapAllocationManager.ReleaseStaleAllocations(LastCompletedFenceValue); } { std::lock_guard<std::mutex> LockGuard(m_DynAllocMutex); - m_MaxDynamicStaleSize = std::max(m_MaxDynamicStaleSize, static_cast<Uint32>(m_DynamicAllocationsManager.GetNumStaleDescriptors())); + m_MaxDynamicStaleSize = std::max(m_MaxDynamicStaleSize, static_cast<Uint32>(m_DynamicAllocationsManager.GetNumStaleDescriptors())); m_DynamicAllocationsManager.ReleaseStaleAllocations(LastCompletedFenceValue); } } @@ -413,7 +417,7 @@ DescriptorHeapAllocation DynamicSuballocationsManager::Allocate(Uint32 Count) CurrentSuballocation.GetGpuHandle(m_CurrentSuballocationOffset), Count, static_cast<Uint16>(ManagerId) ); - m_CurrentSuballocationOffset += Count; + m_CurrentSuballocationOffset += Count; return Allocation; } diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index 275ab744..a5385da7 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -38,7 +38,11 @@ namespace Diligent { - DeviceContextD3D12Impl::DeviceContextD3D12Impl( IReferenceCounters *pRefCounters, RenderDeviceD3D12Impl *pDeviceD3D12Impl, bool bIsDeferred, const EngineD3D12Attribs &Attribs, Uint32 ContextId) : + DeviceContextD3D12Impl::DeviceContextD3D12Impl( IReferenceCounters* pRefCounters, + RenderDeviceD3D12Impl* pDeviceD3D12Impl, + bool bIsDeferred, + const EngineD3D12Attribs& Attribs, + Uint32 ContextId) : TDeviceContextBase(pRefCounters, pDeviceD3D12Impl, bIsDeferred), m_pUploadHeap(pDeviceD3D12Impl->RequestUploadHeap() ), m_NumCommandsInCurCtx(0), @@ -89,7 +93,7 @@ namespace Diligent IMPLEMENT_QUERY_INTERFACE( DeviceContextD3D12Impl, IID_DeviceContextD3D12, TDeviceContextBase ) - void DeviceContextD3D12Impl::SetPipelineState(IPipelineState *pPipelineState) + void DeviceContextD3D12Impl::SetPipelineState(IPipelineState* pPipelineState) { // Never flush deferred context! if (!m_bIsDeferred && m_NumCommandsInCurCtx >= m_NumCommandsToFlush) @@ -154,7 +158,7 @@ namespace Diligent m_pCommittedResourceCache = nullptr; } - void DeviceContextD3D12Impl::TransitionShaderResources(IPipelineState *pPipelineState, IShaderResourceBinding *pShaderResourceBinding) + void DeviceContextD3D12Impl::TransitionShaderResources(IPipelineState* pPipelineState, IShaderResourceBinding* pShaderResourceBinding) { VERIFY_EXPR(pPipelineState != nullptr); @@ -163,7 +167,7 @@ namespace Diligent pPipelineStateD3D12->CommitAndTransitionShaderResources(pShaderResourceBinding, *pCtx, false, true); } - void DeviceContextD3D12Impl::CommitShaderResources(IShaderResourceBinding *pShaderResourceBinding, Uint32 Flags) + void DeviceContextD3D12Impl::CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, Uint32 Flags) { if (!DeviceContextBase::CommitShaderResources<PipelineStateD3D12Impl>(pShaderResourceBinding, Flags, 0 /*Dummy*/)) return; @@ -242,7 +246,7 @@ namespace Diligent m_bCommittedD3D12IBUpToDate = !IsDynamic; } - void DeviceContextD3D12Impl::TransitionD3D12VertexBuffers(GraphicsContext &GraphCtx) + void DeviceContextD3D12Impl::TransitionD3D12VertexBuffers(GraphicsContext& GraphCtx) { for( UINT Buff = 0; Buff < m_NumVertexStreams; ++Buff ) { @@ -254,7 +258,7 @@ namespace Diligent } } - void DeviceContextD3D12Impl::CommitD3D12VertexBuffers(GraphicsContext &GraphCtx) + void DeviceContextD3D12Impl::CommitD3D12VertexBuffers(GraphicsContext& GraphCtx) { auto *pPipelineStateD3D12 = m_pPipelineState.RawPtr<PipelineStateD3D12Impl>(); @@ -300,7 +304,7 @@ namespace Diligent m_bCommittedD3D12VBsUpToDate = !DynamicBufferPresent; } - void DeviceContextD3D12Impl::Draw( DrawAttribs &DrawAttribs ) + void DeviceContextD3D12Impl::Draw( DrawAttribs& DrawAttribs ) { #ifdef _DEBUG if (!m_pPipelineState) @@ -378,7 +382,7 @@ namespace Diligent ++m_NumCommandsInCurCtx; } - void DeviceContextD3D12Impl::DispatchCompute( const DispatchComputeAttribs &DispatchAttrs ) + void DeviceContextD3D12Impl::DispatchCompute( const DispatchComputeAttribs& DispatchAttrs ) { #ifdef _DEBUG if (!m_pPipelineState) @@ -434,7 +438,7 @@ namespace Diligent ++m_NumCommandsInCurCtx; } - void DeviceContextD3D12Impl::ClearDepthStencil( ITextureView *pView, Uint32 ClearFlags, float fDepth, Uint8 Stencil ) + void DeviceContextD3D12Impl::ClearDepthStencil( ITextureView* pView, Uint32 ClearFlags, float fDepth, Uint8 Stencil ) { ITextureViewD3D12 *pDSVD3D12 = nullptr; if( pView != nullptr ) @@ -466,7 +470,7 @@ namespace Diligent ++m_NumCommandsInCurCtx; } - void DeviceContextD3D12Impl::ClearRenderTarget( ITextureView *pView, const float *RGBA ) + void DeviceContextD3D12Impl::ClearRenderTarget( ITextureView* pView, const float* RGBA ) { ITextureViewD3D12 *pd3d12RTV = nullptr; if( pView != nullptr ) @@ -533,7 +537,7 @@ namespace Diligent Flush(true); } - void DeviceContextD3D12Impl::SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pOffsets, Uint32 Flags ) + void DeviceContextD3D12Impl::SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer** ppBuffers, Uint32* pOffsets, Uint32 Flags ) { TDeviceContextBase::SetVertexBuffers( StartSlot, NumBuffersSet, ppBuffers, pOffsets, Flags ); m_bCommittedD3D12VBsUpToDate = false; @@ -552,7 +556,7 @@ namespace Diligent m_bCommittedD3D12IBUpToDate = false; } - void DeviceContextD3D12Impl::SetIndexBuffer( IBuffer *pIndexBuffer, Uint32 ByteOffset ) + void DeviceContextD3D12Impl::SetIndexBuffer( IBuffer* pIndexBuffer, Uint32 ByteOffset ) { TDeviceContextBase::SetIndexBuffer( pIndexBuffer, ByteOffset ); m_bCommittedD3D12IBUpToDate = false; @@ -577,7 +581,7 @@ namespace Diligent RequestCmdContext()->AsGraphicsContext().SetViewports( m_NumViewports, d3d12Viewports ); } - void DeviceContextD3D12Impl::SetViewports( Uint32 NumViewports, const Viewport *pViewports, Uint32 RTWidth, Uint32 RTHeight ) + void DeviceContextD3D12Impl::SetViewports( Uint32 NumViewports, const Viewport* pViewports, Uint32 RTWidth, Uint32 RTHeight ) { static_assert(MaxViewports >= D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE, "MaxViewports constant must be greater than D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE"); TDeviceContextBase::SetViewports( NumViewports, pViewports, RTWidth, RTHeight ); @@ -612,8 +616,8 @@ namespace Diligent { 0,0, MaxD3D12TexDim,MaxD3D12TexDim } }; - void DeviceContextD3D12Impl::CommitScissorRects(GraphicsContext &GraphCtx, bool ScissorEnable) - { + void DeviceContextD3D12Impl::CommitScissorRects(GraphicsContext& GraphCtx, bool ScissorEnable) + { if (ScissorEnable) { // Commit currently set scissor rectangles @@ -635,7 +639,7 @@ namespace Diligent } } - void DeviceContextD3D12Impl::SetScissorRects( Uint32 NumRects, const Rect *pRects, Uint32 RTWidth, Uint32 RTHeight ) + void DeviceContextD3D12Impl::SetScissorRects( Uint32 NumRects, const Rect* pRects, Uint32 RTWidth, Uint32 RTHeight ) { const Uint32 MaxScissorRects = D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; VERIFY( NumRects < MaxScissorRects, "Too many scissor rects are being set" ); @@ -708,7 +712,7 @@ namespace Diligent return m_pUploadHeap->Allocate(NumBytes); } - void DeviceContextD3D12Impl::UpdateBufferRegion(class BufferD3D12Impl *pBuffD3D12, DynamicAllocation& Allocation, Uint64 DstOffset, Uint64 NumBytes) + void DeviceContextD3D12Impl::UpdateBufferRegion(class BufferD3D12Impl* pBuffD3D12, DynamicAllocation& Allocation, Uint64 DstOffset, Uint64 NumBytes) { auto pCmdCtx = RequestCmdContext(); VERIFY_EXPR( static_cast<size_t>(NumBytes) == NumBytes ); @@ -720,7 +724,7 @@ namespace Diligent ++m_NumCommandsInCurCtx; } - void DeviceContextD3D12Impl::UpdateBufferRegion(BufferD3D12Impl *pBuffD3D12, const void *pData, Uint64 DstOffset, Uint64 NumBytes) + void DeviceContextD3D12Impl::UpdateBufferRegion(BufferD3D12Impl* pBuffD3D12, const void* pData, Uint64 DstOffset, Uint64 NumBytes) { VERIFY(pBuffD3D12->GetDesc().Usage != USAGE_DYNAMIC, "Dynamic buffers must be updated via Map()"); VERIFY_EXPR( static_cast<size_t>(NumBytes) == NumBytes ); @@ -729,7 +733,7 @@ namespace Diligent UpdateBufferRegion(pBuffD3D12, TmpSpace, DstOffset, NumBytes); } - void DeviceContextD3D12Impl::CopyBufferRegion(BufferD3D12Impl *pSrcBuffD3D12, BufferD3D12Impl *pDstBuffD3D12, Uint64 SrcOffset, Uint64 DstOffset, Uint64 NumBytes) + void DeviceContextD3D12Impl::CopyBufferRegion(BufferD3D12Impl* pSrcBuffD3D12, BufferD3D12Impl* pDstBuffD3D12, Uint64 SrcOffset, Uint64 DstOffset, Uint64 NumBytes) { VERIFY(pDstBuffD3D12->GetDesc().Usage != USAGE_DYNAMIC, "Dynamic buffers cannot be copy destinations"); @@ -746,8 +750,8 @@ namespace Diligent ++m_NumCommandsInCurCtx; } - void DeviceContextD3D12Impl::CopyTextureRegion(TextureD3D12Impl *pSrcTexture, Uint32 SrcSubResIndex, const D3D12_BOX *pD3D12SrcBox, - TextureD3D12Impl *pDstTexture, Uint32 DstSubResIndex, Uint32 DstX, Uint32 DstY, Uint32 DstZ) + void DeviceContextD3D12Impl::CopyTextureRegion(TextureD3D12Impl* pSrcTexture, Uint32 SrcSubResIndex, const D3D12_BOX* pD3D12SrcBox, + TextureD3D12Impl* pDstTexture, Uint32 DstSubResIndex, Uint32 DstX, Uint32 DstY, Uint32 DstZ) { auto pCmdCtx = RequestCmdContext(); pCmdCtx->TransitionResource(pSrcTexture, D3D12_RESOURCE_STATE_COPY_SOURCE); @@ -767,7 +771,7 @@ namespace Diligent ++m_NumCommandsInCurCtx; } - void DeviceContextD3D12Impl::CopyTextureRegion(IBuffer *pSrcBuffer, Uint32 SrcStride, Uint32 SrcDepthStride, class TextureD3D12Impl *pTextureD3D12, Uint32 DstSubResIndex, const Box &DstBox) + void DeviceContextD3D12Impl::CopyTextureRegion(IBuffer* pSrcBuffer, Uint32 SrcStride, Uint32 SrcDepthStride, class TextureD3D12Impl* pTextureD3D12, Uint32 DstSubResIndex, const Box& DstBox) { auto *pBufferD3D12 = ValidatedCast<BufferD3D12Impl>(pSrcBuffer); const auto& TexDesc = pTextureD3D12->GetDesc(); @@ -828,14 +832,14 @@ namespace Diligent } } - void DeviceContextD3D12Impl::GenerateMips(TextureViewD3D12Impl *pTexView) + void DeviceContextD3D12Impl::GenerateMips(TextureViewD3D12Impl* pTexView) { auto *pCtx = RequestCmdContext(); m_MipsGenerator.GenerateMips(m_pDevice.RawPtr<RenderDeviceD3D12Impl>(), pTexView, *pCtx); ++m_NumCommandsInCurCtx; } - void DeviceContextD3D12Impl::FinishCommandList(class ICommandList **ppCommandList) + void DeviceContextD3D12Impl::FinishCommandList(ICommandList** ppCommandList) { CommandListD3D12Impl *pCmdListD3D12( NEW_RC_OBJ(m_CmdListAllocator, "CommandListD3D12Impl instance", CommandListD3D12Impl) (m_pDevice, m_pCurrCmdCtx) ); @@ -846,7 +850,7 @@ namespace Diligent InvalidateState(); } - void DeviceContextD3D12Impl::ExecuteCommandList(class ICommandList *pCommandList) + void DeviceContextD3D12Impl::ExecuteCommandList(ICommandList* pCommandList) { if (m_bIsDeferred) { diff --git a/Graphics/GraphicsEngineD3D12/src/DynamicUploadHeap.cpp b/Graphics/GraphicsEngineD3D12/src/DynamicUploadHeap.cpp index 01e7d4d7..b16b62b8 100644 --- a/Graphics/GraphicsEngineD3D12/src/DynamicUploadHeap.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DynamicUploadHeap.cpp @@ -27,16 +27,19 @@ namespace Diligent { - GPURingBuffer::GPURingBuffer(size_t MaxSize, IMemoryAllocator &Allocator, ID3D12Device *pd3d12Device, bool AllowCPUAccess) : + GPURingBuffer::GPURingBuffer(size_t MaxSize, + IMemoryAllocator& Allocator, + ID3D12Device* pd3d12Device, + bool AllowCPUAccess) : RingBuffer(MaxSize, Allocator), m_CpuVirtualAddress(nullptr), m_GpuVirtualAddress(0) { D3D12_HEAP_PROPERTIES HeapProps; - HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; + HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - HeapProps.CreationNodeMask = 1; - HeapProps.VisibleNodeMask = 1; + HeapProps.CreationNodeMask = 1; + HeapProps.VisibleNodeMask = 1; D3D12_RESOURCE_DESC ResourceDesc; ResourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; @@ -102,7 +105,10 @@ namespace Diligent Destroy(); } - DynamicUploadHeap::DynamicUploadHeap(IMemoryAllocator &Allocator, bool bIsCPUAccessible, class RenderDeviceD3D12Impl* pDevice, size_t InitialSize) : + DynamicUploadHeap::DynamicUploadHeap(IMemoryAllocator& Allocator, + bool bIsCPUAccessible, + RenderDeviceD3D12Impl* pDevice, + size_t InitialSize) : m_Allocator(Allocator), m_pDeviceD3D12(pDevice), m_bIsCPUAccessible(bIsCPUAccessible), diff --git a/Graphics/GraphicsEngineD3D12/src/GenerateMips.cpp b/Graphics/GraphicsEngineD3D12/src/GenerateMips.cpp index 12b64835..d6ec20ec 100644 --- a/Graphics/GraphicsEngineD3D12/src/GenerateMips.cpp +++ b/Graphics/GraphicsEngineD3D12/src/GenerateMips.cpp @@ -103,7 +103,7 @@ namespace Diligent CreatePSO(m_pGenerateMipsGammaPSO[3], g_pGenerateMipsGammaOddCS); } - void GenerateMipsHelper::GenerateMips(RenderDeviceD3D12Impl *pRenderDeviceD3D12, TextureViewD3D12Impl *pTexView, CommandContext& Ctx) + void GenerateMipsHelper::GenerateMips(RenderDeviceD3D12Impl* pRenderDeviceD3D12, TextureViewD3D12Impl* pTexView, CommandContext& Ctx) { auto &ComputeCtx = Ctx.AsComputeContext(); ComputeCtx.SetRootSignature(m_pGenerateMipsRS); diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp index 2964f29a..d9c60b2a 100644 --- a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp @@ -59,7 +59,7 @@ private: std::array<D3D12_PRIMITIVE_TOPOLOGY_TYPE, PRIMITIVE_TOPOLOGY_NUM_TOPOLOGIES> m_Map; }; -void PipelineStateD3D12Impl::ParseShaderResourceLayout(IShader *pShader) +void PipelineStateD3D12Impl::ParseShaderResourceLayout(IShader* pShader) { VERIFY_EXPR(pShader); @@ -77,7 +77,9 @@ void PipelineStateD3D12Impl::ParseShaderResourceLayout(IShader *pShader) m_pShaderResourceLayouts[ShaderInd]->Initialize(pDeviceD3D12Impl->GetD3D12Device(), pShaderD3D12->GetShaderResources(), GetRawAllocator(), nullptr, 0, nullptr, &m_RootSig); } -PipelineStateD3D12Impl :: PipelineStateD3D12Impl(IReferenceCounters *pRefCounters, RenderDeviceD3D12Impl *pDeviceD3D12, const PipelineStateDesc &PipelineDesc) : +PipelineStateD3D12Impl :: PipelineStateD3D12Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D12Impl* pDeviceD3D12, + const PipelineStateDesc& PipelineDesc) : TPipelineStateBase(pRefCounters, pDeviceD3D12, PipelineDesc), m_DummyVar(*this), m_ResourceCacheDataAllocator(GetRawAllocator(), PipelineDesc.SRBAllocationGranularity), @@ -241,7 +243,7 @@ PipelineStateD3D12Impl::~PipelineStateD3D12Impl() IMPLEMENT_QUERY_INTERFACE( PipelineStateD3D12Impl, IID_PipelineStateD3D12, TPipelineStateBase ) -void PipelineStateD3D12Impl::BindShaderResources(IResourceMapping *pResourceMapping, Uint32 Flags) +void PipelineStateD3D12Impl::BindShaderResources(IResourceMapping* pResourceMapping, Uint32 Flags) { if( m_Desc.IsComputePipeline ) { @@ -257,7 +259,7 @@ void PipelineStateD3D12Impl::BindShaderResources(IResourceMapping *pResourceMapp } } -void PipelineStateD3D12Impl::CreateShaderResourceBinding(IShaderResourceBinding **ppShaderResourceBinding) +void PipelineStateD3D12Impl::CreateShaderResourceBinding(IShaderResourceBinding** ppShaderResourceBinding) { auto *pRenderDeviceD3D12 = ValidatedCast<RenderDeviceD3D12Impl>( GetDevice() ); auto &SRBAllocator = pRenderDeviceD3D12->GetSRBAllocator(); @@ -265,7 +267,7 @@ void PipelineStateD3D12Impl::CreateShaderResourceBinding(IShaderResourceBinding pResBindingD3D12->QueryInterface(IID_ShaderResourceBinding, reinterpret_cast<IObject**>(ppShaderResourceBinding)); } -bool PipelineStateD3D12Impl::IsCompatibleWith(const IPipelineState *pPSO)const +bool PipelineStateD3D12Impl::IsCompatibleWith(const IPipelineState* pPSO)const { VERIFY_EXPR(pPSO != nullptr); @@ -320,10 +322,10 @@ const ShaderResourceLayoutD3D12& PipelineStateD3D12Impl::GetShaderResLayout(SHAD return *m_pShaderResourceLayouts[ShaderInd]; } -ShaderResourceCacheD3D12* PipelineStateD3D12Impl::CommitAndTransitionShaderResources(IShaderResourceBinding *pShaderResourceBinding, - CommandContext &Ctx, - bool CommitResources, - bool TransitionResources)const +ShaderResourceCacheD3D12* PipelineStateD3D12Impl::CommitAndTransitionShaderResources(IShaderResourceBinding* pShaderResourceBinding, + CommandContext& Ctx, + bool CommitResources, + bool TransitionResources)const { #ifdef VERIFY_SHADER_BINDINGS if (pShaderResourceBinding == nullptr && diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp index 178267e7..55068388 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp @@ -36,12 +36,30 @@ namespace Diligent { -RenderDeviceD3D12Impl :: RenderDeviceD3D12Impl(IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator, const EngineD3D12Attribs &CreationAttribs, ID3D12Device *pd3d12Device, ICommandQueueD3D12 *pCmdQueue, Uint32 NumDeferredContexts) : - TRenderDeviceBase(pRefCounters, RawMemAllocator, NumDeferredContexts, sizeof(TextureD3D12Impl), sizeof(TextureViewD3D12Impl), sizeof(BufferD3D12Impl), sizeof(BufferViewD3D12Impl), sizeof(ShaderD3D12Impl), sizeof(SamplerD3D12Impl), sizeof(PipelineStateD3D12Impl), sizeof(ShaderResourceBindingD3D12Impl)), - m_pd3d12Device(pd3d12Device), - m_pCommandQueue(pCmdQueue), - m_EngineAttribs(CreationAttribs), - m_FrameNumber(0), +RenderDeviceD3D12Impl :: RenderDeviceD3D12Impl(IReferenceCounters* pRefCounters, + IMemoryAllocator& RawMemAllocator, + const EngineD3D12Attribs& CreationAttribs, + ID3D12Device* pd3d12Device, + ICommandQueueD3D12* pCmdQueue, + Uint32 NumDeferredContexts) : + TRenderDeviceBase + { + pRefCounters, + RawMemAllocator, + NumDeferredContexts, + sizeof(TextureD3D12Impl), + sizeof(TextureViewD3D12Impl), + sizeof(BufferD3D12Impl), + sizeof(BufferViewD3D12Impl), + sizeof(ShaderD3D12Impl), + sizeof(SamplerD3D12Impl), + sizeof(PipelineStateD3D12Impl), + sizeof(ShaderResourceBindingD3D12Impl) + }, + m_pd3d12Device (pd3d12Device), + m_pCommandQueue (pCmdQueue), + m_EngineAttribs (CreationAttribs), + m_FrameNumber (0), m_NextCmdListNumber(0), m_CmdListManager(this), m_CPUDescriptorHeaps @@ -94,7 +112,7 @@ void RenderDeviceD3D12Impl::DisposeCommandContext(CommandContext* pCtx) m_AvailableContexts.push_back(pCtx); } -void RenderDeviceD3D12Impl::CloseAndExecuteCommandContext(CommandContext *pCtx, bool DiscardStaleObjects) +void RenderDeviceD3D12Impl::CloseAndExecuteCommandContext(CommandContext* pCtx, bool DiscardStaleObjects) { CComPtr<ID3D12CommandAllocator> pAllocator; auto *pCmdList = pCtx->Close(&pAllocator); @@ -307,7 +325,7 @@ void RenderDeviceD3D12Impl::ReleaseUploadHeap(DynamicUploadHeap* pUploadHeap) } -CommandContext* RenderDeviceD3D12Impl::AllocateCommandContext(const Char *ID) +CommandContext* RenderDeviceD3D12Impl::AllocateCommandContext(const Char* ID) { std::lock_guard<std::mutex> LockGuard(m_ContextAllocationMutex); @@ -341,7 +359,7 @@ void RenderDeviceD3D12Impl::SafeReleaseD3D12Object(ID3D12Object* pObj) m_ReleaseQueue.SafeReleaseResource(CComPtr<ID3D12Object>(pObj), m_NextCmdListNumber); } -bool CreateTestResource(ID3D12Device *pDevice, const D3D12_RESOURCE_DESC &ResDesc) +bool CreateTestResource(ID3D12Device* pDevice, const D3D12_RESOURCE_DESC& ResDesc) { // Set the texture pointer address to nullptr to validate input parameters // without creating the texture @@ -459,7 +477,7 @@ void RenderDeviceD3D12Impl::TestTextureFormat( TEXTURE_FORMAT TexFormat ) IMPLEMENT_QUERY_INTERFACE( RenderDeviceD3D12Impl, IID_RenderDeviceD3D12, TRenderDeviceBase ) -void RenderDeviceD3D12Impl::CreatePipelineState(const PipelineStateDesc &PipelineDesc, IPipelineState **ppPipelineState) +void RenderDeviceD3D12Impl::CreatePipelineState(const PipelineStateDesc& PipelineDesc, IPipelineState** ppPipelineState) { CreateDeviceObject("Pipeline State", PipelineDesc, ppPipelineState, [&]() @@ -471,7 +489,7 @@ void RenderDeviceD3D12Impl::CreatePipelineState(const PipelineStateDesc &Pipelin ); } -void RenderDeviceD3D12Impl :: CreateBufferFromD3DResource(ID3D12Resource *pd3d12Buffer, const BufferDesc& BuffDesc, IBuffer **ppBuffer) +void RenderDeviceD3D12Impl :: CreateBufferFromD3DResource(ID3D12Resource* pd3d12Buffer, const BufferDesc& BuffDesc, IBuffer** ppBuffer) { CreateDeviceObject("buffer", BuffDesc, ppBuffer, [&]() @@ -484,7 +502,7 @@ void RenderDeviceD3D12Impl :: CreateBufferFromD3DResource(ID3D12Resource *pd3d12 ); } -void RenderDeviceD3D12Impl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData &BuffData, IBuffer **ppBuffer) +void RenderDeviceD3D12Impl :: CreateBuffer(const BufferDesc& BuffDesc, const BufferData& BuffData, IBuffer** ppBuffer) { CreateDeviceObject("buffer", BuffDesc, ppBuffer, [&]() @@ -498,7 +516,7 @@ void RenderDeviceD3D12Impl :: CreateBuffer(const BufferDesc& BuffDesc, const Buf } -void RenderDeviceD3D12Impl :: CreateShader(const ShaderCreationAttribs &ShaderCreationAttribs, IShader **ppShader) +void RenderDeviceD3D12Impl :: CreateShader(const ShaderCreationAttribs& ShaderCreationAttribs, IShader** ppShader) { CreateDeviceObject( "shader", ShaderCreationAttribs.Desc, ppShader, [&]() @@ -511,7 +529,7 @@ void RenderDeviceD3D12Impl :: CreateShader(const ShaderCreationAttribs &ShaderCr ); } -void RenderDeviceD3D12Impl::CreateTextureFromD3DResource(ID3D12Resource *pd3d12Texture, ITexture **ppTexture) +void RenderDeviceD3D12Impl::CreateTextureFromD3DResource(ID3D12Resource* pd3d12Texture, ITexture** ppTexture) { TextureDesc TexDesc; TexDesc.Name = "Texture from d3d12 resource"; @@ -527,7 +545,7 @@ void RenderDeviceD3D12Impl::CreateTextureFromD3DResource(ID3D12Resource *pd3d12T ); } -void RenderDeviceD3D12Impl::CreateTexture(const TextureDesc& TexDesc, ID3D12Resource *pd3d12Texture, class TextureD3D12Impl **ppTexture) +void RenderDeviceD3D12Impl::CreateTexture(const TextureDesc& TexDesc, ID3D12Resource* pd3d12Texture, TextureD3D12Impl** ppTexture) { CreateDeviceObject( "texture", TexDesc, ppTexture, [&]() @@ -538,7 +556,7 @@ void RenderDeviceD3D12Impl::CreateTexture(const TextureDesc& TexDesc, ID3D12Reso ); } -void RenderDeviceD3D12Impl :: CreateTexture(const TextureDesc& TexDesc, const TextureData &Data, ITexture **ppTexture) +void RenderDeviceD3D12Impl :: CreateTexture(const TextureDesc& TexDesc, const TextureData& Data, ITexture** ppTexture) { CreateDeviceObject( "texture", TexDesc, ppTexture, [&]() @@ -552,7 +570,7 @@ void RenderDeviceD3D12Impl :: CreateTexture(const TextureDesc& TexDesc, const Te ); } -void RenderDeviceD3D12Impl :: CreateSampler(const SamplerDesc& SamplerDesc, ISampler **ppSampler) +void RenderDeviceD3D12Impl :: CreateSampler(const SamplerDesc& SamplerDesc, ISampler** ppSampler) { CreateDeviceObject( "sampler", SamplerDesc, ppSampler, [&]() diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp index 9fed8e56..90d15a55 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp @@ -51,23 +51,23 @@ public: } void CreateDeviceAndContextsD3D12( const EngineD3D12Attribs& CreationAttribs, - IRenderDevice **ppDevice, - IDeviceContext **ppContexts, - Uint32 NumDeferredContexts)override final; + IRenderDevice** ppDevice, + IDeviceContext** ppContexts, + Uint32 NumDeferredContexts)override final; - void AttachToD3D12Device(void *pd3d12NativeDevice, - ICommandQueueD3D12 *pCommandQueue, + void AttachToD3D12Device(void* pd3d12NativeDevice, + ICommandQueueD3D12* pCommandQueue, const EngineD3D12Attribs& EngineAttribs, - IRenderDevice **ppDevice, - IDeviceContext **ppContexts, - Uint32 NumDeferredContexts)override final; + IRenderDevice** ppDevice, + IDeviceContext** ppContexts, + Uint32 NumDeferredContexts)override final; - void CreateSwapChainD3D12( IRenderDevice *pDevice, - IDeviceContext *pImmediateContext, - const SwapChainDesc& SwapChainDesc, + void CreateSwapChainD3D12( IRenderDevice* pDevice, + IDeviceContext* pImmediateContext, + const SwapChainDesc& SwapChainDesc, const FullScreenModeDesc& FSDesc, - void* pNativeWndHandle, - ISwapChain **ppSwapChain )override final; + void* pNativeWndHandle, + ISwapChain** ppSwapChain )override final; }; void GetHardwareAdapter(IDXGIFactory2* pFactory, IDXGIAdapter1** ppAdapter) @@ -111,9 +111,9 @@ void GetHardwareAdapter(IDXGIFactory2* pFactory, IDXGIAdapter1** ppAdapter) /// contexts are written to ppContexts array starting /// at position 1 void EngineFactoryD3D12Impl::CreateDeviceAndContextsD3D12( const EngineD3D12Attribs& CreationAttribs, - IRenderDevice **ppDevice, - IDeviceContext **ppContexts, - Uint32 NumDeferredContexts) + IRenderDevice** ppDevice, + IDeviceContext** ppContexts, + Uint32 NumDeferredContexts) { if (CreationAttribs.DebugMessageCallback != nullptr) SetDebugMessageCallback(CreationAttribs.DebugMessageCallback); @@ -279,12 +279,12 @@ void EngineFactoryD3D12Impl::CreateDeviceAndContextsD3D12( const EngineD3D12Attr /// of deferred contexts is requested, pointers to the /// contexts are written to ppContexts array starting /// at position 1 -void EngineFactoryD3D12Impl::AttachToD3D12Device(void *pd3d12NativeDevice, - ICommandQueueD3D12 *pCommandQueue, +void EngineFactoryD3D12Impl::AttachToD3D12Device(void* pd3d12NativeDevice, + ICommandQueueD3D12* pCommandQueue, const EngineD3D12Attribs& EngineAttribs, - IRenderDevice **ppDevice, - IDeviceContext **ppContexts, - Uint32 NumDeferredContexts) + IRenderDevice** ppDevice, + IDeviceContext** ppContexts, + Uint32 NumDeferredContexts) { if (EngineAttribs.DebugMessageCallback != nullptr) SetDebugMessageCallback(EngineAttribs.DebugMessageCallback); @@ -353,12 +353,12 @@ void EngineFactoryD3D12Impl::AttachToD3D12Device(void *pd3d12NativeDevice, /// /// \param [out] ppSwapChain - Address of the memory location where pointer to the new /// swap chain will be written -void EngineFactoryD3D12Impl::CreateSwapChainD3D12( IRenderDevice *pDevice, - IDeviceContext *pImmediateContext, - const SwapChainDesc& SCDesc, +void EngineFactoryD3D12Impl::CreateSwapChainD3D12( IRenderDevice* pDevice, + IDeviceContext* pImmediateContext, + const SwapChainDesc& SCDesc, const FullScreenModeDesc& FSDesc, - void* pNativeWndHandle, - ISwapChain **ppSwapChain ) + void* pNativeWndHandle, + ISwapChain** ppSwapChain ) { VERIFY( ppSwapChain, "Null pointer provided" ); if( !ppSwapChain ) diff --git a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp index 070c3c4e..52854d88 100644 --- a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp @@ -42,12 +42,17 @@ RootSignature::RootParamsManager::RootParamsManager(IMemoryAllocator &MemAllocat m_pMemory(nullptr, STDDeleter<void, IMemoryAllocator>(MemAllocator)) {} -size_t RootSignature::RootParamsManager::GetRequiredMemorySize(Uint32 NumExtraRootTables, Uint32 NumExtraRootViews, Uint32 NumExtraDescriptorRanges)const +size_t RootSignature::RootParamsManager::GetRequiredMemorySize(Uint32 NumExtraRootTables, + Uint32 NumExtraRootViews, + Uint32 NumExtraDescriptorRanges)const { return sizeof(RootParameter) * (m_NumRootTables + NumExtraRootTables + m_NumRootViews + NumExtraRootViews) + sizeof(D3D12_DESCRIPTOR_RANGE) * (m_TotalDescriptorRanges + NumExtraDescriptorRanges); } -D3D12_DESCRIPTOR_RANGE* RootSignature::RootParamsManager::Extend(Uint32 NumExtraRootTables, Uint32 NumExtraRootViews, Uint32 NumExtraDescriptorRanges, Uint32 RootTableToAddRanges) +D3D12_DESCRIPTOR_RANGE* RootSignature::RootParamsManager::Extend(Uint32 NumExtraRootTables, + Uint32 NumExtraRootViews, + Uint32 NumExtraDescriptorRanges, + Uint32 RootTableToAddRanges) { VERIFY(NumExtraRootTables > 0 || NumExtraRootViews > 0 || NumExtraDescriptorRanges > 0, "At least one root table, root view or descriptor range must be added" ); auto MemorySize = GetRequiredMemorySize(NumExtraRootTables, NumExtraRootViews, NumExtraDescriptorRanges); @@ -92,14 +97,21 @@ D3D12_DESCRIPTOR_RANGE* RootSignature::RootParamsManager::Extend(Uint32 NumExtra return pCurrDescriptorRangePtr; } -void RootSignature::RootParamsManager::AddRootView(D3D12_ROOT_PARAMETER_TYPE ParameterType, Uint32 RootIndex, UINT Register, D3D12_SHADER_VISIBILITY Visibility, SHADER_VARIABLE_TYPE VarType) +void RootSignature::RootParamsManager::AddRootView(D3D12_ROOT_PARAMETER_TYPE ParameterType, + Uint32 RootIndex, + UINT Register, + D3D12_SHADER_VISIBILITY Visibility, + SHADER_VARIABLE_TYPE VarType) { auto *pRangePtr = Extend(0, 1, 0); VERIFY_EXPR((char*)pRangePtr == (char*)m_pMemory.get() + GetRequiredMemorySize(0, 0, 0)); new(m_pRootViews + m_NumRootViews-1) RootParameter(ParameterType, RootIndex, Register, 0u, Visibility, VarType); } -void RootSignature::RootParamsManager::AddRootTable(Uint32 RootIndex, D3D12_SHADER_VISIBILITY Visibility, SHADER_VARIABLE_TYPE VarType, Uint32 NumRangesInNewTable) +void RootSignature::RootParamsManager::AddRootTable(Uint32 RootIndex, + D3D12_SHADER_VISIBILITY Visibility, + SHADER_VARIABLE_TYPE VarType, + Uint32 NumRangesInNewTable) { auto *pRangePtr = Extend(1, 0, NumRangesInNewTable); VERIFY_EXPR( (char*)(pRangePtr + NumRangesInNewTable) == (char*)m_pMemory.get() + GetRequiredMemorySize(0, 0, 0)); @@ -250,7 +262,7 @@ D3D12_DESCRIPTOR_HEAP_TYPE HeapTypeFromRangeType(D3D12_DESCRIPTOR_RANGE_TYPE Ran } -void RootSignature::InitStaticSampler(SHADER_TYPE ShaderType, const String &TextureName, const D3DShaderResourceAttribs &SamplerAttribs) +void RootSignature::InitStaticSampler(SHADER_TYPE ShaderType, const String& TextureName, const D3DShaderResourceAttribs& SamplerAttribs) { auto ShaderVisibility = GetShaderVisibility(ShaderType); auto SamplerFound = false; @@ -274,11 +286,11 @@ void RootSignature::InitStaticSampler(SHADER_TYPE ShaderType, const String &Text } // http://diligentgraphics.com/diligent-engine/architecture/d3d12/shader-resource-layout#Initializing-Shader-Resource-Layouts-and-Root-Signature-in-a-Pipeline-State-Object -void RootSignature::AllocateResourceSlot(SHADER_TYPE ShaderType, - const D3DShaderResourceAttribs &ShaderResAttribs, - D3D12_DESCRIPTOR_RANGE_TYPE RangeType, - Uint32 &RootIndex, // Output parameter - Uint32 &OffsetFromTableStart // Output parameter +void RootSignature::AllocateResourceSlot(SHADER_TYPE ShaderType, + const D3DShaderResourceAttribs& ShaderResAttribs, + D3D12_DESCRIPTOR_RANGE_TYPE RangeType, + Uint32& RootIndex, // Output parameter + Uint32& OffsetFromTableStart // Output parameter ) { auto ShaderInd = GetShaderTypeIndex(ShaderType); @@ -398,7 +410,7 @@ void RootSignature::dbgVerifyRootParameters()const } #endif -void RootSignature::AllocateStaticSamplers(IShader* const*ppShaders, Uint32 NumShaders) +void RootSignature::AllocateStaticSamplers(IShader* const* ppShaders, Uint32 NumShaders) { Uint32 TotalSamplers = 0; for(Uint32 s=0;s < NumShaders; ++s) @@ -418,7 +430,7 @@ void RootSignature::AllocateStaticSamplers(IShader* const*ppShaders, Uint32 NumS } } -void RootSignature::Finalize(ID3D12Device *pd3d12Device) +void RootSignature::Finalize(ID3D12Device* pd3d12Device) { for(Uint32 rt = 0; rt < m_RootParams.GetNumRootTables(); ++rt) { @@ -525,7 +537,9 @@ void RootSignature::Finalize(ID3D12Device *pd3d12Device) } //http://diligentgraphics.com/diligent-engine/architecture/d3d12/shader-resource-cache#Initializing-the-Cache-for-Shader-Resource-Binding-Object -void RootSignature::InitResourceCache(RenderDeviceD3D12Impl *pDeviceD3D12Impl, ShaderResourceCacheD3D12& ResourceCache, IMemoryAllocator &CacheMemAllocator)const +void RootSignature::InitResourceCache(RenderDeviceD3D12Impl* pDeviceD3D12Impl, + ShaderResourceCacheD3D12& ResourceCache, + IMemoryAllocator& CacheMemAllocator)const { // Get root table size for every root index // m_RootParams keeps root tables sorted by the array index, not the root index @@ -633,9 +647,9 @@ void RootSignature::InitResourceCache(RenderDeviceD3D12Impl *pDeviceD3D12Impl, S const D3D12_RESOURCE_STATES D3D12_RESOURCE_STATE_SHADER_RESOURCE = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; __forceinline -void TransitionResource(CommandContext &Ctx, - ShaderResourceCacheD3D12::Resource &Res, - D3D12_DESCRIPTOR_RANGE_TYPE RangeType) +void TransitionResource(CommandContext& Ctx, + ShaderResourceCacheD3D12::Resource& Res, + D3D12_DESCRIPTOR_RANGE_TYPE RangeType) { switch (Res.Type) { @@ -702,8 +716,8 @@ void TransitionResource(CommandContext &Ctx, #ifdef _DEBUG -void DbgVerifyResourceState(ShaderResourceCacheD3D12::Resource &Res, - D3D12_DESCRIPTOR_RANGE_TYPE RangeType) +void DbgVerifyResourceState(ShaderResourceCacheD3D12::Resource& Res, + D3D12_DESCRIPTOR_RANGE_TYPE RangeType) { switch (Res.Type) { @@ -797,11 +811,11 @@ __forceinline void RootSignature::RootParamsManager::ProcessRootTables(TOperatio } template<class TOperation> -__forceinline void ProcessCachedTableResources(Uint32 RootInd, +__forceinline void ProcessCachedTableResources(Uint32 RootInd, const D3D12_ROOT_PARAMETER& D3D12Param, - ShaderResourceCacheD3D12& ResourceCache, - D3D12_DESCRIPTOR_HEAP_TYPE dbgHeapType, - TOperation Operation) + ShaderResourceCacheD3D12& ResourceCache, + D3D12_DESCRIPTOR_HEAP_TYPE dbgHeapType, + TOperation Operation) { for (UINT r = 0; r < D3D12Param.DescriptorTable.NumDescriptorRanges; ++r) { @@ -823,10 +837,10 @@ __forceinline void ProcessCachedTableResources(Uint32 RootInd, template<bool PerformResourceTransitions> -void RootSignature::CommitDescriptorHandlesInternal_SMD(RenderDeviceD3D12Impl *pRenderDeviceD3D12, +void RootSignature::CommitDescriptorHandlesInternal_SMD(RenderDeviceD3D12Impl* pRenderDeviceD3D12, ShaderResourceCacheD3D12& ResourceCache, - CommandContext &Ctx, - bool IsCompute)const + CommandContext& Ctx, + bool IsCompute)const { auto *pd3d12Device = pRenderDeviceD3D12->GetD3D12Device(); @@ -932,10 +946,10 @@ void RootSignature::CommitDescriptorHandlesInternal_SMD(RenderDeviceD3D12Impl *p } template<bool PerformResourceTransitions> -void RootSignature::CommitDescriptorHandlesInternal_SM(RenderDeviceD3D12Impl *pRenderDeviceD3D12, +void RootSignature::CommitDescriptorHandlesInternal_SM(RenderDeviceD3D12Impl* pRenderDeviceD3D12, ShaderResourceCacheD3D12& ResourceCache, - CommandContext &Ctx, - bool IsCompute)const + CommandContext& Ctx, + bool IsCompute)const { VERIFY_EXPR(m_TotalSrvCbvUavSlots[SHADER_VARIABLE_TYPE_DYNAMIC] == 0 && m_TotalSamplerSlots[SHADER_VARIABLE_TYPE_DYNAMIC] == 0); @@ -984,7 +998,7 @@ void RootSignature::CommitDescriptorHandlesInternal_SM(RenderDeviceD3D12Impl *pR void RootSignature::TransitionResources(ShaderResourceCacheD3D12& ResourceCache, - class CommandContext &Ctx)const + CommandContext& Ctx)const { m_RootParams.ProcessRootTables( [&](Uint32 RootInd, const RootParameter &RootTable, const D3D12_ROOT_PARAMETER& D3D12Param, bool IsResourceTable, D3D12_DESCRIPTOR_HEAP_TYPE dbgHeapType ) @@ -1001,9 +1015,9 @@ void RootSignature::TransitionResources(ShaderResourceCacheD3D12& ResourceCache, void RootSignature::CommitRootViews(ShaderResourceCacheD3D12& ResourceCache, - CommandContext &Ctx, - bool IsCompute, - Uint32 ContextId)const + CommandContext& Ctx, + bool IsCompute, + Uint32 ContextId)const { for(Uint32 rv = 0; rv < m_RootParams.GetNumRootViews(); ++rv) { diff --git a/Graphics/GraphicsEngineD3D12/src/SamplerD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/SamplerD3D12Impl.cpp index f9083423..9e031339 100644 --- a/Graphics/GraphicsEngineD3D12/src/SamplerD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/SamplerD3D12Impl.cpp @@ -29,7 +29,9 @@ namespace Diligent { -SamplerD3D12Impl::SamplerD3D12Impl(IReferenceCounters *pRefCounters, class RenderDeviceD3D12Impl *pRenderDeviceD3D12, const SamplerDesc& SamplerDesc) : +SamplerD3D12Impl::SamplerD3D12Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D12Impl* pRenderDeviceD3D12, + const SamplerDesc& SamplerDesc) : TSamplerBase(pRefCounters, pRenderDeviceD3D12, SamplerDesc) { auto *pD3D12Device = pRenderDeviceD3D12->GetD3D12Device(); diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp index dc4a0d6c..bc2cc52f 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp @@ -36,7 +36,9 @@ namespace Diligent { -ShaderD3D12Impl::ShaderD3D12Impl(IReferenceCounters *pRefCounters, RenderDeviceD3D12Impl *pRenderDeviceD3D12, const ShaderCreationAttribs &ShaderCreationAttribs) : +ShaderD3D12Impl::ShaderD3D12Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D12Impl* pRenderDeviceD3D12, + const ShaderCreationAttribs& ShaderCreationAttribs) : TShaderBase(pRefCounters, pRenderDeviceD3D12, ShaderCreationAttribs.Desc), ShaderD3DBase(ShaderCreationAttribs), m_StaticResLayout(*this, GetRawAllocator()), diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp index 63552f93..2403b938 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp @@ -30,7 +30,9 @@ namespace Diligent { -ShaderResourceBindingD3D12Impl::ShaderResourceBindingD3D12Impl( IReferenceCounters *pRefCounters, PipelineStateD3D12Impl *pPSO, bool IsPSOInternal) : +ShaderResourceBindingD3D12Impl::ShaderResourceBindingD3D12Impl( IReferenceCounters* pRefCounters, + PipelineStateD3D12Impl* pPSO, + bool IsPSOInternal) : TBase( pRefCounters, pPSO, IsPSOInternal ), m_ShaderResourceCache(ShaderResourceCacheD3D12::DbgCacheContentType::SRBResources) { diff --git a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp index 353a7ef0..3df583d7 100644 --- a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp @@ -32,12 +32,12 @@ namespace Diligent { -SwapChainD3D12Impl::SwapChainD3D12Impl(IReferenceCounters *pRefCounters, - const SwapChainDesc& SCDesc, +SwapChainD3D12Impl::SwapChainD3D12Impl(IReferenceCounters* pRefCounters, + const SwapChainDesc& SCDesc, const FullScreenModeDesc& FSDesc, - RenderDeviceD3D12Impl* pRenderDeviceD3D12, - DeviceContextD3D12Impl* pDeviceContextD3D12, - void* pNativeWndHandle) : + RenderDeviceD3D12Impl* pRenderDeviceD3D12, + DeviceContextD3D12Impl* pDeviceContextD3D12, + void* pNativeWndHandle) : TSwapChainBase(pRefCounters, pRenderDeviceD3D12, pDeviceContextD3D12, SCDesc, FSDesc, pNativeWndHandle), m_pBackBufferRTV(STD_ALLOCATOR_RAW_MEM(RefCntAutoPtr<ITextureView>, GetRawAllocator(), "Allocator for vector<RefCntAutoPtr<ITextureView>>")) { diff --git a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp index 2f5bb078..f9b0ce49 100644 --- a/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/TextureD3D12Impl.cpp @@ -56,11 +56,11 @@ DXGI_FORMAT GetClearFormat(DXGI_FORMAT Fmt, D3D12_RESOURCE_FLAGS Flags) return Fmt; } -TextureD3D12Impl :: TextureD3D12Impl(IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator &TexViewObjAllocator, - RenderDeviceD3D12Impl *pRenderDeviceD3D12, - const TextureDesc& TexDesc, - const TextureData &InitData /*= TextureData()*/) : +TextureD3D12Impl :: TextureD3D12Impl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + RenderDeviceD3D12Impl* pRenderDeviceD3D12, + const TextureDesc& TexDesc, + const TextureData& InitData /*= TextureData()*/) : TTextureBase(pRefCounters, TexViewObjAllocator, pRenderDeviceD3D12, TexDesc) { if( m_Desc.Usage == USAGE_STATIC && InitData.pSubResources == nullptr ) @@ -267,7 +267,7 @@ TextureD3D12Impl :: TextureD3D12Impl(IReferenceCounters *pRefCounters, } -static TextureDesc InitTexDescFromD3D12Resource(ID3D12Resource *pTexture, const TextureDesc& SrcTexDesc) +static TextureDesc InitTexDescFromD3D12Resource(ID3D12Resource* pTexture, const TextureDesc& SrcTexDesc) { auto ResourceDesc = pTexture->GetDesc(); @@ -312,11 +312,11 @@ static TextureDesc InitTexDescFromD3D12Resource(ID3D12Resource *pTexture, const return TexDesc; } -TextureD3D12Impl::TextureD3D12Impl(IReferenceCounters *pRefCounters, - FixedBlockMemoryAllocator &TexViewObjAllocator, - RenderDeviceD3D12Impl *pDeviceD3D12, - const TextureDesc& TexDesc, - ID3D12Resource *pTexture) : +TextureD3D12Impl::TextureD3D12Impl(IReferenceCounters* pRefCounters, + FixedBlockMemoryAllocator& TexViewObjAllocator, + RenderDeviceD3D12Impl* pDeviceD3D12, + const TextureDesc& TexDesc, + ID3D12Resource* pTexture) : TTextureBase(pRefCounters, TexViewObjAllocator, pDeviceD3D12, InitTexDescFromD3D12Resource(pTexture, TexDesc)) { m_pd3d12Resource = pTexture; @@ -401,7 +401,11 @@ TextureD3D12Impl :: ~TextureD3D12Impl() pDeviceD3D12Impl->SafeReleaseD3D12Object(m_pd3d12Resource); } -void TextureD3D12Impl::UpdateData( IDeviceContext *pContext, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData ) +void TextureD3D12Impl::UpdateData( IDeviceContext* pContext, + Uint32 MipLevel, + Uint32 Slice, + const Box& DstBox, + const TextureSubResData& SubresData ) { TTextureBase::UpdateData( pContext, MipLevel, Slice, DstBox, SubresData ); if (SubresData.pSrcBuffer == nullptr) @@ -419,16 +423,16 @@ void TextureD3D12Impl::UpdateData( IDeviceContext *pContext, Uint32 MipLevel, Ui pCtxD3D12->CopyTextureRegion(SubresData.pSrcBuffer, SubresData.Stride, SubresData.DepthStride, this, DstSubResIndex, DstBox); } -void TextureD3D12Impl :: CopyData(IDeviceContext *pContext, - ITexture *pSrcTexture, - Uint32 SrcMipLevel, - Uint32 SrcSlice, - const Box *pSrcBox, - Uint32 DstMipLevel, - Uint32 DstSlice, - Uint32 DstX, - Uint32 DstY, - Uint32 DstZ) +void TextureD3D12Impl :: CopyData(IDeviceContext* pContext, + ITexture* pSrcTexture, + Uint32 SrcMipLevel, + Uint32 SrcSlice, + const Box* pSrcBox, + Uint32 DstMipLevel, + Uint32 DstSlice, + Uint32 DstX, + Uint32 DstY, + Uint32 DstZ) { TTextureBase::CopyData( pContext, pSrcTexture, SrcMipLevel, SrcSlice, pSrcBox, DstMipLevel, DstSlice, DstX, DstY, DstZ ); @@ -453,7 +457,7 @@ void TextureD3D12Impl :: CopyData(IDeviceContext *pContext, pCtxD3D12->CopyTextureRegion(pSrcTexD3D12, SrcSubResIndex, pD3D12SrcBox, this, DstSubResIndex, DstX, DstY, DstZ); } -void TextureD3D12Impl :: Map(IDeviceContext *pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags, MappedTextureSubresource &MappedData) +void TextureD3D12Impl :: Map(IDeviceContext* pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags, MappedTextureSubresource &MappedData) { TTextureBase::Map( pContext, Subresource, MapType, MapFlags, MappedData ); UNSUPPORTED("TextureD3D12Impl::Map() is not implemented"); @@ -462,14 +466,14 @@ void TextureD3D12Impl :: Map(IDeviceContext *pContext, Uint32 Subresource, MAP_T MappedData.pData = nullptr;//TmpDummyBuffer; } -void TextureD3D12Impl::Unmap( IDeviceContext *pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags ) +void TextureD3D12Impl::Unmap( IDeviceContext* pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags ) { TTextureBase::Unmap( pContext, Subresource, MapType, MapFlags ); UNSUPPORTED("TextureD3D12Impl::Unmap() is not implemented"); } -void TextureD3D12Impl::CreateSRV( TextureViewDesc &SRVDesc, D3D12_CPU_DESCRIPTOR_HANDLE SRVHandle ) +void TextureD3D12Impl::CreateSRV( TextureViewDesc& SRVDesc, D3D12_CPU_DESCRIPTOR_HANDLE SRVHandle ) { VERIFY( SRVDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE, "Incorrect view type: shader resource is expected" ); @@ -484,7 +488,7 @@ void TextureD3D12Impl::CreateSRV( TextureViewDesc &SRVDesc, D3D12_CPU_DESCRIPTOR pDeviceD3D12->CreateShaderResourceView(m_pd3d12Resource, &D3D12_SRVDesc, SRVHandle); } -void TextureD3D12Impl::CreateRTV( TextureViewDesc &RTVDesc, D3D12_CPU_DESCRIPTOR_HANDLE RTVHandle ) +void TextureD3D12Impl::CreateRTV( TextureViewDesc& RTVDesc, D3D12_CPU_DESCRIPTOR_HANDLE RTVHandle ) { VERIFY( RTVDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET, "Incorrect view type: render target is expected" ); @@ -500,7 +504,7 @@ void TextureD3D12Impl::CreateRTV( TextureViewDesc &RTVDesc, D3D12_CPU_DESCRIPTOR pDeviceD3D12->CreateRenderTargetView( m_pd3d12Resource, &D3D12_RTVDesc, RTVHandle ); } -void TextureD3D12Impl::CreateDSV( TextureViewDesc &DSVDesc, D3D12_CPU_DESCRIPTOR_HANDLE DSVHandle ) +void TextureD3D12Impl::CreateDSV( TextureViewDesc& DSVDesc, D3D12_CPU_DESCRIPTOR_HANDLE DSVHandle ) { VERIFY( DSVDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL, "Incorrect view type: depth stencil is expected" ); @@ -516,7 +520,7 @@ void TextureD3D12Impl::CreateDSV( TextureViewDesc &DSVDesc, D3D12_CPU_DESCRIPTOR pDeviceD3D12->CreateDepthStencilView( m_pd3d12Resource, &D3D12_DSVDesc, DSVHandle ); } -void TextureD3D12Impl::CreateUAV( TextureViewDesc &UAVDesc, D3D12_CPU_DESCRIPTOR_HANDLE UAVHandle ) +void TextureD3D12Impl::CreateUAV( TextureViewDesc& UAVDesc, D3D12_CPU_DESCRIPTOR_HANDLE UAVHandle ) { VERIFY( UAVDesc.ViewType == TEXTURE_VIEW_UNORDERED_ACCESS, "Incorrect view type: unordered access is expected" ); diff --git a/Graphics/GraphicsEngineD3D12/src/TextureViewD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/TextureViewD3D12Impl.cpp index 7f5ee5e5..8ba089d4 100644 --- a/Graphics/GraphicsEngineD3D12/src/TextureViewD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/TextureViewD3D12Impl.cpp @@ -28,12 +28,12 @@ namespace Diligent { -TextureViewD3D12Impl::TextureViewD3D12Impl( IReferenceCounters *pRefCounters, - IRenderDevice *pDevice, - const TextureViewDesc& ViewDesc, - ITexture *pTexture, - DescriptorHeapAllocation &&HandleAlloc, - bool bIsDefaultView ) : +TextureViewD3D12Impl::TextureViewD3D12Impl( IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + const TextureViewDesc& ViewDesc, + ITexture* pTexture, + DescriptorHeapAllocation&& HandleAlloc, + bool bIsDefaultView ) : TTextureViewBase( pRefCounters, pDevice, ViewDesc, pTexture, bIsDefaultView ), m_Descriptor(std::move(HandleAlloc)) { |
