From 404459e2cb9a17e94ee7d26c22fbe2485828b496 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Wed, 25 Jul 2018 08:09:57 -0700 Subject: Improved performance of DeviceObjectBase::Release() --- Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h | 5 +++-- Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h | 7 ++++--- Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h | 11 ++++++----- Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.h | 11 ++++++----- Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h | 7 ++++--- Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h | 11 ++++++----- Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h | 7 ++++--- Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h | 8 ++++---- Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h | 7 ++++--- Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp | 2 +- Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp | 5 +++-- Graphics/GraphicsEngineD3D12/src/FenceD3D12Impl.cpp | 6 +++--- Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp | 11 ++++------- Graphics/GraphicsEngineD3D12/src/TextureViewD3D12Impl.cpp | 2 +- 14 files changed, 53 insertions(+), 47 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h index 9a804c0c..b32ddb74 100644 --- a/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.h @@ -32,6 +32,7 @@ #include "BufferViewD3D12Impl.h" #include "D3D12ResourceBase.h" #include "DynamicUploadHeap.h" +#include "RenderDeviceD3D12Impl.h" namespace Diligent { @@ -39,10 +40,10 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IBufferD3D12 interface -class BufferD3D12Impl : public BufferBase, public D3D12ResourceBase +class BufferD3D12Impl : public BufferBase, public D3D12ResourceBase { public: - using TBufferBase = BufferBase; + using TBufferBase = BufferBase; BufferD3D12Impl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, diff --git a/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h index 8b074440..a722cdf0 100644 --- a/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.h @@ -30,19 +30,20 @@ #include "RenderDeviceD3D12.h" #include "BufferViewBase.h" #include "DescriptorHeap.h" +#include "RenderDeviceD3D12Impl.h" namespace Diligent { class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IBufferViewD3D12 interface -class BufferViewD3D12Impl : public BufferViewBase +class BufferViewD3D12Impl : public BufferViewBase { public: - using TBufferViewBase = BufferViewBase; + using TBufferViewBase = BufferViewBase; BufferViewD3D12Impl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceD3D12Impl* pDevice, const BufferViewDesc& ViewDesc, class IBuffer* pBuffer, DescriptorHeapAllocation&& HandleAlloc, diff --git a/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h index 767abf3b..2cb36faf 100644 --- a/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h @@ -27,19 +27,20 @@ /// Declaration of Diligent::CommandListD3D12Impl class #include "CommandListBase.h" +#include "RenderDeviceD3D12Impl.h" namespace Diligent { /// Implementation of the Diligent::ICommandList interface -class CommandListD3D12Impl : public CommandListBase +class CommandListD3D12Impl : public CommandListBase { public: - using TCommandListBase = CommandListBase; + using TCommandListBase = CommandListBase; - CommandListD3D12Impl(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - class CommandContext* pCmdContext) : + CommandListD3D12Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D12Impl* pDevice, + class CommandContext* pCmdContext) : TCommandListBase(pRefCounters, pDevice), m_pCmdContext(pCmdContext) { diff --git a/Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.h index 636557a9..4ab564d4 100644 --- a/Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.h @@ -29,6 +29,7 @@ #include "FenceD3D12.h" #include "RenderDeviceD3D12.h" #include "FenceBase.h" +#include "RenderDeviceD3D12Impl.h" namespace Diligent { @@ -36,14 +37,14 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IFenceD3D12 interface -class FenceD3D12Impl : public FenceBase +class FenceD3D12Impl : public FenceBase { public: - using TFenceBase = FenceBase; + using TFenceBase = FenceBase; - FenceD3D12Impl(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - const FenceDesc& Desc); + FenceD3D12Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D12Impl* pDevice, + const FenceDesc& Desc); ~FenceD3D12Impl(); virtual Uint64 GetCompletedValue()override final; diff --git a/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h index d0525325..72d66900 100644 --- a/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.h @@ -32,6 +32,7 @@ #include "RootSignature.h" #include "ShaderResourceLayoutD3D12.h" #include "SRBMemoryAllocator.h" +#include "RenderDeviceD3D12Impl.h" /// Namespace for the Direct3D11 implementation of the graphics engine namespace Diligent @@ -39,12 +40,12 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IRenderDeviceD3D12 interface -class PipelineStateD3D12Impl : public PipelineStateBase +class PipelineStateD3D12Impl : public PipelineStateBase { public: - using TPipelineStateBase = PipelineStateBase; + using TPipelineStateBase = PipelineStateBase; - PipelineStateD3D12Impl( IReferenceCounters *pRefCounters, class RenderDeviceD3D12Impl *pDeviceD3D12, const PipelineStateDesc &PipelineDesc ); + PipelineStateD3D12Impl( IReferenceCounters *pRefCounters, RenderDeviceD3D12Impl *pDeviceD3D12, const PipelineStateDesc &PipelineDesc ); ~PipelineStateD3D12Impl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ); diff --git a/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h index 65813e83..fb9b7681 100644 --- a/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.h @@ -30,20 +30,21 @@ #include "RenderDeviceD3D12.h" #include "SamplerBase.h" #include "DescriptorHeap.h" +#include "RenderDeviceD3D12Impl.h" namespace Diligent { class FixedBlockMemoryAllocator; /// Implementation of the Diligent::ISamplerD3D12 interface -class SamplerD3D12Impl : public SamplerBase +class SamplerD3D12Impl : public SamplerBase { public: - using TSamplerBase = SamplerBase; + using TSamplerBase = SamplerBase; - SamplerD3D12Impl(IReferenceCounters* pRefCounters, - class RenderDeviceD3D12Impl* pRenderDeviceD3D12, - const SamplerDesc& SamplerDesc); + SamplerD3D12Impl(IReferenceCounters* pRefCounters, + 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 5005f9d6..9fcb75da 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.h @@ -31,6 +31,7 @@ #include "ShaderBase.h" #include "ShaderD3DBase.h" #include "ShaderResourceLayoutD3D12.h" +#include "RenderDeviceD3D12Impl.h" #ifdef _DEBUG # define VERIFY_SHADER_BINDINGS @@ -43,13 +44,13 @@ class ResourceMapping; class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IShaderD3D12 interface -class ShaderD3D12Impl : public ShaderBase, public ShaderD3DBase +class ShaderD3D12Impl : public ShaderBase, public ShaderD3DBase { public: - using TShaderBase = ShaderBase; + using TShaderBase = ShaderBase; ShaderD3D12Impl(IReferenceCounters* pRefCounters, - class RenderDeviceD3D12Impl* pRenderDeviceD3D12, + RenderDeviceD3D12Impl* pRenderDeviceD3D12, const ShaderCreationAttribs& ShaderCreationAttribs); ~ShaderD3D12Impl(); diff --git a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h index 46d88f6c..81353c01 100644 --- a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.h @@ -31,7 +31,7 @@ #include "TextureBase.h" #include "TextureViewD3D12Impl.h" #include "D3D12ResourceBase.h" - +#include "RenderDeviceD3D12Impl.h" namespace Diligent { @@ -39,15 +39,15 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Base implementation of the Diligent::ITextureD3D12 interface -class TextureD3D12Impl : public TextureBase, public D3D12ResourceBase +class TextureD3D12Impl : public TextureBase, public D3D12ResourceBase { public: - using TTextureBase = TextureBase; + using TTextureBase = TextureBase; // Creates a new D3D12 resource TextureD3D12Impl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceD3D12Impl* pDeviceD3D12, + RenderDeviceD3D12Impl* pDeviceD3D12, const TextureDesc& TexDesc, const TextureData& InitData = TextureData()); // Attaches to an existing D3D12 resource diff --git a/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h index 219fedf5..b220dde8 100644 --- a/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.h @@ -30,19 +30,20 @@ #include "RenderDeviceD3D12.h" #include "TextureViewBase.h" #include "DescriptorHeap.h" +#include "RenderDeviceD3D12Impl.h" namespace Diligent { class FixedBlockMemoryAllocator; /// Implementation of the Diligent::ITextureViewD3D12 interface -class TextureViewD3D12Impl : public TextureViewBase +class TextureViewD3D12Impl : public TextureViewBase { public: - using TTextureViewBase = TextureViewBase; + using TTextureViewBase = TextureViewBase; TextureViewD3D12Impl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceD3D12Impl* pDevice, const TextureViewDesc& ViewDesc, class ITexture* pTexture, DescriptorHeapAllocation&& HandleAlloc, diff --git a/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp index 2f9a0661..e3a4364a 100644 --- a/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp @@ -28,7 +28,7 @@ namespace Diligent { BufferViewD3D12Impl::BufferViewD3D12Impl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceD3D12Impl* pDevice, const BufferViewDesc& ViewDesc, IBuffer* pBuffer, DescriptorHeapAllocation&& HandleAlloc, diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index d5210e40..eccdcb1d 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -835,8 +835,9 @@ namespace Diligent void DeviceContextD3D12Impl::FinishCommandList(ICommandList** ppCommandList) { - CommandListD3D12Impl *pCmdListD3D12( NEW_RC_OBJ(m_CmdListAllocator, "CommandListD3D12Impl instance", CommandListD3D12Impl) - (m_pDevice, m_pCurrCmdCtx) ); + auto* pDeviceD3D12Impl = m_pDevice.RawPtr(); + CommandListD3D12Impl* pCmdListD3D12( NEW_RC_OBJ(m_CmdListAllocator, "CommandListD3D12Impl instance", CommandListD3D12Impl) + (pDeviceD3D12Impl, m_pCurrCmdCtx) ); pCmdListD3D12->QueryInterface( IID_CommandList, reinterpret_cast(ppCommandList) ); m_pCurrCmdCtx = nullptr; Flush(true); diff --git a/Graphics/GraphicsEngineD3D12/src/FenceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/FenceD3D12Impl.cpp index 7577c9c4..aac8e7ef 100644 --- a/Graphics/GraphicsEngineD3D12/src/FenceD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/FenceD3D12Impl.cpp @@ -30,9 +30,9 @@ namespace Diligent { -FenceD3D12Impl :: FenceD3D12Impl(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - const FenceDesc& Desc) : +FenceD3D12Impl :: FenceD3D12Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D12Impl* pDevice, + const FenceDesc& Desc) : TFenceBase(pRefCounters, pDevice, Desc) { auto* pd3d12Device = ValidatedCast(pDevice)->GetD3D12Device(); diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp index d99d2aad..be1ac008 100644 --- a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp @@ -238,8 +238,7 @@ PipelineStateD3D12Impl::~PipelineStateD3D12Impl() ShaderResLayoutAllocator.Free(m_pShaderResourceLayouts); // D3D12 object can only be destroyed when it is no longer used by the GPU - auto* pDeviceD3D12Impl = GetDevice(); - pDeviceD3D12Impl->SafeReleaseD3D12Object(m_pd3d12PSO); + m_pDevice->SafeReleaseD3D12Object(m_pd3d12PSO); } IMPLEMENT_QUERY_INTERFACE( PipelineStateD3D12Impl, IID_PipelineStateD3D12, TPipelineStateBase ) @@ -247,8 +246,7 @@ IMPLEMENT_QUERY_INTERFACE( PipelineStateD3D12Impl, IID_PipelineStateD3D12, TPipe void PipelineStateD3D12Impl::CreateShaderResourceBinding(IShaderResourceBinding** ppShaderResourceBinding) { - auto* pRenderDeviceD3D12 = GetDevice(); - auto& SRBAllocator = pRenderDeviceD3D12->GetSRBAllocator(); + auto& SRBAllocator = m_pDevice->GetSRBAllocator(); auto pResBindingD3D12 = NEW_RC_OBJ(SRBAllocator, "ShaderResourceBindingD3D12Impl instance", ShaderResourceBindingD3D12Impl)(this, false); pResBindingD3D12->QueryInterface(IID_ShaderResourceBinding, reinterpret_cast(ppShaderResourceBinding)); } @@ -352,7 +350,6 @@ ShaderResourceCacheD3D12* PipelineStateD3D12Impl::CommitAndTransitionShaderResou pResBindingD3D12Impl->dbgVerifyResourceBindings(this); #endif - auto* pDeviceD3D12Impl = GetDevice(); auto& ResourceCache = pResBindingD3D12Impl->GetResourceCache(); if(CommitResources) { @@ -362,9 +359,9 @@ ShaderResourceCacheD3D12* PipelineStateD3D12Impl::CommitAndTransitionShaderResou Ctx.AsGraphicsContext().SetRootSignature( GetD3D12RootSignature() ); if(TransitionResources) - (m_RootSig.*m_RootSig.TransitionAndCommitDescriptorHandles)(pDeviceD3D12Impl, ResourceCache, Ctx, m_Desc.IsComputePipeline); + (m_RootSig.*m_RootSig.TransitionAndCommitDescriptorHandles)(m_pDevice, ResourceCache, Ctx, m_Desc.IsComputePipeline); else - (m_RootSig.*m_RootSig.CommitDescriptorHandles)(pDeviceD3D12Impl, ResourceCache, Ctx, m_Desc.IsComputePipeline); + (m_RootSig.*m_RootSig.CommitDescriptorHandles)(m_pDevice, ResourceCache, Ctx, m_Desc.IsComputePipeline); } else { diff --git a/Graphics/GraphicsEngineD3D12/src/TextureViewD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/TextureViewD3D12Impl.cpp index 8ba089d4..aa11f98d 100644 --- a/Graphics/GraphicsEngineD3D12/src/TextureViewD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/TextureViewD3D12Impl.cpp @@ -29,7 +29,7 @@ namespace Diligent { TextureViewD3D12Impl::TextureViewD3D12Impl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceD3D12Impl* pDevice, const TextureViewDesc& ViewDesc, ITexture* pTexture, DescriptorHeapAllocation&& HandleAlloc, -- cgit v1.2.3