diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-07-20 05:41:05 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-07-20 05:41:05 +0000 |
| commit | 908672f5b447e1e96e0dcbb3ec1eaabbd1d503f4 (patch) | |
| tree | d0ae2d5956d803b7f4ce11195bebed8deecb124a /Graphics/GraphicsEngine | |
| parent | Added comment about shader reflection data (diff) | |
| download | DiligentCore-908672f5b447e1e96e0dcbb3ec1eaabbd1d503f4.tar.gz DiligentCore-908672f5b447e1e96e0dcbb3ec1eaabbd1d503f4.zip | |
Added fence object stubs + code formatting
Diffstat (limited to 'Graphics/GraphicsEngine')
19 files changed, 364 insertions, 201 deletions
diff --git a/Graphics/GraphicsEngine/CMakeLists.txt b/Graphics/GraphicsEngine/CMakeLists.txt index c226701e..31bdc256 100644 --- a/Graphics/GraphicsEngine/CMakeLists.txt +++ b/Graphics/GraphicsEngine/CMakeLists.txt @@ -10,6 +10,7 @@ set(INCLUDE include/DeviceContextBase.h include/DeviceObjectBase.h include/EngineMemory.h + include/FenceBase.h include/pch.h include/PipelineStateBase.h include/RenderDeviceBase.h @@ -33,6 +34,7 @@ set(INTERFACE interface/DeviceCaps.h interface/DeviceContext.h interface/DeviceObject.h + interface/Fence.h interface/GraphicsTypes.h interface/InputLayout.h interface/MapHelper.h diff --git a/Graphics/GraphicsEngine/include/BufferBase.h b/Graphics/GraphicsEngine/include/BufferBase.h index 9acd562c..66096e3c 100644 --- a/Graphics/GraphicsEngine/include/BufferBase.h +++ b/Graphics/GraphicsEngine/include/BufferBase.h @@ -37,10 +37,12 @@ namespace Diligent /// Template class implementing base functionality for a buffer object -/// \tparam BaseInterface - base interface that this class will inheret -/// (Diligent::IBufferD3D11, Diligent::IBufferD3D12 or Diligent::IBufferGL). +/// \tparam BaseInterface - base interface that this class will inheret +/// (Diligent::IBufferD3D11, Diligent::IBufferD3D12, +/// Diligent::IBufferGL or Diligent::IBufferVk). /// \tparam BufferViewImplType - type of the buffer view implementation -/// (Diligent::BufferViewD3D11Impl, Diligent::BufferViewD3D12Impl or Diligent::BufferViewGLImpl) +/// (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> @@ -55,11 +57,11 @@ public: /// \param BuffDesc - buffer description. /// \param bIsDeviceInternal - flag indicating if the buffer is an internal device object and /// must not keep a strong reference to the device. - BufferBase( IReferenceCounters *pRefCounters, - TBuffViewObjAllocator &BuffViewObjAllocator, - IRenderDevice *pDevice, - const BufferDesc& BuffDesc, - bool bIsDeviceInternal) : + BufferBase( IReferenceCounters* pRefCounters, + TBuffViewObjAllocator& BuffViewObjAllocator, + IRenderDevice* pDevice, + const BufferDesc& BuffDesc, + bool bIsDeviceInternal) : TDeviceObjectBase( pRefCounters, pDevice, BuffDesc, bIsDeviceInternal), #ifdef _DEBUG m_dbgBuffViewAllocator(BuffViewObjAllocator), @@ -108,20 +110,20 @@ public: IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_Buffer, TDeviceObjectBase ) /// Base implementation of IBuffer::UpdateData(); validates input parameters. - virtual void UpdateData( IDeviceContext *pContext, Uint32 Offset, Uint32 Size, const PVoid pData )override = 0; + virtual void UpdateData( IDeviceContext* pContext, Uint32 Offset, Uint32 Size, const PVoid pData )override = 0; /// Base implementation of IBuffer::CopyData(); validates input parameters. - virtual void CopyData( IDeviceContext *pContext, IBuffer *pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size )override = 0; + virtual void CopyData( IDeviceContext* pContext, IBuffer* pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size )override = 0; /// Base implementation of IBuffer::Map(); validates input parameters. - virtual void Map( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData )override; + virtual void Map( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid& pMappedData )override; /// Base implementation of IBuffer::Unmap() - virtual void Unmap( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags )override = 0; + virtual void Unmap( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags )override = 0; /// Implementation of IBuffer::CreateView(); calls CreateViewInternal() virtual function /// that creates buffer view for the specific engine implementation. - virtual void CreateView( const struct BufferViewDesc &ViewDesc, IBufferView **ppView )override; + virtual void CreateView( const struct BufferViewDesc& ViewDesc, IBufferView** ppView )override; /// Implementation of IBuffer::GetDefaultView(). virtual IBufferView* GetDefaultView( BUFFER_VIEW_TYPE ViewType )override; @@ -138,13 +140,13 @@ public: protected: /// Pure virtual function that creates buffer view for the specific engine implementation. - virtual void CreateViewInternal( const struct BufferViewDesc &ViewDesc, IBufferView **ppView, bool bIsDefaultView ) = 0; + virtual void CreateViewInternal( const struct BufferViewDesc& ViewDesc, IBufferView **ppView, bool bIsDefaultView ) = 0; /// Corrects buffer view description and validates view parameters. - void CorrectBufferViewDesc( struct BufferViewDesc &ViewDesc ); + void CorrectBufferViewDesc( struct BufferViewDesc& ViewDesc ); #ifdef _DEBUG - TBuffViewObjAllocator &m_dbgBuffViewAllocator; + TBuffViewObjAllocator& m_dbgBuffViewAllocator; #endif /// Default UAV addressing the entire buffer @@ -155,7 +157,7 @@ protected: }; template<class BaseInterface, class BufferViewImplType, class TBuffViewObjAllocator> -void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: UpdateData( IDeviceContext *pContext, Uint32 Offset, Uint32 Size, const PVoid pData ) +void BufferBase<BaseInterface, 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, ")" ); @@ -163,7 +165,7 @@ void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: Upd } template<class BaseInterface, class BufferViewImplType, class TBuffViewObjAllocator> -void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: CopyData( IDeviceContext *pContext, IBuffer *pSrcBuffer, Uint32 SrcOffset, Uint32 DstOffset, Uint32 Size ) +void BufferBase<BaseInterface, 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,")" ); @@ -171,7 +173,7 @@ void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: Cop template<class BaseInterface, class BufferViewImplType, class TBuffViewObjAllocator> -void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: Map( IDeviceContext *pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData ) +void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: Map( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags, PVoid &pMappedData ) { switch( MapType ) { @@ -209,7 +211,7 @@ 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 ) +void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: Unmap( IDeviceContext* pContext, MAP_TYPE MapType, Uint32 MapFlags ) { } @@ -258,7 +260,7 @@ void BufferBase<BaseInterface, BufferViewImplType, TBuffViewObjAllocator> :: Cre { BufferViewDesc ViewDesc; ViewDesc.ViewType = BUFFER_VIEW_UNORDERED_ACCESS; - IBufferView *pUAV = nullptr; + IBufferView* pUAV = nullptr; CreateViewInternal( ViewDesc, &pUAV, true ); m_pDefaultUAV.reset( static_cast<BufferViewImplType*>(pUAV) ); VERIFY( m_pDefaultUAV->GetDesc().ViewType == BUFFER_VIEW_UNORDERED_ACCESS, "Unexpected view type" ); diff --git a/Graphics/GraphicsEngine/include/BufferViewBase.h b/Graphics/GraphicsEngine/include/BufferViewBase.h index de97f64c..b09b479e 100644 --- a/Graphics/GraphicsEngine/include/BufferViewBase.h +++ b/Graphics/GraphicsEngine/include/BufferViewBase.h @@ -39,9 +39,9 @@ class IBuffer; /// Template class implementing base functionality for a buffer view object -/// \tparam BaseInterface - base interface that this class will inheret -/// (Diligent::IBufferViewD3D11, Diligent::IBufferViewD3D12 or Diligent::IBufferViewGL). -/// \tparam BuffViewObjAllocator - type of the allocator that is used to allocate memory for the buffer view object instances +/// \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> { @@ -55,11 +55,11 @@ public: /// \param bIsDefaultView - flag indicating if the view is default view, and is thus /// part of the buffer object. In this case the view will attach /// to the buffer's reference counters. - BufferViewBase( IReferenceCounters *pRefCounters, - IRenderDevice *pDevice, + BufferViewBase( IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, const BufferViewDesc& ViewDesc, - IBuffer *pBuffer, - bool bIsDefaultView ) : + IBuffer* pBuffer, + bool bIsDefaultView ) : // Default views are created as part of the buffer, so we cannot not keep strong // reference to the buffer to avoid cyclic links. Instead, we will attach to the // reference counters of the buffer. diff --git a/Graphics/GraphicsEngine/include/CommandListBase.h b/Graphics/GraphicsEngine/include/CommandListBase.h index 74725d31..77c85d86 100644 --- a/Graphics/GraphicsEngine/include/CommandListBase.h +++ b/Graphics/GraphicsEngine/include/CommandListBase.h @@ -51,7 +51,7 @@ public: /// \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, IRenderDevice* pDevice, bool bIsDeviceInternal = false ) : TDeviceObjectBase( pRefCounters, pDevice, CommandListDesc(), bIsDeviceInternal ) {} diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.h b/Graphics/GraphicsEngine/include/DeviceContextBase.h index 86b213ad..d84956b1 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.h +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.h @@ -65,7 +65,7 @@ public: /// \param pRefCounters - reference counters object that controls the lifetime of this device context. /// \param pRenderDevice - render device. /// \param bIsDeferred - flag indicating if this instance is a deferred context - DeviceContextBase(IReferenceCounters *pRefCounters, IRenderDevice *pRenderDevice, bool bIsDeferred) : + DeviceContextBase(IReferenceCounters* pRefCounters, IRenderDevice* pRenderDevice, bool bIsDeferred) : TObjectBase(pRefCounters), m_pDevice(pRenderDevice), m_bIsDeferred(bIsDeferred) @@ -80,32 +80,32 @@ public: /// Base implementation of IDeviceContext::SetVertexBuffers(); validates parameters and /// caches references to the buffers. - inline virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pOffsets, Uint32 Flags )override = 0; + inline virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer** ppBuffers, Uint32* pOffsets, Uint32 Flags )override = 0; inline virtual void InvalidateState()override = 0; /// Base implementation of IDeviceContext::SetPipelineState(); caches references to the pipeline state object. - inline virtual void SetPipelineState(IPipelineState *pPipelineState)override = 0; + inline virtual void SetPipelineState(IPipelineState* pPipelineState)override = 0; /// Base implementation of IDeviceContext::CommitShaderResources(); validates parameters. template<typename PSOImplType> - inline bool CommitShaderResources(IShaderResourceBinding *pShaderResourceBinding, Uint32 Flags, int); + inline bool CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, Uint32 Flags, int); /// Base implementation of IDeviceContext::SetIndexBuffer(); caches the strong reference to the index buffer - inline virtual void SetIndexBuffer( IBuffer *pIndexBuffer, Uint32 ByteOffset )override = 0; + inline virtual void SetIndexBuffer( IBuffer* pIndexBuffer, Uint32 ByteOffset )override = 0; /// Caches the viewports - inline void SetViewports( Uint32 NumViewports, const Viewport *pViewports, Uint32 &RTWidth, Uint32 &RTHeight ); + inline void SetViewports( Uint32 NumViewports, const Viewport* pViewports, Uint32& RTWidth, Uint32& RTHeight ); /// Caches the scissor rects - inline void SetScissorRects( Uint32 NumRects, const Rect *pRects, Uint32 &RTWidth, Uint32 &RTHeight ); + inline void SetScissorRects( Uint32 NumRects, const Rect* pRects, Uint32& RTWidth, Uint32& RTHeight ); /// Caches the render target and depth stencil views. Returns true if any view is different /// from the cached value and false otherwise. - inline bool SetRenderTargets( Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil, Uint32 Dummy = 0 ); + inline bool SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil, Uint32 Dummy = 0 ); /// Sets the strong pointer to the swap chain - virtual void SetSwapChain( ISwapChain *pSwapChain )override final { m_pSwapChain = pSwapChain; } + virtual void SetSwapChain( ISwapChain* pSwapChain )override final { m_pSwapChain = pSwapChain; } /// Returns the swap chain ISwapChain *GetSwapChain() { return m_pSwapChain; } @@ -114,13 +114,13 @@ public: inline bool IsDefaultFBBound(){ return m_IsDefaultFramebufferBound; } /// Returns currently bound pipeline state and blend factors - inline void GetPipelineState(IPipelineState **ppPSO, float* BlendFactors, Uint32 &StencilRef); + inline void GetPipelineState(IPipelineState** ppPSO, float* BlendFactors, Uint32& StencilRef); /// Returns currently bound render targets - inline void GetRenderTargets(Uint32 &NumRenderTargets, ITextureView **ppRTVs, ITextureView **ppDSV); + inline void GetRenderTargets(Uint32& NumRenderTargets, ITextureView** ppRTVs, ITextureView** ppDSV); /// Returns currently set viewports - inline void GetViewports( Uint32 &NumViewports, Viewport *pViewports ); + inline void GetViewports( Uint32& NumViewports, Viewport* pViewports ); /// Returns the render device IRenderDevice *GetDevice(){return m_pDevice;} @@ -130,7 +130,7 @@ public: bool IsDeferred()const{return m_bIsDeferred;} protected: - inline bool SetBlendFactors(const float *BlendFactors, int Dummy); + inline bool SetBlendFactors(const float* BlendFactors, int Dummy); inline bool SetStencilRef(Uint32 StencilRef, int Dummy); @@ -197,7 +197,7 @@ protected: template<typename BaseInterface> -inline void DeviceContextBase<BaseInterface> :: SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pOffsets, Uint32 Flags ) +inline void DeviceContextBase<BaseInterface> :: SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer** ppBuffers, Uint32* pOffsets, Uint32 Flags ) { #ifdef DEVELOPMENT if ( StartSlot >= MaxBufferSlots ) @@ -243,14 +243,14 @@ inline void DeviceContextBase<BaseInterface> :: SetVertexBuffers( Uint32 StartSl } template<typename BaseInterface> -inline void DeviceContextBase<BaseInterface> :: SetPipelineState(IPipelineState *pPipelineState) +inline void DeviceContextBase<BaseInterface> :: SetPipelineState(IPipelineState* pPipelineState) { m_pPipelineState = pPipelineState; } template<typename BaseInterface> template<typename PSOImplType> -inline bool DeviceContextBase<BaseInterface> :: CommitShaderResources(IShaderResourceBinding *pShaderResourceBinding, Uint32 Flags, int) +inline bool DeviceContextBase<BaseInterface> :: CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding, Uint32 Flags, int) { #ifdef DEVELOPMENT if (!m_pPipelineState) @@ -261,7 +261,7 @@ inline bool DeviceContextBase<BaseInterface> :: CommitShaderResources(IShaderRes if (pShaderResourceBinding) { - auto *pPSOImpl = m_pPipelineState.RawPtr<PSOImplType>(); + auto* pPSOImpl = m_pPipelineState.RawPtr<PSOImplType>(); if (pPSOImpl->IsIncompatibleWith(pShaderResourceBinding->GetPipelineState())) { LOG_ERROR_MESSAGE("Shader resource binding object is not compatible with the currently bound pipeline state"); @@ -280,7 +280,7 @@ inline void DeviceContextBase<BaseInterface> :: InvalidateState() } template<typename BaseInterface> -inline void DeviceContextBase<BaseInterface> :: SetIndexBuffer( IBuffer *pIndexBuffer, Uint32 ByteOffset ) +inline void DeviceContextBase<BaseInterface> :: SetIndexBuffer( IBuffer* pIndexBuffer, Uint32 ByteOffset ) { m_pIndexBuffer = pIndexBuffer; m_IndexDataStartOffset = ByteOffset; @@ -295,17 +295,17 @@ inline void DeviceContextBase<BaseInterface> :: SetIndexBuffer( IBuffer *pIndexB template<typename BaseInterface> -inline void DeviceContextBase<BaseInterface> :: GetPipelineState(IPipelineState **ppPSO, float* BlendFactors, Uint32 &StencilRef) +inline void DeviceContextBase<BaseInterface> :: GetPipelineState(IPipelineState** ppPSO, float* BlendFactors, Uint32& StencilRef) { VERIFY( ppPSO != nullptr, "Null pointer provided null" ); - VERIFY( *ppPSO == nullptr, "Memory address contains a pointer to a non-null blend state" ); + VERIFY(* ppPSO == nullptr, "Memory address contains a pointer to a non-null blend state" ); if (m_pPipelineState) { m_pPipelineState->QueryInterface( IID_PipelineState, reinterpret_cast<IObject**>( ppPSO ) ); } else { - *ppPSO = nullptr; + * ppPSO = nullptr; } for( Uint32 f = 0; f < 4; ++f ) @@ -314,7 +314,7 @@ inline void DeviceContextBase<BaseInterface> :: GetPipelineState(IPipelineState }; template<typename BaseInterface> -inline bool DeviceContextBase<BaseInterface> ::SetBlendFactors(const float *BlendFactors, int) +inline bool DeviceContextBase<BaseInterface> ::SetBlendFactors(const float* BlendFactors, int) { bool FactorsDiffer = false; for( Uint32 f = 0; f < 4; ++f ) @@ -338,7 +338,7 @@ inline bool DeviceContextBase<BaseInterface> :: SetStencilRef(Uint32 StencilRef, } template<typename BaseInterface> -inline void DeviceContextBase<BaseInterface> :: SetViewports( Uint32 NumViewports, const Viewport *pViewports, Uint32 &RTWidth, Uint32 &RTHeight ) +inline void DeviceContextBase<BaseInterface> :: SetViewports( Uint32 NumViewports, const Viewport* pViewports, Uint32& RTWidth, Uint32& RTHeight ) { if ( RTWidth == 0 || RTHeight == 0 ) { @@ -366,7 +366,7 @@ inline void DeviceContextBase<BaseInterface> :: SetViewports( Uint32 NumViewport } template<typename BaseInterface> -inline void DeviceContextBase<BaseInterface> :: GetViewports( Uint32 &NumViewports, Viewport *pViewports ) +inline void DeviceContextBase<BaseInterface> :: GetViewports( Uint32 &NumViewports, Viewport* pViewports ) { NumViewports = m_NumViewports; if ( pViewports ) @@ -377,7 +377,7 @@ inline void DeviceContextBase<BaseInterface> :: GetViewports( Uint32 &NumViewpor } template<typename BaseInterface> -inline void DeviceContextBase<BaseInterface> :: SetScissorRects( Uint32 NumRects, const Rect *pRects, Uint32 &RTWidth, Uint32 &RTHeight ) +inline void DeviceContextBase<BaseInterface> :: SetScissorRects( Uint32 NumRects, const Rect* pRects, Uint32& RTWidth, Uint32& RTHeight ) { if ( RTWidth == 0 || RTHeight == 0 ) { @@ -434,7 +434,7 @@ inline bool DeviceContextBase<BaseInterface> :: SetRenderTargets( Uint32 NumRend for( Uint32 rt = 0; rt < NumRenderTargets; ++rt ) { - auto *pRTView = ppRenderTargets[rt]; + auto* pRTView = ppRenderTargets[rt]; if ( pRTView ) { const auto &RTVDesc = pRTView->GetDesc(); @@ -445,7 +445,7 @@ inline bool DeviceContextBase<BaseInterface> :: SetRenderTargets( Uint32 NumRend // Use this RTV to set the render target size if (m_FramebufferWidth == 0) { - auto *pTex = pRTView->GetTexture(); + auto* pTex = pRTView->GetTexture(); const auto &TexDesc = pTex->GetDesc(); m_FramebufferWidth = std::max(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U); m_FramebufferHeight = std::max(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U); @@ -486,7 +486,7 @@ inline bool DeviceContextBase<BaseInterface> :: SetRenderTargets( Uint32 NumRend // Use depth stencil size to set render target size if (m_FramebufferWidth == 0) { - auto *pTex = pDepthStencil->GetTexture(); + auto* pTex = pDepthStencil->GetTexture(); const auto &TexDesc = pTex->GetDesc(); m_FramebufferWidth = std::max(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U); m_FramebufferHeight = std::max(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U); @@ -519,7 +519,7 @@ inline bool DeviceContextBase<BaseInterface> :: SetRenderTargets( Uint32 NumRend } template<typename BaseInterface> -inline void DeviceContextBase<BaseInterface> :: GetRenderTargets( Uint32 &NumRenderTargets, ITextureView **ppRTVs, ITextureView **ppDSV ) +inline void DeviceContextBase<BaseInterface> :: GetRenderTargets( Uint32 &NumRenderTargets, ITextureView** ppRTVs, ITextureView** ppDSV ) { NumRenderTargets = m_NumBoundRenderTargets; @@ -543,11 +543,11 @@ inline void DeviceContextBase<BaseInterface> :: GetRenderTargets( Uint32 &NumRen if ( ppDSV ) { - VERIFY( *ppDSV == nullptr, "Non-null DSV pointer found" ); + VERIFY(* ppDSV == nullptr, "Non-null DSV pointer found" ); if ( m_pBoundDepthStencil ) m_pBoundDepthStencil->QueryInterface( IID_TextureView, reinterpret_cast<IObject**>(ppDSV) ); else - *ppDSV = nullptr; + * ppDSV = nullptr; } } diff --git a/Graphics/GraphicsEngine/include/DeviceObjectBase.h b/Graphics/GraphicsEngine/include/DeviceObjectBase.h index 522b40c1..a0038e46 100644 --- a/Graphics/GraphicsEngine/include/DeviceObjectBase.h +++ b/Graphics/GraphicsEngine/include/DeviceObjectBase.h @@ -52,10 +52,10 @@ public: /// \param ObjDesc - object description. /// \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, - const ObjectDescType &ObjDesc, - bool bIsDeviceInternal = false) : + DeviceObjectBase( IReferenceCounters* pRefCounters, + IRenderDevice* 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 ), @@ -119,7 +119,7 @@ public: return m_UniqueID.GetID(); } - IRenderDevice *GetDevice()const{return m_pDevice;} + IRenderDevice* GetDevice()const{return m_pDevice;} template<typename Type> Type* GetDevice()const{return ValidatedCast<Type>(m_pDevice);} @@ -129,7 +129,7 @@ private: RefCntAutoPtr<IRenderDevice> m_spDevice; /// Pointer to the device - IRenderDevice *m_pDevice; + IRenderDevice* m_pDevice; protected: diff --git a/Graphics/GraphicsEngine/include/FenceBase.h b/Graphics/GraphicsEngine/include/FenceBase.h new file mode 100644 index 00000000..f743d157 --- /dev/null +++ b/Graphics/GraphicsEngine/include/FenceBase.h @@ -0,0 +1,66 @@ +/* Copyright 2015-2018 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +/// \file +/// Implementation of the Diligent::FenceBase template class + +#include "DeviceObjectBase.h" +#include "GraphicsTypes.h" +#include "RefCntAutoPtr.h" + +namespace Diligent +{ + +class IRenderDevice; +class IFence; + +/// Template class implementing base functionality for a Fence object + +/// \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> +{ +public: + typedef DeviceObjectBase<BaseInterface, 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 ) : + TDeviceObjectBase( pRefCounters, pDevice, Desc, bIsDeviceInternal ) + {} + + ~FenceBase() + { + } + + IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_Fence, TDeviceObjectBase ) +}; + +} diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.h b/Graphics/GraphicsEngine/include/PipelineStateBase.h index 092122f8..62e8bf91 100644 --- a/Graphics/GraphicsEngine/include/PipelineStateBase.h +++ b/Graphics/GraphicsEngine/include/PipelineStateBase.h @@ -38,11 +38,12 @@ namespace Diligent /// Template class implementing base functionality for a pipeline state object. -/// \tparam BaseInterface - base interface that this class will inheret -/// (Diligent::IPipelineStateD3D11, Diligent::IPipelineStateD3D12 or Diligent::IPipelineStateGL). +/// \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, -/// or Diligent::IRenderDeviceGLES). +/// (Diligent::IRenderDeviceD3D11, Diligent::IRenderDeviceD3D12, +/// Diligent::IRenderDeviceGL, Diligent::IRenderDeviceGLES or Diligent::IRenderDeviceVk). template<class BaseInterface, class RenderDeviceBaseInterface> class PipelineStateBase : public DeviceObjectBase<BaseInterface, PipelineStateDesc> { @@ -55,7 +56,10 @@ public: /// \param PSODesc - pipeline state description. /// \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, const PipelineStateDesc& PSODesc, bool bIsDeviceInternal = false ) : + PipelineStateBase( IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + const PipelineStateDesc& PSODesc, + bool bIsDeviceInternal = false ) : TDeviceObjectBase( pRefCounters, pDevice, PSODesc, bIsDeviceInternal ), m_LayoutElements( PSODesc.GraphicsPipeline.InputLayout.NumElements, LayoutElement(), STD_ALLOCATOR_RAW_MEM(LayoutElement, GetRawAllocator(), "Allocator for vector<LayoutElement>" ) ), m_NumShaders(0) @@ -222,12 +226,12 @@ public: // This function only compares shader resource layout hashes, so // it can potentially give false negatives - bool IsIncompatibleWith(IPipelineState *pPSO)const + bool IsIncompatibleWith(IPipelineState* pPSO)const { return m_ShaderResourceLayoutHash != ValidatedCast<PipelineStateBase>(pPSO)->m_ShaderResourceLayoutHash; } - virtual void BindShaderResources( IResourceMapping *pResourceMapping, Uint32 Flags )override + virtual void BindShaderResources( IResourceMapping* pResourceMapping, Uint32 Flags )override { for(Uint32 s=0; s < m_NumShaders; ++s) m_ppShaders[s]->BindResources(pResourceMapping, Flags); diff --git a/Graphics/GraphicsEngine/include/RenderDeviceBase.h b/Graphics/GraphicsEngine/include/RenderDeviceBase.h index 57f7e163..70cf4707 100644 --- a/Graphics/GraphicsEngine/include/RenderDeviceBase.h +++ b/Graphics/GraphicsEngine/include/RenderDeviceBase.h @@ -46,7 +46,7 @@ namespace std template<> struct hash<Diligent::SamplerDesc> { - size_t operator()( const Diligent::SamplerDesc &SamDesc ) const + size_t operator()( const Diligent::SamplerDesc& SamDesc ) const { // Sampler name is ignored in comparison operator // and should not be hashed @@ -72,7 +72,7 @@ namespace std template<> struct hash<Diligent::StencilOpDesc> { - size_t operator()( const Diligent::StencilOpDesc &StOpDesc ) const + size_t operator()( const Diligent::StencilOpDesc& StOpDesc ) const { return Diligent::ComputeHash( static_cast<int>( StOpDesc.StencilFailOp ), static_cast<int>( StOpDesc.StencilDepthFailOp ), @@ -85,7 +85,7 @@ namespace std template<> struct hash<Diligent::DepthStencilStateDesc> { - size_t operator()( const Diligent::DepthStencilStateDesc &DepthStencilDesc ) const + size_t operator()( const Diligent::DepthStencilStateDesc& DepthStencilDesc ) const { return Diligent::ComputeHash( DepthStencilDesc.DepthEnable, DepthStencilDesc.DepthWriteEnable, @@ -102,7 +102,7 @@ namespace std template<> struct hash<Diligent::RasterizerStateDesc> { - size_t operator()( const Diligent::RasterizerStateDesc &RasterizerDesc ) const + size_t operator()( const Diligent::RasterizerStateDesc& RasterizerDesc ) const { return Diligent::ComputeHash( static_cast<int>( RasterizerDesc.FillMode ), static_cast<int>( RasterizerDesc.CullMode ), @@ -120,7 +120,7 @@ namespace std template<> struct hash<Diligent::BlendStateDesc> { - size_t operator()( const Diligent::BlendStateDesc &BSDesc ) const + size_t operator()( const Diligent::BlendStateDesc& BSDesc ) const { std::size_t Seed = 0; for( int i = 0; i < Diligent::BlendStateDesc::MaxRenderTargets; ++i ) @@ -148,7 +148,7 @@ namespace std template<> struct hash<Diligent::TextureViewDesc> { - size_t operator()( const Diligent::TextureViewDesc &TexViewDesc ) const + size_t operator()( const Diligent::TextureViewDesc& TexViewDesc ) const { std::size_t Seed = 0; Diligent::HashCombine( Seed, @@ -187,18 +187,19 @@ public: /// \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) /// \param NumDeferredContexts - number of deferred device contexts - /// \param TextureObjSize - size of the texture object, in bytes - /// \param TexViewObjSize - size of the texture view object, in bytes - /// \param BufferObjSize - size of the buffer object, in bytes - /// \param BuffViewObjSize - size of the buffer view object, in bytes - /// \param ShaderObjSize - size of the shader object, in bytes - /// \param SamplerObjSize - size of the sampler object, in bytes - /// \param PSOSize - size of the pipeline state object, in bytes - /// \param SRBSize - size of the shader resource binding object, in bytes + /// \param TextureObjSize - size of the texture object, in bytes + /// \param TexViewObjSize - size of the texture view object, in bytes + /// \param BufferObjSize - size of the buffer object, in bytes + /// \param BuffViewObjSize - size of the buffer view object, in bytes + /// \param ShaderObjSize - size of the shader object, in bytes + /// \param SamplerObjSize - size of the sampler object, in bytes + /// \param PSOSize - size of the pipeline state object, in bytes + /// \param SRBSize - size of the shader resource binding object, in bytes + /// \param FenceSize - size of the fence object, in bytes /// \remarks Render device uses fixed block allocators (see FixedBlockMemoryAllocator) to allocate memory for /// device objects. The object sizes provided to constructor are used to initialize the allocators. - RenderDeviceBase(IReferenceCounters *pRefCounters, - IMemoryAllocator &RawMemAllocator, + RenderDeviceBase(IReferenceCounters* pRefCounters, + IMemoryAllocator& RawMemAllocator, Uint32 NumDeferredContexts, size_t TextureObjSize, size_t TexViewObjSize, @@ -207,21 +208,23 @@ public: size_t ShaderObjSize, size_t SamplerObjSize, size_t PSOSize, - size_t SRBSize) : - TObjectBase(pRefCounters), - m_SamplersRegistry(RawMemAllocator, "sampler"), - m_TextureFormatsInfo( TEX_FORMAT_NUM_FORMATS, TextureFormatInfoExt(), STD_ALLOCATOR_RAW_MEM(TextureFormatInfoExt, RawMemAllocator, "Allocator for vector<TextureFormatInfoExt>") ), - m_TexFmtInfoInitFlags( TEX_FORMAT_NUM_FORMATS, false, STD_ALLOCATOR_RAW_MEM(bool, RawMemAllocator, "Allocator for vector<bool>") ), - m_wpDeferredContexts(NumDeferredContexts, RefCntWeakPtr<IDeviceContext>(), STD_ALLOCATOR_RAW_MEM(RefCntWeakPtr<IDeviceContext>, RawMemAllocator, "Allocator for vector< RefCntWeakPtr<IDeviceContext> >")), - m_TexObjAllocator(RawMemAllocator, TextureObjSize, 64), - m_TexViewObjAllocator(RawMemAllocator, TexViewObjSize, 64), - m_BufObjAllocator(RawMemAllocator, BufferObjSize, 128), - m_BuffViewObjAllocator(RawMemAllocator, BuffViewObjSize, 128), - m_ShaderObjAllocator(RawMemAllocator, ShaderObjSize, 32), - m_SamplerObjAllocator(RawMemAllocator, SamplerObjSize, 32), - m_PSOAllocator(RawMemAllocator, PSOSize, 128), - m_SRBAllocator(RawMemAllocator, SRBSize, 1024), - m_ResMappingAllocator(RawMemAllocator, sizeof(ResourceMappingImpl), 16) + size_t SRBSize, + size_t FenceSize) : + TObjectBase (pRefCounters), + m_SamplersRegistry (RawMemAllocator, "sampler"), + m_TextureFormatsInfo (TEX_FORMAT_NUM_FORMATS, TextureFormatInfoExt(), STD_ALLOCATOR_RAW_MEM(TextureFormatInfoExt, RawMemAllocator, "Allocator for vector<TextureFormatInfoExt>") ), + m_TexFmtInfoInitFlags (TEX_FORMAT_NUM_FORMATS, false, STD_ALLOCATOR_RAW_MEM(bool, RawMemAllocator, "Allocator for vector<bool>") ), + m_wpDeferredContexts (NumDeferredContexts, RefCntWeakPtr<IDeviceContext>(), STD_ALLOCATOR_RAW_MEM(RefCntWeakPtr<IDeviceContext>, RawMemAllocator, "Allocator for vector< RefCntWeakPtr<IDeviceContext> >")), + m_TexObjAllocator (RawMemAllocator, TextureObjSize, 64), + m_TexViewObjAllocator (RawMemAllocator, TexViewObjSize, 64), + m_BufObjAllocator (RawMemAllocator, BufferObjSize, 128), + m_BuffViewObjAllocator (RawMemAllocator, BuffViewObjSize, 128), + m_ShaderObjAllocator (RawMemAllocator, ShaderObjSize, 32), + m_SamplerObjAllocator (RawMemAllocator, SamplerObjSize, 32), + m_PSOAllocator (RawMemAllocator, PSOSize, 128), + m_SRBAllocator (RawMemAllocator, SRBSize, 1024), + m_FenceAllocator (RawMemAllocator, FenceSize, 16), + m_ResMappingAllocator (RawMemAllocator, sizeof(ResourceMappingImpl), 16) { // Initialize texture format info for( Uint32 Fmt = TEX_FORMAT_UNKNOWN; Fmt < TEX_FORMAT_NUM_FORMATS; ++Fmt ) @@ -289,7 +292,7 @@ public: } /// Implementation of IRenderDevice::GetTextureFormatInfo(). - virtual const TextureFormatInfo &GetTextureFormatInfo(TEXTURE_FORMAT TexFormat)override final + virtual const TextureFormatInfo& GetTextureFormatInfo(TEXTURE_FORMAT TexFormat)override final { VERIFY( TexFormat >= TEX_FORMAT_UNKNOWN && TexFormat < TEX_FORMAT_NUM_FORMATS, "Texture format out of range" ); const auto& TexFmtInfo = m_TextureFormatsInfo[TexFormat]; @@ -298,7 +301,7 @@ public: } /// Implementation of IRenderDevice::GetTextureFormatInfoExt(). - virtual const TextureFormatInfoExt &GetTextureFormatInfoExt( TEXTURE_FORMAT TexFormat )override final + virtual const TextureFormatInfoExt& GetTextureFormatInfoExt( TEXTURE_FORMAT TexFormat )override final { VERIFY( TexFormat >= TEX_FORMAT_UNKNOWN && TexFormat < TEX_FORMAT_NUM_FORMATS, "Texture format out of range" ); const auto& TexFmtInfo = m_TextureFormatsInfo[TexFormat]; @@ -312,21 +315,21 @@ public: return TexFmtInfo; } - void OnCreateDeviceObject( IDeviceObject *pNewObject ) + void OnCreateDeviceObject( IDeviceObject* pNewObject ) { } StateObjectsRegistry<SamplerDesc>& GetSamplerRegistry(){ return m_SamplersRegistry; } /// Set weak reference to the immediate context - void SetImmediateContext(IDeviceContext *pImmediateContext) + void SetImmediateContext(IDeviceContext* pImmediateContext) { VERIFY( m_wpImmediateContext.Lock() == nullptr, "Immediate context has already been set" ); m_wpImmediateContext = pImmediateContext; } /// Set weak reference to the deferred context - void SetDeferredContext(size_t Ctx, IDeviceContext *pDeferredCtx) + void SetDeferredContext(size_t Ctx, IDeviceContext* pDeferredCtx) { VERIFY( m_wpDeferredContexts[Ctx].Lock() == nullptr, "Deferred context has already been set" ); m_wpDeferredContexts[Ctx] = pDeferredCtx; @@ -378,6 +381,7 @@ protected: FixedBlockMemoryAllocator m_PSOAllocator; ///< Allocator for pipeline state objects FixedBlockMemoryAllocator m_SRBAllocator; ///< Allocator for shader resource binding objects FixedBlockMemoryAllocator m_ResMappingAllocator; ///< Allocator for resource mapping objects + FixedBlockMemoryAllocator m_FenceAllocator; ///< Allocator for fence objects }; @@ -389,11 +393,11 @@ void RenderDeviceBase<BaseInterface>::CreateResourceMapping( const ResourceMappi return; VERIFY( *ppMapping == nullptr, "Overwriting reference to existing object may cause memory leaks" ); - auto *pResourceMapping( NEW_RC_OBJ(m_ResMappingAllocator, "ResourceMappingImpl instance", ResourceMappingImpl)(GetRawAllocator()) ); + auto* pResourceMapping( NEW_RC_OBJ(m_ResMappingAllocator, "ResourceMappingImpl instance", ResourceMappingImpl)(GetRawAllocator()) ); pResourceMapping->QueryInterface( IID_ResourceMapping, reinterpret_cast<IObject**>(ppMapping) ); if( MappingDesc.pEntries ) { - for( auto *pEntry = MappingDesc.pEntries; pEntry->Name && pEntry->pObject; ++pEntry ) + for( auto* pEntry = MappingDesc.pEntries; pEntry->Name && pEntry->pObject; ++pEntry ) { (*ppMapping)->AddResourceArray( pEntry->Name, pEntry->ArrayIndex, &pEntry->pObject, 1, true ); } @@ -416,7 +420,7 @@ void RenderDeviceBase<BaseInterface> :: CreateDeviceObject( const Char *ObjectTy if(!ppObject) return; - VERIFY( *ppObject == nullptr, "Overwriting reference to existing object may cause memory leaks" ); + VERIFY(*ppObject == nullptr, "Overwriting reference to existing object may cause memory leaks" ); // Do not release *ppObject here! // Should this happen, RefCntAutoPtr<> will take care of this! //if( *ppObject ) diff --git a/Graphics/GraphicsEngine/include/ResourceMappingImpl.h b/Graphics/GraphicsEngine/include/ResourceMappingImpl.h index cbbf963a..76337d59 100644 --- a/Graphics/GraphicsEngine/include/ResourceMappingImpl.h +++ b/Graphics/GraphicsEngine/include/ResourceMappingImpl.h @@ -42,7 +42,7 @@ namespace Diligent { } - ResMappingHashKey(ResMappingHashKey &&rhs) : + ResMappingHashKey(ResMappingHashKey&& rhs) : StrKey(std::move(rhs.StrKey)), ArrayIndex(rhs.ArrayIndex) {} @@ -63,7 +63,7 @@ namespace Diligent } - ResMappingHashKey( const ResMappingHashKey& ) = delete; + ResMappingHashKey ( const ResMappingHashKey& ) = delete; ResMappingHashKey& operator = ( const ResMappingHashKey& ) = delete; ResMappingHashKey& operator = ( ResMappingHashKey&& ) = delete; @@ -78,7 +78,7 @@ namespace std template<> struct hash<Diligent::ResMappingHashKey> { - size_t operator()( const Diligent::ResMappingHashKey &Key ) const + size_t operator()( const Diligent::ResMappingHashKey& Key ) const { return Key.GetHash(); } @@ -97,26 +97,26 @@ namespace Diligent /// \param pRefCounters - reference counters object that controls the lifetime of this resource mapping /// \param RawMemAllocator - raw memory allocator that is used by the m_HashTable member - ResourceMappingImpl(IReferenceCounters *pRefCounters, IMemoryAllocator &RawMemAllocator) : + ResourceMappingImpl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator) : TObjectBase(pRefCounters), m_HashTable(STD_ALLOCATOR_RAW_MEM(HashTableElem, RawMemAllocator, "Allocator for unordered_map< ResMappingHashKey, RefCntAutoPtr<IDeviceObject> >") ) {} ~ResourceMappingImpl(); - virtual void QueryInterface( const Diligent::INTERFACE_ID &IID, IObject **ppInterface )override final; + virtual void QueryInterface( const Diligent::INTERFACE_ID& IID, IObject** ppInterface )override final; /// Implementation of IResourceMapping::AddResource() - virtual void AddResource( const Char *Name, IDeviceObject *pObject, bool bIsUnique )override final; + virtual void AddResource( const Char* Name, IDeviceObject* pObject, bool bIsUnique )override final; /// Implementation of IResourceMapping::AddResourceArray() - virtual void AddResourceArray( const Char *Name, Uint32 StartIndex, IDeviceObject * const* ppObjects, Uint32 NumElements, bool bIsUnique )override final; + virtual void AddResourceArray( const Char* Name, Uint32 StartIndex, IDeviceObject* const* ppObjects, Uint32 NumElements, bool bIsUnique )override final; /// Implementation of IResourceMapping::RemoveResourceByName() - virtual void RemoveResourceByName( const Char *Name, Uint32 ArrayIndex )override final; + virtual void RemoveResourceByName( const Char* Name, Uint32 ArrayIndex )override final; /// Implementation of IResourceMapping::GetResource() - virtual void GetResource( const Char *Name, IDeviceObject **ppResource, Uint32 ArrayIndex )override final; + virtual void GetResource( const Char* Name, IDeviceObject** ppResource, Uint32 ArrayIndex )override final; /// Returns number of resources in the resource mapping. virtual size_t GetSize()override final; diff --git a/Graphics/GraphicsEngine/include/SamplerBase.h b/Graphics/GraphicsEngine/include/SamplerBase.h index 0eeb37e6..c6e69c7e 100644 --- a/Graphics/GraphicsEngine/include/SamplerBase.h +++ b/Graphics/GraphicsEngine/include/SamplerBase.h @@ -35,10 +35,12 @@ namespace Diligent /// Template class implementing base functionality for a sampler object. -/// \tparam BaseInterface - base interface that this class will inheret -/// (Diligent::ISamplerD3D11, Diligent::ISamplerD3D12 or Diligent::ISamplerGL). +/// \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, or Diligent::IRenderDeviceGLES). +/// (Diligent::IRenderDeviceD3D11, Diligent::IRenderDeviceD3D12, Diligent::IRenderDeviceGL, +/// Diligent::IRenderDeviceGLES or Diligent::IRenderDeviceVk). template<class BaseInterface, class RenderDeviceBaseInterface> class SamplerBase : public DeviceObjectBase<BaseInterface, SamplerDesc> { @@ -51,7 +53,7 @@ public: /// \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, IRenderDevice* pDevice, const SamplerDesc& SamDesc, bool bIsDeviceInternal = false ) : TDeviceObjectBase( pRefCounters, pDevice, SamDesc, bIsDeviceInternal ) {} @@ -59,7 +61,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 = static_cast<TRenderDeviceBase*>(this->GetDevice())->GetSamplerRegistry(); SamplerRegistry.ReportDeletedObject(); } diff --git a/Graphics/GraphicsEngine/include/ShaderBase.h b/Graphics/GraphicsEngine/include/ShaderBase.h index 5b47bcbd..7db44cfe 100644 --- a/Graphics/GraphicsEngine/include/ShaderBase.h +++ b/Graphics/GraphicsEngine/include/ShaderBase.h @@ -69,7 +69,7 @@ static const int DSInd = GetShaderTypeIndex(SHADER_TYPE_DOMAIN); static const int CSInd = GetShaderTypeIndex(SHADER_TYPE_COMPUTE); template<typename TNameCompare> -SHADER_VARIABLE_TYPE GetShaderVariableType(SHADER_VARIABLE_TYPE DefaultVariableType, const ShaderVariableDesc *VariableDesc, Uint32 NumVars, TNameCompare NameCompare) +SHADER_VARIABLE_TYPE GetShaderVariableType(SHADER_VARIABLE_TYPE DefaultVariableType, const ShaderVariableDesc* VariableDesc, Uint32 NumVars, TNameCompare NameCompare) { for (Uint32 v = 0; v < NumVars; ++v) { @@ -82,7 +82,7 @@ SHADER_VARIABLE_TYPE GetShaderVariableType(SHADER_VARIABLE_TYPE DefaultVariableT return DefaultVariableType; } -inline SHADER_VARIABLE_TYPE GetShaderVariableType(const Char* Name, SHADER_VARIABLE_TYPE DefaultVariableType, const ShaderVariableDesc *VariableDesc, Uint32 NumVars) +inline SHADER_VARIABLE_TYPE GetShaderVariableType(const Char* Name, SHADER_VARIABLE_TYPE DefaultVariableType, const ShaderVariableDesc* VariableDesc, Uint32 NumVars) { return GetShaderVariableType(DefaultVariableType, VariableDesc, NumVars, [&](const char *VarName) @@ -117,7 +117,7 @@ inline SHADER_VARIABLE_TYPE GetShaderVariableType(const String& Name, const Shad struct ShaderVariableBase : public IShaderVariable { - ShaderVariableBase(IObject &Owner) : + ShaderVariableBase(IObject& Owner) : // Shader variables are always created as part of the shader, or // shader resource binding, so we must provide owner pointer to // the base class constructor @@ -145,7 +145,7 @@ struct ShaderVariableBase : public IShaderVariable return m_Owner.Release(); } - virtual void QueryInterface( const INTERFACE_ID &IID, IObject **ppInterface )override final + virtual void QueryInterface( const INTERFACE_ID& IID, IObject** ppInterface )override final { if( ppInterface == nullptr ) return; @@ -165,7 +165,7 @@ protected: /// Implementation of a dummy shader variable that silently ignores all operations struct DummyShaderVariable : ShaderVariableBase { - DummyShaderVariable(IObject &Owner) : + DummyShaderVariable(IObject& Owner) : ShaderVariableBase(Owner) {} @@ -184,10 +184,12 @@ struct DummyShaderVariable : ShaderVariableBase /// Template class implementing base functionality for a shader object -/// \tparam BaseInterface - base interface that this class will inheret -/// (Diligent::IShaderD3D11, Diligent::IShaderD3D12 or Diligent::IShaderGL). +/// \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, or Diligent::IRenderDeviceGLES). +/// (Diligent::IRenderDeviceD3D11, Diligent::IRenderDeviceD3D12, +/// Diligent::IRenderDeviceGL, Diligent::IRenderDeviceGLES or Diligent::IRenderDeviceVk). template<class BaseInterface, class RenderDeviceBaseInterface> class ShaderBase : public DeviceObjectBase<BaseInterface, ShaderDesc> { @@ -199,11 +201,11 @@ public: /// \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, IRenderDevice* 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>") ), - m_StringPool(ShdrDesc.NumVariables + ShdrDesc.NumStaticSamplers, String(), STD_ALLOCATOR_RAW_MEM(String, GetRawAllocator(), "Allocator for vector<String>")), + m_VariablesDesc (ShdrDesc.NumVariables, ShaderVariableDesc(), STD_ALLOCATOR_RAW_MEM(ShaderVariableDesc, GetRawAllocator(), "Allocator for vector<ShaderVariableDesc>") ), + m_StringPool (ShdrDesc.NumVariables + ShdrDesc.NumStaticSamplers, String(), STD_ALLOCATOR_RAW_MEM(String, GetRawAllocator(), "Allocator for vector<String>")), m_StaticSamplers(ShdrDesc.NumStaticSamplers, StaticSamplerDesc(), STD_ALLOCATOR_RAW_MEM(StaticSamplerDesc, GetRawAllocator(), "Allocator for vector<StaticSamplerDesc>") ) { auto Str = m_StringPool.begin(); diff --git a/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.h b/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.h index 14e4e89e..822d44b9 100644 --- a/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.h +++ b/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.h @@ -37,7 +37,8 @@ namespace Diligent /// Template class implementing base functionality for a shader resource binding /// \tparam BaseInterface - base interface that this class will inheret -/// (Diligent::IShaderResourceBindingGL, Diligent::IShaderResourceBindingD3D11, or Diligent::IShaderResourceBindingD3D12). +/// (Diligent::IShaderResourceBindingGL, Diligent::IShaderResourceBindingD3D11, +/// Diligent::IShaderResourceBindingD3D12 or Diligent::IShaderResourceBindingVk). template<class BaseInterface> class ShaderResourceBindingBase : public ObjectBase<BaseInterface> { @@ -48,7 +49,7 @@ public: /// \param pPSO - pipeline state that this SRB belongs to. /// \param IsInternal - flag indicating if the shader resource binding is an internal PSO object and /// must not keep a strong reference to the PSO. - ShaderResourceBindingBase( IReferenceCounters *pRefCounters, IPipelineState *pPSO, bool IsInternal = false ) : + ShaderResourceBindingBase( IReferenceCounters* pRefCounters, IPipelineState* pPSO, bool IsInternal = false ) : TObjectBase( pRefCounters ), m_spPSO( IsInternal ? nullptr : pPSO ), m_pPSO( pPSO ) @@ -68,7 +69,7 @@ protected: /// shader resource binding uses PSO's memory allocator to allocate /// memory for shader resource cache. RefCntAutoPtr<IPipelineState> m_spPSO; - IPipelineState *m_pPSO; + IPipelineState* const m_pPSO; }; } diff --git a/Graphics/GraphicsEngine/include/StateObjectsRegistry.h b/Graphics/GraphicsEngine/include/StateObjectsRegistry.h index a1bc96bc..75883f5d 100644 --- a/Graphics/GraphicsEngine/include/StateObjectsRegistry.h +++ b/Graphics/GraphicsEngine/include/StateObjectsRegistry.h @@ -61,7 +61,7 @@ namespace Diligent /// Number of outstanding deleted objects to purge the registry. static constexpr int DeletedObjectsToPurge = 32; - StateObjectsRegistry(IMemoryAllocator &RawAllocator, const Char* RegistryName) : + StateObjectsRegistry(IMemoryAllocator& RawAllocator, const Char* RegistryName) : m_DescToObjHashMap(STD_ALLOCATOR_RAW_MEM(HashMapElem, RawAllocator, "Allocator for unordered_map<ResourceDescType, RefCntWeakPtr<IDeviceObject> >") ), m_RegistryName( RegistryName ) {} @@ -88,7 +88,7 @@ namespace Diligent /// assumed to be an expensive operation and should be performed during /// the initialization. Occasional purge operations should not add significant /// cost to it. - void Add( const ResourceDescType& ObjectDesc, IDeviceObject *pObject ) + void Add( const ResourceDescType& ObjectDesc, IDeviceObject* pObject ) { ThreadingTools::LockHelper Lock( m_LockFlag ); @@ -126,7 +126,7 @@ namespace Diligent } /// Finds the object in the registry - void Find( const ResourceDescType &Desc, IDeviceObject **ppObject ) + void Find( const ResourceDescType& Desc, IDeviceObject** ppObject ) { VERIFY( *ppObject == nullptr, "Overwriting reference to existing object may cause memory leaks" ); *ppObject = nullptr; diff --git a/Graphics/GraphicsEngine/include/SwapChainBase.h b/Graphics/GraphicsEngine/include/SwapChainBase.h index c01c7d04..2f74d3c1 100644 --- a/Graphics/GraphicsEngine/include/SwapChainBase.h +++ b/Graphics/GraphicsEngine/include/SwapChainBase.h @@ -36,7 +36,8 @@ namespace Diligent /// Base implementation of the swap chain. /// \tparam BaseInterface - base interface that this class will inheret -/// (Diligent::ISwapChainGL, Diligent::ISwapChainD3D11, or Diligent::ISwapChainD3D12). +/// (Diligent::ISwapChainGL, Diligent::ISwapChainD3D11, +/// Diligent::ISwapChainD3D12 or Diligent::ISwapChainVk). /// \remarks Swap chain holds the strong reference to the device and a weak reference to the /// immediate context. template<class BaseInterface> @@ -49,9 +50,9 @@ public: /// \param pDevice - pointer to the device. /// \param pDeviceContext - pointer to the device context. /// \param SCDesc - swap chain description - SwapChainBase( IReferenceCounters *pRefCounters, - IRenderDevice *pDevice, - IDeviceContext *pDeviceContext, + SwapChainBase( IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, + IDeviceContext* pDeviceContext, const SwapChainDesc& SCDesc ) : TObjectBase(pRefCounters), m_pRenderDevice(pDevice), @@ -98,8 +99,8 @@ protected: SwapChainDesc m_SwapChainDesc; private: - SwapChainBase( const SwapChainBase& ); - SwapChainBase( SwapChainBase&& ); + SwapChainBase ( const SwapChainBase& ); + SwapChainBase ( SwapChainBase&& ); const SwapChainBase& operator = ( const SwapChainBase& ); const SwapChainBase& operator = ( SwapChainBase&& ); }; diff --git a/Graphics/GraphicsEngine/include/TextureBase.h b/Graphics/GraphicsEngine/include/TextureBase.h index 60d08e0c..c9abf042 100644 --- a/Graphics/GraphicsEngine/include/TextureBase.h +++ b/Graphics/GraphicsEngine/include/TextureBase.h @@ -36,17 +36,19 @@ namespace Diligent { void ValidateTextureDesc(const TextureDesc& TexDesc); -void ValidateUpdateDataParams( const TextureDesc &TexDesc, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData ); -void VliadateCopyTextureDataParams( const TextureDesc &SrcTexDesc, Uint32 SrcMipLevel, Uint32 SrcSlice, const Box *pSrcBox, - const TextureDesc &DstTexDesc, Uint32 DstMipLevel, Uint32 DstSlice, +void ValidateUpdateDataParams( const TextureDesc &TexDesc, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData ); +void VliadateCopyTextureDataParams( const TextureDesc& SrcTexDesc, Uint32 SrcMipLevel, Uint32 SrcSlice, const Box* pSrcBox, + const TextureDesc& DstTexDesc, Uint32 DstMipLevel, Uint32 DstSlice, Uint32 DstX, Uint32 DstY, Uint32 DstZ ); /// Base implementation of the ITexture interface -/// \tparam BaseInterface - base interface that this class will inheret -/// (Diligent::ITextureD3D11, Diligent::ITextureD3D12 or Diligent::ITextureGL). -/// \tparam TTextureViewImpl - type of the texture view implementation -/// (Diligent::TextureViewD3D11Impl, Diligent::TextureViewD3D12Impl or Diligent::TextureViewGLImpl). +/// \tparam BaseInterface - base interface that this class will inheret +/// (Diligent::ITextureD3D11, Diligent::ITextureD3D12, +/// Diligent::ITextureGL or Diligent::ITextureVk). +/// \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> @@ -61,11 +63,11 @@ public: /// \param Desc - texture description /// \param bIsDeviceInternal - flag indicating if the texture is an internal device object and /// must not keep a strong reference to the device - TextureBase( IReferenceCounters *pRefCounters, - TTexViewObjAllocator &TexViewObjAllocator, - IRenderDevice *pDevice, - const TextureDesc& Desc, - bool bIsDeviceInternal = false ) : + TextureBase( IReferenceCounters* pRefCounters, + TTexViewObjAllocator& TexViewObjAllocator, + IRenderDevice* pDevice, + const TextureDesc& Desc, + bool bIsDeviceInternal = false ) : TDeviceObjectBase( pRefCounters, pDevice, Desc, bIsDeviceInternal ), #ifdef _DEBUG m_dbgTexViewObjAllocator(TexViewObjAllocator), @@ -108,17 +110,17 @@ public: /// Implementaiton of ITexture::CreateView(); calls CreateViewInternal() virtual function that /// creates texture view for the specific engine implementation. - virtual void CreateView( const struct TextureViewDesc &ViewDesc, ITextureView **ppView )override + virtual void CreateView( const struct TextureViewDesc& ViewDesc, ITextureView** ppView )override { CreateViewInternal( ViewDesc, ppView, false ); } /// Base implementaiton of ITexture::UpdateData(); validates input parameters - virtual void UpdateData( IDeviceContext *pContext, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData )override = 0; + virtual void UpdateData( IDeviceContext* pContext, Uint32 MipLevel, Uint32 Slice, const Box& DstBox, const TextureSubResData& SubresData )override = 0; /// Base implementaiton of ITexture::CopyData(); validates input parameters - virtual void CopyData( IDeviceContext *pContext, - ITexture *pSrcTexture, + virtual void CopyData( IDeviceContext* pContext, + ITexture* pSrcTexture, Uint32 SrcMipLevel, Uint32 SrcSlice, const Box *pSrcBox, @@ -129,10 +131,10 @@ public: Uint32 DstZ )override = 0; /// Base implementaiton of ITexture::Map() - virtual void Map( IDeviceContext *pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags, MappedTextureSubresource &MappedData )override = 0; + virtual void Map( IDeviceContext* pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags, MappedTextureSubresource& MappedData )override = 0; /// Base implementaiton of ITexture::Unmap() - virtual void Unmap( IDeviceContext *pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags )override = 0; + virtual void Unmap( IDeviceContext* pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags )override = 0; /// Creates default texture views. @@ -148,7 +150,7 @@ public: protected: /// Pure virtual function that creates texture view for the specific engine implementation. - virtual void CreateViewInternal( const struct TextureViewDesc &ViewDesc, ITextureView **ppView, bool bIsDefaultView ) = 0; + virtual void CreateViewInternal( const struct TextureViewDesc& ViewDesc, ITextureView** ppView, bool bIsDefaultView ) = 0; #ifdef _DEBUG TTexViewObjAllocator &m_dbgTexViewObjAllocator; @@ -176,12 +178,12 @@ protected: } } - void CorrectTextureViewDesc( struct TextureViewDesc &ViewDesc ); + void CorrectTextureViewDesc( struct TextureViewDesc& ViewDesc ); }; template<class BaseInterface, class TTextureViewImpl, class TTexViewObjAllocator> -void TextureBase<BaseInterface, TTextureViewImpl, TTexViewObjAllocator> :: CorrectTextureViewDesc(struct TextureViewDesc &ViewDesc) +void TextureBase<BaseInterface, TTextureViewImpl, TTexViewObjAllocator> :: CorrectTextureViewDesc(struct TextureViewDesc& ViewDesc) { #define TEX_VIEW_VALIDATION_ERROR(...) LOG_ERROR_AND_THROW( "Texture view \"", ViewDesc.Name ? ViewDesc.Name : "", "\": ", ##__VA_ARGS__ ) @@ -441,14 +443,15 @@ 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 ) +void TextureBase<BaseInterface, 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( IDeviceContext *pContext, - ITexture *pSrcTexture, +void TextureBase<BaseInterface, TTextureViewImpl, TTexViewObjAllocator> :: CopyData( + IDeviceContext* pContext, + ITexture* pSrcTexture, Uint32 SrcMipLevel, Uint32 SrcSlice, const Box *pSrcBox, @@ -465,12 +468,12 @@ void TextureBase<BaseInterface, TTextureViewImpl, TTexViewObjAllocator> :: CopyD } template<class BaseInterface, class TTextureViewImpl, class TTexViewObjAllocator> -void TextureBase<BaseInterface, TTextureViewImpl, TTexViewObjAllocator> :: Map( IDeviceContext *pContext, Uint32 Subresource, MAP_TYPE MapType, Uint32 MapFlags, MappedTextureSubresource &MappedData ) +void TextureBase<BaseInterface, 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 ) +void TextureBase<BaseInterface, 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 b8e7847a..0837b962 100644 --- a/Graphics/GraphicsEngine/include/TextureViewBase.h +++ b/Graphics/GraphicsEngine/include/TextureViewBase.h @@ -37,7 +37,8 @@ namespace Diligent /// Template class implementing base functionality for a texture view interface /// \tparam BaseInterface - base interface that this class will inheret -/// (Diligent::ITextureViewD3D11, Diligent::ITextureViewD3D12 or Diligent::ITextureViewGL). +/// (Diligent::ITextureViewD3D11, Diligent::ITextureViewD3D12, +/// Diligent::ITextureViewGL or Diligent::ITextureViewVk). template<class BaseInterface> class TextureViewBase : public DeviceObjectBase<BaseInterface, TextureViewDesc> { @@ -52,11 +53,11 @@ public: /// \param bIsDefaultView - flag indicating if the view is default view, and is thus /// part of the texture object. In this case the view will attach /// to the texture's reference counters. - TextureViewBase( IReferenceCounters *pRefCounters, - IRenderDevice *pDevice, + TextureViewBase( IReferenceCounters* pRefCounters, + IRenderDevice* pDevice, const TextureViewDesc& ViewDesc, - class ITexture *pTexture, - bool bIsDefaultView ) : + class ITexture* pTexture, + bool bIsDefaultView ) : // Default views are created as part of the texture, so we cannot not keep strong // reference to the texture to avoid cyclic links. Instead, we will attach to the // reference counters of the texture. @@ -117,7 +118,7 @@ protected: Diligent::RefCntAutoPtr<ISampler> m_pSampler; /// Raw pointer to the texture - ITexture *m_pTexture; + ITexture* const m_pTexture; /// Strong reference to the texture. Used for non-default views /// to keep the texture alive diff --git a/Graphics/GraphicsEngine/interface/Fence.h b/Graphics/GraphicsEngine/interface/Fence.h new file mode 100644 index 00000000..aab72307 --- /dev/null +++ b/Graphics/GraphicsEngine/interface/Fence.h @@ -0,0 +1,63 @@ +/* Copyright 2015-2018 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +/// \file +/// Defines Diligent::IFence interface and related data structures + +#include "DeviceObject.h" + +namespace Diligent +{ + +// {3B19184D-32AB-4701-84F4-9A0C03AE1672} +static constexpr INTERFACE_ID IID_Fence = +{ 0x3b19184d, 0x32ab, 0x4701, { 0x84, 0xf4, 0x9a, 0xc, 0x3, 0xae, 0x16, 0x72 } }; + +/// Buffer description +struct FenceDesc : DeviceObjectAttribs +{ + +}; + +/// Fence interface + +/// Fence the methods to manipulate a fence object +class IFence : public IDeviceObject +{ +public: + /// Queries the specific interface, see IObject::QueryInterface() for details + virtual void QueryInterface( const Diligent::INTERFACE_ID& IID, IObject** ppInterface ) = 0; + + /// Returns the fence description used to create the object + virtual const FenceDesc& GetDesc()const = 0; + + /// Returns the last completed value signaled by the GPU + virtual Uint64 GetCompletedValue() = 0; + + /// Resets the fence to the specified value. + virtual void Reset(Uint64 Value) = 0; +}; + +} diff --git a/Graphics/GraphicsEngine/interface/RenderDevice.h b/Graphics/GraphicsEngine/interface/RenderDevice.h index f99a885a..6f0b8c63 100644 --- a/Graphics/GraphicsEngine/interface/RenderDevice.h +++ b/Graphics/GraphicsEngine/interface/RenderDevice.h @@ -39,6 +39,7 @@ #include "TextureView.h" #include "BufferView.h" #include "PipelineState.h" +#include "Fence.h" #include "DepthStencilState.h" #include "RasterizerState.h" @@ -56,7 +57,7 @@ class IRenderDevice : public IObject { public: /// Queries the specific interface, see IObject::QueryInterface() for details - virtual void QueryInterface( const INTERFACE_ID &IID, IObject **ppInterface ) = 0; + virtual void QueryInterface( const INTERFACE_ID& IID, IObject** ppInterface ) = 0; /// Creates a new buffer object @@ -76,7 +77,7 @@ public: /// ElementByteStride member of buffer description is set to default value (0). virtual void CreateBuffer(const BufferDesc& BuffDesc, const BufferData& BuffData, - IBuffer **ppBuffer) = 0; + IBuffer** ppBuffer) = 0; /// Creates a new shader object @@ -86,8 +87,8 @@ public: /// shader interface will be stored. /// The function calls AddRef(), so that the new object will contain /// one refernce. - virtual void CreateShader(const ShaderCreationAttribs &CreationAttribs, - IShader **ppShader) = 0; + virtual void CreateShader(const ShaderCreationAttribs& CreationAttribs, + IShader** ppShader) = 0; /// Creates a new texture object @@ -112,12 +113,12 @@ public: /// For a 15 x 6 x 4 3D texture, the following array of subresources should be provided:\n /// 15x6x4, 7x3x2, 3x1x1, 1x1x1 virtual void CreateTexture(const TextureDesc& TexDesc, - const TextureData &Data, - ITexture **ppTexture) = 0; + const TextureData& Data, + ITexture** ppTexture) = 0; /// Creates a new sampler object - /// \param [in] SamDesc - Sampler description, see Diligent::SamplerDesc for details. + /// \param [in] SamDesc - Sampler description, see Diligent::SamplerDesc for details. /// \param [out] ppSampler - Address of the memory location where the pointer to the /// sampler interface will be stored. /// The function calls AddRef(), so that the new object will contain @@ -126,27 +127,38 @@ public: /// as an existing interface, the same interface will be returned. /// \note In D3D11, 4096 unique sampler state objects can be created on a device at a time. virtual void CreateSampler(const SamplerDesc& SamDesc, - ISampler **ppSampler) = 0; + ISampler** ppSampler) = 0; /// Creates a new resource mapping - /// \param [in] MappingDesc - Resource mapping description, see Diligent::ResourceMappingDesc for details. - /// \param [out] ppMapping - Address of the memory location where the pointer to the - /// resource mapping interface will be stored. - /// The function calls AddRef(), so that the new object will contain - /// one refernce. - virtual void CreateResourceMapping( const ResourceMappingDesc &MappingDesc, - IResourceMapping **ppMapping ) = 0; + /// \param [in] MappingDesc - Resource mapping description, see Diligent::ResourceMappingDesc for details. + /// \param [out] ppMapping - Address of the memory location where the pointer to the + /// resource mapping interface will be stored. + /// The function calls AddRef(), so that the new object will contain + /// one refernce. + virtual void CreateResourceMapping( const ResourceMappingDesc& MappingDesc, + IResourceMapping** ppMapping ) = 0; /// Creates a new pipeline state object - /// \param [in] PipelineDesc - Pipeline state description, see Diligent::PipelineStateDesc for details. + /// \param [in] PipelineDesc - Pipeline state description, see Diligent::PipelineStateDesc for details. /// \param [out] ppPipelineState - Address of the memory location where the pointer to the /// pipeline state interface will be stored. /// The function calls AddRef(), so that the new object will contain /// one refernce. - virtual void CreatePipelineState( const PipelineStateDesc &PipelineDesc, - IPipelineState **ppPipelineState ) = 0; + virtual void CreatePipelineState( const PipelineStateDesc& PipelineDesc, + IPipelineState** ppPipelineState ) = 0; + + + /// Creates a new pipeline state object + + /// \param [in] Desc - Fence description, see Diligent::FenceDesc for details. + /// \param [out] ppFence - Address of the memory location where the pointer to the + /// fence interface will be stored. + /// The function calls AddRef(), so that the new object will contain + /// one refernce. + virtual void CreateFence( const FenceDesc& Desc, + IFence** ppFence) = 0; /// Gets the device capabilities, see Diligent::DeviceCaps for details @@ -158,7 +170,7 @@ public: /// \param [in] TexFormat - Texture format for which to provide the information /// \return Const reference to the TextureFormatInfo structure containing the /// texture format description. - virtual const TextureFormatInfo &GetTextureFormatInfo( TEXTURE_FORMAT TexFormat ) = 0; + virtual const TextureFormatInfo& GetTextureFormatInfo( TEXTURE_FORMAT TexFormat ) = 0; /// Returns the extended texture format information. @@ -170,7 +182,7 @@ public: /// \remark The first time this method is called for a particular format, it may be /// considerably slower than GetTextureFormatInfo(). If you do not require /// extended information, call GetTextureFormatInfo() instead. - virtual const TextureFormatInfoExt &GetTextureFormatInfoExt( TEXTURE_FORMAT TexFormat ) = 0; + virtual const TextureFormatInfoExt& GetTextureFormatInfoExt( TEXTURE_FORMAT TexFormat ) = 0; }; } |
