diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-07-25 15:09:57 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-07-25 15:09:57 +0000 |
| commit | 404459e2cb9a17e94ee7d26c22fbe2485828b496 (patch) | |
| tree | 7b81d6ed6fa0612a35443b91e7b7948c51d824c5 /Graphics | |
| parent | Few improvements to RefCntAutoPtr & DeviceContextBase::SetPipelineState (diff) | |
| download | DiligentCore-404459e2cb9a17e94ee7d26c22fbe2485828b496.tar.gz DiligentCore-404459e2cb9a17e94ee7d26c22fbe2485828b496.zip | |
Improved performance of DeviceObjectBase::Release()
Diffstat (limited to 'Graphics')
69 files changed, 325 insertions, 288 deletions
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 BaseInterface, class BufferViewImplType, class TBuffViewObjAllocator> -class BufferBase : public DeviceObjectBase < BaseInterface, BufferDesc> +template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator> +class BufferBase : public DeviceObjectBase <BaseInterface, RenderDeviceImplType, BufferDesc> { public: - typedef DeviceObjectBase<BaseInterface, BufferDesc> TDeviceObjectBase; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, BufferDesc>; /// \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<BufferViewImplType, STDDeleter<BufferViewImplType, TBuffViewObjAllocator> > m_pDefaultSRV; }; -template<class BaseInterface, class BufferViewImplType, class TBuffViewObjAllocator> -void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: UpdateData( IDeviceContext* pContext, Uint32 Offset, Uint32 Size, const PVoid pData ) +template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator> +void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator> :: 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<class BaseInterface, class BufferViewImplType, class TBuffViewObjAllocator> -void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: CopyData( IDeviceContext* pContext, IBuffer* pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size ) +template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator> +void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator> :: 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<class BaseInterface, class BufferViewImplType, class TBuffViewObjAllocator> -void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: Map( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid& pMappedData ) +template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator> +void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator> :: Map( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid& pMappedData ) { pMappedData = nullptr; switch( MapType ) @@ -212,22 +215,22 @@ void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: Map } } -template<class BaseInterface, class BufferViewImplType, class TBuffViewObjAllocator> -void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: Unmap( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags ) +template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator> +void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator> :: Unmap( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags ) { } -template<class BaseInterface, class BufferViewImplType, class TBuffViewObjAllocator> -void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: CreateView( const struct BufferViewDesc &ViewDesc, IBufferView **ppView ) +template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator> +void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator> :: CreateView( const struct BufferViewDesc &ViewDesc, IBufferView **ppView ) { CreateViewInternal( ViewDesc, ppView, false ); } -template<class BaseInterface, class BufferViewImplType, class TBuffViewObjAllocator> -void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: CorrectBufferViewDesc( struct BufferViewDesc &ViewDesc ) +template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator> +void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator> :: CorrectBufferViewDesc( struct BufferViewDesc &ViewDesc ) { if( ViewDesc.ByteWidth == 0 ) ViewDesc.ByteWidth = this->m_Desc.uiSizeInBytes; @@ -244,8 +247,8 @@ void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: Cor } } -template<class BaseInterface, class BufferViewImplType, class TBuffViewObjAllocator> -IBufferView* BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> ::GetDefaultView( BUFFER_VIEW_TYPE ViewType ) +template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator> +IBufferView* BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator> ::GetDefaultView( BUFFER_VIEW_TYPE ViewType ) { switch( ViewType ) { @@ -255,8 +258,8 @@ IBufferView* BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator } } -template<class BaseInterface, class BufferViewImplType, class TBuffViewObjAllocator> -void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: CreateDefaultViews() +template<class BaseInterface, class RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator> +void BufferBase<BaseInterface, RenderDeviceImplType, BufferViewImplType, TBuffViewObjAllocator> :: 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 BaseInterface> -class BufferViewBase : public DeviceObjectBase<BaseInterface, BufferViewDesc> +/// \tparam RenderDeviceImplType - type of the render device implementation +/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, +/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) +template<class BaseInterface, class RenderDeviceImplType> +class BufferViewBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, BufferViewDesc> { public: - typedef DeviceObjectBase<BaseInterface, BufferViewDesc> TDeviceObjectBase; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, BufferViewDesc>; /// \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 BaseInterface> -class CommandListBase : public DeviceObjectBase<BaseInterface, CommandListDesc> +/// (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 BaseInterface, class RenderDeviceImplType> +class CommandListBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, CommandListDesc> { public: - typedef DeviceObjectBase<BaseInterface, CommandListDesc> TDeviceObjectBase; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, CommandListDesc>; /// \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<typename BaseInterface> -class RenderDeviceBase; - -class IRenderDevice; - /// Template class implementing base functionality for a device object -template<class BaseInterface, typename ObjectDescType> +template<class BaseInterface, typename RenderDeviceImplType, typename ObjectDescType> class DeviceObjectBase : public ObjectBase<BaseInterface> { 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<IRenderDevice> pDevice(m_spDevice); - // Note that internal device object do not keep strong reference to the device - return TBase::Release(); + RefCntAutoPtr<RenderDeviceImplType> pDevice; + return ValidatedCast<RefCountersImpl>(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<typename Type> - Type* GetDevice()const{return ValidatedCast<Type>(m_pDevice);} - private: /// Strong reference to the device - RefCntAutoPtr<IRenderDevice> m_spDevice; + RefCntAutoPtr<RenderDeviceImplType> 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 BaseInterface> -class FenceBase : public DeviceObjectBase<BaseInterface, FenceDesc> +/// \tparam RenderDeviceImplType - type of the render device implementation +template<class BaseInterface, class RenderDeviceImplType> +class FenceBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, FenceDesc> { public: - typedef DeviceObjectBase<BaseInterface, FenceDesc> TDeviceObjectBase; + typedef DeviceObjectBase<BaseInterface, RenderDeviceImplType, FenceDesc> 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 BaseInterface, class RenderDeviceBaseInterface> -class PipelineStateBase : public DeviceObjectBase<BaseInterface, PipelineStateDesc> +/// \tparam RenderDeviceImplType - type of the render device implementation +/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, +/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) +template<class BaseInterface, class RenderDeviceImplType> +class PipelineStateBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, PipelineStateDesc> { public: - typedef DeviceObjectBase<BaseInterface, PipelineStateDesc> TDeviceObjectBase; - typedef RenderDeviceBase < RenderDeviceBaseInterface > TRenderDeviceBase; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, PipelineStateDesc>; /// \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<BaseInterface> { public: - typedef ObjectBase<BaseInterface> TObjectBase; + using TObjectBase = ObjectBase<BaseInterface>; /// \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<BaseInterface> ) + // 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 BaseInterface, class RenderDeviceBaseInterface> -class SamplerBase : public DeviceObjectBase<BaseInterface, SamplerDesc> +/// \tparam RenderDeviceImplType - type of the render device implementation +/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, +/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) +template<class BaseInterface, class RenderDeviceImplType> +class SamplerBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, SamplerDesc> { public: - typedef DeviceObjectBase<BaseInterface, SamplerDesc> TDeviceObjectBase; - typedef RenderDeviceBase<RenderDeviceBaseInterface> TRenderDeviceBase; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, SamplerDesc>; /// \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<TRenderDeviceBase*>(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 BaseInterface, class RenderDeviceBaseInterface> -class ShaderBase : public DeviceObjectBase<BaseInterface, ShaderDesc> +/// \tparam RenderDeviceImplType - type of the render device implementation +/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, +/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) +template<class BaseInterface, class RenderDeviceImplType> +class ShaderBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, ShaderDesc> { public: - typedef DeviceObjectBase<BaseInterface, ShaderDesc> TDeviceObjectBase; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, ShaderDesc>; /// \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<ShaderVariableDesc>") ), 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 BaseInterface, class TTextureViewImpl, class TTexViewObjAllocator> -class TextureBase : public DeviceObjectBase<BaseInterface, TextureDesc> +template<class BaseInterface, class TRenderDeviceImpl,class TTextureViewImpl, class TTexViewObjAllocator> +class TextureBase : public DeviceObjectBase<BaseInterface, TRenderDeviceImpl, TextureDesc> { public: - typedef DeviceObjectBase<BaseInterface, TextureDesc> TDeviceObjectBase; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, TRenderDeviceImpl, TextureDesc>; /// \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<class BaseInterface, class TTextureViewImpl, class TTexViewObjAllocator> -void TextureBase<BaseInterface, TTextureViewImpl, TTexViewObjAllocator> :: CorrectTextureViewDesc(struct TextureViewDesc& ViewDesc) +template<class BaseInterface, class TRenderDeviceImpl,class TTextureViewImpl, class TTexViewObjAllocator> +void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObjAllocator> :: 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<BaseInterface, TTextureViewImpl, TTexViewObjAllocator> :: Corre } } -template<class BaseInterface, class TTextureViewImpl, class TTexViewObjAllocator> -void TextureBase<BaseInterface, TTextureViewImpl, TTexViewObjAllocator> :: CreateDefaultViews() +template<class BaseInterface, class TRenderDeviceImpl,class TTextureViewImpl, class TTexViewObjAllocator> +void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObjAllocator> :: CreateDefaultViews() { const auto& TexFmtAttribs = GetTextureFormatAttribs(this->m_Desc.Format); if (TexFmtAttribs.ComponentType == COMPONENT_TYPE_UNDEFINED) @@ -442,14 +445,14 @@ void TextureBase<BaseInterface, TTextureViewImpl, TTexViewObjAllocator> :: Creat } -template<class BaseInterface, class TTextureViewImpl, class TTexViewObjAllocator> -void TextureBase<BaseInterface, TTextureViewImpl, TTexViewObjAllocator> :: UpdateData( IDeviceContext* pContext, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData ) +template<class BaseInterface, class TRenderDeviceImpl,class TTextureViewImpl, class TTexViewObjAllocator> +void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObjAllocator> :: UpdateData( IDeviceContext* pContext, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData ) { ValidateUpdateDataParams( this->m_Desc, MipLevel, Slice, DstBox, SubresData ); } -template<class BaseInterface, class TTextureViewImpl, class TTexViewObjAllocator> -void TextureBase<BaseInterface, TTextureViewImpl, TTexViewObjAllocator> :: CopyData( +template<class BaseInterface, class TRenderDeviceImpl,class TTextureViewImpl, class TTexViewObjAllocator> +void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObjAllocator> :: CopyData( IDeviceContext* pContext, ITexture* pSrcTexture, Uint32 SrcMipLevel, @@ -467,13 +470,13 @@ void TextureBase<BaseInterface, TTextureViewImpl, TTexViewObjAllocator> :: CopyD this->GetDesc(), DstMipLevel, DstSlice, DstX, DstY, DstZ ); } -template<class BaseInterface, class TTextureViewImpl, class TTexViewObjAllocator> -void TextureBase<BaseInterface, TTextureViewImpl, TTexViewObjAllocator> :: Map( IDeviceContext* pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags, MappedTextureSubresource &MappedData ) +template<class BaseInterface, class TRenderDeviceImpl,class TTextureViewImpl, class TTexViewObjAllocator> +void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObjAllocator> :: Map( IDeviceContext* pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags, MappedTextureSubresource &MappedData ) { } -template<class BaseInterface, class TTextureViewImpl, class TTexViewObjAllocator> -void TextureBase<BaseInterface, TTextureViewImpl, TTexViewObjAllocator> :: Unmap( IDeviceContext* pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags ) +template<class BaseInterface, class TRenderDeviceImpl,class TTextureViewImpl, class TTexViewObjAllocator> +void TextureBase<BaseInterface, TRenderDeviceImpl, TTextureViewImpl, TTexViewObjAllocator> :: 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 BaseInterface> -class TextureViewBase : public DeviceObjectBase<BaseInterface, TextureViewDesc> +/// \tparam RenderDeviceImplType - type of the render device implementation +/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, +/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) +template<class BaseInterface, class RenderDeviceImplType> +class TextureViewBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, TextureViewDesc> { public: - typedef DeviceObjectBase<BaseInterface, TextureViewDesc> TDeviceObjectBase; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, TextureViewDesc>; /// \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<IBufferD3D11, BufferViewD3D11Impl, FixedBlockMemoryAllocator> +class BufferD3D11Impl : public BufferBase<IBufferD3D11, RenderDeviceD3D11Impl, BufferViewD3D11Impl, FixedBlockMemoryAllocator> { public: - using TBufferBase = BufferBase<IBufferD3D11, BufferViewD3D11Impl, FixedBlockMemoryAllocator>; + using TBufferBase = BufferBase<IBufferD3D11, RenderDeviceD3D11Impl, BufferViewD3D11Impl, FixedBlockMemoryAllocator>; 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<IBufferViewD3D11> +class BufferViewD3D11Impl : public BufferViewBase<IBufferViewD3D11, RenderDeviceD3D11Impl> { public: - using TBufferViewBase = BufferViewBase<IBufferViewD3D11>; + using TBufferViewBase = BufferViewBase<IBufferViewD3D11, RenderDeviceD3D11Impl>; 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<ICommandList> +class CommandListD3D11Impl : public CommandListBase<ICommandList, RenderDeviceD3D11Impl> { public: - using TCommandListBase = CommandListBase<ICommandList>; + using TCommandListBase = CommandListBase<ICommandList, RenderDeviceD3D11Impl>; - 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<IFenceD3D11> +class FenceD3D11Impl : public FenceBase<IFenceD3D11, RenderDeviceD3D11Impl> { public: - using TFenceBase = FenceBase<IFenceD3D11>; + using TFenceBase = FenceBase<IFenceD3D11, RenderDeviceD3D11Impl>; - 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<IPipelineStateD3D11, IRenderDeviceD3D11> +class PipelineStateD3D11Impl : public PipelineStateBase<IPipelineStateD3D11, RenderDeviceD3D11Impl> { public: - using TPipelineStateBase = PipelineStateBase<IPipelineStateD3D11, IRenderDeviceD3D11>; + using TPipelineStateBase = PipelineStateBase<IPipelineStateD3D11, RenderDeviceD3D11Impl>; 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<ISamplerD3D11, IRenderDeviceD3D11> +class SamplerD3D11Impl : public SamplerBase<ISamplerD3D11, RenderDeviceD3D11Impl> { public: - using TSamplerBase = SamplerBase<ISamplerD3D11, IRenderDeviceD3D11>; + using TSamplerBase = SamplerBase<ISamplerD3D11, RenderDeviceD3D11Impl>; 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<IShaderD3D11, IRenderDeviceD3D11>, public ShaderD3DBase +class ShaderD3D11Impl : public ShaderBase<IShaderD3D11, RenderDeviceD3D11Impl>, public ShaderD3DBase { public: - using TShaderBase = ShaderBase<IShaderD3D11, IRenderDeviceD3D11>; + using TShaderBase = ShaderBase<IShaderD3D11, RenderDeviceD3D11Impl>; 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<ITextureD3D11, TextureViewD3D11Impl, FixedBlockMemoryAllocator> +class TextureBaseD3D11 : public TextureBase<ITextureD3D11, RenderDeviceD3D11Impl, TextureViewD3D11Impl, FixedBlockMemoryAllocator> { public: - typedef TextureBase<ITextureD3D11, TextureViewD3D11Impl, FixedBlockMemoryAllocator> TTextureBase; + typedef TextureBase<ITextureD3D11, RenderDeviceD3D11Impl, TextureViewD3D11Impl, FixedBlockMemoryAllocator> 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<ITextureViewD3D11> +class TextureViewD3D11Impl : public TextureViewBase<ITextureViewD3D11, RenderDeviceD3D11Impl> { public: - using TTextureViewBase = TextureViewBase<ITextureViewD3D11>; + using TTextureViewBase = TextureViewBase<ITextureViewD3D11, RenderDeviceD3D11Impl>; 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<RenderDeviceD3D11Impl>(); + CommandListD3D11Impl* pCmdListD3D11( NEW_RC_OBJ(m_CmdListAllocator, "CommandListD3D11Impl instance", CommandListD3D11Impl)(pDeviceD3D11Impl, pd3d11CmdList) ); pCmdListD3D11->QueryInterface( IID_CommandList, reinterpret_cast<IObject**>(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<IBufferD3D12, BufferViewD3D12Impl, FixedBlockMemoryAllocator>, public D3D12ResourceBase +class BufferD3D12Impl : public BufferBase<IBufferD3D12, RenderDeviceD3D12Impl, BufferViewD3D12Impl, FixedBlockMemoryAllocator>, public D3D12ResourceBase { public: - using TBufferBase = BufferBase<IBufferD3D12, BufferViewD3D12Impl, FixedBlockMemoryAllocator>; + using TBufferBase = BufferBase<IBufferD3D12, RenderDeviceD3D12Impl, BufferViewD3D12Impl, FixedBlockMemoryAllocator>; 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<IBufferViewD3D12> +class BufferViewD3D12Impl : public BufferViewBase<IBufferViewD3D12, RenderDeviceD3D12Impl> { public: - using TBufferViewBase = BufferViewBase<IBufferViewD3D12>; + using TBufferViewBase = BufferViewBase<IBufferViewD3D12, RenderDeviceD3D12Impl>; 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<ICommandList> +class CommandListD3D12Impl : public CommandListBase<ICommandList, RenderDeviceD3D12Impl> { public: - using TCommandListBase = CommandListBase<ICommandList>; + using TCommandListBase = CommandListBase<ICommandList, RenderDeviceD3D12Impl>; - 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<IFenceD3D12> +class FenceD3D12Impl : public FenceBase<IFenceD3D12, RenderDeviceD3D12Impl> { public: - using TFenceBase = FenceBase<IFenceD3D12>; + using TFenceBase = FenceBase<IFenceD3D12, RenderDeviceD3D12Impl>; - 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<IPipelineStateD3D12, IRenderDeviceD3D12> +class PipelineStateD3D12Impl : public PipelineStateBase<IPipelineStateD3D12, RenderDeviceD3D12Impl> { public: - using TPipelineStateBase = PipelineStateBase<IPipelineStateD3D12, IRenderDeviceD3D12>; + using TPipelineStateBase = PipelineStateBase<IPipelineStateD3D12, RenderDeviceD3D12Impl>; - 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<ISamplerD3D12, IRenderDeviceD3D12> +class SamplerD3D12Impl : public SamplerBase<ISamplerD3D12, RenderDeviceD3D12Impl> { public: - using TSamplerBase = SamplerBase<ISamplerD3D12, IRenderDeviceD3D12>; + using TSamplerBase = SamplerBase<ISamplerD3D12, RenderDeviceD3D12Impl>; - 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<IShaderD3D12, IRenderDeviceD3D12>, public ShaderD3DBase +class ShaderD3D12Impl : public ShaderBase<IShaderD3D12, RenderDeviceD3D12Impl>, public ShaderD3DBase { public: - using TShaderBase = ShaderBase<IShaderD3D12, IRenderDeviceD3D12>; + using TShaderBase = ShaderBase<IShaderD3D12, RenderDeviceD3D12Impl>; 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<ITextureD3D12, TextureViewD3D12Impl, FixedBlockMemoryAllocator>, public D3D12ResourceBase +class TextureD3D12Impl : public TextureBase<ITextureD3D12, RenderDeviceD3D12Impl, TextureViewD3D12Impl, FixedBlockMemoryAllocator>, public D3D12ResourceBase { public: - using TTextureBase = TextureBase<ITextureD3D12, TextureViewD3D12Impl, FixedBlockMemoryAllocator>; + using TTextureBase = TextureBase<ITextureD3D12, RenderDeviceD3D12Impl, TextureViewD3D12Impl, FixedBlockMemoryAllocator>; // 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<ITextureViewD3D12> +class TextureViewD3D12Impl : public TextureViewBase<ITextureViewD3D12, RenderDeviceD3D12Impl> { public: - using TTextureViewBase = TextureViewBase<ITextureViewD3D12>; + using TTextureViewBase = TextureViewBase<ITextureViewD3D12, RenderDeviceD3D12Impl>; 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<RenderDeviceD3D12Impl>(); + CommandListD3D12Impl* pCmdListD3D12( NEW_RC_OBJ(m_CmdListAllocator, "CommandListD3D12Impl instance", CommandListD3D12Impl) + (pDeviceD3D12Impl, m_pCurrCmdCtx) ); pCmdListD3D12->QueryInterface( IID_CommandList, reinterpret_cast<IObject**>(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<RenderDeviceD3D12Impl>(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<RenderDeviceD3D12Impl>(); - 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<RenderDeviceD3D12Impl>(); - 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<IObject**>(ppShaderResourceBinding)); } @@ -352,7 +350,6 @@ ShaderResourceCacheD3D12* PipelineStateD3D12Impl::CommitAndTransitionShaderResou pResBindingD3D12Impl->dbgVerifyResourceBindings(this); #endif - auto* pDeviceD3D12Impl = GetDevice<RenderDeviceD3D12Impl>(); 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<IBufferGL, BufferViewGLImpl, FixedBlockMemoryAllocator>, public AsyncWritableResource +class BufferGLImpl : public BufferBase<IBufferGL, RenderDeviceGLImpl, BufferViewGLImpl, FixedBlockMemoryAllocator>, public AsyncWritableResource { public: - using TBufferBase = BufferBase<IBufferGL, BufferViewGLImpl, FixedBlockMemoryAllocator>; + using TBufferBase = BufferBase<IBufferGL, RenderDeviceGLImpl, BufferViewGLImpl, FixedBlockMemoryAllocator>; 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<IBufferViewGL> +class BufferViewGLImpl : public BufferViewBase<IBufferViewGL, RenderDeviceGLImpl> { public: - using TBuffViewBase = BufferViewBase<IBufferViewGL>; + using TBuffViewBase = BufferViewBase<IBufferViewGL, RenderDeviceGLImpl>; 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<IFenceGL> +class FenceGLImpl : public FenceBase<IFenceGL, RenderDeviceGLImpl> { public: - using TFenceBase = FenceBase<IFenceGL>; + using TFenceBase = FenceBase<IFenceGL, RenderDeviceGLImpl>; 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<IPipelineStateGL, IGLDeviceBaseInterface> +class PipelineStateGLImpl : public PipelineStateBase<IPipelineStateGL, RenderDeviceGLImpl> { public: - using TPipelineStateBase = PipelineStateBase<IPipelineStateGL, IGLDeviceBaseInterface>; + using TPipelineStateBase = PipelineStateBase<IPipelineStateGL, RenderDeviceGLImpl>; - 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<ISamplerGL, IGLDeviceBaseInterface> +class SamplerGLImpl : public SamplerBase<ISamplerGL, RenderDeviceGLImpl> { public: - using TSamplerBase = SamplerBase<ISamplerGL, IGLDeviceBaseInterface>; + using TSamplerBase = SamplerBase<ISamplerGL, RenderDeviceGLImpl>; - 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<IShaderGL, IGLDeviceBaseInterface> +class ShaderGLImpl : public ShaderBase<IShaderGL, RenderDeviceGLImpl> { public: - using TShaderBase = ShaderBase<IShaderGL, IGLDeviceBaseInterface>; + using TShaderBase = ShaderBase<IShaderGL, RenderDeviceGLImpl>; - 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<ITextureGL, TextureViewGLImpl, FixedBlockMemoryAllocator>, public AsyncWritableResource +class TextureBaseGL : public TextureBase<ITextureGL, RenderDeviceGLImpl, TextureViewGLImpl, FixedBlockMemoryAllocator>, public AsyncWritableResource { public: - using TTextureBase = TextureBase<ITextureGL, TextureViewGLImpl, FixedBlockMemoryAllocator>; + using TTextureBase = TextureBase<ITextureGL, RenderDeviceGLImpl, TextureViewGLImpl, FixedBlockMemoryAllocator>; 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<ITextureViewGL> +class TextureViewGLImpl : public TextureViewBase<ITextureViewGL, RenderDeviceGLImpl> { public: - using TTextureViewBase = TextureViewBase<ITextureViewGL>; + using TTextureViewBase = TextureViewBase<ITextureViewGL, RenderDeviceGLImpl>; 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<BufferGLImpl> VertexStreams[], + VertexStreamInfo<class BufferGLImpl> 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<IBufferViewVk> +class BufferViewVkImpl : public BufferViewBase<IBufferViewVk, RenderDeviceVkImpl> { public: - using TBufferViewBase = BufferViewBase<IBufferViewVk>; + using TBufferViewBase = BufferViewBase<IBufferViewVk, RenderDeviceVkImpl>; 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<IBufferVk, BufferViewVkImpl, FixedBlockMemoryAllocator> +class BufferVkImpl : public BufferBase<IBufferVk, RenderDeviceVkImpl, BufferViewVkImpl, FixedBlockMemoryAllocator> { public: - using TBufferBase = BufferBase<IBufferVk, BufferViewVkImpl, FixedBlockMemoryAllocator>; + using TBufferBase = BufferBase<IBufferVk, RenderDeviceVkImpl, BufferViewVkImpl, FixedBlockMemoryAllocator>; 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<ICommandList> +class CommandListVkImpl : public CommandListBase<ICommandList, RenderDeviceVkImpl> { public: - using TCommandListBase = CommandListBase<ICommandList>; + using TCommandListBase = CommandListBase<ICommandList, RenderDeviceVkImpl>; 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<IFenceVk> +class FenceVkImpl : public FenceBase<IFenceVk, RenderDeviceVkImpl> { public: - using TFenceBase = FenceBase<IFenceVk>; + using TFenceBase = FenceBase<IFenceVk, RenderDeviceVkImpl>; 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<IPipelineStateVk, IRenderDeviceVk> +class PipelineStateVkImpl : public PipelineStateBase<IPipelineStateVk, RenderDeviceVkImpl> { public: - using TPipelineStateBase = PipelineStateBase<IPipelineStateVk, IRenderDeviceVk>; + using TPipelineStateBase = PipelineStateBase<IPipelineStateVk, RenderDeviceVkImpl>; - 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<ISamplerVk, IRenderDeviceVk> +class SamplerVkImpl : public SamplerBase<ISamplerVk, RenderDeviceVkImpl> { public: - using TSamplerBase = SamplerBase<ISamplerVk, IRenderDeviceVk>; + using TSamplerBase = SamplerBase<ISamplerVk, RenderDeviceVkImpl>; - 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<IShaderVk, IRenderDeviceVk> +class ShaderVkImpl : public ShaderBase<IShaderVk, RenderDeviceVkImpl> { public: - using TShaderBase = ShaderBase<IShaderVk, IRenderDeviceVk>; + using TShaderBase = ShaderBase<IShaderVk, RenderDeviceVkImpl>; - 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<ITextureViewVk> +class TextureViewVkImpl : public TextureViewBase<ITextureViewVk, RenderDeviceVkImpl> { public: - using TTextureViewBase = TextureViewBase<ITextureViewVk>; + using TTextureViewBase = TextureViewBase<ITextureViewVk, RenderDeviceVkImpl>; 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<ITextureVk, TextureViewVkImpl, FixedBlockMemoryAllocator> +class TextureVkImpl : public TextureBase<ITextureVk, RenderDeviceVkImpl, TextureViewVkImpl, FixedBlockMemoryAllocator> { public: - using TTextureBase = TextureBase<ITextureVk, TextureViewVkImpl, FixedBlockMemoryAllocator>; + using TTextureBase = TextureBase<ITextureVk, RenderDeviceVkImpl, TextureViewVkImpl, FixedBlockMemoryAllocator>; // 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<RenderDeviceVkImpl>(); - 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<RenderDeviceVkImpl>(); // 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<DeviceContextVkImpl>(pContext); - auto* pDeviceVk = GetDevice<RenderDeviceVkImpl>(); #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<RenderDeviceVkImpl>(); - 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<RenderDeviceVkImpl>(); - 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<RenderDeviceVkImpl>()->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<RenderDeviceVkImpl>()->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<RenderDeviceVkImpl>(); 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<IObject**>(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<RenderDeviceVkImpl>()->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<RenderDeviceVkImpl>()->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<RenderDeviceVkImpl>(); - 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<RenderDeviceVkImpl>(); - 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<IObject**>(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<RenderDeviceVkImpl>(); - 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<RenderDeviceVkImpl>(); + 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<RenderDeviceVkImpl>(); 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<RenderDeviceVkImpl>(); - 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<RenderDeviceVkImpl>(); // 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<RenderDeviceVkImpl>(); - const auto& LogicalDevice = pRenderDeviceVk->GetLogicalDevice(); + const auto& LogicalDevice = m_pDevice->GetLogicalDevice(); std::string ViewName = "Image view for \'"; ViewName += m_Desc.Name; |
