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/GraphicsEngine/include/BufferBase.h | 43 ++++++++++++---------- Graphics/GraphicsEngine/include/BufferViewBase.h | 11 ++++-- Graphics/GraphicsEngine/include/CommandListBase.h | 13 ++++--- Graphics/GraphicsEngine/include/DeviceObjectBase.h | 41 ++++++++++----------- Graphics/GraphicsEngine/include/FenceBase.h | 9 +++-- .../GraphicsEngine/include/PipelineStateBase.h | 15 ++++---- Graphics/GraphicsEngine/include/RenderDeviceBase.h | 9 ++++- Graphics/GraphicsEngine/include/SamplerBase.h | 17 ++++----- Graphics/GraphicsEngine/include/ShaderBase.h | 14 +++---- Graphics/GraphicsEngine/include/TextureBase.h | 35 ++++++++++-------- Graphics/GraphicsEngine/include/TextureViewBase.h | 11 ++++-- .../GraphicsEngineD3D11/include/BufferD3D11Impl.h | 5 ++- .../include/BufferViewD3D11Impl.h | 7 ++-- .../include/CommandListD3D11Impl.h | 11 +++--- .../GraphicsEngineD3D11/include/FenceD3D11Impl.h | 11 +++--- .../include/PipelineStateD3D11Impl.h | 5 ++- .../GraphicsEngineD3D11/include/SamplerD3D11Impl.h | 5 ++- .../GraphicsEngineD3D11/include/ShaderD3D11Impl.h | 5 ++- .../GraphicsEngineD3D11/include/TextureBaseD3D11.h | 5 ++- .../include/TextureViewD3D11Impl.h | 7 ++-- .../src/BufferViewD3D11Impl.cpp | 12 +++--- .../src/CommandListD3D11Impl.cpp | 6 +-- .../src/DeviceContextD3D11Impl.cpp | 3 +- .../GraphicsEngineD3D11/src/FenceD3D11Impl.cpp | 6 +-- .../src/TextureViewD3D11Impl.cpp | 2 +- .../GraphicsEngineD3D12/include/BufferD3D12Impl.h | 5 ++- .../include/BufferViewD3D12Impl.h | 7 ++-- .../include/CommandListD3D12Impl.h | 11 +++--- .../GraphicsEngineD3D12/include/FenceD3D12Impl.h | 11 +++--- .../include/PipelineStateD3D12Impl.h | 7 ++-- .../GraphicsEngineD3D12/include/SamplerD3D12Impl.h | 11 +++--- .../GraphicsEngineD3D12/include/ShaderD3D12Impl.h | 7 ++-- .../GraphicsEngineD3D12/include/TextureD3D12Impl.h | 8 ++-- .../include/TextureViewD3D12Impl.h | 7 ++-- .../src/BufferViewD3D12Impl.cpp | 2 +- .../src/DeviceContextD3D12Impl.cpp | 5 ++- .../GraphicsEngineD3D12/src/FenceD3D12Impl.cpp | 6 +-- .../src/PipelineStateD3D12Impl.cpp | 11 ++---- .../src/TextureViewD3D12Impl.cpp | 2 +- .../GraphicsEngineOpenGL/include/BufferGLImpl.h | 8 ++-- .../include/BufferViewGLImpl.h | 7 ++-- .../GraphicsEngineOpenGL/include/FenceGLImpl.h | 7 ++-- .../include/PipelineStateGLImpl.h | 7 ++-- .../GraphicsEngineOpenGL/include/SamplerGLImpl.h | 7 ++-- .../GraphicsEngineOpenGL/include/ShaderGLImpl.h | 7 ++-- .../GraphicsEngineOpenGL/include/TextureBaseGL.h | 8 ++-- .../include/TextureViewGLImpl.h | 15 ++++---- Graphics/GraphicsEngineOpenGL/include/VAOCache.h | 3 +- .../GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp | 2 +- Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp | 2 +- .../GraphicsEngineOpenGL/src/TextureViewGLImpl.cpp | 2 +- .../include/BufferViewVkImpl.h | 7 ++-- .../GraphicsEngineVulkan/include/BufferVkImpl.h | 7 ++-- .../include/CommandListVkImpl.h | 7 ++-- .../GraphicsEngineVulkan/include/FenceVkImpl.h | 6 +-- .../include/PipelineStateVkImpl.h | 7 ++-- .../GraphicsEngineVulkan/include/SamplerVkImpl.h | 8 ++-- .../GraphicsEngineVulkan/include/ShaderVkImpl.h | 7 ++-- .../include/TextureViewVkImpl.h | 7 ++-- .../GraphicsEngineVulkan/include/TextureVkImpl.h | 7 ++-- .../GraphicsEngineVulkan/src/BufferViewVkImpl.cpp | 5 +-- Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp | 20 ++++------ .../src/DeviceContextVkImpl.cpp | 3 +- Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp | 4 +- .../src/PipelineStateVkImpl.cpp | 10 ++--- .../GraphicsEngineVulkan/src/SamplerVkImpl.cpp | 3 +- .../src/ShaderResourceBindingVkImpl.cpp | 4 +- .../GraphicsEngineVulkan/src/TextureViewVkImpl.cpp | 7 ++-- .../GraphicsEngineVulkan/src/TextureVkImpl.cpp | 11 ++---- 69 files changed, 325 insertions(+), 288 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngine/include/BufferBase.h b/Graphics/GraphicsEngine/include/BufferBase.h index d3eaf2d4..b841d0b1 100644 --- a/Graphics/GraphicsEngine/include/BufferBase.h +++ b/Graphics/GraphicsEngine/include/BufferBase.h @@ -40,15 +40,18 @@ namespace Diligent /// \tparam BaseInterface - base interface that this class will inheret /// (Diligent::IBufferD3D11, Diligent::IBufferD3D12, /// Diligent::IBufferGL or Diligent::IBufferVk). +/// \tparam RenderDeviceImplType - type of the render device implementation +/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, +/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) /// \tparam BufferViewImplType - type of the buffer view implementation /// (Diligent::BufferViewD3D11Impl, Diligent::BufferViewD3D12Impl, /// Diligent::BufferViewGLImpl or Diligent::BufferViewVkImpl) /// \tparam TBuffViewObjAllocator - type of the allocator that is used to allocate memory for the buffer view object instances -template -class BufferBase : public DeviceObjectBase < BaseInterface, BufferDesc> +template +class BufferBase : public DeviceObjectBase { public: - typedef DeviceObjectBase TDeviceObjectBase; + using TDeviceObjectBase = DeviceObjectBase; /// \param pRefCounters - reference counters object that controls the lifetime of this buffer. /// \param BuffViewObjAllocator - allocator that is used to allocate memory for the buffer view instances. @@ -59,7 +62,7 @@ public: /// must not keep a strong reference to the device. BufferBase( IReferenceCounters* pRefCounters, TBuffViewObjAllocator& BuffViewObjAllocator, - IRenderDevice* pDevice, + RenderDeviceImplType* pDevice, const BufferDesc& BuffDesc, bool bIsDeviceInternal) : TDeviceObjectBase( pRefCounters, pDevice, BuffDesc, bIsDeviceInternal), @@ -156,24 +159,24 @@ protected: std::unique_ptr > m_pDefaultSRV; }; -template -void BufferBase :: UpdateData( IDeviceContext* pContext, Uint32 Offset, Uint32 Size, const PVoid pData ) +template +void BufferBase :: UpdateData( IDeviceContext* pContext, Uint32 Offset, Uint32 Size, const PVoid pData ) { VERIFY_BUFFER( this->m_Desc.Usage == USAGE_DEFAULT, "Only default usage buffers can be updated with UpdateData()" ); VERIFY_BUFFER( Offset < this->m_Desc.uiSizeInBytes, "Offset (", Offset, ") exceeds the buffer size (", this->m_Desc.uiSizeInBytes, ")" ); VERIFY_BUFFER( Size + Offset <= this->m_Desc.uiSizeInBytes, "Update region [", Offset, ",", Size + Offset, ") is out of buffer bounds [0,",this->m_Desc.uiSizeInBytes,")" ); } -template -void BufferBase :: CopyData( IDeviceContext* pContext, IBuffer* pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size ) +template +void BufferBase :: CopyData( IDeviceContext* pContext, IBuffer* pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size ) { VERIFY_BUFFER( DstOffset + Size <= this->m_Desc.uiSizeInBytes, "Destination range [", DstOffset, ",", DstOffset + Size, ") is out of buffer bounds [0,",this->m_Desc.uiSizeInBytes,")" ); VERIFY_BUFFER( SrcOffset + Size <= pSrcBuffer->GetDesc().uiSizeInBytes, "Source range [", SrcOffset, ",", SrcOffset + Size, ") is out of buffer bounds [0,",this->m_Desc.uiSizeInBytes,")" ); } -template -void BufferBase :: Map( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid& pMappedData ) +template +void BufferBase :: Map( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid& pMappedData ) { pMappedData = nullptr; switch( MapType ) @@ -212,22 +215,22 @@ void BufferBase :: Map } } -template -void BufferBase :: Unmap( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags ) +template +void BufferBase :: Unmap( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags ) { } -template -void BufferBase :: CreateView( const struct BufferViewDesc &ViewDesc, IBufferView **ppView ) +template +void BufferBase :: CreateView( const struct BufferViewDesc &ViewDesc, IBufferView **ppView ) { CreateViewInternal( ViewDesc, ppView, false ); } -template -void BufferBase :: CorrectBufferViewDesc( struct BufferViewDesc &ViewDesc ) +template +void BufferBase :: CorrectBufferViewDesc( struct BufferViewDesc &ViewDesc ) { if( ViewDesc.ByteWidth == 0 ) ViewDesc.ByteWidth = this->m_Desc.uiSizeInBytes; @@ -244,8 +247,8 @@ void BufferBase :: Cor } } -template -IBufferView* BufferBase ::GetDefaultView( BUFFER_VIEW_TYPE ViewType ) +template +IBufferView* BufferBase ::GetDefaultView( BUFFER_VIEW_TYPE ViewType ) { switch( ViewType ) { @@ -255,8 +258,8 @@ IBufferView* BufferBase -void BufferBase :: CreateDefaultViews() +template +void BufferBase :: CreateDefaultViews() { if( this->m_Desc.BindFlags & BIND_UNORDERED_ACCESS ) { diff --git a/Graphics/GraphicsEngine/include/BufferViewBase.h b/Graphics/GraphicsEngine/include/BufferViewBase.h index b09b479e..c672fa43 100644 --- a/Graphics/GraphicsEngine/include/BufferViewBase.h +++ b/Graphics/GraphicsEngine/include/BufferViewBase.h @@ -42,11 +42,14 @@ class IBuffer; /// \tparam BaseInterface - base interface that this class will inheret /// (Diligent::IBufferViewD3D11, Diligent::IBufferViewD3D12, /// Diligent::IBufferViewGL or Diligent::IBufferViewVk). -template -class BufferViewBase : public DeviceObjectBase +/// \tparam RenderDeviceImplType - type of the render device implementation +/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, +/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) +template +class BufferViewBase : public DeviceObjectBase { public: - typedef DeviceObjectBase TDeviceObjectBase; + using TDeviceObjectBase = DeviceObjectBase; /// \param pRefCounters - reference counters object that controls the lifetime of this buffer view. /// \param pDevice - pointer to the render device. @@ -56,7 +59,7 @@ public: /// part of the buffer object. In this case the view will attach /// to the buffer's reference counters. BufferViewBase( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceImplType* pDevice, const BufferViewDesc& ViewDesc, IBuffer* pBuffer, bool bIsDefaultView ) : diff --git a/Graphics/GraphicsEngine/include/CommandListBase.h b/Graphics/GraphicsEngine/include/CommandListBase.h index 77c85d86..8075f70c 100644 --- a/Graphics/GraphicsEngine/include/CommandListBase.h +++ b/Graphics/GraphicsEngine/include/CommandListBase.h @@ -40,18 +40,21 @@ struct CommandListDesc : public DeviceObjectAttribs /// Template class implementing base functionality for a command list object. /// \tparam BaseInterface - base interface that this class will inheret -/// (Diligent::ICommandListD3D11 or Diligent::ICommandListD3D12). -template -class CommandListBase : public DeviceObjectBase +/// (Diligent::ICommandListD3D11, Diligent::ICommandListD3D12 or Diligent::ICommandListVk). +/// \tparam RenderDeviceImplType - type of the render device implementation +/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, +/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) +template +class CommandListBase : public DeviceObjectBase { public: - typedef DeviceObjectBase TDeviceObjectBase; + using TDeviceObjectBase = DeviceObjectBase; /// \param pRefCounters - reference counters object that controls the lifetime of this command list. /// \param pDevice - pointer to the device. /// \param bIsDeviceInternal - flag indicating if the CommandList is an internal device object and /// must not keep a strong reference to the device. - CommandListBase( IReferenceCounters* pRefCounters, IRenderDevice* pDevice, bool bIsDeviceInternal = false ) : + CommandListBase( IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, bool bIsDeviceInternal = false ) : TDeviceObjectBase( pRefCounters, pDevice, CommandListDesc(), bIsDeviceInternal ) {} diff --git a/Graphics/GraphicsEngine/include/DeviceObjectBase.h b/Graphics/GraphicsEngine/include/DeviceObjectBase.h index b7874487..3d98b426 100644 --- a/Graphics/GraphicsEngine/include/DeviceObjectBase.h +++ b/Graphics/GraphicsEngine/include/DeviceObjectBase.h @@ -35,13 +35,8 @@ namespace Diligent { -template -class RenderDeviceBase; - -class IRenderDevice; - /// Template class implementing base functionality for a device object -template +template class DeviceObjectBase : public ObjectBase { public: @@ -53,15 +48,15 @@ public: /// \param bIsDeviceInternal - flag indicating if the object is an internal device object /// and must not keep a strong reference to the device. DeviceObjectBase( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceImplType* pDevice, const ObjectDescType& ObjDesc, bool bIsDeviceInternal = false) : TBase(pRefCounters), // Do not keep strong reference to the device if the object is an internal device object - m_spDevice( bIsDeviceInternal ? nullptr : pDevice ), - m_pDevice( pDevice ), + m_spDevice (bIsDeviceInternal ? nullptr : pDevice), + m_pDevice (pDevice), m_ObjectNameCopy(ObjDesc.Name ? ObjDesc.Name : ThisToString()), - m_Desc( ObjDesc ) + m_Desc (ObjDesc) { m_Desc.Name = m_ObjectNameCopy.c_str(); @@ -95,10 +90,16 @@ public: // 4. RefCountersImpl::ObjectWrapperBase::DestroyObject() calls // m_pAllocator->Free(m_pObject) - crash! - // We must keep the device alive while the object is being destroyed - RefCntAutoPtr pDevice(m_spDevice); - // Note that internal device object do not keep strong reference to the device - return TBase::Release(); + RefCntAutoPtr pDevice; + return ValidatedCast(this->GetReferenceCounters())-> + ReleaseStrongRef( + [&]() + { + // We must keep the device alive while the object is being destroyed + // Note that internal device objects do not keep strong reference to the device + pDevice = m_spDevice; + } + ); } IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_DeviceObject, TBase ) @@ -119,20 +120,16 @@ public: return m_UniqueID.GetID(); } - IRenderDevice* GetDevice()const{return m_pDevice;} + RenderDeviceImplType* GetDevice()const{return m_pDevice;} - template - Type* GetDevice()const{return ValidatedCast(m_pDevice);} - private: /// Strong reference to the device - RefCntAutoPtr m_spDevice; + RefCntAutoPtr m_spDevice; +protected: /// Pointer to the device - IRenderDevice* m_pDevice; + RenderDeviceImplType* const m_pDevice; -protected: - /// Copy of a device object name. /// When new object is created, its description structure is copied diff --git a/Graphics/GraphicsEngine/include/FenceBase.h b/Graphics/GraphicsEngine/include/FenceBase.h index f743d157..494960d5 100644 --- a/Graphics/GraphicsEngine/include/FenceBase.h +++ b/Graphics/GraphicsEngine/include/FenceBase.h @@ -41,18 +41,19 @@ class IFence; /// \tparam BaseInterface - base interface that this class will inheret /// (Diligent::IFenceD3D11, Diligent::IFenceD3D12, /// Diligent::IFenceGL or Diligent::IFenceVk). -template -class FenceBase : public DeviceObjectBase +/// \tparam RenderDeviceImplType - type of the render device implementation +template +class FenceBase : public DeviceObjectBase { public: - typedef DeviceObjectBase TDeviceObjectBase; + typedef DeviceObjectBase TDeviceObjectBase; /// \param pRefCounters - reference counters object that controls the lifetime of this command list. /// \param Desc - fence description /// \param pDevice - pointer to the device. /// \param bIsDeviceInternal - flag indicating if the Fence is an internal device object and /// must not keep a strong reference to the device. - FenceBase( IReferenceCounters* pRefCounters, IRenderDevice* pDevice, const FenceDesc& Desc, bool bIsDeviceInternal = false ) : + FenceBase( IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, const FenceDesc& Desc, bool bIsDeviceInternal = false ) : TDeviceObjectBase( pRefCounters, pDevice, Desc, bIsDeviceInternal ) {} diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.h b/Graphics/GraphicsEngine/include/PipelineStateBase.h index 62e8bf91..5a8f6a65 100644 --- a/Graphics/GraphicsEngine/include/PipelineStateBase.h +++ b/Graphics/GraphicsEngine/include/PipelineStateBase.h @@ -41,15 +41,14 @@ namespace Diligent /// \tparam BaseInterface - base interface that this class will inheret /// (Diligent::IPipelineStateD3D11, Diligent::IPipelineStateD3D12, /// Diligent::IPipelineStateGL or Diligent::IPipelineStateVk). -/// \tparam RenderDeviceBaseInterface - base interface for the render device -/// (Diligent::IRenderDeviceD3D11, Diligent::IRenderDeviceD3D12, -/// Diligent::IRenderDeviceGL, Diligent::IRenderDeviceGLES or Diligent::IRenderDeviceVk). -template -class PipelineStateBase : public DeviceObjectBase +/// \tparam RenderDeviceImplType - type of the render device implementation +/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, +/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) +template +class PipelineStateBase : public DeviceObjectBase { public: - typedef DeviceObjectBase TDeviceObjectBase; - typedef RenderDeviceBase < RenderDeviceBaseInterface > TRenderDeviceBase; + using TDeviceObjectBase = DeviceObjectBase; /// \param pRefCounters - reference counters object that controls the lifetime of this PSO /// \param pDevice - pointer to the device. @@ -57,7 +56,7 @@ public: /// \param bIsDeviceInternal - flag indicating if the blend state is an internal device object and /// must not keep a strong reference to the device. PipelineStateBase( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceImplType* pDevice, const PipelineStateDesc& PSODesc, bool bIsDeviceInternal = false ) : TDeviceObjectBase( pRefCounters, pDevice, PSODesc, bIsDeviceInternal ), diff --git a/Graphics/GraphicsEngine/include/RenderDeviceBase.h b/Graphics/GraphicsEngine/include/RenderDeviceBase.h index 70cf4707..db7234e4 100644 --- a/Graphics/GraphicsEngine/include/RenderDeviceBase.h +++ b/Graphics/GraphicsEngine/include/RenderDeviceBase.h @@ -182,7 +182,7 @@ class RenderDeviceBase : public ObjectBase { public: - typedef ObjectBase TObjectBase; + using TObjectBase = ObjectBase; /// \param pRefCounters - reference counters object that controls the lifetime of this render device /// \param RawMemAllocator - allocator that will be used to allocate memory for all device objects (including render device itself) @@ -282,6 +282,13 @@ public: IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_RenderDevice, ObjectBase ) + // It is important to have final implementation of Release() method to avoid + // virtual calls + inline virtual IReferenceCounters::CounterValueType Release()override final + { + return TObjectBase::Release(); + } + /// Implementation of IRenderDevice::CreateResourceMapping(). virtual void CreateResourceMapping( const ResourceMappingDesc &MappingDesc, IResourceMapping **ppMapping )override final; diff --git a/Graphics/GraphicsEngine/include/SamplerBase.h b/Graphics/GraphicsEngine/include/SamplerBase.h index c6e69c7e..49772c5d 100644 --- a/Graphics/GraphicsEngine/include/SamplerBase.h +++ b/Graphics/GraphicsEngine/include/SamplerBase.h @@ -38,22 +38,21 @@ namespace Diligent /// \tparam BaseInterface - base interface that this class will inheret /// (Diligent::ISamplerD3D11, Diligent::ISamplerD3D12, /// Diligent::ISamplerGL or Diligent::ISamplerVk). -/// \tparam RenderDeviceBaseInterface - base interface for the render device -/// (Diligent::IRenderDeviceD3D11, Diligent::IRenderDeviceD3D12, Diligent::IRenderDeviceGL, -/// Diligent::IRenderDeviceGLES or Diligent::IRenderDeviceVk). -template -class SamplerBase : public DeviceObjectBase +/// \tparam RenderDeviceImplType - type of the render device implementation +/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, +/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) +template +class SamplerBase : public DeviceObjectBase { public: - typedef DeviceObjectBase TDeviceObjectBase; - typedef RenderDeviceBase TRenderDeviceBase; + using TDeviceObjectBase = DeviceObjectBase; /// \param pRefCounters - reference counters object that controls the lifetime of this sampler. /// \param pDevice - pointer to the device. /// \param SamDesc - sampler description. /// \param bIsDeviceInternal - flag indicating if the sampler is an internal device object and /// must not keep a strong reference to the device. - SamplerBase( IReferenceCounters* pRefCounters, IRenderDevice* pDevice, const SamplerDesc& SamDesc, bool bIsDeviceInternal = false ) : + SamplerBase( IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, const SamplerDesc& SamDesc, bool bIsDeviceInternal = false ) : TDeviceObjectBase( pRefCounters, pDevice, SamDesc, bIsDeviceInternal ) {} @@ -61,7 +60,7 @@ public: { /// \note Destructor cannot directly remove the object from the registry as this may cause a /// deadlock. - auto &SamplerRegistry = static_cast(this->GetDevice())->GetSamplerRegistry(); + auto &SamplerRegistry = this->GetDevice()->GetSamplerRegistry(); SamplerRegistry.ReportDeletedObject(); } diff --git a/Graphics/GraphicsEngine/include/ShaderBase.h b/Graphics/GraphicsEngine/include/ShaderBase.h index 7db44cfe..c62dc0bb 100644 --- a/Graphics/GraphicsEngine/include/ShaderBase.h +++ b/Graphics/GraphicsEngine/include/ShaderBase.h @@ -187,21 +187,21 @@ struct DummyShaderVariable : ShaderVariableBase /// \tparam BaseInterface - base interface that this class will inheret /// (Diligent::IShaderD3D11, Diligent::IShaderD3D12, /// Diligent::IShaderGL or Diligent::IShaderVk). -/// \tparam RenderDeviceBaseInterface - base interface for the render device -/// (Diligent::IRenderDeviceD3D11, Diligent::IRenderDeviceD3D12, -/// Diligent::IRenderDeviceGL, Diligent::IRenderDeviceGLES or Diligent::IRenderDeviceVk). -template -class ShaderBase : public DeviceObjectBase +/// \tparam RenderDeviceImplType - type of the render device implementation +/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, +/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) +template +class ShaderBase : public DeviceObjectBase { public: - typedef DeviceObjectBase TDeviceObjectBase; + using TDeviceObjectBase = DeviceObjectBase; /// \param pRefCounters - reference counters object that controls the lifetime of this shader. /// \param pDevice - pointer to the device. /// \param ShdrDesc - shader description. /// \param bIsDeviceInternal - flag indicating if the shader is an internal device object and /// must not keep a strong reference to the device. - ShaderBase( IReferenceCounters* pRefCounters, IRenderDevice* pDevice, const ShaderDesc& ShdrDesc, bool bIsDeviceInternal = false ) : + ShaderBase( IReferenceCounters* pRefCounters, RenderDeviceImplType* pDevice, const ShaderDesc& ShdrDesc, bool bIsDeviceInternal = false ) : TDeviceObjectBase( pRefCounters, pDevice, ShdrDesc, bIsDeviceInternal ), m_DummyShaderVar(*this), m_VariablesDesc (ShdrDesc.NumVariables, ShaderVariableDesc(), STD_ALLOCATOR_RAW_MEM(ShaderVariableDesc, GetRawAllocator(), "Allocator for vector") ), diff --git a/Graphics/GraphicsEngine/include/TextureBase.h b/Graphics/GraphicsEngine/include/TextureBase.h index c9abf042..a4b19b21 100644 --- a/Graphics/GraphicsEngine/include/TextureBase.h +++ b/Graphics/GraphicsEngine/include/TextureBase.h @@ -46,15 +46,18 @@ void VliadateCopyTextureDataParams( const TextureDesc& SrcTexDesc, Uint32 SrcMip /// \tparam BaseInterface - base interface that this class will inheret /// (Diligent::ITextureD3D11, Diligent::ITextureD3D12, /// Diligent::ITextureGL or Diligent::ITextureVk). +/// \tparam TRenderDeviceImpl - type of the render device implementation +/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, +/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) /// \tparam TTextureViewImpl - type of the texture view implementation /// (Diligent::TextureViewD3D11Impl, Diligent::TextureViewD3D12Impl, /// Diligent::TextureViewGLImpl or Diligent::TextureViewVkImpl). /// \tparam TTexViewObjAllocator - type of the allocator that is used to allocate memory for the texture view object instances -template -class TextureBase : public DeviceObjectBase +template +class TextureBase : public DeviceObjectBase { public: - typedef DeviceObjectBase TDeviceObjectBase; + using TDeviceObjectBase = DeviceObjectBase; /// \param pRefCounters - reference counters object that controls the lifetime of this texture. /// \param TexViewObjAllocator - allocator that is used to allocate memory for the instances of the texture view object. @@ -65,7 +68,7 @@ public: /// must not keep a strong reference to the device TextureBase( IReferenceCounters* pRefCounters, TTexViewObjAllocator& TexViewObjAllocator, - IRenderDevice* pDevice, + TRenderDeviceImpl* pDevice, const TextureDesc& Desc, bool bIsDeviceInternal = false ) : TDeviceObjectBase( pRefCounters, pDevice, Desc, bIsDeviceInternal ), @@ -182,8 +185,8 @@ protected: }; -template -void TextureBase :: CorrectTextureViewDesc(struct TextureViewDesc& ViewDesc) +template +void TextureBase :: CorrectTextureViewDesc(struct TextureViewDesc& ViewDesc) { #define TEX_VIEW_VALIDATION_ERROR(...) LOG_ERROR_AND_THROW( "Texture view \"", ViewDesc.Name ? ViewDesc.Name : "", "\": ", ##__VA_ARGS__ ) @@ -389,8 +392,8 @@ void TextureBase :: Corre } } -template -void TextureBase :: CreateDefaultViews() +template +void TextureBase :: CreateDefaultViews() { const auto& TexFmtAttribs = GetTextureFormatAttribs(this->m_Desc.Format); if (TexFmtAttribs.ComponentType == COMPONENT_TYPE_UNDEFINED) @@ -442,14 +445,14 @@ void TextureBase :: Creat } -template -void TextureBase :: UpdateData( IDeviceContext* pContext, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData ) +template +void TextureBase :: UpdateData( IDeviceContext* pContext, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData ) { ValidateUpdateDataParams( this->m_Desc, MipLevel, Slice, DstBox, SubresData ); } -template -void TextureBase :: CopyData( +template +void TextureBase :: CopyData( IDeviceContext* pContext, ITexture* pSrcTexture, Uint32 SrcMipLevel, @@ -467,13 +470,13 @@ void TextureBase :: CopyD this->GetDesc(), DstMipLevel, DstSlice, DstX, DstY, DstZ ); } -template -void TextureBase :: Map( IDeviceContext* pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags, MappedTextureSubresource &MappedData ) +template +void TextureBase :: Map( IDeviceContext* pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags, MappedTextureSubresource &MappedData ) { } -template -void TextureBase :: Unmap( IDeviceContext* pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags ) +template +void TextureBase :: Unmap( IDeviceContext* pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags ) { } diff --git a/Graphics/GraphicsEngine/include/TextureViewBase.h b/Graphics/GraphicsEngine/include/TextureViewBase.h index 0837b962..722c544e 100644 --- a/Graphics/GraphicsEngine/include/TextureViewBase.h +++ b/Graphics/GraphicsEngine/include/TextureViewBase.h @@ -39,11 +39,14 @@ namespace Diligent /// \tparam BaseInterface - base interface that this class will inheret /// (Diligent::ITextureViewD3D11, Diligent::ITextureViewD3D12, /// Diligent::ITextureViewGL or Diligent::ITextureViewVk). -template -class TextureViewBase : public DeviceObjectBase +/// \tparam RenderDeviceImplType - type of the render device implementation +/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, +/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) +template +class TextureViewBase : public DeviceObjectBase { public: - typedef DeviceObjectBase TDeviceObjectBase; + using TDeviceObjectBase = DeviceObjectBase; /// \param pRefCounters - reference counters object that controls the lifetime of this texture view. @@ -54,7 +57,7 @@ public: /// part of the texture object. In this case the view will attach /// to the texture's reference counters. TextureViewBase( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceImplType* pDevice, const TextureViewDesc& ViewDesc, class ITexture* pTexture, bool bIsDefaultView ) : diff --git a/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h index 1a37c0d8..b2b09730 100644 --- a/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/BufferD3D11Impl.h @@ -30,6 +30,7 @@ #include "RenderDeviceD3D11.h" #include "BufferBase.h" #include "BufferViewD3D11Impl.h" +#include "RenderDeviceD3D11Impl.h" namespace Diligent { @@ -48,10 +49,10 @@ enum class D3D11BufferState }; /// Implementation of the Diligent::IBufferD3D11 interface -class BufferD3D11Impl : public BufferBase +class BufferD3D11Impl : public BufferBase { public: - using TBufferBase = BufferBase; + using TBufferBase = BufferBase; BufferD3D11Impl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, diff --git a/Graphics/GraphicsEngineD3D11/include/BufferViewD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/BufferViewD3D11Impl.h index 7b875fa8..f1f48b93 100644 --- a/Graphics/GraphicsEngineD3D11/include/BufferViewD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/BufferViewD3D11Impl.h @@ -29,19 +29,20 @@ #include "BufferViewD3D11.h" #include "RenderDeviceD3D11.h" #include "BufferViewBase.h" +#include "RenderDeviceD3D11Impl.h" namespace Diligent { class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IBufferViewD3D11 interface -class BufferViewD3D11Impl : public BufferViewBase +class BufferViewD3D11Impl : public BufferViewBase { public: - using TBufferViewBase = BufferViewBase; + using TBufferViewBase = BufferViewBase; BufferViewD3D11Impl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceD3D11Impl* pDevice, const BufferViewDesc& ViewDesc, class IBuffer* pBuffer, ID3D11View* pD3D11View, diff --git a/Graphics/GraphicsEngineD3D11/include/CommandListD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/CommandListD3D11Impl.h index 24235560..6dbe28bb 100644 --- a/Graphics/GraphicsEngineD3D11/include/CommandListD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/CommandListD3D11Impl.h @@ -28,6 +28,7 @@ #include "RenderDeviceD3D11.h" #include "CommandListBase.h" +#include "RenderDeviceD3D11Impl.h" namespace Diligent { @@ -35,14 +36,14 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Implementation of the Diligent::ICommandListD3D11 interface -class CommandListD3D11Impl : public CommandListBase +class CommandListD3D11Impl : public CommandListBase { public: - using TCommandListBase = CommandListBase; + using TCommandListBase = CommandListBase; - CommandListD3D11Impl(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - ID3D11CommandList* pd3d11CommandList); + CommandListD3D11Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D11Impl* pDevice, + ID3D11CommandList* pd3d11CommandList); ~CommandListD3D11Impl(); ID3D11CommandList *GetD3D11CommandList(){ return m_pd3d11CommandList; } diff --git a/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h index 618a3e63..0b84cbae 100644 --- a/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/FenceD3D11Impl.h @@ -30,6 +30,7 @@ #include "FenceD3D11.h" #include "RenderDeviceD3D11.h" #include "FenceBase.h" +#include "RenderDeviceD3D11Impl.h" namespace Diligent { @@ -37,14 +38,14 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IFenceD3D11 interface -class FenceD3D11Impl : public FenceBase +class FenceD3D11Impl : public FenceBase { public: - using TFenceBase = FenceBase; + using TFenceBase = FenceBase; - FenceD3D11Impl(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - const FenceDesc& Desc); + FenceD3D11Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D11Impl* pDevice, + const FenceDesc& Desc); ~FenceD3D11Impl(); virtual Uint64 GetCompletedValue()override final; diff --git a/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.h index 04d0d8e6..d52d66f2 100644 --- a/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.h @@ -31,16 +31,17 @@ #include "PipelineStateBase.h" #include "ShaderD3D11Impl.h" #include "SRBMemoryAllocator.h" +#include "RenderDeviceD3D11Impl.h" namespace Diligent { class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IPipelineStateD3D11 interface -class PipelineStateD3D11Impl : public PipelineStateBase +class PipelineStateD3D11Impl : public PipelineStateBase { public: - using TPipelineStateBase = PipelineStateBase; + using TPipelineStateBase = PipelineStateBase; PipelineStateD3D11Impl(IReferenceCounters* pRefCounters, class RenderDeviceD3D11Impl* pDeviceD3D11, diff --git a/Graphics/GraphicsEngineD3D11/include/SamplerD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/SamplerD3D11Impl.h index 2d060515..58b7250a 100644 --- a/Graphics/GraphicsEngineD3D11/include/SamplerD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/SamplerD3D11Impl.h @@ -29,16 +29,17 @@ #include "SamplerD3D11.h" #include "RenderDeviceD3D11.h" #include "SamplerBase.h" +#include "RenderDeviceD3D11Impl.h" namespace Diligent { class FixedBlockMemoryAllocator; /// Implementation of the Diligent::ISamplerD3D11 interface -class SamplerD3D11Impl : public SamplerBase +class SamplerD3D11Impl : public SamplerBase { public: - using TSamplerBase = SamplerBase; + using TSamplerBase = SamplerBase; SamplerD3D11Impl(IReferenceCounters* pRefCounters, class RenderDeviceD3D11Impl* pRenderDeviceD3D11, diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.h index 53d6d209..23f22ffc 100644 --- a/Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/ShaderD3D11Impl.h @@ -34,6 +34,7 @@ #include "ShaderResourceCacheD3D11.h" #include "EngineD3D11Defines.h" #include "ShaderResourcesD3D11.h" +#include "RenderDeviceD3D11Impl.h" namespace Diligent { @@ -42,10 +43,10 @@ class FixedBlockMemoryAllocator; class ResourceMapping; /// Implementation of the Diligent::IShaderD3D11 interface -class ShaderD3D11Impl : public ShaderBase, public ShaderD3DBase +class ShaderD3D11Impl : public ShaderBase, public ShaderD3DBase { public: - using TShaderBase = ShaderBase; + using TShaderBase = ShaderBase; ShaderD3D11Impl(IReferenceCounters* pRefCounters, class RenderDeviceD3D11Impl* pRenderDeviceD3D11, diff --git a/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h b/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h index dcd58c0d..1284c52e 100644 --- a/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h +++ b/Graphics/GraphicsEngineD3D11/include/TextureBaseD3D11.h @@ -30,6 +30,7 @@ #include "RenderDeviceD3D11.h" #include "TextureBase.h" #include "TextureViewD3D11Impl.h" +#include "RenderDeviceD3D11Impl.h" namespace Diligent { @@ -47,10 +48,10 @@ enum class D3D11TextureState }; /// Base implementation of the Diligent::ITextureD3D11 interface -class TextureBaseD3D11 : public TextureBase +class TextureBaseD3D11 : public TextureBase { public: - typedef TextureBase TTextureBase; + typedef TextureBase TTextureBase; TextureBaseD3D11(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, diff --git a/Graphics/GraphicsEngineD3D11/include/TextureViewD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/TextureViewD3D11Impl.h index b4882089..9fcdf352 100644 --- a/Graphics/GraphicsEngineD3D11/include/TextureViewD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/TextureViewD3D11Impl.h @@ -29,6 +29,7 @@ #include "TextureViewD3D11.h" #include "RenderDeviceD3D11.h" #include "TextureViewBase.h" +#include "RenderDeviceD3D11Impl.h" namespace Diligent { @@ -36,13 +37,13 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Implementation of the Diligent::ITextureViewD3D11 interface -class TextureViewD3D11Impl : public TextureViewBase +class TextureViewD3D11Impl : public TextureViewBase { public: - using TTextureViewBase = TextureViewBase; + using TTextureViewBase = TextureViewBase; TextureViewD3D11Impl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceD3D11Impl* pDevice, const TextureViewDesc& ViewDesc, class ITexture* pTexture, ID3D11View* pD3D11View, diff --git a/Graphics/GraphicsEngineD3D11/src/BufferViewD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/BufferViewD3D11Impl.cpp index f500e9c1..10d8bbc1 100644 --- a/Graphics/GraphicsEngineD3D11/src/BufferViewD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/BufferViewD3D11Impl.cpp @@ -27,12 +27,12 @@ namespace Diligent { -BufferViewD3D11Impl::BufferViewD3D11Impl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - const BufferViewDesc& ViewDesc, - IBuffer* pBuffer, - ID3D11View* pD3D11View, - bool bIsDefaultView ) : +BufferViewD3D11Impl::BufferViewD3D11Impl( IReferenceCounters* pRefCounters, + RenderDeviceD3D11Impl* pDevice, + const BufferViewDesc& ViewDesc, + IBuffer* pBuffer, + ID3D11View* pD3D11View, + bool bIsDefaultView ) : TBufferViewBase( pRefCounters, pDevice, ViewDesc, pBuffer, bIsDefaultView ), m_pD3D11View( pD3D11View ) { diff --git a/Graphics/GraphicsEngineD3D11/src/CommandListD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/CommandListD3D11Impl.cpp index c415c998..06e476c1 100644 --- a/Graphics/GraphicsEngineD3D11/src/CommandListD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/CommandListD3D11Impl.cpp @@ -30,9 +30,9 @@ namespace Diligent { -CommandListD3D11Impl :: CommandListD3D11Impl(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - ID3D11CommandList* pd3d11CommandList) : +CommandListD3D11Impl :: CommandListD3D11Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D11Impl* pDevice, + ID3D11CommandList* pd3d11CommandList) : TCommandListBase(pRefCounters, pDevice), m_pd3d11CommandList(pd3d11CommandList) { diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index a36260ef..da8ac073 100644 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -1256,7 +1256,8 @@ namespace Diligent // ID3D11DeviceContext::ClearState() was called. &pd3d11CmdList); - CommandListD3D11Impl* pCmdListD3D11( NEW_RC_OBJ(m_CmdListAllocator, "CommandListD3D11Impl instance", CommandListD3D11Impl)(m_pDevice, pd3d11CmdList) ); + auto* pDeviceD3D11Impl = m_pDevice.RawPtr(); + CommandListD3D11Impl* pCmdListD3D11( NEW_RC_OBJ(m_CmdListAllocator, "CommandListD3D11Impl instance", CommandListD3D11Impl)(pDeviceD3D11Impl, pd3d11CmdList) ); pCmdListD3D11->QueryInterface( IID_CommandList, reinterpret_cast(ppCommandList) ); // Device context is now in default state diff --git a/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp index 81d288be..950f13e5 100644 --- a/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/FenceD3D11Impl.cpp @@ -30,9 +30,9 @@ namespace Diligent { -FenceD3D11Impl :: FenceD3D11Impl(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, - const FenceDesc& Desc) : +FenceD3D11Impl :: FenceD3D11Impl(IReferenceCounters* pRefCounters, + RenderDeviceD3D11Impl* pDevice, + const FenceDesc& Desc) : TFenceBase(pRefCounters, pDevice, Desc) { } diff --git a/Graphics/GraphicsEngineD3D11/src/TextureViewD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/TextureViewD3D11Impl.cpp index f24e2661..9af2324c 100644 --- a/Graphics/GraphicsEngineD3D11/src/TextureViewD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/TextureViewD3D11Impl.cpp @@ -29,7 +29,7 @@ namespace Diligent { TextureViewD3D11Impl::TextureViewD3D11Impl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceD3D11Impl* pDevice, const TextureViewDesc& ViewDesc, ITexture* pTexture, ID3D11View* pD3D11View, 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, diff --git a/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.h index eb3b2de5..69b6d7f9 100644 --- a/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.h @@ -29,7 +29,7 @@ #include "AsyncWritableResource.h" #include "BaseInterfacesGL.h" #include "BufferViewGLImpl.h" - +#include "RenderDeviceGLImpl.h" namespace Diligent { @@ -37,14 +37,14 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IBufferGL interface -class BufferGLImpl : public BufferBase, public AsyncWritableResource +class BufferGLImpl : public BufferBase, public AsyncWritableResource { public: - using TBufferBase = BufferBase; + using TBufferBase = BufferBase; BufferGLImpl(IReferenceCounters *pRefCounters, FixedBlockMemoryAllocator &BuffViewObjMemAllocator, - class RenderDeviceGLImpl *pDeviceGL, + RenderDeviceGLImpl *pDeviceGL, const BufferDesc& BuffDesc, const BufferData& BuffData, bool bIsDeviceInternal); diff --git a/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.h index 28cca382..f30e44b7 100644 --- a/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.h @@ -28,6 +28,7 @@ #include "BufferViewBase.h" #include "RenderDevice.h" #include "GLObjectWrapper.h" +#include "RenderDeviceGLImpl.h" namespace Diligent { @@ -39,13 +40,13 @@ class BufferGLImpl; struct BufferViewDesc; /// Implementation of the Diligent::IBufferViewGL interface -class BufferViewGLImpl : public BufferViewBase +class BufferViewGLImpl : public BufferViewBase { public: - using TBuffViewBase = BufferViewBase; + using TBuffViewBase = BufferViewBase; BufferViewGLImpl( IReferenceCounters *pRefCounters, - IRenderDevice *pDevice, + RenderDeviceGLImpl *pDevice, IDeviceContext *pContext, const BufferViewDesc& ViewDesc, BufferGLImpl *pBuffer, diff --git a/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h index e62a2a5c..a87e8eb1 100644 --- a/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.h @@ -31,6 +31,7 @@ #include "RenderDeviceGL.h" #include "FenceBase.h" #include "GLObjectWrapper.h" +#include "RenderDeviceGLImpl.h" namespace Diligent { @@ -38,13 +39,13 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IFenceGL interface -class FenceGLImpl : public FenceBase +class FenceGLImpl : public FenceBase { public: - using TFenceBase = FenceBase; + using TFenceBase = FenceBase; FenceGLImpl(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceGLImpl* pDevice, const FenceDesc& Desc); ~FenceGLImpl(); diff --git a/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.h index 6e48b7b8..6730e89e 100644 --- a/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.h @@ -29,6 +29,7 @@ #include "GLProgram.h" #include "GLObjectWrapper.h" #include "GLContext.h" +#include "RenderDeviceGLImpl.h" namespace Diligent { @@ -36,12 +37,12 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IPipelineStateGL interface -class PipelineStateGLImpl : public PipelineStateBase +class PipelineStateGLImpl : public PipelineStateBase { public: - using TPipelineStateBase = PipelineStateBase; + using TPipelineStateBase = PipelineStateBase; - PipelineStateGLImpl(IReferenceCounters *pRefCounters, class RenderDeviceGLImpl *pDeviceGL, const PipelineStateDesc& PipelineDesc, bool IsDeviceInternal = false); + PipelineStateGLImpl(IReferenceCounters *pRefCounters, RenderDeviceGLImpl *pDeviceGL, const PipelineStateDesc& PipelineDesc, bool IsDeviceInternal = false); ~PipelineStateGLImpl(); /// Queries the specific interface, see IObject::QueryInterface() for details diff --git a/Graphics/GraphicsEngineOpenGL/include/SamplerGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/SamplerGLImpl.h index 19e3a480..b2b33392 100644 --- a/Graphics/GraphicsEngineOpenGL/include/SamplerGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/SamplerGLImpl.h @@ -28,18 +28,19 @@ #include "SamplerBase.h" #include "RenderDevice.h" #include "GLObjectWrapper.h" +#include "RenderDeviceGLImpl.h" namespace Diligent { class FixedBlockMemoryAllocator; /// Implementation of the Diligent::ISamplerGL interface -class SamplerGLImpl : public SamplerBase +class SamplerGLImpl : public SamplerBase { public: - using TSamplerBase = SamplerBase; + using TSamplerBase = SamplerBase; - SamplerGLImpl( IReferenceCounters *pRefCounters, class RenderDeviceGLImpl *pDeviceGL, const SamplerDesc& SamplerDesc, bool bIsDeviceInternal = false ); + SamplerGLImpl( IReferenceCounters *pRefCounters, RenderDeviceGLImpl *pDeviceGL, const SamplerDesc& SamplerDesc, bool bIsDeviceInternal = false ); ~SamplerGLImpl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface ); diff --git a/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.h index cf0116c5..cfdad4fd 100644 --- a/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.h @@ -29,6 +29,7 @@ #include "RenderDevice.h" #include "GLObjectWrapper.h" #include "GLProgram.h" +#include "RenderDeviceGLImpl.h" namespace Diligent { @@ -64,12 +65,12 @@ inline GLenum ShaderTypeToGLShaderBit(SHADER_TYPE ShaderType) } /// Implementation of the Diligent::IShaderGL interface -class ShaderGLImpl : public ShaderBase +class ShaderGLImpl : public ShaderBase { public: - using TShaderBase = ShaderBase; + using TShaderBase = ShaderBase; - ShaderGLImpl( IReferenceCounters *pRefCounters, class RenderDeviceGLImpl *pDeviceGL, const ShaderCreationAttribs &ShaderCreationAttribs, bool bIsDeviceInternal = false ); + ShaderGLImpl( IReferenceCounters *pRefCounters, RenderDeviceGLImpl *pDeviceGL, const ShaderCreationAttribs &ShaderCreationAttribs, bool bIsDeviceInternal = false ); ~ShaderGLImpl(); virtual void BindResources( IResourceMapping* pResourceMapping, Uint32 Flags )override; diff --git a/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.h b/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.h index f8be69c2..1af707a0 100644 --- a/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.h +++ b/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.h @@ -30,7 +30,7 @@ #include "GLObjectWrapper.h" #include "TextureViewGLImpl.h" #include "AsyncWritableResource.h" - +#include "RenderDeviceGLImpl.h" namespace Diligent { @@ -38,14 +38,14 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Base implementation of the Diligent::ITextureGL interface -class TextureBaseGL : public TextureBase, public AsyncWritableResource +class TextureBaseGL : public TextureBase, public AsyncWritableResource { public: - using TTextureBase = TextureBase; + using TTextureBase = TextureBase; TextureBaseGL(IReferenceCounters *pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceGLImpl *pDeviceGL, + RenderDeviceGLImpl *pDeviceGL, const TextureDesc &TexDesc, GLenum BindTarget, const TextureData &InitData = TextureData(), diff --git a/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.h index 8675a86c..3bff9a36 100644 --- a/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.h @@ -28,23 +28,24 @@ #include "TextureViewBase.h" #include "RenderDevice.h" #include "GLObjectWrapper.h" +#include "RenderDeviceGLImpl.h" namespace Diligent { class FixedBlockMemoryAllocator; /// Implementation of the Diligent::ITextureViewGL interface -class TextureViewGLImpl : public TextureViewBase +class TextureViewGLImpl : public TextureViewBase { public: - using TTextureViewBase = TextureViewBase; + using TTextureViewBase = TextureViewBase; TextureViewGLImpl(IReferenceCounters *pRefCounters, - class IRenderDevice *pDevice, - const struct TextureViewDesc& ViewDesc, - class TextureBaseGL *pTexture, - bool bCreateGLViewTex, - bool bIsDefaultView ); + RenderDeviceGLImpl *pDevice, + const struct TextureViewDesc& ViewDesc, + class TextureBaseGL *pTexture, + bool bCreateGLViewTex, + bool bIsDefaultView ); ~TextureViewGLImpl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override; diff --git a/Graphics/GraphicsEngineOpenGL/include/VAOCache.h b/Graphics/GraphicsEngineOpenGL/include/VAOCache.h index 2160d97f..26e34299 100644 --- a/Graphics/GraphicsEngineOpenGL/include/VAOCache.h +++ b/Graphics/GraphicsEngineOpenGL/include/VAOCache.h @@ -31,7 +31,6 @@ #include "HashUtils.h" #include "DeviceContextBase.h" #include "BaseInterfacesGL.h" -#include "BufferGLImpl.h" namespace Diligent { @@ -51,7 +50,7 @@ public: const GLObjectWrappers::GLVertexArrayObj& GetVAO( IPipelineState *pPSO, IBuffer *pIndexBuffer, - VertexStreamInfo VertexStreams[], + VertexStreamInfo VertexStreams[], Uint32 NumVertexStreams, class GLContextState &GLContextState); const GLObjectWrappers::GLVertexArrayObj& GetEmptyVAO(); diff --git a/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp index 46ee6ca2..51e2e2e1 100644 --- a/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp @@ -32,7 +32,7 @@ namespace Diligent { BufferViewGLImpl::BufferViewGLImpl( IReferenceCounters *pRefCounters, - IRenderDevice *pDevice, + RenderDeviceGLImpl *pDevice, IDeviceContext *pContext, const BufferViewDesc& ViewDesc, BufferGLImpl* pBuffer, diff --git a/Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp index 3c222b41..ae284154 100644 --- a/Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/FenceGLImpl.cpp @@ -30,7 +30,7 @@ namespace Diligent { FenceGLImpl :: FenceGLImpl(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceGLImpl* pDevice, const FenceDesc& Desc) : TFenceBase(pRefCounters, pDevice, Desc) { diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureViewGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureViewGLImpl.cpp index c955a33c..60b94439 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureViewGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureViewGLImpl.cpp @@ -31,7 +31,7 @@ namespace Diligent { TextureViewGLImpl::TextureViewGLImpl( IReferenceCounters *pRefCounters, - IRenderDevice *pDevice, + RenderDeviceGLImpl *pDevice, const TextureViewDesc& ViewDesc, TextureBaseGL* pTexture, bool bCreateGLViewTex, diff --git a/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h b/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h index 5d6671ce..1108597d 100644 --- a/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.h @@ -30,6 +30,7 @@ #include "RenderDeviceVk.h" #include "BufferViewBase.h" #include "VulkanUtilities/VulkanObjectWrappers.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { @@ -38,13 +39,13 @@ class FixedBlockMemoryAllocator; class BufferVkImpl; /// Implementation of the Diligent::IBufferViewVk interface -class BufferViewVkImpl : public BufferViewBase +class BufferViewVkImpl : public BufferViewBase { public: - using TBufferViewBase = BufferViewBase; + using TBufferViewBase = BufferViewBase; BufferViewVkImpl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceVkImpl* pDevice, const BufferViewDesc& ViewDesc, class IBuffer* pBuffer, VulkanUtilities::BufferViewWrapper&& BuffView, diff --git a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h index 6b448e1b..e94ed304 100644 --- a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.h @@ -35,6 +35,7 @@ #include "VulkanUtilities/VulkanMemoryManager.h" #include "VulkanDynamicHeap.h" #include "STDAllocator.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { @@ -42,14 +43,14 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IBufferVk interface -class BufferVkImpl : public BufferBase +class BufferVkImpl : public BufferBase { public: - using TBufferBase = BufferBase; + using TBufferBase = BufferBase; BufferVkImpl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, - class RenderDeviceVkImpl* pDeviceVk, + RenderDeviceVkImpl* pDeviceVk, const BufferDesc& BuffDesc, const BufferData& BuffData = BufferData()); diff --git a/Graphics/GraphicsEngineVulkan/include/CommandListVkImpl.h b/Graphics/GraphicsEngineVulkan/include/CommandListVkImpl.h index d4507a28..19051478 100644 --- a/Graphics/GraphicsEngineVulkan/include/CommandListVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/CommandListVkImpl.h @@ -28,18 +28,19 @@ #include "vulkan.h" #include "CommandListBase.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { /// Implementation of the Diligent::ICommandList interface -class CommandListVkImpl : public CommandListBase +class CommandListVkImpl : public CommandListBase { public: - using TCommandListBase = CommandListBase; + using TCommandListBase = CommandListBase; CommandListVkImpl(IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceVkImpl* pDevice, IDeviceContext* pDeferredCtx, VkCommandBuffer vkCmdBuff, Uint64 CommandListNumber) : diff --git a/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h b/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h index fcb5f979..7883d268 100644 --- a/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.h @@ -30,18 +30,18 @@ #include "FenceVk.h" #include "FenceBase.h" #include "VulkanUtilities/VulkanFencePool.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { class FixedBlockMemoryAllocator; -class RenderDeviceVkImpl; /// Implementation of the Diligent::IFenceVk interface -class FenceVkImpl : public FenceBase +class FenceVkImpl : public FenceBase { public: - using TFenceBase = FenceBase; + using TFenceBase = FenceBase; FenceVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pRendeDeviceVkImpl, diff --git a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h index b98dedf5..bb5bdd3f 100644 --- a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h @@ -38,6 +38,7 @@ #include "VulkanUtilities/VulkanObjectWrappers.h" #include "VulkanUtilities/VulkanCommandBuffer.h" #include "PipelineLayout.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { @@ -45,12 +46,12 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IRenderDeviceVk interface -class PipelineStateVkImpl : public PipelineStateBase +class PipelineStateVkImpl : public PipelineStateBase { public: - using TPipelineStateBase = PipelineStateBase; + using TPipelineStateBase = PipelineStateBase; - PipelineStateVkImpl( IReferenceCounters* pRefCounters, class RenderDeviceVkImpl* pDeviceVk, const PipelineStateDesc &PipelineDesc ); + PipelineStateVkImpl( IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pDeviceVk, const PipelineStateDesc &PipelineDesc ); ~PipelineStateVkImpl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject** ppInterface ); diff --git a/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.h b/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.h index c3595b0e..290ce87c 100644 --- a/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.h @@ -30,17 +30,19 @@ #include "RenderDeviceVk.h" #include "SamplerBase.h" #include "VulkanUtilities/VulkanObjectWrappers.h" +#include "RenderDeviceVkImpl.h" + namespace Diligent { class FixedBlockMemoryAllocator; /// Implementation of the Diligent::ISamplerVk interface -class SamplerVkImpl : public SamplerBase +class SamplerVkImpl : public SamplerBase { public: - using TSamplerBase = SamplerBase; + using TSamplerBase = SamplerBase; - SamplerVkImpl(IReferenceCounters* pRefCounters, class RenderDeviceVkImpl* pRenderDeviceVk, const SamplerDesc& SamplerDesc); + SamplerVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pRenderDeviceVk, const SamplerDesc& SamplerDesc); ~SamplerVkImpl(); virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override; diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h b/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h index 09d14a9b..c091a46a 100644 --- a/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.h @@ -32,6 +32,7 @@ #include "ShaderResourceLayoutVk.h" #include "SPIRVShaderResources.h" #include "ShaderVariableVk.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { @@ -40,12 +41,12 @@ class ResourceMapping; class FixedBlockMemoryAllocator; /// Implementation of the Diligent::IShaderVk interface -class ShaderVkImpl : public ShaderBase +class ShaderVkImpl : public ShaderBase { public: - using TShaderBase = ShaderBase; + using TShaderBase = ShaderBase; - ShaderVkImpl(IReferenceCounters* pRefCounters, class RenderDeviceVkImpl* pRenderDeviceVk, const ShaderCreationAttribs &CreationAttribs); + ShaderVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pRenderDeviceVk, const ShaderCreationAttribs &CreationAttribs); ~ShaderVkImpl(); //virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override; diff --git a/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.h b/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.h index 9863d6aa..4d283d51 100644 --- a/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.h @@ -30,19 +30,20 @@ #include "RenderDeviceVk.h" #include "TextureViewBase.h" #include "VulkanUtilities/VulkanObjectWrappers.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { class FixedBlockMemoryAllocator; /// Implementation of the Diligent::ITextureViewVk interface -class TextureViewVkImpl : public TextureViewBase +class TextureViewVkImpl : public TextureViewBase { public: - using TTextureViewBase = TextureViewBase; + using TTextureViewBase = TextureViewBase; TextureViewVkImpl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceVkImpl* pDevice, const TextureViewDesc& ViewDesc, class ITexture* pTexture, VulkanUtilities::ImageViewWrapper&& ImgView, diff --git a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h index 825a5f44..b027710a 100644 --- a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.h @@ -31,6 +31,7 @@ #include "TextureBase.h" #include "TextureViewVkImpl.h" #include "VulkanUtilities/VulkanMemoryManager.h" +#include "RenderDeviceVkImpl.h" namespace Diligent { @@ -38,15 +39,15 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Base implementation of the Diligent::ITextureVk interface -class TextureVkImpl : public TextureBase +class TextureVkImpl : public TextureBase { public: - using TTextureBase = TextureBase; + using TTextureBase = TextureBase; // Creates a new Vk resource TextureVkImpl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& TexViewObjAllocator, - class RenderDeviceVkImpl* pDeviceVk, + RenderDeviceVkImpl* pDeviceVk, const TextureDesc& TexDesc, const TextureData& InitData = TextureData()); diff --git a/Graphics/GraphicsEngineVulkan/src/BufferViewVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/BufferViewVkImpl.cpp index fe8778c8..355aae7a 100644 --- a/Graphics/GraphicsEngineVulkan/src/BufferViewVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/BufferViewVkImpl.cpp @@ -30,7 +30,7 @@ namespace Diligent { BufferViewVkImpl::BufferViewVkImpl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceVkImpl* pDevice, const BufferViewDesc& ViewDesc, IBuffer* pBuffer, VulkanUtilities::BufferViewWrapper&& BuffView, @@ -42,8 +42,7 @@ BufferViewVkImpl::BufferViewVkImpl( IReferenceCounters* pRefCou BufferViewVkImpl::~BufferViewVkImpl() { - auto *pDeviceVkImpl = GetDevice(); - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_BuffView)); + m_pDevice->SafeReleaseVkObject(std::move(m_BuffView)); } IMPLEMENT_QUERY_INTERFACE( BufferViewVkImpl, IID_BufferViewVk, TBufferViewBase ) diff --git a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp index 4a55a902..93ac343b 100644 --- a/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/BufferVkImpl.cpp @@ -255,12 +255,11 @@ BufferVkImpl :: BufferVkImpl(IReferenceCounters* pRefCounters, BufferVkImpl :: ~BufferVkImpl() { - auto *pDeviceVkImpl = GetDevice(); // Vk object can only be destroyed when it is no longer used by the GPU if(m_VulkanBuffer != VK_NULL_HANDLE) - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_VulkanBuffer)); + m_pDevice->SafeReleaseVkObject(std::move(m_VulkanBuffer)); if(m_MemoryAllocation.Page != nullptr) - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_MemoryAllocation)); + m_pDevice->SafeReleaseVkObject(std::move(m_MemoryAllocation)); } IMPLEMENT_QUERY_INTERFACE( BufferVkImpl, IID_BufferVk, TBufferBase ) @@ -287,7 +286,6 @@ void BufferVkImpl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapF TBufferBase::Map( pContext, MapType, MapFlags, pMappedData ); auto* pDeviceContextVk = ValidatedCast(pContext); - auto* pDeviceVk = GetDevice(); #ifdef DEVELOPMENT if(pDeviceContextVk != nullptr) m_DvpMapType[pDeviceContextVk->GetContextId()] = std::make_pair(MapType, MapFlags); @@ -299,7 +297,7 @@ void BufferVkImpl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapF #if 0 LOG_WARNING_MESSAGE_ONCE("Mapping CPU buffer for reading on Vk currently requires flushing context and idling GPU"); pDeviceContextVk->Flush(); - pDeviceVk->IdleGPU(false); + m_pDevice->IdleGPU(false); VERIFY(m_Desc.Usage == USAGE_CPU_ACCESSIBLE, "Buffer must be created as USAGE_CPU_ACCESSIBLE to be mapped for reading"); Vk_RANGE MapRange; @@ -346,7 +344,7 @@ void BufferVkImpl :: Map(IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapF if (DynAllocation.pParentDynamicHeap != nullptr) { - const auto& DynamicHeap = pDeviceVk->GetDynamicHeapRingBuffer(); + const auto& DynamicHeap = m_pDevice->GetDynamicHeapRingBuffer(); auto* CPUAddress = DynamicHeap.GetCPUAddress(); pMappedData = CPUAddress + DynAllocation.Offset; } @@ -443,8 +441,7 @@ void BufferVkImpl::CreateViewInternal( const BufferViewDesc& OrigViewDesc, IBuff try { - auto *pDeviceVkImpl = GetDevice(); - auto &BuffViewAllocator = pDeviceVkImpl->GetBuffViewObjAllocator(); + auto& BuffViewAllocator = m_pDevice->GetBuffViewObjAllocator(); VERIFY( &BuffViewAllocator == &m_dbgBuffViewAllocator, "Buff view allocator does not match allocator provided at buffer initialization" ); BufferViewDesc ViewDesc = OrigViewDesc; @@ -482,8 +479,7 @@ VulkanUtilities::BufferViewWrapper BufferVkImpl::CreateView(struct BufferViewDes ViewCI.offset = ViewDesc.ByteOffset; ViewCI.range = ViewDesc.ByteWidth; // size in bytes of the buffer view - auto *pDeviceVkImpl = GetDevice(); - const auto& LogicalDevice = pDeviceVkImpl->GetLogicalDevice(); + const auto& LogicalDevice = m_pDevice->GetLogicalDevice(); BuffView = LogicalDevice.CreateBufferView(ViewCI, ViewDesc.Name); } return BuffView; @@ -496,7 +492,7 @@ VkBuffer BufferVkImpl::GetVkBuffer()const else { VERIFY(m_Desc.Usage == USAGE_DYNAMIC, "Dynamic buffer expected"); - return GetDevice()->GetDynamicHeapRingBuffer().GetVkBuffer(); + return m_pDevice->GetDynamicHeapRingBuffer().GetVkBuffer(); } } @@ -506,7 +502,7 @@ void BufferVkImpl::DvpVerifyDynamicAllocation(Uint32 ContextId)const const auto& DynAlloc = m_DynamicAllocations[ContextId]; if (DynAlloc.pParentDynamicHeap == nullptr) LOG_ERROR_MESSAGE("Dynamic buffer '", m_Desc.Name, "' was not mapped before its first use. Context Id: ", ContextId); - auto CurrentFrame = GetDevice()->GetCurrentFrameNumber(); + auto CurrentFrame = m_pDevice->GetCurrentFrameNumber(); if (DynAlloc.dbgFrameNumber != CurrentFrame) LOG_ERROR_MESSAGE("Dynamic allocation is out-of-date. Dynamic buffer '", m_Desc.Name, "' must be mapped in the same frame it is used."); } diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index ba888614..dc04f2a2 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -1217,8 +1217,9 @@ namespace Diligent auto err = vkEndCommandBuffer(vkCmdBuff); VERIFY(err == VK_SUCCESS, "Failed to end command buffer"); + auto* pDeviceVkImpl = m_pDevice.RawPtr(); CommandListVkImpl *pCmdListVk( NEW_RC_OBJ(m_CmdListAllocator, "CommandListVkImpl instance", CommandListVkImpl) - (m_pDevice, this, vkCmdBuff, m_NextCmdBuffNumber) ); + (pDeviceVkImpl, this, vkCmdBuff, m_NextCmdBuffNumber) ); pCmdListVk->QueryInterface( IID_CommandList, reinterpret_cast(ppCommandList) ); m_CommandBuffer.SetVkCmdBuffer(VK_NULL_HANDLE); diff --git a/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp index bbd872fc..caafb42b 100644 --- a/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/FenceVkImpl.cpp @@ -50,7 +50,7 @@ FenceVkImpl :: ~FenceVkImpl() Uint64 FenceVkImpl :: GetCompletedValue() { - const auto& LogicalDevice = GetDevice()->GetLogicalDevice(); + const auto& LogicalDevice = m_pDevice->GetLogicalDevice(); while (!m_PendingFences.empty()) { auto& Value_Fence = m_PendingFences.front(); @@ -81,7 +81,7 @@ void FenceVkImpl :: Reset(Uint64 Value) void FenceVkImpl :: Wait() { - const auto& LogicalDevice = GetDevice()->GetLogicalDevice(); + const auto& LogicalDevice = m_pDevice->GetLogicalDevice(); for (auto& val_fence : m_PendingFences) { while (LogicalDevice.GetFenceStatus(val_fence.second) != VK_SUCCESS) diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp index 985ce5ab..f3c60eb2 100644 --- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp @@ -403,15 +403,14 @@ PipelineStateVkImpl :: PipelineStateVkImpl(IReferenceCounters* pRefCounters PipelineStateVkImpl::~PipelineStateVkImpl() { - auto pDeviceVkImpl = GetDevice(); - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_Pipeline)); - m_PipelineLayout.Release(pDeviceVkImpl); + m_pDevice->SafeReleaseVkObject(std::move(m_Pipeline)); + m_PipelineLayout.Release(m_pDevice); for (auto& ShaderModule : m_ShaderModules) { if (ShaderModule != VK_NULL_HANDLE) { - pDeviceVkImpl->SafeReleaseVkObject(std::move(ShaderModule)); + m_pDevice->SafeReleaseVkObject(std::move(ShaderModule)); } } @@ -432,8 +431,7 @@ IMPLEMENT_QUERY_INTERFACE( PipelineStateVkImpl, IID_PipelineStateVk, TPipelineSt void PipelineStateVkImpl::CreateShaderResourceBinding(IShaderResourceBinding **ppShaderResourceBinding) { - auto* pRenderDeviceVk = GetDevice(); - auto& SRBAllocator = pRenderDeviceVk->GetSRBAllocator(); + auto& SRBAllocator = m_pDevice->GetSRBAllocator(); auto pResBindingVk = NEW_RC_OBJ(SRBAllocator, "ShaderResourceBindingVkImpl instance", ShaderResourceBindingVkImpl)(this, false); pResBindingVk->QueryInterface(IID_ShaderResourceBinding, reinterpret_cast(ppShaderResourceBinding)); } diff --git a/Graphics/GraphicsEngineVulkan/src/SamplerVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SamplerVkImpl.cpp index ff248c3a..8f748100 100644 --- a/Graphics/GraphicsEngineVulkan/src/SamplerVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/SamplerVkImpl.cpp @@ -75,8 +75,7 @@ SamplerVkImpl::SamplerVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImp SamplerVkImpl::~SamplerVkImpl() { - auto pDeviceVkImpl = GetDevice(); - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_VkSampler)); + m_pDevice->SafeReleaseVkObject(std::move(m_VkSampler)); } IMPLEMENT_QUERY_INTERFACE( SamplerVkImpl, IID_SamplerVk, TSamplerBase ) diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp index 4e8e4edf..4d1f1015 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp @@ -35,10 +35,10 @@ ShaderResourceBindingVkImpl::ShaderResourceBindingVkImpl( IReferenceCounters* pR TBase( pRefCounters, pPSO, IsPSOInternal ), m_ShaderResourceCache(ShaderResourceCacheVk::DbgCacheContentType::SRBResources) { - auto *ppShaders = pPSO->GetShaders(); + auto* ppShaders = pPSO->GetShaders(); m_NumShaders = pPSO->GetNumShaders(); - auto *pRenderDeviceVkImpl = pPSO->GetDevice(); + auto* pRenderDeviceVkImpl = pPSO->GetDevice(); // This will only allocate memory and initialize descriptor sets in the resource cache // Resources will be initialized by InitializeResourceMemoryInCache() auto& ResourceCacheDataAllocator = pPSO->GetSRBMemoryAllocator().GetResourceCacheDataAllocator(0); diff --git a/Graphics/GraphicsEngineVulkan/src/TextureViewVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureViewVkImpl.cpp index a1263f98..72b6b34b 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureViewVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureViewVkImpl.cpp @@ -30,7 +30,7 @@ namespace Diligent { TextureViewVkImpl::TextureViewVkImpl( IReferenceCounters* pRefCounters, - IRenderDevice* pDevice, + RenderDeviceVkImpl* pDevice, const TextureViewDesc& ViewDesc, ITexture* pTexture, VulkanUtilities::ImageViewWrapper&& ImgView, @@ -42,10 +42,9 @@ TextureViewVkImpl::TextureViewVkImpl( IReferenceCounters* pRefCo TextureViewVkImpl::~TextureViewVkImpl() { - auto *pDeviceVkImpl = GetDevice(); if(m_Desc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL || m_Desc.ViewType == TEXTURE_VIEW_RENDER_TARGET) - pDeviceVkImpl->GetFramebufferCache().OnDestroyImageView(m_ImageView); - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_ImageView)); + m_pDevice->GetFramebufferCache().OnDestroyImageView(m_ImageView); + m_pDevice->SafeReleaseVkObject(std::move(m_ImageView)); } IMPLEMENT_QUERY_INTERFACE( TextureViewVkImpl, IID_TextureViewVk, TTextureViewBase ) diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp index eb396192..2d3a74cc 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp @@ -437,8 +437,7 @@ void TextureVkImpl::CreateViewInternal( const struct TextureViewDesc &ViewDesc, try { - auto *pDeviceVkImpl = GetDevice(); - auto &TexViewAllocator = pDeviceVkImpl->GetTexViewObjAllocator(); + auto &TexViewAllocator = m_pDevice->GetTexViewObjAllocator(); VERIFY( &TexViewAllocator == &m_dbgTexViewObjAllocator, "Texture view allocator does not match allocator provided during texture initialization" ); auto UpdatedViewDesc = ViewDesc; @@ -464,11 +463,10 @@ void TextureVkImpl::CreateViewInternal( const struct TextureViewDesc &ViewDesc, TextureVkImpl :: ~TextureVkImpl() { - auto *pDeviceVkImpl = GetDevice(); // Vk object can only be destroyed when it is no longer used by the GPU // Wrappers for external texture will not be destroyed as they are created with null device pointer - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_VulkanImage)); - pDeviceVkImpl->SafeReleaseVkObject(std::move(m_MemoryAllocation)); + m_pDevice->SafeReleaseVkObject(std::move(m_VulkanImage)); + m_pDevice->SafeReleaseVkObject(std::move(m_MemoryAllocation)); } void TextureVkImpl::UpdateData( IDeviceContext *pContext, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData ) @@ -703,8 +701,7 @@ VulkanUtilities::ImageViewWrapper TextureVkImpl::CreateImageView(TextureViewDesc ImageViewCI.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; } - auto *pRenderDeviceVk = GetDevice(); - const auto& LogicalDevice = pRenderDeviceVk->GetLogicalDevice(); + const auto& LogicalDevice = m_pDevice->GetLogicalDevice(); std::string ViewName = "Image view for \'"; ViewName += m_Desc.Name; -- cgit v1.2.3