diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2021-03-04 20:46:21 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2021-03-19 00:38:15 +0000 |
| commit | 4f5a4499cf0eee3761788eb6a422cd25e02ace40 (patch) | |
| tree | a4caf790bcb35483de2eaa56b7735230a0f1b7a5 | |
| parent | Minor updates to ValidatePipelineResourceSignatureDesc (diff) | |
| download | DiligentCore-4f5a4499cf0eee3761788eb6a422cd25e02ace40.tar.gz DiligentCore-4f5a4499cf0eee3761788eb6a422cd25e02ace40.zip | |
Refactored passing template arguments to base classes
79 files changed, 826 insertions, 611 deletions
diff --git a/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp b/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp index 3b6dfd91..096042ea 100644 --- a/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp +++ b/Graphics/GraphicsEngine/include/BottomLevelASBase.hpp @@ -69,14 +69,17 @@ void CopyBLASGeometryDesc(const BottomLevelASDesc& SrcDesc, /// Template class implementing base functionality of the bottom-level acceleration structure object. -/// \tparam BaseInterface - Base interface that this class will inheret -/// (Diligent::IBottomLevelASD3D12 or Diligent::IBottomLevelASVk). -/// \tparam RenderDeviceImplType - Type of the render device implementation -/// (Diligent::RenderDeviceD3D12Impl or Diligent::RenderDeviceVkImpl) -template <class BaseInterface, class RenderDeviceImplType> -class BottomLevelASBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, BottomLevelASDesc> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class BottomLevelASBase : public DeviceObjectBase<typename EngineImplTraits::BottomLevelASInterface, typename EngineImplTraits::RenderDeviceImplType, BottomLevelASDesc> { public: + // Base interface that this class inherits (IBottomLevelASD3D12 or IBottomLevelASVk). + using BaseInterface = typename EngineImplTraits::BottomLevelASInterface; + + // Render device implementation type (RenderDeviceD3D12Impl or RenderDeviceVkImpl). + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, BottomLevelASDesc>; /// \param pRefCounters - Reference counters object that controls the lifetime of this BLAS. diff --git a/Graphics/GraphicsEngine/include/BufferBase.hpp b/Graphics/GraphicsEngine/include/BufferBase.hpp index 7928af57..217dd109 100644 --- a/Graphics/GraphicsEngine/include/BufferBase.hpp +++ b/Graphics/GraphicsEngine/include/BufferBase.hpp @@ -54,20 +54,23 @@ void ValidateAndCorrectBufferViewDesc(const BufferDesc& BuffDesc, BufferViewDesc /// Template class implementing base functionality of the buffer object -/// \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 RenderDeviceImplType, class BufferViewImplType, class TBuffViewObjAllocator> -class BufferBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, BufferDesc> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class BufferBase : public DeviceObjectBase<typename EngineImplTraits::BufferInterface, typename EngineImplTraits::RenderDeviceImplType, BufferDesc> { public: + // Base interface that this class inherits (IBufferD3D12, IBufferVk, etc.). + using BaseInterface = typename EngineImplTraits::BufferInterface; + + // Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.). + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + + // Buffer view implementation type (BufferViewD3D12Impl, BufferViewVkImpl, etc.). + using BufferViewImplType = typename EngineImplTraits::BufferViewImplType; + + // The type of the allocator that is used to allocate memory for the buffer view object instances. + using TBuffViewObjAllocator = typename EngineImplTraits::BuffViewObjAllocatorType; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, BufferDesc>; /// \param pRefCounters - Reference counters object that controls the lifetime of this buffer. diff --git a/Graphics/GraphicsEngine/include/BufferViewBase.hpp b/Graphics/GraphicsEngine/include/BufferViewBase.hpp index 21b917e5..7de94c3e 100644 --- a/Graphics/GraphicsEngine/include/BufferViewBase.hpp +++ b/Graphics/GraphicsEngine/include/BufferViewBase.hpp @@ -40,16 +40,20 @@ namespace Diligent /// Template class implementing base functionality of the buffer view object -/// \tparam BaseInterface - Base interface that this class will inheret -/// (Diligent::IBufferViewD3D11, Diligent::IBufferViewD3D12, -/// Diligent::IBufferViewGL or Diligent::IBufferViewVk). -/// \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> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class BufferViewBase : public DeviceObjectBase<typename EngineImplTraits::BufferViewInterface, typename EngineImplTraits::RenderDeviceImplType, BufferViewDesc> { public: + // Base interface that this class inherits (IBufferViewD3D12, IBufferViewVk, etc.). + using BaseInterface = typename EngineImplTraits::BufferViewInterface; + + // Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.). + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + + // Buffer implementation type (BufferD3D12Impl, BufferVkImpl, etc.). + using BufferImplType = typename EngineImplTraits::BufferImplType; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, BufferViewDesc>; /// \param pRefCounters - Reference counters object that controls the lifetime of this buffer view. diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp index f6d12e11..70356e75 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp @@ -90,28 +90,28 @@ struct VertexStreamInfo /// Base implementation of the device context. -/// \tparam BaseInterface - Base interface that this class will inheret. -/// \tparam ImplementationTraits - Implementation traits that define specific implementation details +/// \tparam EngineImplTraits - Engine implementation traits that define specific implementation details /// (texture implemenation type, buffer implementation type, etc.) /// \remarks Device context keeps strong references to all objects currently bound to /// the pipeline: buffers, tetxures, states, SRBs, etc. /// The context also keeps strong references to the device and /// the swap chain. -template <typename BaseInterface, typename ImplementationTraits> -class DeviceContextBase : public ObjectBase<BaseInterface> +template <typename EngineImplTraits> +class DeviceContextBase : public ObjectBase<typename EngineImplTraits::DeviceContextInterface> { public: + using BaseInterface = typename EngineImplTraits::DeviceContextInterface; using TObjectBase = ObjectBase<BaseInterface>; - using DeviceImplType = typename ImplementationTraits::DeviceType; - using BufferImplType = typename ImplementationTraits::BufferType; - using TextureImplType = typename ImplementationTraits::TextureType; - using PipelineStateImplType = typename ImplementationTraits::PipelineStateType; - using TextureViewImplType = typename TextureImplType::ViewImplType; - using QueryImplType = typename ImplementationTraits::QueryType; - using FramebufferImplType = typename ImplementationTraits::FramebufferType; - using RenderPassImplType = typename ImplementationTraits::RenderPassType; - using BottomLevelASType = typename ImplementationTraits::BottomLevelASType; - using TopLevelASType = typename ImplementationTraits::TopLevelASType; + using DeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + using BufferImplType = typename EngineImplTraits::BufferImplType; + using TextureImplType = typename EngineImplTraits::TextureImplType; + using PipelineStateImplType = typename EngineImplTraits::PipelineStateImplType; + using TextureViewImplType = typename EngineImplTraits::TextureViewImplType; + using QueryImplType = typename EngineImplTraits::QueryImplType; + using FramebufferImplType = typename EngineImplTraits::FramebufferImplType; + using RenderPassImplType = typename EngineImplTraits::RenderPassImplType; + using BottomLevelASType = typename EngineImplTraits::BottomLevelASImplType; + using TopLevelASType = typename EngineImplTraits::TopLevelASImplType; /// \param pRefCounters - Reference counters object that controls the lifetime of this device context. /// \param pRenderDevice - Render device. @@ -415,8 +415,8 @@ protected: }; -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::SetVertexBuffers( +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer** ppBuffers, @@ -476,16 +476,16 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::SetVertexBuf m_VertexStreams[m_NumVertexStreams--] = VertexStreamInfo<BufferImplType>{}; } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::SetPipelineState( +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::SetPipelineState( PipelineStateImplType* pPipelineState, int /*Dummy*/) { m_pPipelineState = pPipelineState; } -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::CommitShaderResources( +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::CommitShaderResources( IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, int) @@ -505,17 +505,17 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::CommitShader return true; } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::InvalidateState() +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::InvalidateState() { if (m_pActiveRenderPass != nullptr) LOG_ERROR_MESSAGE("Invalidating context inside an active render pass. Call EndRenderPass() to finish the pass."); - DeviceContextBase<BaseInterface, ImplementationTraits>::ClearStateCache(); + DeviceContextBase<ImplementationTraits>::ClearStateCache(); } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::SetIndexBuffer( +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::SetIndexBuffer( IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) @@ -539,8 +539,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::SetIndexBuff } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::GetPipelineState(IPipelineState** ppPSO, float* BlendFactors, Uint32& StencilRef) +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::GetPipelineState(IPipelineState** ppPSO, float* BlendFactors, Uint32& StencilRef) { DEV_CHECK_ERR(ppPSO != nullptr, "Null pointer provided null"); DEV_CHECK_ERR(*ppPSO == nullptr, "Memory address contains a pointer to a non-null blend state"); @@ -558,8 +558,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::GetPipelineS StencilRef = m_StencilRef; }; -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetBlendFactors(const float* BlendFactors, int) +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::SetBlendFactors(const float* BlendFactors, int) { bool FactorsDiffer = false; for (Uint32 f = 0; f < 4; ++f) @@ -571,8 +571,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetBlendFact return FactorsDiffer; } -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetStencilRef(Uint32 StencilRef, int) +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::SetStencilRef(Uint32 StencilRef, int) { if (m_StencilRef != StencilRef) { @@ -582,8 +582,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetStencilRe return false; } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::SetViewports( +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::SetViewports( Uint32 NumViewports, const Viewport* pViewports, Uint32& RTWidth, @@ -614,8 +614,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::SetViewports } } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::GetViewports(Uint32& NumViewports, Viewport* pViewports) +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::GetViewports(Uint32& NumViewports, Viewport* pViewports) { NumViewports = m_NumViewports; if (pViewports) @@ -625,8 +625,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::GetViewports } } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::SetScissorRects( +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::SetScissorRects( Uint32 NumRects, const Rect* pRects, Uint32& RTWidth, @@ -649,8 +649,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::SetScissorRe } } -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetRenderTargets( +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil) @@ -768,8 +768,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetRenderTar return bBindRenderTargets; } -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetSubpassRenderTargets() +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::SetSubpassRenderTargets() { VERIFY_EXPR(m_pBoundFramebuffer); VERIFY_EXPR(m_pActiveRenderPass); @@ -828,8 +828,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::SetSubpassRe } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::GetRenderTargets( +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::GetRenderTargets( Uint32& NumRenderTargets, ITextureView** ppRTVs, ITextureView** ppDSV) @@ -864,8 +864,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::GetRenderTar } } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::ClearStateCache() +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::ClearStateCache() { for (Uint32 stream = 0; stream < m_NumVertexStreams; ++stream) m_VertexStreams[stream] = VertexStreamInfo<BufferImplType>{}; @@ -903,8 +903,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::ClearStateCa m_pBoundFramebuffer = nullptr; } -template <typename BaseInterface, typename ImplementationTraits> -bool DeviceContextBase<BaseInterface, ImplementationTraits>::CheckIfBoundAsRenderTarget(TextureImplType* pTexture) +template <typename ImplementationTraits> +bool DeviceContextBase<ImplementationTraits>::CheckIfBoundAsRenderTarget(TextureImplType* pTexture) { if (pTexture == nullptr) return false; @@ -920,8 +920,8 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::CheckIfBoundAsRende return false; } -template <typename BaseInterface, typename ImplementationTraits> -bool DeviceContextBase<BaseInterface, ImplementationTraits>::CheckIfBoundAsDepthStencil(TextureImplType* pTexture) +template <typename ImplementationTraits> +bool DeviceContextBase<ImplementationTraits>::CheckIfBoundAsDepthStencil(TextureImplType* pTexture) { if (pTexture == nullptr) return false; @@ -929,8 +929,8 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::CheckIfBoundAsDepth return m_pBoundDepthStencil && m_pBoundDepthStencil->GetTexture() == pTexture; } -template <typename BaseInterface, typename ImplementationTraits> -bool DeviceContextBase<BaseInterface, ImplementationTraits>::UnbindTextureFromFramebuffer(TextureImplType* pTexture, bool bShowMessage) +template <typename ImplementationTraits> +bool DeviceContextBase<ImplementationTraits>::UnbindTextureFromFramebuffer(TextureImplType* pTexture, bool bShowMessage) { VERIFY(m_pActiveRenderPass == nullptr, "State transitions are not allowed inside a render pass."); @@ -983,8 +983,8 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::UnbindTextureFromFr return bResetRenderTargets; } -template <typename BaseInterface, typename ImplementationTraits> -void DeviceContextBase<BaseInterface, ImplementationTraits>::ResetRenderTargets() +template <typename ImplementationTraits> +void DeviceContextBase<ImplementationTraits>::ResetRenderTargets() { for (Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt) m_pBoundRenderTargets[rt].Release(); @@ -1006,8 +1006,8 @@ void DeviceContextBase<BaseInterface, ImplementationTraits>::ResetRenderTargets( // be a subpass without any render target attachments. } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::BeginRenderPass(const BeginRenderPassAttribs& Attribs) +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::BeginRenderPass(const BeginRenderPassAttribs& Attribs) { VERIFY(m_pActiveRenderPass == nullptr, "Attempting to begin render pass while another render pass ('", m_pActiveRenderPass->GetDesc().Name, "') is active."); VERIFY(m_pBoundFramebuffer == nullptr, "Attempting to begin render pass while another framebuffer ('", m_pBoundFramebuffer->GetDesc().Name, "') is bound."); @@ -1058,8 +1058,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::BeginRenderP SetSubpassRenderTargets(); } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::NextSubpass() +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::NextSubpass() { VERIFY(m_pActiveRenderPass != nullptr, "There is no active render pass"); VERIFY(m_SubpassIndex + 1 < m_pActiveRenderPass->GetDesc().SubpassCount, "The render pass has reached the final subpass already"); @@ -1068,8 +1068,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::NextSubpass( SetSubpassRenderTargets(); } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::UpdateAttachmentStates(Uint32 SubpassIndex) +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::UpdateAttachmentStates(Uint32 SubpassIndex) { if (m_RenderPassAttachmentsTransitionMode != RESOURCE_STATE_TRANSITION_MODE_TRANSITION) return; @@ -1098,8 +1098,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::UpdateAttach } } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::EndRenderPass() +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::EndRenderPass() { VERIFY(m_pActiveRenderPass != nullptr, "There is no active render pass"); VERIFY(m_pBoundFramebuffer != nullptr, "There is no active framebuffer"); @@ -1116,8 +1116,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::EndRenderPas } -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::ClearDepthStencil(ITextureView* pView) +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::ClearDepthStencil(ITextureView* pView) { if (pView == nullptr) { @@ -1165,8 +1165,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::ClearDepthSt return true; } -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::ClearRenderTarget(ITextureView* pView) +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::ClearRenderTarget(ITextureView* pView) { if (pView == nullptr) { @@ -1219,8 +1219,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::ClearRenderT return true; } -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::BeginQuery(IQuery* pQuery, int) +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::BeginQuery(IQuery* pQuery, int) { if (pQuery == nullptr) { @@ -1248,8 +1248,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::BeginQuery(I return true; } -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::EndQuery(IQuery* pQuery, int) +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::EndQuery(IQuery* pQuery, int) { if (pQuery == nullptr) { @@ -1271,8 +1271,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::EndQuery(IQu return true; } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::UpdateBuffer( +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::UpdateBuffer( IBuffer* pBuffer, Uint32 Offset, Uint32 Size, @@ -1291,8 +1291,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::UpdateBuffer #endif } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::CopyBuffer( +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::CopyBuffer( IBuffer* pSrcBuffer, Uint32 SrcOffset, RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, @@ -1314,8 +1314,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::CopyBuffer( #endif } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::MapBuffer( +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::MapBuffer( IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, @@ -1372,8 +1372,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::MapBuffer( } } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType) +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType) { VERIFY(pBuffer, "pBuffer must not be null"); #ifdef DILIGENT_DEBUG @@ -1387,8 +1387,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::UnmapBuffer( } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::UpdateTexture( +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::UpdateTexture( ITexture* pTexture, Uint32 MipLevel, Uint32 Slice, @@ -1403,8 +1403,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::UpdateTextur ValidateUpdateTextureParams(pTexture->GetDesc(), MipLevel, Slice, DstBox, SubresData); } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::CopyTexture(const CopyTextureAttribs& CopyAttribs) +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::CopyTexture(const CopyTextureAttribs& CopyAttribs) { DEV_CHECK_ERR(CopyAttribs.pSrcTexture, "Src texture must not be null"); DEV_CHECK_ERR(CopyAttribs.pDstTexture, "Dst texture must not be null"); @@ -1413,8 +1413,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::CopyTexture( ValidateCopyTextureParams(CopyAttribs); } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::MapTextureSubresource( +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::MapTextureSubresource( ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice, @@ -1427,8 +1427,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::MapTextureSu ValidateMapTextureParams(pTexture->GetDesc(), MipLevel, ArraySlice, MapType, MapFlags, pMapRegion); } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::UnmapTextureSubresource( +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::UnmapTextureSubresource( ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice) @@ -1438,8 +1438,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::UnmapTexture DEV_CHECK_ERR(ArraySlice < pTexture->GetDesc().ArraySize, "Array slice is out of range"); } -template <typename BaseInterface, typename ImplementationTraits> -inline void DeviceContextBase<BaseInterface, ImplementationTraits>::GenerateMips(ITextureView* pTexView) +template <typename ImplementationTraits> +inline void DeviceContextBase<ImplementationTraits>::GenerateMips(ITextureView* pTexView) { DEV_CHECK_ERR(pTexView != nullptr, "pTexView must not be null"); DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "GenerateMips command must be used outside of render pass."); @@ -1455,8 +1455,8 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::GenerateMips } -template <typename BaseInterface, typename ImplementationTraits> -void DeviceContextBase<BaseInterface, ImplementationTraits>::ResolveTextureSubresource( +template <typename ImplementationTraits> +void DeviceContextBase<ImplementationTraits>::ResolveTextureSubresource( ITexture* pSrcTexture, ITexture* pDstTexture, const ResolveTextureSubresourceAttribs& ResolveAttribs) @@ -1473,8 +1473,8 @@ void DeviceContextBase<BaseInterface, ImplementationTraits>::ResolveTextureSubre } -template <typename BaseInterface, typename ImplementationTraits> -bool DeviceContextBase<BaseInterface, ImplementationTraits>::BuildBLAS(const BuildBLASAttribs& Attribs, int) const +template <typename ImplementationTraits> +bool DeviceContextBase<ImplementationTraits>::BuildBLAS(const BuildBLASAttribs& Attribs, int) const { #ifdef DILIGENT_DEVELOPMENT if (m_pDevice->GetDeviceCaps().Features.RayTracing != DEVICE_FEATURE_STATE_ENABLED) @@ -1496,8 +1496,8 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::BuildBLAS(const Bui return true; } -template <typename BaseInterface, typename ImplementationTraits> -bool DeviceContextBase<BaseInterface, ImplementationTraits>::BuildTLAS(const BuildTLASAttribs& Attribs, int) const +template <typename ImplementationTraits> +bool DeviceContextBase<ImplementationTraits>::BuildTLAS(const BuildTLASAttribs& Attribs, int) const { #ifdef DILIGENT_DEVELOPMENT if (m_pDevice->GetDeviceCaps().Features.RayTracing != DEVICE_FEATURE_STATE_ENABLED) @@ -1519,8 +1519,8 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::BuildTLAS(const Bui return true; } -template <typename BaseInterface, typename ImplementationTraits> -bool DeviceContextBase<BaseInterface, ImplementationTraits>::CopyBLAS(const CopyBLASAttribs& Attribs, int) const +template <typename ImplementationTraits> +bool DeviceContextBase<ImplementationTraits>::CopyBLAS(const CopyBLASAttribs& Attribs, int) const { #ifdef DILIGENT_DEVELOPMENT if (m_pDevice->GetDeviceCaps().Features.RayTracing != DEVICE_FEATURE_STATE_ENABLED) @@ -1542,8 +1542,8 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::CopyBLAS(const Copy return true; } -template <typename BaseInterface, typename ImplementationTraits> -bool DeviceContextBase<BaseInterface, ImplementationTraits>::CopyTLAS(const CopyTLASAttribs& Attribs, int) const +template <typename ImplementationTraits> +bool DeviceContextBase<ImplementationTraits>::CopyTLAS(const CopyTLASAttribs& Attribs, int) const { #ifdef DILIGENT_DEVELOPMENT if (m_pDevice->GetDeviceCaps().Features.RayTracing != DEVICE_FEATURE_STATE_ENABLED) @@ -1571,8 +1571,8 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::CopyTLAS(const Copy return true; } -template <typename BaseInterface, typename ImplementationTraits> -bool DeviceContextBase<BaseInterface, ImplementationTraits>::WriteBLASCompactedSize(const WriteBLASCompactedSizeAttribs& Attribs, int) const +template <typename ImplementationTraits> +bool DeviceContextBase<ImplementationTraits>::WriteBLASCompactedSize(const WriteBLASCompactedSizeAttribs& Attribs, int) const { #ifdef DILIGENT_DEVELOPMENT if (m_pDevice->GetDeviceCaps().Features.RayTracing != DEVICE_FEATURE_STATE_ENABLED) @@ -1594,8 +1594,8 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::WriteBLASCompactedS return true; } -template <typename BaseInterface, typename ImplementationTraits> -bool DeviceContextBase<BaseInterface, ImplementationTraits>::WriteTLASCompactedSize(const WriteTLASCompactedSizeAttribs& Attribs, int) const +template <typename ImplementationTraits> +bool DeviceContextBase<ImplementationTraits>::WriteTLASCompactedSize(const WriteTLASCompactedSizeAttribs& Attribs, int) const { #ifdef DILIGENT_DEVELOPMENT if (m_pDevice->GetDeviceCaps().Features.RayTracing != DEVICE_FEATURE_STATE_ENABLED) @@ -1617,8 +1617,8 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::WriteTLASCompactedS return true; } -template <typename BaseInterface, typename ImplementationTraits> -bool DeviceContextBase<BaseInterface, ImplementationTraits>::TraceRays(const TraceRaysAttribs& Attribs, int) const +template <typename ImplementationTraits> +bool DeviceContextBase<ImplementationTraits>::TraceRays(const TraceRaysAttribs& Attribs, int) const { #ifdef DILIGENT_DEVELOPMENT if (m_pDevice->GetDeviceCaps().Features.RayTracing != DEVICE_FEATURE_STATE_ENABLED) @@ -1670,8 +1670,8 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::TraceRays(const Tra #ifdef DILIGENT_DEVELOPMENT -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDrawArguments(const DrawAttribs& Attribs) const +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::DvpVerifyDrawArguments(const DrawAttribs& Attribs) const { if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0) return true; @@ -1691,8 +1691,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDra return VerifyDrawAttribs(Attribs); } -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDrawIndexedArguments(const DrawIndexedAttribs& Attribs) const +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::DvpVerifyDrawIndexedArguments(const DrawIndexedAttribs& Attribs) const { if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0) return true; @@ -1719,8 +1719,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDra return VerifyDrawIndexedAttribs(Attribs); } -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDrawMeshArguments(const DrawMeshAttribs& Attribs) const +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::DvpVerifyDrawMeshArguments(const DrawMeshAttribs& Attribs) const { if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0) return true; @@ -1747,8 +1747,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDra return VerifyDrawMeshAttribs(m_pDevice->GetProperties().MaxDrawMeshTasksCount, Attribs); } -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDrawIndirectArguments( +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::DvpVerifyDrawIndirectArguments( const DrawIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const { @@ -1779,8 +1779,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDra return VerifyDrawIndirectAttribs(Attribs, pAttribsBuffer); } -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDrawIndexedIndirectArguments( +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::DvpVerifyDrawIndexedIndirectArguments( const DrawIndexedIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const { @@ -1816,8 +1816,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDra return VerifyDrawIndexedIndirectAttribs(Attribs, pAttribsBuffer); } -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDrawMeshIndirectArguments( +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::DvpVerifyDrawMeshIndirectArguments( const DrawMeshIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const { @@ -1846,8 +1846,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDra return VerifyDrawMeshIndirectAttribs(Attribs, pAttribsBuffer); } -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyRenderTargets() const +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::DvpVerifyRenderTargets() const { if (!m_pPipelineState) { @@ -1907,8 +1907,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyRen -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDispatchArguments(const DispatchComputeAttribs& Attribs) const +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::DvpVerifyDispatchArguments(const DispatchComputeAttribs& Attribs) const { if (!m_pPipelineState) { @@ -1932,8 +1932,8 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDis return VerifyDispatchComputeAttribs(Attribs); } -template <typename BaseInterface, typename ImplementationTraits> -inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDispatchIndirectArguments( +template <typename ImplementationTraits> +inline bool DeviceContextBase<ImplementationTraits>::DvpVerifyDispatchIndirectArguments( const DispatchComputeIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const { @@ -1960,14 +1960,14 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyDis } -template <typename BaseInterface, typename ImplementationTraits> -bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyStateTransitionDesc(const StateTransitionDesc& Barrier) const +template <typename ImplementationTraits> +bool DeviceContextBase<ImplementationTraits>::DvpVerifyStateTransitionDesc(const StateTransitionDesc& Barrier) const { return VerifyStateTransitionDesc(m_pDevice, Barrier); } -template <typename BaseInterface, typename ImplementationTraits> -bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyTextureState( +template <typename ImplementationTraits> +bool DeviceContextBase<ImplementationTraits>::DvpVerifyTextureState( const TextureImplType& Texture, RESOURCE_STATE RequiredState, const char* OperationName) const @@ -1983,8 +1983,8 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyTextureSta return true; } -template <typename BaseInterface, typename ImplementationTraits> -bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyBufferState( +template <typename ImplementationTraits> +bool DeviceContextBase<ImplementationTraits>::DvpVerifyBufferState( const BufferImplType& Buffer, RESOURCE_STATE RequiredState, const char* OperationName) const @@ -2000,8 +2000,8 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyBufferStat return true; } -template <typename BaseInterface, typename ImplementationTraits> -bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyBLASState( +template <typename ImplementationTraits> +bool DeviceContextBase<ImplementationTraits>::DvpVerifyBLASState( const BottomLevelASType& BLAS, RESOURCE_STATE RequiredState, const char* OperationName) const @@ -2017,8 +2017,8 @@ bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyBLASState( return true; } -template <typename BaseInterface, typename ImplementationTraits> -bool DeviceContextBase<BaseInterface, ImplementationTraits>::DvpVerifyTLASState( +template <typename ImplementationTraits> +bool DeviceContextBase<ImplementationTraits>::DvpVerifyTLASState( const TopLevelASType& TLAS, RESOURCE_STATE RequiredState, const char* OperationName) const diff --git a/Graphics/GraphicsEngine/include/FenceBase.hpp b/Graphics/GraphicsEngine/include/FenceBase.hpp index bf65d840..0bcaae36 100644 --- a/Graphics/GraphicsEngine/include/FenceBase.hpp +++ b/Graphics/GraphicsEngine/include/FenceBase.hpp @@ -39,14 +39,17 @@ namespace Diligent /// Template class implementing base functionality of the fence object -/// \tparam BaseInterface - Base interface that this class will inheret -/// (Diligent::IFenceD3D11, Diligent::IFenceD3D12, -/// Diligent::IFenceGL or Diligent::IFenceVk). -/// \tparam RenderDeviceImplType - type of the render device implementation -template <class BaseInterface, class RenderDeviceImplType> -class FenceBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, FenceDesc> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class FenceBase : public DeviceObjectBase<typename EngineImplTraits::FenceInterface, typename EngineImplTraits::RenderDeviceImplType, FenceDesc> { public: + // Base interface that this class inherits (IFenceD3D12, IFenceVk, etc.). + using BaseInterface = typename EngineImplTraits::FenceInterface; + + // Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.). + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + typedef DeviceObjectBase<BaseInterface, RenderDeviceImplType, FenceDesc> TDeviceObjectBase; /// \param pRefCounters - Reference counters object that controls the lifetime of this command list. diff --git a/Graphics/GraphicsEngine/include/FramebufferBase.hpp b/Graphics/GraphicsEngine/include/FramebufferBase.hpp index 112d3149..3b99142c 100644 --- a/Graphics/GraphicsEngine/include/FramebufferBase.hpp +++ b/Graphics/GraphicsEngine/include/FramebufferBase.hpp @@ -43,15 +43,17 @@ void ValidateFramebufferDesc(const FramebufferDesc& Desc) noexcept(false); /// Template class implementing base functionality of the framebuffer object. -/// \tparam BaseInterface - Base interface that this class will inheret -/// (e.g. Diligent::IFramebufferVk). -/// \tparam RenderDeviceImplType - Type of the render device implementation -/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, -/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) -template <class BaseInterface, class RenderDeviceImplType> -class FramebufferBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, FramebufferDesc> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class FramebufferBase : public DeviceObjectBase<typename EngineImplTraits::FramebufferInterface, typename EngineImplTraits::RenderDeviceImplType, FramebufferDesc> { public: + // Base interface that this class inherits (e.g. IFramebufferVk). + using BaseInterface = typename EngineImplTraits::FramebufferInterface; + + // Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.). + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, FramebufferDesc>; /// \param pRefCounters - Reference counters object that controls the lifetime of this framebuffer pass. diff --git a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp index 9311a4c0..a185aa9d 100644 --- a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp +++ b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp @@ -69,14 +69,17 @@ size_t CalculatePipelineResourceSignatureDescHash(const PipelineResourceSignatur /// Template class implementing base functionality of the pipeline resource signature object. -/// \tparam BaseInterface - Base interface that this class will inheret -/// (Diligent::IPipelineResourceSignatureD3D12, Diligent::PipelineResourceSignatureVk, ...). -/// \tparam RenderDeviceImplType - Type of the render device implementation -/// (Diligent::RenderDeviceD3D12Impl or Diligent::RenderDeviceVkImpl) -template <class BaseInterface, class RenderDeviceImplType> -class PipelineResourceSignatureBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, PipelineResourceSignatureDesc> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class PipelineResourceSignatureBase : public DeviceObjectBase<typename EngineImplTraits::PipelineResourceSignatureInterface, typename EngineImplTraits::RenderDeviceImplType, PipelineResourceSignatureDesc> { public: + // Base interface this class inherits (IPipelineResourceSignatureD3D12, PipelineResourceSignatureVk, etc.) + using BaseInterface = typename EngineImplTraits::PipelineResourceSignatureInterface; + + // Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.). + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, PipelineResourceSignatureDesc>; /// \param pRefCounters - Reference counters object that controls the lifetime of this resource signature. diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp index 57359d37..558daf29 100644 --- a/Graphics/GraphicsEngine/include/PipelineStateBase.hpp +++ b/Graphics/GraphicsEngine/include/PipelineStateBase.hpp @@ -83,16 +83,17 @@ Uint32 FindPipelineResourceLayoutVariable(const PipelineResourceLayoutDesc& Layo /// Template class implementing base functionality of the pipeline state object. -/// \tparam BaseInterface - Base interface that this class will inheret -/// (Diligent::IPipelineStateD3D11, Diligent::IPipelineStateD3D12, -/// Diligent::IPipelineStateGL or Diligent::IPipelineStateVk). -/// \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> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class PipelineStateBase : public DeviceObjectBase<typename EngineImplTraits::PipelineStateInterface, typename EngineImplTraits::RenderDeviceImplType, PipelineStateDesc> { private: + // Base interface this class inherits (IPipelineStateD3D12, IPipelineStateVk, etc.) + using BaseInterface = typename EngineImplTraits::PipelineStateInterface; + + // Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.). + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, PipelineStateDesc>; /// \param pRefCounters - Reference counters object that controls the lifetime of this PSO diff --git a/Graphics/GraphicsEngine/include/QueryBase.hpp b/Graphics/GraphicsEngine/include/QueryBase.hpp index 3ca2f106..d208736d 100644 --- a/Graphics/GraphicsEngine/include/QueryBase.hpp +++ b/Graphics/GraphicsEngine/include/QueryBase.hpp @@ -40,14 +40,17 @@ namespace Diligent /// Template class implementing base functionality of the query object -/// \tparam BaseInterface - Base interface that this class will inheret -/// (Diligent::IQueryD3D11, Diligent::IQueryD3D12, -/// Diligent::IQueryGL or Diligent::IQueryVk). -/// \tparam RenderDeviceImplType - type of the render device implementation -template <class BaseInterface, class RenderDeviceImplType> -class QueryBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, QueryDesc> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class QueryBase : public DeviceObjectBase<typename EngineImplTraits::QueryInterface, typename EngineImplTraits::RenderDeviceImplType, QueryDesc> { public: + // Base interface this class inherits (IQueryD3D12, IQueryVk, etc.) + using BaseInterface = typename EngineImplTraits::QueryInterface; + + // Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.). + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + enum class QueryState { Inactive, diff --git a/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp b/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp index faafb9d2..110e2bc2 100644 --- a/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp +++ b/Graphics/GraphicsEngine/include/RenderDeviceBase.hpp @@ -175,36 +175,36 @@ namespace Diligent /// Base implementation of a render device -/// \tparam RenderDeviceImplTraits - Render device implementation type traits. +/// \tparam EngineImplTraits - Engine implementation type traits. /// /// \warning Render device must *NOT* hold strong references to any object it creates /// to avoid cyclic dependencies. Device context, swap chain and all object /// the device creates keep strong reference to the device. /// Device only holds weak reference to the immediate context. -template <typename RenderDeviceImplTraits> -class RenderDeviceBase : public ObjectBase<typename RenderDeviceImplTraits::BaseInterface> +template <typename EngineImplTraits> +class RenderDeviceBase : public ObjectBase<typename EngineImplTraits::RenderDeviceInterface> { public: - using BaseInterface = typename RenderDeviceImplTraits::BaseInterface; + using BaseInterface = typename EngineImplTraits::RenderDeviceInterface; using TObjectBase = ObjectBase<BaseInterface>; - using RenderDeviceImplType = typename RenderDeviceImplTraits::RenderDeviceImplType; - using PipelineStateImplType = typename RenderDeviceImplTraits::PipelineStateImplType; - using ShaderResourceBindingImplType = typename RenderDeviceImplTraits::ShaderResourceBindingImplType; - using BufferImplType = typename RenderDeviceImplTraits::BufferImplType; - using BufferViewImplType = typename RenderDeviceImplTraits::BufferViewImplType; - using TextureImplType = typename RenderDeviceImplTraits::TextureImplType; - using TextureViewImplType = typename RenderDeviceImplTraits::TextureViewImplType; - using ShaderImplType = typename RenderDeviceImplTraits::ShaderImplType; - using SamplerImplType = typename RenderDeviceImplTraits::SamplerImplType; - using FenceImplType = typename RenderDeviceImplTraits::FenceImplType; - using QueryImplType = typename RenderDeviceImplTraits::QueryImplType; - using RenderPassImplType = typename RenderDeviceImplTraits::RenderPassImplType; - using FramebufferImplType = typename RenderDeviceImplTraits::FramebufferImplType; - using BottomLevelASImplType = typename RenderDeviceImplTraits::BottomLevelASImplType; - using TopLevelASImplType = typename RenderDeviceImplTraits::TopLevelASImplType; - using ShaderBindingTableImplType = typename RenderDeviceImplTraits::ShaderBindingTableImplType; - using PipelineResourceSignatureImplType = typename RenderDeviceImplTraits::PipelineResourceSignatureImplType; + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + using PipelineStateImplType = typename EngineImplTraits::PipelineStateImplType; + using ShaderResourceBindingImplType = typename EngineImplTraits::ShaderResourceBindingImplType; + using BufferImplType = typename EngineImplTraits::BufferImplType; + using BufferViewImplType = typename EngineImplTraits::BufferViewImplType; + using TextureImplType = typename EngineImplTraits::TextureImplType; + using TextureViewImplType = typename EngineImplTraits::TextureViewImplType; + using ShaderImplType = typename EngineImplTraits::ShaderImplType; + using SamplerImplType = typename EngineImplTraits::SamplerImplType; + using FenceImplType = typename EngineImplTraits::FenceImplType; + using QueryImplType = typename EngineImplTraits::QueryImplType; + using RenderPassImplType = typename EngineImplTraits::RenderPassImplType; + using FramebufferImplType = typename EngineImplTraits::FramebufferImplType; + using BottomLevelASImplType = typename EngineImplTraits::BottomLevelASImplType; + using TopLevelASImplType = typename EngineImplTraits::TopLevelASImplType; + using ShaderBindingTableImplType = typename EngineImplTraits::ShaderBindingTableImplType; + using PipelineResourceSignatureImplType = typename EngineImplTraits::PipelineResourceSignatureImplType; /// \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) diff --git a/Graphics/GraphicsEngine/include/RenderPassBase.hpp b/Graphics/GraphicsEngine/include/RenderPassBase.hpp index b04540fa..36f743da 100644 --- a/Graphics/GraphicsEngine/include/RenderPassBase.hpp +++ b/Graphics/GraphicsEngine/include/RenderPassBase.hpp @@ -59,15 +59,17 @@ inline void _CorrectAttachmentState<class RenderDeviceVkImpl>(RESOURCE_STATE& St /// Template class implementing base functionality of the render pass object. -/// \tparam BaseInterface - Base interface that this class will inheret -/// (e.g. Diligent::IRenderPassVk). -/// \tparam RenderDeviceImplType - Type of the render device implementation -/// (Diligent::RenderDeviceD3D11Impl, Diligent::RenderDeviceD3D12Impl, -/// Diligent::RenderDeviceGLImpl, or Diligent::RenderDeviceVkImpl) -template <class BaseInterface, class RenderDeviceImplType> -class RenderPassBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, RenderPassDesc> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class RenderPassBase : public DeviceObjectBase<typename EngineImplTraits::RenderPassInterface, typename EngineImplTraits::RenderDeviceImplType, RenderPassDesc> { public: + // Base interface this class inherits (e.g. IRenderPassVk) + using BaseInterface = typename EngineImplTraits::RenderPassInterface; + + // Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.). + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, RenderPassDesc>; /// \param pRefCounters - Reference counters object that controls the lifetime of this render pass. diff --git a/Graphics/GraphicsEngine/include/SamplerBase.hpp b/Graphics/GraphicsEngine/include/SamplerBase.hpp index 07dede38..95fae463 100644 --- a/Graphics/GraphicsEngine/include/SamplerBase.hpp +++ b/Graphics/GraphicsEngine/include/SamplerBase.hpp @@ -39,16 +39,17 @@ namespace Diligent /// Template class implementing base functionality of the sampler object. -/// \tparam BaseInterface - Base interface that this class will inheret -/// (Diligent::ISamplerD3D11, Diligent::ISamplerD3D12, -/// Diligent::ISamplerGL or Diligent::ISamplerVk). -/// \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> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class SamplerBase : public DeviceObjectBase<typename EngineImplTraits::SamplerInterface, typename EngineImplTraits::RenderDeviceImplType, SamplerDesc> { public: + // Base interface this class inherits (ISamplerD3D12, ISamplerVk, etc.) + using BaseInterface = typename EngineImplTraits::SamplerInterface; + + // Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.). + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, SamplerDesc>; /// \param pRefCounters - Reference counters object that controls the lifetime of this sampler. diff --git a/Graphics/GraphicsEngine/include/ShaderBase.hpp b/Graphics/GraphicsEngine/include/ShaderBase.hpp index 54fd578a..4b8abc6e 100644 --- a/Graphics/GraphicsEngine/include/ShaderBase.hpp +++ b/Graphics/GraphicsEngine/include/ShaderBase.hpp @@ -44,16 +44,17 @@ namespace Diligent /// Template class implementing base functionality of the shader object -/// \tparam BaseInterface - Base interface that this class will inheret -/// (Diligent::IShaderD3D11, Diligent::IShaderD3D12, -/// Diligent::IShaderGL or Diligent::IShaderVk). -/// \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> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class ShaderBase : public DeviceObjectBase<typename EngineImplTraits::ShaderInterface, typename EngineImplTraits::RenderDeviceImplType, ShaderDesc> { public: + // Base interface this class inherits (IShaderD3D12, IShaderVk, etc.) + using BaseInterface = typename EngineImplTraits::ShaderInterface; + + // Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.). + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, ShaderDesc>; /// \param pRefCounters - Reference counters object that controls the lifetime of this shader. diff --git a/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp b/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp index 6af272e9..ea457eb4 100644 --- a/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp +++ b/Graphics/GraphicsEngine/include/ShaderBindingTableBase.hpp @@ -48,14 +48,23 @@ void ValidateShaderBindingTableDesc(const ShaderBindingTableDesc& Desc, Uint32 S /// Template class implementing base functionality of the shader binding table object. -/// \tparam BaseInterface - Base interface that this class will inheret -/// (Diligent::IShaderBindingTableD3D12 or Diligent::IShaderBindingTableVk). -/// \tparam RenderDeviceImplType - Type of the render device implementation -/// (Diligent::RenderDeviceD3D12Impl or Diligent::RenderDeviceVkImpl) -template <class BaseInterface, class PipelineStateImplType, class TopLevelASImplType, class RenderDeviceImplType> -class ShaderBindingTableBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, ShaderBindingTableDesc> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class ShaderBindingTableBase : public DeviceObjectBase<typename EngineImplTraits::ShaderBindingTableInterface, typename EngineImplTraits::RenderDeviceImplType, ShaderBindingTableDesc> { public: + // Base interface this class inherits (IShaderBindingTableD3D12, IShaderBindingTableVk, etc.) + using BaseInterface = typename EngineImplTraits::ShaderBindingTableInterface; + + // Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.). + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + + // Pipeline state implementation type (PipelineStateD3D12Impl, PipelineStateVkImpl, etc.). + using PipelineStateImplType = typename EngineImplTraits::PipelineStateImplType; + + // Top-level AS implementation type (TopLevelASD3D12Impl, TopLevelASVkImpl, etc.). + using TopLevelASImplType = typename EngineImplTraits::TopLevelASImplType; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, ShaderBindingTableDesc>; /// \param pRefCounters - Reference counters object that controls the lifetime of this SBT. diff --git a/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp b/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp index 2d8a5bb5..597f19e1 100644 --- a/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp +++ b/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp @@ -45,16 +45,18 @@ namespace Diligent /// Template class implementing base functionality of the shader resource binding -/// \tparam BaseInterface - Base interface that this class will inheret -/// (Diligent::IShaderResourceBindingGL, Diligent::IShaderResourceBindingD3D11, -/// Diligent::IShaderResourceBindingD3D12 or Diligent::IShaderResourceBindingVk). -/// \tparam ResourceSignatureType - Type of the pipeline resource signature implementation -/// (Diligent::PipelineResourceSignatureD3D12Impl, Diligent::PipelineResourceSignatureVkImpl, etc.) -template <class BaseInterface, class ResourceSignatureType> -class ShaderResourceBindingBase : public ObjectBase<BaseInterface> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class ShaderResourceBindingBase : public ObjectBase<typename EngineImplTraits::ShaderResourceBindingInterface> { public: - typedef ObjectBase<BaseInterface> TObjectBase; + // Base interface this class inherits (IShaderResourceBindingD3D12, IShaderResourceBindingVk, etc.) + using BaseInterface = typename EngineImplTraits::ShaderResourceBindingInterface; + + // Type of the pipeline resource signature implementation (PipelineResourceSignatureD3D12Impl, PipelineResourceSignatureVkImpl, etc.). + using ResourceSignatureType = typename EngineImplTraits::PipelineResourceSignatureImplType; + + using TObjectBase = ObjectBase<BaseInterface>; /// \param pRefCounters - Reference counters object that controls the lifetime of this SRB. /// \param pPRS - Pipeline resource signature that this SRB belongs to. diff --git a/Graphics/GraphicsEngine/include/TextureBase.hpp b/Graphics/GraphicsEngine/include/TextureBase.hpp index fc5b8f2f..211f7c60 100644 --- a/Graphics/GraphicsEngine/include/TextureBase.hpp +++ b/Graphics/GraphicsEngine/include/TextureBase.hpp @@ -66,21 +66,24 @@ void ValidateMapTextureParams(const TextureDesc& TexDesc, /// Base implementation of the ITexture interface -/// \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 TRenderDeviceImpl, class TTextureViewImpl, class TTexViewObjAllocator> -class TextureBase : public DeviceObjectBase<BaseInterface, TRenderDeviceImpl, TextureDesc> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class TextureBase : public DeviceObjectBase<typename EngineImplTraits::TextureInterface, typename EngineImplTraits::RenderDeviceImplType, TextureDesc> { public: - using TDeviceObjectBase = DeviceObjectBase<BaseInterface, TRenderDeviceImpl, TextureDesc>; + // Base interface this class inherits (ITextureD3D12, ITextureVk, etc.) + using BaseInterface = typename EngineImplTraits::TextureInterface; + + // Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.). + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + + // Texture view implementation type (TextureViewD3D12Impl, TextureViewVkImpl, etc.). + using TextureViewImplType = typename EngineImplTraits::TextureViewImplType; + + // Type of the texture view object allocator. + using TexViewObjAllocatorType = typename EngineImplTraits::TexViewObjAllocatorType; + + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, 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. @@ -89,19 +92,19 @@ 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, - TRenderDeviceImpl* pDevice, - const TextureDesc& Desc, - bool bIsDeviceInternal = false) : + TextureBase(IReferenceCounters* pRefCounters, + TexViewObjAllocatorType& TexViewObjAllocator, + RenderDeviceImplType* pDevice, + const TextureDesc& Desc, + bool bIsDeviceInternal = false) : TDeviceObjectBase(pRefCounters, pDevice, Desc, bIsDeviceInternal), #ifdef DILIGENT_DEBUG m_dbgTexViewObjAllocator(TexViewObjAllocator), #endif - m_pDefaultSRV{nullptr, STDDeleter<TTextureViewImpl, TTexViewObjAllocator>(TexViewObjAllocator)}, - m_pDefaultRTV{nullptr, STDDeleter<TTextureViewImpl, TTexViewObjAllocator>(TexViewObjAllocator)}, - m_pDefaultDSV{nullptr, STDDeleter<TTextureViewImpl, TTexViewObjAllocator>(TexViewObjAllocator)}, - m_pDefaultUAV{nullptr, STDDeleter<TTextureViewImpl, TTexViewObjAllocator>(TexViewObjAllocator)} + m_pDefaultSRV{nullptr, STDDeleter<TextureViewImplType, TexViewObjAllocatorType>(TexViewObjAllocator)}, + m_pDefaultRTV{nullptr, STDDeleter<TextureViewImplType, TexViewObjAllocatorType>(TexViewObjAllocator)}, + m_pDefaultDSV{nullptr, STDDeleter<TextureViewImplType, TexViewObjAllocatorType>(TexViewObjAllocator)}, + m_pDefaultUAV{nullptr, STDDeleter<TextureViewImplType, TexViewObjAllocatorType>(TexViewObjAllocator)} { if (this->m_Desc.MipLevels == 0) { @@ -220,7 +223,7 @@ public: VERIFY(pView != nullptr, "Failed to create default view for texture '", this->m_Desc.Name, "'."); VERIFY(pView->GetDesc().ViewType == ViewType, "Unexpected view type."); - return static_cast<TTextureViewImpl*>(pView); + return static_cast<TextureViewImplType*>(pView); }; if (this->m_Desc.BindFlags & BIND_SHADER_RESOURCE) @@ -292,17 +295,17 @@ protected: virtual void CreateViewInternal(const struct TextureViewDesc& ViewDesc, ITextureView** ppView, bool bIsDefaultView) = 0; #ifdef DILIGENT_DEBUG - TTexViewObjAllocator& m_dbgTexViewObjAllocator; + TexViewObjAllocatorType& m_dbgTexViewObjAllocator; #endif // WARNING! We cannot use ITextureView here, because ITextureView has no virtual dtor! /// Default SRV addressing the entire texture - std::unique_ptr<TTextureViewImpl, STDDeleter<TTextureViewImpl, TTexViewObjAllocator>> m_pDefaultSRV; + std::unique_ptr<TextureViewImplType, STDDeleter<TextureViewImplType, TexViewObjAllocatorType>> m_pDefaultSRV; /// Default RTV addressing the most detailed mip level - std::unique_ptr<TTextureViewImpl, STDDeleter<TTextureViewImpl, TTexViewObjAllocator>> m_pDefaultRTV; + std::unique_ptr<TextureViewImplType, STDDeleter<TextureViewImplType, TexViewObjAllocatorType>> m_pDefaultRTV; /// Default DSV addressing the most detailed mip level - std::unique_ptr<TTextureViewImpl, STDDeleter<TTextureViewImpl, TTexViewObjAllocator>> m_pDefaultDSV; + std::unique_ptr<TextureViewImplType, STDDeleter<TextureViewImplType, TexViewObjAllocatorType>> m_pDefaultDSV; /// Default UAV addressing the entire texture - std::unique_ptr<TTextureViewImpl, STDDeleter<TTextureViewImpl, TTexViewObjAllocator>> m_pDefaultUAV; + std::unique_ptr<TextureViewImplType, STDDeleter<TextureViewImplType, TexViewObjAllocatorType>> m_pDefaultUAV; RESOURCE_STATE m_State = RESOURCE_STATE_UNKNOWN; }; diff --git a/Graphics/GraphicsEngine/include/TextureViewBase.hpp b/Graphics/GraphicsEngine/include/TextureViewBase.hpp index 166f3188..77d72608 100644 --- a/Graphics/GraphicsEngine/include/TextureViewBase.hpp +++ b/Graphics/GraphicsEngine/include/TextureViewBase.hpp @@ -40,16 +40,17 @@ namespace Diligent /// Template class implementing base functionality of the texture view interface -/// \tparam BaseInterface - Base interface that this class will inheret -/// (Diligent::ITextureViewD3D11, Diligent::ITextureViewD3D12, -/// Diligent::ITextureViewGL or Diligent::ITextureViewVk). -/// \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> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class TextureViewBase : public DeviceObjectBase<typename EngineImplTraits::TextureViewInterface, typename EngineImplTraits::RenderDeviceImplType, TextureViewDesc> { public: + // Base interface that this class inherits (ITextureViewD3D12, ITextureViewVk, etc.). + using BaseInterface = typename EngineImplTraits::TextureViewInterface; + + // Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.). + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + using TDeviceObjectBase = DeviceObjectBase<BaseInterface, RenderDeviceImplType, TextureViewDesc>; diff --git a/Graphics/GraphicsEngine/include/TopLevelASBase.hpp b/Graphics/GraphicsEngine/include/TopLevelASBase.hpp index 2994ad83..763ce0e6 100644 --- a/Graphics/GraphicsEngine/include/TopLevelASBase.hpp +++ b/Graphics/GraphicsEngine/include/TopLevelASBase.hpp @@ -48,19 +48,25 @@ void ValidateTopLevelASDesc(const TopLevelASDesc& Desc) noexcept(false); /// Template class implementing base functionality of the top-level acceleration structure object. -/// \tparam BaseInterface - Base interface that this class will inheret -/// (Diligent::ITopLevelASD3D12 or Diligent::ITopLevelASVk). -/// \tparam RenderDeviceImplType - Type of the render device implementation -/// (Diligent::RenderDeviceD3D12Impl or Diligent::RenderDeviceVkImpl) -template <class BaseInterface, class BottomLevelASType, class RenderDeviceImplType> -class TopLevelASBase : public DeviceObjectBase<BaseInterface, RenderDeviceImplType, TopLevelASDesc> +/// \tparam EngineImplTraits - Engine implementation type traits. +template <typename EngineImplTraits> +class TopLevelASBase : public DeviceObjectBase<typename EngineImplTraits::TopLevelASInterface, typename EngineImplTraits::RenderDeviceImplType, TopLevelASDesc> { private: + // Base interface that this class inherits (ITopLevelASD3D12, ITopLevelASVk, etc.). + using BaseInterface = typename EngineImplTraits::TopLevelASInterface; + + // Render device implementation type (RenderDeviceD3D12Impl, RenderDeviceVkImpl, etc.). + using RenderDeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + + // Bottom-level AS implementation type (BottomLevelASD3D12Impl, BottomLevelASVkImpl, etc.). + using BottomLevelASImplType = typename EngineImplTraits::BottomLevelASImplType; + struct InstanceDesc { - Uint32 ContributionToHitGroupIndex = 0; - Uint32 InstanceIndex = 0; - RefCntAutoPtr<BottomLevelASType> pBLAS; + Uint32 ContributionToHitGroupIndex = 0; + Uint32 InstanceIndex = 0; + RefCntAutoPtr<BottomLevelASImplType> pBLAS; #ifdef DILIGENT_DEVELOPMENT Uint32 Version = 0; #endif @@ -116,7 +122,7 @@ public: const char* NameCopy = this->m_StringPool.CopyString(Inst.InstanceName); InstanceDesc Desc = {}; - Desc.pBLAS = ValidatedCast<BottomLevelASType>(Inst.pBLAS); + Desc.pBLAS = ValidatedCast<BottomLevelASImplType>(Inst.pBLAS); Desc.ContributionToHitGroupIndex = Inst.ContributionToHitGroupIndex; Desc.InstanceIndex = i; CalculateHitGroupIndex(Desc, InstanceOffset, HitGroupStride, BindingMode); @@ -181,7 +187,7 @@ public: const auto PrevIndex = Desc.ContributionToHitGroupIndex; const auto pPrevBLAS = Desc.pBLAS; - Desc.pBLAS = ValidatedCast<BottomLevelASType>(Inst.pBLAS); + Desc.pBLAS = ValidatedCast<BottomLevelASImplType>(Inst.pBLAS); Desc.ContributionToHitGroupIndex = Inst.ContributionToHitGroupIndex; //Desc.InstanceIndex = i; // keep Desc.InstanceIndex unmodified CalculateHitGroupIndex(Desc, InstanceOffset, HitGroupStride, BindingMode); diff --git a/Graphics/GraphicsEngineD3D12/CMakeLists.txt b/Graphics/GraphicsEngineD3D12/CMakeLists.txt index a5c643c1..a497ad68 100644 --- a/Graphics/GraphicsEngineD3D12/CMakeLists.txt +++ b/Graphics/GraphicsEngineD3D12/CMakeLists.txt @@ -16,6 +16,7 @@ set(INCLUDE include/d3dx12_win.h include/DescriptorHeap.hpp include/DeviceContextD3D12Impl.hpp + include/EngineD3D12ImplTraits.hpp include/D3D12DynamicHeap.hpp include/FenceD3D12Impl.hpp include/FramebufferD3D12Impl.hpp diff --git a/Graphics/GraphicsEngineD3D12/include/BottomLevelASD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/BottomLevelASD3D12Impl.hpp index 2017b0f3..9ffba139 100644 --- a/Graphics/GraphicsEngineD3D12/include/BottomLevelASD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/BottomLevelASD3D12Impl.hpp @@ -40,10 +40,10 @@ namespace Diligent { /// Bottom-level acceleration structure object implementation in Direct3D12 backend. -class BottomLevelASD3D12Impl final : public BottomLevelASBase<IBottomLevelASD3D12, RenderDeviceD3D12Impl>, public D3D12ResourceBase +class BottomLevelASD3D12Impl final : public BottomLevelASBase<EngineD3D12ImplTraits>, public D3D12ResourceBase { public: - using TBottomLevelASBase = BottomLevelASBase<IBottomLevelASD3D12, RenderDeviceD3D12Impl>; + using TBottomLevelASBase = BottomLevelASBase<EngineD3D12ImplTraits>; BottomLevelASD3D12Impl(IReferenceCounters* pRefCounters, class RenderDeviceD3D12Impl* pDeviceD3D12, diff --git a/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.hpp index 33dde6e4..49dbb25b 100644 --- a/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/BufferD3D12Impl.hpp @@ -41,13 +41,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Buffer object implementation in Direct3D12 backend. -class BufferD3D12Impl final : public BufferBase<IBufferD3D12, RenderDeviceD3D12Impl, BufferViewD3D12Impl, FixedBlockMemoryAllocator>, public D3D12ResourceBase +class BufferD3D12Impl final : public BufferBase<EngineD3D12ImplTraits>, public D3D12ResourceBase { public: - using TBufferBase = BufferBase<IBufferD3D12, RenderDeviceD3D12Impl, BufferViewD3D12Impl, FixedBlockMemoryAllocator>; + using TBufferBase = BufferBase<EngineD3D12ImplTraits>; BufferD3D12Impl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, diff --git a/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.hpp index 74d541e1..beeeeb49 100644 --- a/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/BufferViewD3D12Impl.hpp @@ -40,15 +40,15 @@ namespace Diligent { /// Buffer view implementation in Direct3D12 backend. -class BufferViewD3D12Impl final : public BufferViewBase<IBufferViewD3D12, RenderDeviceD3D12Impl> +class BufferViewD3D12Impl final : public BufferViewBase<EngineD3D12ImplTraits> { public: - using TBufferViewBase = BufferViewBase<IBufferViewD3D12, RenderDeviceD3D12Impl>; + using TBufferViewBase = BufferViewBase<EngineD3D12ImplTraits>; BufferViewD3D12Impl(IReferenceCounters* pRefCounters, RenderDeviceD3D12Impl* pDevice, const BufferViewDesc& ViewDesc, - IBuffer* pBuffer, + BufferD3D12Impl* pBuffer, DescriptorHeapAllocation&& HandleAlloc, bool bIsDefaultView); diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.hpp index 91c3f6f7..7fb46e60 100644 --- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.hpp @@ -48,25 +48,11 @@ namespace Diligent { -struct DeviceContextD3D12ImplTraits -{ - using BufferType = BufferD3D12Impl; - using TextureType = TextureD3D12Impl; - using PipelineStateType = PipelineStateD3D12Impl; - using DeviceType = RenderDeviceD3D12Impl; - using ICommandQueueType = ICommandQueueD3D12; - using QueryType = QueryD3D12Impl; - using FramebufferType = FramebufferD3D12Impl; - using RenderPassType = RenderPassD3D12Impl; - using BottomLevelASType = BottomLevelASD3D12Impl; - using TopLevelASType = TopLevelASD3D12Impl; -}; - /// Device context implementation in Direct3D12 backend. -class DeviceContextD3D12Impl final : public DeviceContextNextGenBase<IDeviceContextD3D12, DeviceContextD3D12ImplTraits> +class DeviceContextD3D12Impl final : public DeviceContextNextGenBase<EngineD3D12ImplTraits> { public: - using TDeviceContextBase = DeviceContextNextGenBase<IDeviceContextD3D12, DeviceContextD3D12ImplTraits>; + using TDeviceContextBase = DeviceContextNextGenBase<EngineD3D12ImplTraits>; DeviceContextD3D12Impl(IReferenceCounters* pRefCounters, RenderDeviceD3D12Impl* pDevice, diff --git a/Graphics/GraphicsEngineD3D12/include/EngineD3D12ImplTraits.hpp b/Graphics/GraphicsEngineD3D12/include/EngineD3D12ImplTraits.hpp new file mode 100644 index 00000000..deb6d970 --- /dev/null +++ b/Graphics/GraphicsEngineD3D12/include/EngineD3D12ImplTraits.hpp @@ -0,0 +1,122 @@ +/* + * Copyright 2019-2021 Diligent Graphics LLC + * Copyright 2015-2019 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 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 +/// Declaration of Diligent::EngineD3D12ImplTraits struct + +#include "RenderDeviceD3D12.h" +#include "PipelineStateD3D12.h" +#include "ShaderResourceBindingD3D12.h" +#include "BufferD3D12.h" +#include "BufferViewD3D12.h" +#include "TextureD3D12.h" +#include "TextureViewD3D12.h" +#include "ShaderD3D12.h" +#include "SamplerD3D12.h" +#include "FenceD3D12.h" +#include "QueryD3D12.h" +#include "RenderPass.h" +#include "Framebuffer.h" +#include "BottomLevelASD3D12.h" +#include "TopLevelASD3D12.h" +#include "ShaderBindingTableD3D12.h" +#include "PipelineResourceSignature.h" +#include "CommandQueueD3D12.h" +#include "DeviceContextD3D12.h" + +namespace Diligent +{ + +class RenderDeviceD3D12Impl; +class DeviceContextD3D12Impl; +class PipelineStateD3D12Impl; +class ShaderResourceBindingD3D12Impl; +class BufferD3D12Impl; +class BufferViewD3D12Impl; +class TextureD3D12Impl; +class TextureViewD3D12Impl; +class ShaderD3D12Impl; +class SamplerD3D12Impl; +class FenceD3D12Impl; +class QueryD3D12Impl; +class RenderPassD3D12Impl; +class FramebufferD3D12Impl; +class BottomLevelASD3D12Impl; +class TopLevelASD3D12Impl; +class ShaderBindingTableD3D12Impl; +class PipelineResourceSignatureD3D12Impl; + +class FixedBlockMemoryAllocator; + +struct EngineD3D12ImplTraits +{ + using RenderDeviceInterface = IRenderDeviceD3D12; + using DeviceContextInterface = IDeviceContextD3D12; + using PipelineStateInterface = IPipelineStateD3D12; + using ShaderResourceBindingInterface = IShaderResourceBindingD3D12; + using BufferInterface = IBufferD3D12; + using BufferViewInterface = IBufferViewD3D12; + using TextureInterface = ITextureD3D12; + using TextureViewInterface = ITextureViewD3D12; + using ShaderInterface = IShaderD3D12; + using SamplerInterface = ISamplerD3D12; + using FenceInterface = IFenceD3D12; + using QueryInterface = IQueryD3D12; + using RenderPassInterface = IRenderPass; + using FramebufferInterface = IFramebuffer; + using BottomLevelASInterface = IBottomLevelASD3D12; + using TopLevelASInterface = ITopLevelASD3D12; + using ShaderBindingTableInterface = IShaderBindingTableD3D12; + using PipelineResourceSignatureInterface = IPipelineResourceSignature; + using CommandQueueInterface = ICommandQueueD3D12; + + using RenderDeviceImplType = RenderDeviceD3D12Impl; + using DeviceContextImplType = DeviceContextD3D12Impl; + using PipelineStateImplType = PipelineStateD3D12Impl; + using ShaderResourceBindingImplType = ShaderResourceBindingD3D12Impl; + using BufferImplType = BufferD3D12Impl; + using BufferViewImplType = BufferViewD3D12Impl; + using TextureImplType = TextureD3D12Impl; + using TextureViewImplType = TextureViewD3D12Impl; + using ShaderImplType = ShaderD3D12Impl; + using SamplerImplType = SamplerD3D12Impl; + using FenceImplType = FenceD3D12Impl; + using QueryImplType = QueryD3D12Impl; + using RenderPassImplType = RenderPassD3D12Impl; + using FramebufferImplType = FramebufferD3D12Impl; + using BottomLevelASImplType = BottomLevelASD3D12Impl; + using TopLevelASImplType = TopLevelASD3D12Impl; + using ShaderBindingTableImplType = ShaderBindingTableD3D12Impl; + using PipelineResourceSignatureImplType = PipelineResourceSignatureD3D12Impl; + + using BuffViewObjAllocatorType = FixedBlockMemoryAllocator; + using TexViewObjAllocatorType = FixedBlockMemoryAllocator; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.hpp index e4ce0b8f..81437a65 100644 --- a/Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/FenceD3D12Impl.hpp @@ -39,10 +39,10 @@ namespace Diligent { /// Fence implementation in Direct3D12 backend. -class FenceD3D12Impl final : public FenceBase<IFenceD3D12, RenderDeviceD3D12Impl> +class FenceD3D12Impl final : public FenceBase<EngineD3D12ImplTraits> { public: - using TFenceBase = FenceBase<IFenceD3D12, RenderDeviceD3D12Impl>; + using TFenceBase = FenceBase<EngineD3D12ImplTraits>; FenceD3D12Impl(IReferenceCounters* pRefCounters, RenderDeviceD3D12Impl* pDevice, diff --git a/Graphics/GraphicsEngineD3D12/include/FramebufferD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/FramebufferD3D12Impl.hpp index 38ac63cc..243107e4 100644 --- a/Graphics/GraphicsEngineD3D12/include/FramebufferD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/FramebufferD3D12Impl.hpp @@ -38,10 +38,10 @@ namespace Diligent { /// Render pass implementation in Direct3D12 backend. -class FramebufferD3D12Impl final : public FramebufferBase<IFramebuffer, RenderDeviceD3D12Impl> +class FramebufferD3D12Impl final : public FramebufferBase<EngineD3D12ImplTraits> { public: - using TFramebufferBase = FramebufferBase<IFramebuffer, RenderDeviceD3D12Impl>; + using TFramebufferBase = FramebufferBase<EngineD3D12ImplTraits>; FramebufferD3D12Impl(IReferenceCounters* pRefCounters, RenderDeviceD3D12Impl* pDevice, diff --git a/Graphics/GraphicsEngineD3D12/include/PipelineResourceSignatureD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/PipelineResourceSignatureD3D12Impl.hpp index 4dc06446..abfd1b1f 100644 --- a/Graphics/GraphicsEngineD3D12/include/PipelineResourceSignatureD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/PipelineResourceSignatureD3D12Impl.hpp @@ -32,6 +32,7 @@ #include <array> +#include "EngineD3D12ImplTraits.hpp" #include "PipelineResourceSignatureBase.hpp" #include "SRBMemoryAllocator.hpp" #include "RootParamsManager.hpp" @@ -42,16 +43,14 @@ namespace Diligent { class CommandContext; -class RenderDeviceD3D12Impl; -class DeviceContextD3D12Impl; class ShaderVariableManagerD3D12; struct D3DShaderResourceAttribs; /// Implementation of the Diligent::PipelineResourceSignatureD3D12Impl class -class PipelineResourceSignatureD3D12Impl final : public PipelineResourceSignatureBase<IPipelineResourceSignature, RenderDeviceD3D12Impl> +class PipelineResourceSignatureD3D12Impl final : public PipelineResourceSignatureBase<EngineD3D12ImplTraits> { public: - using TPipelineResourceSignatureBase = PipelineResourceSignatureBase<IPipelineResourceSignature, RenderDeviceD3D12Impl>; + using TPipelineResourceSignatureBase = PipelineResourceSignatureBase<EngineD3D12ImplTraits>; PipelineResourceSignatureD3D12Impl(IReferenceCounters* pRefCounters, RenderDeviceD3D12Impl* pDevice, diff --git a/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.hpp index dd9f2344..c9e938c3 100644 --- a/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.hpp @@ -42,15 +42,13 @@ namespace Diligent { -class ShaderD3D12Impl; class ShaderResourcesD3D12; -class ShaderResourceBindingD3D12Impl; /// Pipeline state object implementation in Direct3D12 backend. -class PipelineStateD3D12Impl final : public PipelineStateBase<IPipelineStateD3D12, RenderDeviceD3D12Impl> +class PipelineStateD3D12Impl final : public PipelineStateBase<EngineD3D12ImplTraits> { public: - using TPipelineStateBase = PipelineStateBase<IPipelineStateD3D12, RenderDeviceD3D12Impl>; + using TPipelineStateBase = PipelineStateBase<EngineD3D12ImplTraits>; PipelineStateD3D12Impl(IReferenceCounters* pRefCounters, RenderDeviceD3D12Impl* pDeviceD3D12, const GraphicsPipelineStateCreateInfo& CreateInfo); PipelineStateD3D12Impl(IReferenceCounters* pRefCounters, RenderDeviceD3D12Impl* pDeviceD3D12, const ComputePipelineStateCreateInfo& CreateInfo); diff --git a/Graphics/GraphicsEngineD3D12/include/QueryD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/QueryD3D12Impl.hpp index f9317aec..b39b37c5 100644 --- a/Graphics/GraphicsEngineD3D12/include/QueryD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/QueryD3D12Impl.hpp @@ -42,10 +42,10 @@ namespace Diligent // https://microsoft.github.io/DirectX-Specs/d3d/CountersAndQueries.html#queries /// Query implementation in Direct3D12 backend. -class QueryD3D12Impl final : public QueryBase<IQueryD3D12, RenderDeviceD3D12Impl> +class QueryD3D12Impl final : public QueryBase<EngineD3D12ImplTraits> { public: - using TQueryBase = QueryBase<IQueryD3D12, RenderDeviceD3D12Impl>; + using TQueryBase = QueryBase<EngineD3D12ImplTraits>; QueryD3D12Impl(IReferenceCounters* pRefCounters, RenderDeviceD3D12Impl* pDevice, diff --git a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp index 5224d50c..0a63ed51 100644 --- a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp @@ -32,19 +32,19 @@ #include <atomic> -#include "RenderDeviceD3D12.h" +#include "EngineD3D12ImplTraits.hpp" #include "RenderDeviceD3DBase.hpp" #include "RenderDeviceNextGenBase.hpp" #include "DescriptorHeap.hpp" #include "CommandListManager.hpp" #include "CommandContext.hpp" #include "D3D12DynamicHeap.hpp" -#include "CommandQueueD3D12.h" #include "GenerateMips.hpp" #include "QueryManagerD3D12.hpp" #include "DXCompiler.hpp" #include "RootSignature.hpp" + // The macros below are only defined in Win SDK 19041+ and are missing in 17763 #ifndef D3D12_RAYTRACING_MAX_RAY_GENERATION_SHADER_THREADS # define D3D12_RAYTRACING_MAX_RAY_GENERATION_SHADER_THREADS (1073741824) @@ -66,53 +66,12 @@ namespace Diligent { -class RenderDeviceD3D12Impl; -class PipelineStateD3D12Impl; -class ShaderResourceBindingD3D12Impl; -class BufferD3D12Impl; -class BufferViewD3D12Impl; -class TextureD3D12Impl; -class TextureViewD3D12Impl; -class ShaderD3D12Impl; -class SamplerD3D12Impl; -class FenceD3D12Impl; -class QueryD3D12Impl; -class RenderPassD3D12Impl; -class FramebufferD3D12Impl; -class BottomLevelASD3D12Impl; -class TopLevelASD3D12Impl; -class ShaderBindingTableD3D12Impl; -class PipelineResourceSignatureD3D12Impl; - -struct RenderDeviceD3D12ImplTraits -{ - using BaseInterface = IRenderDeviceD3D12; - - using RenderDeviceImplType = RenderDeviceD3D12Impl; - using PipelineStateImplType = PipelineStateD3D12Impl; - using ShaderResourceBindingImplType = ShaderResourceBindingD3D12Impl; - using BufferImplType = BufferD3D12Impl; - using BufferViewImplType = BufferViewD3D12Impl; - using TextureImplType = TextureD3D12Impl; - using TextureViewImplType = TextureViewD3D12Impl; - using ShaderImplType = ShaderD3D12Impl; - using SamplerImplType = SamplerD3D12Impl; - using FenceImplType = FenceD3D12Impl; - using QueryImplType = QueryD3D12Impl; - using RenderPassImplType = RenderPassD3D12Impl; - using FramebufferImplType = FramebufferD3D12Impl; - using BottomLevelASImplType = BottomLevelASD3D12Impl; - using TopLevelASImplType = TopLevelASD3D12Impl; - using ShaderBindingTableImplType = ShaderBindingTableD3D12Impl; - using PipelineResourceSignatureImplType = PipelineResourceSignatureD3D12Impl; -}; - /// Render device implementation in Direct3D12 backend. -class RenderDeviceD3D12Impl final : public RenderDeviceNextGenBase<RenderDeviceD3DBase<RenderDeviceD3D12ImplTraits>, ICommandQueueD3D12> +class RenderDeviceD3D12Impl final : public RenderDeviceNextGenBase<RenderDeviceD3DBase<EngineD3D12ImplTraits>, ICommandQueueD3D12> { public: using BaseInterface = IRenderDeviceD3D12; - using TRenderDeviceBase = RenderDeviceNextGenBase<RenderDeviceD3DBase<RenderDeviceD3D12ImplTraits>, ICommandQueueD3D12>; + using TRenderDeviceBase = RenderDeviceNextGenBase<RenderDeviceD3DBase<EngineD3D12ImplTraits>, ICommandQueueD3D12>; RenderDeviceD3D12Impl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, diff --git a/Graphics/GraphicsEngineD3D12/include/RenderPassD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/RenderPassD3D12Impl.hpp index 43d505d0..750a3381 100644 --- a/Graphics/GraphicsEngineD3D12/include/RenderPassD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/RenderPassD3D12Impl.hpp @@ -38,10 +38,10 @@ namespace Diligent { /// Render pass implementation in Direct3D12 backend. -class RenderPassD3D12Impl final : public RenderPassBase<IRenderPass, RenderDeviceD3D12Impl> +class RenderPassD3D12Impl final : public RenderPassBase<EngineD3D12ImplTraits> { public: - using TRenderPassBase = RenderPassBase<IRenderPass, RenderDeviceD3D12Impl>; + using TRenderPassBase = RenderPassBase<EngineD3D12ImplTraits>; RenderPassD3D12Impl(IReferenceCounters* pRefCounters, RenderDeviceD3D12Impl* pDevice, diff --git a/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.hpp index d427916a..19c11df9 100644 --- a/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/SamplerD3D12Impl.hpp @@ -40,10 +40,10 @@ namespace Diligent { /// Sampler object implementation in Direct3D12 backend. -class SamplerD3D12Impl final : public SamplerBase<ISamplerD3D12, RenderDeviceD3D12Impl> +class SamplerD3D12Impl final : public SamplerBase<EngineD3D12ImplTraits> { public: - using TSamplerBase = SamplerBase<ISamplerD3D12, RenderDeviceD3D12Impl>; + using TSamplerBase = SamplerBase<EngineD3D12ImplTraits>; SamplerD3D12Impl(IReferenceCounters* pRefCounters, RenderDeviceD3D12Impl* pRenderDeviceD3D12, diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderBindingTableD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/ShaderBindingTableD3D12Impl.hpp index 92fa88ce..ced783ba 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderBindingTableD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/ShaderBindingTableD3D12Impl.hpp @@ -42,10 +42,10 @@ namespace Diligent { /// Shader binding table object implementation in Direct3D12 backend. -class ShaderBindingTableD3D12Impl final : public ShaderBindingTableBase<IShaderBindingTableD3D12, PipelineStateD3D12Impl, TopLevelASD3D12Impl, RenderDeviceD3D12Impl>, public D3D12ResourceBase +class ShaderBindingTableD3D12Impl final : public ShaderBindingTableBase<EngineD3D12ImplTraits>, public D3D12ResourceBase { public: - using TShaderBindingTableBase = ShaderBindingTableBase<IShaderBindingTableD3D12, PipelineStateD3D12Impl, TopLevelASD3D12Impl, RenderDeviceD3D12Impl>; + using TShaderBindingTableBase = ShaderBindingTableBase<EngineD3D12ImplTraits>; ShaderBindingTableD3D12Impl(IReferenceCounters* pRefCounters, class RenderDeviceD3D12Impl* pDeviceD3D12, diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.hpp index 9a4b8f9d..cbdb0df3 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/ShaderD3D12Impl.hpp @@ -43,10 +43,10 @@ namespace Diligent class ResourceMapping; /// Implementation of a shader object in Direct3D12 backend. -class ShaderD3D12Impl final : public ShaderBase<IShaderD3D12, RenderDeviceD3D12Impl>, public ShaderD3DBase +class ShaderD3D12Impl final : public ShaderBase<EngineD3D12ImplTraits>, public ShaderD3DBase { public: - using TShaderBase = ShaderBase<IShaderD3D12, RenderDeviceD3D12Impl>; + using TShaderBase = ShaderBase<EngineD3D12ImplTraits>; ShaderD3D12Impl(IReferenceCounters* pRefCounters, RenderDeviceD3D12Impl* pRenderDeviceD3D12, diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.hpp index 498c6ea4..105f6e8d 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.hpp @@ -42,10 +42,10 @@ namespace Diligent /// Implementation of the Diligent::IShaderResourceBindingD3D12 interface // sizeof(ShaderResourceBindingD3D12Impl) == 96 (x64, msvc, Release) -class ShaderResourceBindingD3D12Impl final : public ShaderResourceBindingBase<IShaderResourceBindingD3D12, PipelineResourceSignatureD3D12Impl> +class ShaderResourceBindingD3D12Impl final : public ShaderResourceBindingBase<EngineD3D12ImplTraits> { public: - using TBase = ShaderResourceBindingBase<IShaderResourceBindingD3D12, PipelineResourceSignatureD3D12Impl>; + using TBase = ShaderResourceBindingBase<EngineD3D12ImplTraits>; ShaderResourceBindingD3D12Impl(IReferenceCounters* pRefCounters, PipelineResourceSignatureD3D12Impl* pPRS); diff --git a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.hpp index 203af1fe..8a911fd3 100644 --- a/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/TextureD3D12Impl.hpp @@ -40,13 +40,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Implementation of a texture object in Direct3D12 backend. -class TextureD3D12Impl final : public TextureBase<ITextureD3D12, RenderDeviceD3D12Impl, TextureViewD3D12Impl, FixedBlockMemoryAllocator>, public D3D12ResourceBase +class TextureD3D12Impl final : public TextureBase<EngineD3D12ImplTraits>, public D3D12ResourceBase { public: - using TTextureBase = TextureBase<ITextureD3D12, RenderDeviceD3D12Impl, TextureViewD3D12Impl, FixedBlockMemoryAllocator>; + using TTextureBase = TextureBase<EngineD3D12ImplTraits>; using ViewImplType = TextureViewD3D12Impl; // Creates a new D3D12 resource diff --git a/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.hpp index 9d6627ed..6fa2bdb2 100644 --- a/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/TextureViewD3D12Impl.hpp @@ -40,10 +40,10 @@ namespace Diligent { /// Texture view object implementation in Direct3D12 backend. -class TextureViewD3D12Impl final : public TextureViewBase<ITextureViewD3D12, RenderDeviceD3D12Impl> +class TextureViewD3D12Impl final : public TextureViewBase<EngineD3D12ImplTraits> { public: - using TTextureViewBase = TextureViewBase<ITextureViewD3D12, RenderDeviceD3D12Impl>; + using TTextureViewBase = TextureViewBase<EngineD3D12ImplTraits>; TextureViewD3D12Impl(IReferenceCounters* pRefCounters, RenderDeviceD3D12Impl* pDevice, diff --git a/Graphics/GraphicsEngineD3D12/include/TopLevelASD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/TopLevelASD3D12Impl.hpp index 166c52a4..a62bd7ce 100644 --- a/Graphics/GraphicsEngineD3D12/include/TopLevelASD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/TopLevelASD3D12Impl.hpp @@ -41,10 +41,10 @@ namespace Diligent { /// Top-level acceleration structure object implementation in Direct3D12 backend. -class TopLevelASD3D12Impl final : public TopLevelASBase<ITopLevelASD3D12, BottomLevelASD3D12Impl, RenderDeviceD3D12Impl>, public D3D12ResourceBase +class TopLevelASD3D12Impl final : public TopLevelASBase<EngineD3D12ImplTraits>, public D3D12ResourceBase { public: - using TTopLevelASBase = TopLevelASBase<ITopLevelASD3D12, BottomLevelASD3D12Impl, RenderDeviceD3D12Impl>; + using TTopLevelASBase = TopLevelASBase<EngineD3D12ImplTraits>; TopLevelASD3D12Impl(IReferenceCounters* pRefCounters, class RenderDeviceD3D12Impl* pDeviceD3D12, diff --git a/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp index a59d9cf5..ee40368c 100644 --- a/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/BufferViewD3D12Impl.cpp @@ -27,6 +27,7 @@ #include "pch.h" #include "BufferViewD3D12Impl.hpp" +#include "BufferD3D12Impl.hpp" namespace Diligent { @@ -34,7 +35,7 @@ namespace Diligent BufferViewD3D12Impl::BufferViewD3D12Impl(IReferenceCounters* pRefCounters, RenderDeviceD3D12Impl* pDevice, const BufferViewDesc& ViewDesc, - IBuffer* pBuffer, + BufferD3D12Impl* pBuffer, DescriptorHeapAllocation&& HandleAlloc, bool bIsDefaultView) : // clang-format off diff --git a/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.hpp b/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.hpp index 1f245a6d..558af369 100644 --- a/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.hpp +++ b/Graphics/GraphicsEngineD3DBase/include/RenderDeviceD3DBase.hpp @@ -39,15 +39,15 @@ namespace Diligent /// Base implementation of a D3D render device -template <typename RenderDeviceImplTraits> -class RenderDeviceD3DBase : public RenderDeviceBase<RenderDeviceImplTraits> +template <typename EngineImplTraits> +class RenderDeviceD3DBase : public RenderDeviceBase<EngineImplTraits> { public: RenderDeviceD3DBase(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, IEngineFactory* pEngineFactory, Uint32 NumDeferredContexts) : - RenderDeviceBase<RenderDeviceImplTraits>{pRefCounters, RawMemAllocator, pEngineFactory, NumDeferredContexts} + RenderDeviceBase<EngineImplTraits>{pRefCounters, RawMemAllocator, pEngineFactory, NumDeferredContexts} { // Flag texture formats always supported in D3D11 and D3D12 diff --git a/Graphics/GraphicsEngineNextGenBase/include/DeviceContextNextGenBase.hpp b/Graphics/GraphicsEngineNextGenBase/include/DeviceContextNextGenBase.hpp index cb059bca..173060fa 100644 --- a/Graphics/GraphicsEngineNextGenBase/include/DeviceContextNextGenBase.hpp +++ b/Graphics/GraphicsEngineNextGenBase/include/DeviceContextNextGenBase.hpp @@ -38,13 +38,13 @@ namespace Diligent /// Base implementation of the device context for next-generation backends. -template <typename BaseInterface, typename ImplementationTraits> -class DeviceContextNextGenBase : public DeviceContextBase<BaseInterface, ImplementationTraits> +template <typename EngineImplTraits> +class DeviceContextNextGenBase : public DeviceContextBase<EngineImplTraits> { public: - using TBase = DeviceContextBase<BaseInterface, ImplementationTraits>; - using DeviceImplType = typename ImplementationTraits::DeviceType; - using ICommandQueueType = typename ImplementationTraits::ICommandQueueType; + using TBase = DeviceContextBase<EngineImplTraits>; + using DeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + using ICommandQueueType = typename EngineImplTraits::CommandQueueInterface; DeviceContextNextGenBase(IReferenceCounters* pRefCounters, DeviceImplType* pRenderDevice, diff --git a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt index 6890b22d..d2853156 100644 --- a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt +++ b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt @@ -7,6 +7,7 @@ set(INCLUDE include/BufferGLImpl.hpp include/BufferViewGLImpl.hpp include/DeviceContextGLImpl.hpp + include/EngineGLImplTraits.hpp include/FBOCache.hpp include/FenceGLImpl.hpp include/FramebufferGLImpl.hpp diff --git a/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.hpp index ba10834e..9fd8be2f 100644 --- a/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/BufferGLImpl.hpp @@ -39,13 +39,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Buffer object implementation in OpenGL backend. -class BufferGLImpl final : public BufferBase<IBufferGL, RenderDeviceGLImpl, BufferViewGLImpl, FixedBlockMemoryAllocator>, public AsyncWritableResource +class BufferGLImpl final : public BufferBase<EngineGLImplTraits>, public AsyncWritableResource { public: - using TBufferBase = BufferBase<IBufferGL, RenderDeviceGLImpl, BufferViewGLImpl, FixedBlockMemoryAllocator>; + using TBufferBase = BufferBase<EngineGLImplTraits>; BufferGLImpl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, diff --git a/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.hpp index 73d654a9..a61e7e6d 100644 --- a/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/BufferViewGLImpl.hpp @@ -37,10 +37,10 @@ namespace Diligent { /// Buffer view implementation in OpenGL backend. -class BufferViewGLImpl final : public BufferViewBase<IBufferViewGL, RenderDeviceGLImpl> +class BufferViewGLImpl final : public BufferViewBase<EngineGLImplTraits> { public: - using TBuffViewBase = BufferViewBase<IBufferViewGL, RenderDeviceGLImpl>; + using TBuffViewBase = BufferViewBase<EngineGLImplTraits>; BufferViewGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDevice, diff --git a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.hpp index dc27008f..9926204f 100644 --- a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.hpp @@ -47,24 +47,11 @@ namespace Diligent { -struct DeviceContextGLImplTraits -{ - using BufferType = BufferGLImpl; - using TextureType = TextureBaseGL; - using PipelineStateType = PipelineStateGLImpl; - using DeviceType = RenderDeviceGLImpl; - using QueryType = QueryGLImpl; - using FramebufferType = FramebufferGLImpl; - using RenderPassType = RenderPassGLImpl; - using BottomLevelASType = BottomLevelASBase<IBottomLevelAS, RenderDeviceGLImpl>; - using TopLevelASType = TopLevelASBase<ITopLevelAS, BottomLevelASType, RenderDeviceGLImpl>; -}; - /// Device context implementation in OpenGL backend. -class DeviceContextGLImpl final : public DeviceContextBase<IDeviceContextGL, DeviceContextGLImplTraits> +class DeviceContextGLImpl final : public DeviceContextBase<EngineGLImplTraits> { public: - using TDeviceContextBase = DeviceContextBase<IDeviceContextGL, DeviceContextGLImplTraits>; + using TDeviceContextBase = DeviceContextBase<EngineGLImplTraits>; DeviceContextGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDeviceGL, bool bIsDeferred); diff --git a/Graphics/GraphicsEngineOpenGL/include/EngineGLImplTraits.hpp b/Graphics/GraphicsEngineOpenGL/include/EngineGLImplTraits.hpp new file mode 100644 index 00000000..077c11ce --- /dev/null +++ b/Graphics/GraphicsEngineOpenGL/include/EngineGLImplTraits.hpp @@ -0,0 +1,115 @@ +/* + * Copyright 2019-2021 Diligent Graphics LLC + * Copyright 2015-2019 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 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 +/// Declaration of Diligent::EngineGLImplTraits struct + +#include "RenderDeviceGL.h" +#include "PipelineStateGL.h" +#include "ShaderResourceBindingGL.h" +#include "BufferGL.h" +#include "BufferViewGL.h" +#include "TextureGL.h" +#include "TextureViewGL.h" +#include "ShaderGL.h" +#include "SamplerGL.h" +#include "FenceGL.h" +#include "QueryGL.h" +#include "RenderPass.h" +#include "Framebuffer.h" +#include "PipelineResourceSignature.h" +#include "DeviceContextGL.h" +#include "BaseInterfacesGL.h" + +namespace Diligent +{ + +class RenderDeviceGLImpl; +class DeviceContextGLImpl; +class PipelineStateGLImpl; +class ShaderResourceBindingGLImpl; +class BufferGLImpl; +class BufferViewGLImpl; +class TextureBaseGL; +class TextureViewGLImpl; +class ShaderGLImpl; +class SamplerGLImpl; +class FenceGLImpl; +class QueryGLImpl; +class RenderPassGLImpl; +class FramebufferGLImpl; +class BottomLevelASGLImpl; +class TopLevelASGLImpl; +class ShaderBindingTableGLImpl; +class PipelineResourceSignatureGLImpl; + +class FixedBlockMemoryAllocator; + +struct EngineGLImplTraits +{ + using RenderDeviceInterface = IGLDeviceBaseInterface; + using DeviceContextInterface = IDeviceContextGL; + using PipelineStateInterface = IPipelineStateGL; + using ShaderResourceBindingInterface = IShaderResourceBindingGL; + using BufferInterface = IBufferGL; + using BufferViewInterface = IBufferViewGL; + using TextureInterface = ITextureGL; + using TextureViewInterface = ITextureViewGL; + using ShaderInterface = IShaderGL; + using SamplerInterface = ISamplerGL; + using FenceInterface = IFenceGL; + using QueryInterface = IQueryGL; + using RenderPassInterface = IRenderPass; + using FramebufferInterface = IFramebuffer; + using PipelineResourceSignatureInterface = IPipelineResourceSignature; + + using RenderDeviceImplType = RenderDeviceGLImpl; + using DeviceContextImplType = DeviceContextGLImpl; + using PipelineStateImplType = PipelineStateGLImpl; + using ShaderResourceBindingImplType = ShaderResourceBindingGLImpl; + using BufferImplType = BufferGLImpl; + using BufferViewImplType = BufferViewGLImpl; + using TextureImplType = TextureBaseGL; + using TextureViewImplType = TextureViewGLImpl; + using ShaderImplType = ShaderGLImpl; + using SamplerImplType = SamplerGLImpl; + using FenceImplType = FenceGLImpl; + using QueryImplType = QueryGLImpl; + using RenderPassImplType = RenderPassGLImpl; + using FramebufferImplType = FramebufferGLImpl; + using BottomLevelASImplType = BottomLevelASGLImpl; + using TopLevelASImplType = TopLevelASGLImpl; + using ShaderBindingTableImplType = ShaderBindingTableGLImpl; + using PipelineResourceSignatureImplType = PipelineResourceSignatureGLImpl; + + using BuffViewObjAllocatorType = FixedBlockMemoryAllocator; + using TexViewObjAllocatorType = FixedBlockMemoryAllocator; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.hpp index ba99aa71..108a676d 100644 --- a/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/FenceGLImpl.hpp @@ -40,13 +40,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Fence object implementation in OpenGL backend. -class FenceGLImpl final : public FenceBase<IFenceGL, RenderDeviceGLImpl> +class FenceGLImpl final : public FenceBase<EngineGLImplTraits> { public: - using TFenceBase = FenceBase<IFenceGL, RenderDeviceGLImpl>; + using TFenceBase = FenceBase<EngineGLImplTraits>; FenceGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDevice, diff --git a/Graphics/GraphicsEngineOpenGL/include/FramebufferGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/FramebufferGLImpl.hpp index f7e604e2..67ddc685 100644 --- a/Graphics/GraphicsEngineOpenGL/include/FramebufferGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/FramebufferGLImpl.hpp @@ -40,13 +40,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Framebuffer implementation in OpenGL backend. -class FramebufferGLImpl final : public FramebufferBase<IFramebuffer, RenderDeviceGLImpl> +class FramebufferGLImpl final : public FramebufferBase<EngineGLImplTraits> { public: - using TFramebufferBase = FramebufferBase<IFramebuffer, RenderDeviceGLImpl>; + using TFramebufferBase = FramebufferBase<EngineGLImplTraits>; FramebufferGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDevice, diff --git a/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp index 5c5d7c53..1966c12d 100644 --- a/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/PipelineResourceSignatureGLImpl.hpp @@ -57,10 +57,10 @@ const char* GetBindingRangeName(BINDING_RANGE Range); /// Implementation of the Diligent::PipelineResourceSignatureGLImpl class -class PipelineResourceSignatureGLImpl final : public PipelineResourceSignatureBase<IPipelineResourceSignature, RenderDeviceGLImpl> +class PipelineResourceSignatureGLImpl final : public PipelineResourceSignatureBase<EngineGLImplTraits> { public: - using TPipelineResourceSignatureBase = PipelineResourceSignatureBase<IPipelineResourceSignature, RenderDeviceGLImpl>; + using TPipelineResourceSignatureBase = PipelineResourceSignatureBase<EngineGLImplTraits>; PipelineResourceSignatureGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDevice, diff --git a/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.hpp index 476a742b..2ba8fd21 100644 --- a/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/PipelineStateGLImpl.hpp @@ -41,13 +41,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Pipeline state object implementation in OpenGL backend. -class PipelineStateGLImpl final : public PipelineStateBase<IPipelineStateGL, RenderDeviceGLImpl> +class PipelineStateGLImpl final : public PipelineStateBase<EngineGLImplTraits> { public: - using TPipelineStateBase = PipelineStateBase<IPipelineStateGL, RenderDeviceGLImpl>; + using TPipelineStateBase = PipelineStateBase<EngineGLImplTraits>; PipelineStateGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDeviceGL, diff --git a/Graphics/GraphicsEngineOpenGL/include/QueryGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/QueryGLImpl.hpp index 8b69862b..b5a95fad 100644 --- a/Graphics/GraphicsEngineOpenGL/include/QueryGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/QueryGLImpl.hpp @@ -39,13 +39,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Query object implementation in OpenGL backend. -class QueryGLImpl final : public QueryBase<IQueryGL, RenderDeviceGLImpl> +class QueryGLImpl final : public QueryBase<EngineGLImplTraits> { public: - using TQueryBase = QueryBase<IQueryGL, RenderDeviceGLImpl>; + using TQueryBase = QueryBase<EngineGLImplTraits>; QueryGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDevice, diff --git a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.hpp index 5342ed3e..a0821579 100644 --- a/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/RenderDeviceGLImpl.hpp @@ -28,6 +28,8 @@ #pragma once #include <memory> + +#include "EngineGLImplTraits.hpp" #include "RenderDeviceBase.hpp" #include "GLContext.hpp" #include "VAOCache.hpp" @@ -38,54 +40,12 @@ namespace Diligent { - -class RenderDeviceGLImpl; -class PipelineStateGLImpl; -class ShaderResourceBindingGLImpl; -class BufferGLImpl; -class BufferViewGLImpl; -class TextureBaseGL; -class TextureViewGLImpl; -class ShaderGLImpl; -class SamplerGLImpl; -class FenceGLImpl; -class QueryGLImpl; -class RenderPassGLImpl; -class FramebufferGLImpl; -class BottomLevelASGLImpl; -class TopLevelASGLImpl; -class ShaderBindingTableGLImpl; -class PipelineResourceSignatureGLImpl; - -struct RenderDeviceGLImplTraits -{ - using BaseInterface = IGLDeviceBaseInterface; - - using RenderDeviceImplType = RenderDeviceGLImpl; - using PipelineStateImplType = PipelineStateGLImpl; - using ShaderResourceBindingImplType = ShaderResourceBindingGLImpl; - using BufferImplType = BufferGLImpl; - using BufferViewImplType = BufferViewGLImpl; - using TextureImplType = TextureBaseGL; - using TextureViewImplType = TextureViewGLImpl; - using ShaderImplType = ShaderGLImpl; - using SamplerImplType = SamplerGLImpl; - using FenceImplType = FenceGLImpl; - using QueryImplType = QueryGLImpl; - using RenderPassImplType = RenderPassGLImpl; - using FramebufferImplType = FramebufferGLImpl; - using BottomLevelASImplType = BottomLevelASGLImpl; - using TopLevelASImplType = TopLevelASGLImpl; - using ShaderBindingTableImplType = ShaderBindingTableGLImpl; - using PipelineResourceSignatureImplType = PipelineResourceSignatureGLImpl; -}; - /// Render device implementation in OpenGL backend. // RenderDeviceGLESImpl is inherited from RenderDeviceGLImpl -class RenderDeviceGLImpl : public RenderDeviceBase<RenderDeviceGLImplTraits> +class RenderDeviceGLImpl : public RenderDeviceBase<EngineGLImplTraits> { public: - using TRenderDeviceBase = RenderDeviceBase<RenderDeviceGLImplTraits>; + using TRenderDeviceBase = RenderDeviceBase<EngineGLImplTraits>; RenderDeviceGLImpl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, diff --git a/Graphics/GraphicsEngineOpenGL/include/RenderPassGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/RenderPassGLImpl.hpp index 0dc5f98d..f307ae15 100644 --- a/Graphics/GraphicsEngineOpenGL/include/RenderPassGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/RenderPassGLImpl.hpp @@ -40,10 +40,10 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Render pass implementation in Direct3D11 backend. -class RenderPassGLImpl final : public RenderPassBase<IRenderPass, RenderDeviceGLImpl> +class RenderPassGLImpl final : public RenderPassBase<EngineGLImplTraits> { public: - using TRenderPassBase = RenderPassBase<IRenderPass, RenderDeviceGLImpl>; + using TRenderPassBase = RenderPassBase<EngineGLImplTraits>; RenderPassGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDevice, diff --git a/Graphics/GraphicsEngineOpenGL/include/SamplerGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/SamplerGLImpl.hpp index 81705735..3dcc95e7 100644 --- a/Graphics/GraphicsEngineOpenGL/include/SamplerGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/SamplerGLImpl.hpp @@ -37,13 +37,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Sampler implementation in OpenGL backend. -class SamplerGLImpl final : public SamplerBase<ISamplerGL, RenderDeviceGLImpl> +class SamplerGLImpl final : public SamplerBase<EngineGLImplTraits> { public: - using TSamplerBase = SamplerBase<ISamplerGL, RenderDeviceGLImpl>; + using TSamplerBase = SamplerBase<EngineGLImplTraits>; SamplerGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDeviceGL, const SamplerDesc& SamplerDesc, bool bIsDeviceInternal = false); ~SamplerGLImpl(); diff --git a/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.hpp index b958d59d..31c4686b 100644 --- a/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/ShaderGLImpl.hpp @@ -38,8 +38,6 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - inline GLenum GetGLShaderType(SHADER_TYPE ShaderType) { switch (ShaderType) @@ -73,10 +71,10 @@ inline GLenum ShaderTypeToGLShaderBit(SHADER_TYPE ShaderType) } /// Shader object implementation in OpenGL backend. -class ShaderGLImpl final : public ShaderBase<IShaderGL, RenderDeviceGLImpl> +class ShaderGLImpl final : public ShaderBase<EngineGLImplTraits> { public: - using TShaderBase = ShaderBase<IShaderGL, RenderDeviceGLImpl>; + using TShaderBase = ShaderBase<EngineGLImplTraits>; ShaderGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDeviceGL, diff --git a/Graphics/GraphicsEngineOpenGL/include/ShaderResourceBindingGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/ShaderResourceBindingGLImpl.hpp index 08efc5fe..5c585383 100644 --- a/Graphics/GraphicsEngineOpenGL/include/ShaderResourceBindingGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/ShaderResourceBindingGLImpl.hpp @@ -42,10 +42,10 @@ namespace Diligent { /// Shader resource binding object implementation in OpenGL backend. -class ShaderResourceBindingGLImpl final : public ShaderResourceBindingBase<IShaderResourceBindingGL, PipelineResourceSignatureGLImpl> +class ShaderResourceBindingGLImpl final : public ShaderResourceBindingBase<EngineGLImplTraits> { public: - using TBase = ShaderResourceBindingBase<IShaderResourceBindingGL, PipelineResourceSignatureGLImpl>; + using TBase = ShaderResourceBindingBase<EngineGLImplTraits>; ShaderResourceBindingGLImpl(IReferenceCounters* pRefCounters, PipelineResourceSignatureGLImpl* pPRS); diff --git a/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.hpp b/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.hpp index 6b507c67..2d4101ea 100644 --- a/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/TextureBaseGL.hpp @@ -39,13 +39,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Base implementation of a texture object in OpenGL backend. -class TextureBaseGL : public TextureBase<ITextureGL, RenderDeviceGLImpl, TextureViewGLImpl, FixedBlockMemoryAllocator>, public AsyncWritableResource +class TextureBaseGL : public TextureBase<EngineGLImplTraits>, public AsyncWritableResource { public: - using TTextureBase = TextureBase<ITextureGL, RenderDeviceGLImpl, TextureViewGLImpl, FixedBlockMemoryAllocator>; + using TTextureBase = TextureBase<EngineGLImplTraits>; using ViewImplType = TextureViewGLImpl; TextureBaseGL(IReferenceCounters* pRefCounters, diff --git a/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.hpp index 47e110a5..ae50f76c 100644 --- a/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/TextureViewGLImpl.hpp @@ -40,10 +40,10 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Texture view implementation in OpenGL backend. -class TextureViewGLImpl final : public TextureViewBase<ITextureViewGL, RenderDeviceGLImpl> +class TextureViewGLImpl final : public TextureViewBase<EngineGLImplTraits> { public: - using TTextureViewBase = TextureViewBase<ITextureViewGL, RenderDeviceGLImpl>; + using TTextureViewBase = TextureViewBase<EngineGLImplTraits>; TextureViewGLImpl(IReferenceCounters* pRefCounters, RenderDeviceGLImpl* pDevice, diff --git a/Graphics/GraphicsEngineOpenGL/src/ShaderVariableGL.cpp b/Graphics/GraphicsEngineOpenGL/src/ShaderVariableGL.cpp index aa36a7aa..be2312de 100644 --- a/Graphics/GraphicsEngineOpenGL/src/ShaderVariableGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/ShaderVariableGL.cpp @@ -223,6 +223,7 @@ void ShaderVariableManagerGL::DestroyVariables(IMemoryAllocator& Allocator) ssbo.~StorageBufferBindInfo(); }); + Allocator.Free(m_ResourceBuffer); m_ResourceBuffer = nullptr; } diff --git a/Graphics/GraphicsEngineVulkan/CMakeLists.txt b/Graphics/GraphicsEngineVulkan/CMakeLists.txt index ff540add..61fe931e 100644 --- a/Graphics/GraphicsEngineVulkan/CMakeLists.txt +++ b/Graphics/GraphicsEngineVulkan/CMakeLists.txt @@ -10,6 +10,7 @@ set(INCLUDE include/CommandQueueVkImpl.hpp include/DescriptorPoolManager.hpp include/DeviceContextVkImpl.hpp + include/EngineVkImplTraits.hpp include/FenceVkImpl.hpp include/FramebufferVkImpl.hpp include/VulkanDynamicHeap.hpp diff --git a/Graphics/GraphicsEngineVulkan/include/BottomLevelASVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/BottomLevelASVkImpl.hpp index ea990054..469aef6d 100644 --- a/Graphics/GraphicsEngineVulkan/include/BottomLevelASVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/BottomLevelASVkImpl.hpp @@ -39,10 +39,10 @@ namespace Diligent { -class BottomLevelASVkImpl final : public BottomLevelASBase<IBottomLevelASVk, RenderDeviceVkImpl> +class BottomLevelASVkImpl final : public BottomLevelASBase<EngineVkImplTraits> { public: - using TBottomLevelASBase = BottomLevelASBase<IBottomLevelASVk, RenderDeviceVkImpl>; + using TBottomLevelASBase = BottomLevelASBase<EngineVkImplTraits>; BottomLevelASVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pRenderDeviceVk, diff --git a/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.hpp index bbba917f..15091572 100644 --- a/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/BufferViewVkImpl.hpp @@ -39,14 +39,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; -class BufferVkImpl; - /// Buffer view implementation in Vulkan backend. -class BufferViewVkImpl final : public BufferViewBase<IBufferViewVk, RenderDeviceVkImpl> +class BufferViewVkImpl final : public BufferViewBase<EngineVkImplTraits> { public: - using TBufferViewBase = BufferViewBase<IBufferViewVk, RenderDeviceVkImpl>; + using TBufferViewBase = BufferViewBase<EngineVkImplTraits>; BufferViewVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pDevice, diff --git a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.hpp index ca50a35b..caffa62f 100644 --- a/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/BufferVkImpl.hpp @@ -43,14 +43,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; -class DeviceContextVkImpl; - /// Buffer object implementation in Vulkan backend. -class BufferVkImpl final : public BufferBase<IBufferVk, RenderDeviceVkImpl, BufferViewVkImpl, FixedBlockMemoryAllocator> +class BufferVkImpl final : public BufferBase<EngineVkImplTraits> { public: - using TBufferBase = BufferBase<IBufferVk, RenderDeviceVkImpl, BufferViewVkImpl, FixedBlockMemoryAllocator>; + using TBufferBase = BufferBase<EngineVkImplTraits>; BufferVkImpl(IReferenceCounters* pRefCounters, FixedBlockMemoryAllocator& BuffViewObjMemAllocator, diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.hpp index e32405a9..ff0e27de 100644 --- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.hpp @@ -61,25 +61,11 @@ namespace Diligent { -struct DeviceContextVkImplTraits -{ - using BufferType = BufferVkImpl; - using TextureType = TextureVkImpl; - using PipelineStateType = PipelineStateVkImpl; - using DeviceType = RenderDeviceVkImpl; - using ICommandQueueType = ICommandQueueVk; - using QueryType = QueryVkImpl; - using FramebufferType = FramebufferVkImpl; - using RenderPassType = RenderPassVkImpl; - using BottomLevelASType = BottomLevelASVkImpl; - using TopLevelASType = TopLevelASVkImpl; -}; - /// Device context implementation in Vulkan backend. -class DeviceContextVkImpl final : public DeviceContextNextGenBase<IDeviceContextVk, DeviceContextVkImplTraits> +class DeviceContextVkImpl final : public DeviceContextNextGenBase<EngineVkImplTraits> { public: - using TDeviceContextBase = DeviceContextNextGenBase<IDeviceContextVk, DeviceContextVkImplTraits>; + using TDeviceContextBase = DeviceContextNextGenBase<EngineVkImplTraits>; DeviceContextVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pDevice, diff --git a/Graphics/GraphicsEngineVulkan/include/EngineVkImplTraits.hpp b/Graphics/GraphicsEngineVulkan/include/EngineVkImplTraits.hpp new file mode 100644 index 00000000..aace213f --- /dev/null +++ b/Graphics/GraphicsEngineVulkan/include/EngineVkImplTraits.hpp @@ -0,0 +1,122 @@ +/* + * Copyright 2019-2021 Diligent Graphics LLC + * Copyright 2015-2019 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 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 +/// Declaration of Diligent::EngineVkImplTraits struct + +#include "RenderDeviceVk.h" +#include "PipelineStateVk.h" +#include "ShaderResourceBindingVk.h" +#include "BufferVk.h" +#include "BufferViewVk.h" +#include "TextureVk.h" +#include "TextureViewVk.h" +#include "ShaderVk.h" +#include "SamplerVk.h" +#include "FenceVk.h" +#include "QueryVk.h" +#include "RenderPassVk.h" +#include "FramebufferVk.h" +#include "BottomLevelASVk.h" +#include "TopLevelASVk.h" +#include "ShaderBindingTableVk.h" +#include "PipelineResourceSignature.h" +#include "CommandQueueVk.h" +#include "DeviceContextVk.h" + +namespace Diligent +{ + +class RenderDeviceVkImpl; +class DeviceContextVkImpl; +class PipelineStateVkImpl; +class ShaderResourceBindingVkImpl; +class BufferVkImpl; +class BufferViewVkImpl; +class TextureVkImpl; +class TextureViewVkImpl; +class ShaderVkImpl; +class SamplerVkImpl; +class FenceVkImpl; +class QueryVkImpl; +class RenderPassVkImpl; +class FramebufferVkImpl; +class BottomLevelASVkImpl; +class TopLevelASVkImpl; +class ShaderBindingTableVkImpl; +class PipelineResourceSignatureVkImpl; + +class FixedBlockMemoryAllocator; + +struct EngineVkImplTraits +{ + using RenderDeviceInterface = IRenderDeviceVk; + using DeviceContextInterface = IDeviceContextVk; + using PipelineStateInterface = IPipelineStateVk; + using ShaderResourceBindingInterface = IShaderResourceBindingVk; + using BufferInterface = IBufferVk; + using BufferViewInterface = IBufferViewVk; + using TextureInterface = ITextureVk; + using TextureViewInterface = ITextureViewVk; + using ShaderInterface = IShaderVk; + using SamplerInterface = ISamplerVk; + using FenceInterface = IFenceVk; + using QueryInterface = IQueryVk; + using RenderPassInterface = IRenderPassVk; + using FramebufferInterface = IFramebufferVk; + using BottomLevelASInterface = IBottomLevelASVk; + using TopLevelASInterface = ITopLevelASVk; + using ShaderBindingTableInterface = IShaderBindingTableVk; + using PipelineResourceSignatureInterface = IPipelineResourceSignature; + using CommandQueueInterface = ICommandQueueVk; + + using RenderDeviceImplType = RenderDeviceVkImpl; + using DeviceContextImplType = DeviceContextVkImpl; + using PipelineStateImplType = PipelineStateVkImpl; + using ShaderResourceBindingImplType = ShaderResourceBindingVkImpl; + using BufferImplType = BufferVkImpl; + using BufferViewImplType = BufferViewVkImpl; + using TextureImplType = TextureVkImpl; + using TextureViewImplType = TextureViewVkImpl; + using ShaderImplType = ShaderVkImpl; + using SamplerImplType = SamplerVkImpl; + using FenceImplType = FenceVkImpl; + using QueryImplType = QueryVkImpl; + using RenderPassImplType = RenderPassVkImpl; + using FramebufferImplType = FramebufferVkImpl; + using BottomLevelASImplType = BottomLevelASVkImpl; + using TopLevelASImplType = TopLevelASVkImpl; + using ShaderBindingTableImplType = ShaderBindingTableVkImpl; + using PipelineResourceSignatureImplType = PipelineResourceSignatureVkImpl; + + using BuffViewObjAllocatorType = FixedBlockMemoryAllocator; + using TexViewObjAllocatorType = FixedBlockMemoryAllocator; +}; + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.hpp index 303fe6cf..a3a81edc 100644 --- a/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/FenceVkImpl.hpp @@ -41,13 +41,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Fence implementation in Vulkan backend. -class FenceVkImpl final : public FenceBase<IFenceVk, RenderDeviceVkImpl> +class FenceVkImpl final : public FenceBase<EngineVkImplTraits> { public: - using TFenceBase = FenceBase<IFenceVk, RenderDeviceVkImpl>; + using TFenceBase = FenceBase<EngineVkImplTraits>; FenceVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pRendeDeviceVkImpl, diff --git a/Graphics/GraphicsEngineVulkan/include/FramebufferVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/FramebufferVkImpl.hpp index de3ec01c..6877fd3d 100644 --- a/Graphics/GraphicsEngineVulkan/include/FramebufferVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/FramebufferVkImpl.hpp @@ -38,13 +38,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Framebuffer implementation in Vulkan backend. -class FramebufferVkImpl final : public FramebufferBase<IFramebufferVk, RenderDeviceVkImpl> +class FramebufferVkImpl final : public FramebufferBase<EngineVkImplTraits> { public: - using TFramebufferBase = FramebufferBase<IFramebufferVk, RenderDeviceVkImpl>; + using TFramebufferBase = FramebufferBase<EngineVkImplTraits>; FramebufferVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pDevice, diff --git a/Graphics/GraphicsEngineVulkan/include/PipelineResourceSignatureVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/PipelineResourceSignatureVkImpl.hpp index 1fb11c53..f9d5d5ec 100644 --- a/Graphics/GraphicsEngineVulkan/include/PipelineResourceSignatureVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/PipelineResourceSignatureVkImpl.hpp @@ -32,6 +32,7 @@ #include <array> +#include "EngineVkImplTraits.hpp" #include "PipelineResourceSignatureBase.hpp" #include "VulkanUtilities/VulkanObjectWrappers.hpp" #include "SRBMemoryAllocator.hpp" @@ -66,10 +67,10 @@ enum class DescriptorType : Uint8 }; /// Implementation of the Diligent::PipelineResourceSignatureVkImpl class -class PipelineResourceSignatureVkImpl final : public PipelineResourceSignatureBase<IPipelineResourceSignature, RenderDeviceVkImpl> +class PipelineResourceSignatureVkImpl final : public PipelineResourceSignatureBase<EngineVkImplTraits> { public: - using TPipelineResourceSignatureBase = PipelineResourceSignatureBase<IPipelineResourceSignature, RenderDeviceVkImpl>; + using TPipelineResourceSignatureBase = PipelineResourceSignatureBase<EngineVkImplTraits>; // Descriptor set identifier (this is not the descriptor set index in the set layout!) enum DESCRIPTOR_SET_ID : size_t diff --git a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.hpp index 80d1a46b..d2f289af 100644 --- a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.hpp @@ -54,10 +54,10 @@ class ShaderVkImpl; class ShaderResourceBindingVkImpl; /// Pipeline state object implementation in Vulkan backend. -class PipelineStateVkImpl final : public PipelineStateBase<IPipelineStateVk, RenderDeviceVkImpl> +class PipelineStateVkImpl final : public PipelineStateBase<EngineVkImplTraits> { public: - using TPipelineStateBase = PipelineStateBase<IPipelineStateVk, RenderDeviceVkImpl>; + using TPipelineStateBase = PipelineStateBase<EngineVkImplTraits>; PipelineStateVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pDeviceVk, const GraphicsPipelineStateCreateInfo& CreateInfo); PipelineStateVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pDeviceVk, const ComputePipelineStateCreateInfo& CreateInfo); diff --git a/Graphics/GraphicsEngineVulkan/include/QueryVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/QueryVkImpl.hpp index 718628e6..cc3919c9 100644 --- a/Graphics/GraphicsEngineVulkan/include/QueryVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/QueryVkImpl.hpp @@ -43,10 +43,10 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Query implementation in Vulkan backend. -class QueryVkImpl final : public QueryBase<IQueryVk, RenderDeviceVkImpl> +class QueryVkImpl final : public QueryBase<EngineVkImplTraits> { public: - using TQueryBase = QueryBase<IQueryVk, RenderDeviceVkImpl>; + using TQueryBase = QueryBase<EngineVkImplTraits>; QueryVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pRendeDeviceVkImpl, diff --git a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.hpp index 7e003fca..71294e24 100644 --- a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.hpp @@ -31,7 +31,8 @@ /// Declaration of Diligent::RenderDeviceVkImpl class #include <memory> -#include "RenderDeviceVk.h" +#include "EngineVkImplTraits.hpp" + #include "RenderDeviceBase.hpp" #include "RenderDeviceNextGenBase.hpp" #include "DescriptorPoolManager.hpp" @@ -54,52 +55,11 @@ namespace Diligent { -class RenderDeviceVkImpl; -class PipelineStateVkImpl; -class ShaderResourceBindingVkImpl; -class BufferVkImpl; -class BufferViewVkImpl; -class TextureVkImpl; -class TextureViewVkImpl; -class ShaderVkImpl; -class SamplerVkImpl; -class FenceVkImpl; -class QueryVkImpl; -class RenderPassVkImpl; -class FramebufferVkImpl; -class BottomLevelASVkImpl; -class TopLevelASVkImpl; -class ShaderBindingTableVkImpl; -class PipelineResourceSignatureVkImpl; - -struct RenderDeviceVkImplTraits -{ - using BaseInterface = IRenderDeviceVk; - - using RenderDeviceImplType = RenderDeviceVkImpl; - using PipelineStateImplType = PipelineStateVkImpl; - using ShaderResourceBindingImplType = ShaderResourceBindingVkImpl; - using BufferImplType = BufferVkImpl; - using BufferViewImplType = BufferViewVkImpl; - using TextureImplType = TextureVkImpl; - using TextureViewImplType = TextureViewVkImpl; - using ShaderImplType = ShaderVkImpl; - using SamplerImplType = SamplerVkImpl; - using FenceImplType = FenceVkImpl; - using QueryImplType = QueryVkImpl; - using RenderPassImplType = RenderPassVkImpl; - using FramebufferImplType = FramebufferVkImpl; - using BottomLevelASImplType = BottomLevelASVkImpl; - using TopLevelASImplType = TopLevelASVkImpl; - using ShaderBindingTableImplType = ShaderBindingTableVkImpl; - using PipelineResourceSignatureImplType = PipelineResourceSignatureVkImpl; -}; - /// Render device implementation in Vulkan backend. -class RenderDeviceVkImpl final : public RenderDeviceNextGenBase<RenderDeviceBase<RenderDeviceVkImplTraits>, ICommandQueueVk> +class RenderDeviceVkImpl final : public RenderDeviceNextGenBase<RenderDeviceBase<EngineVkImplTraits>, ICommandQueueVk> { public: - using TRenderDeviceBase = RenderDeviceNextGenBase<RenderDeviceBase<RenderDeviceVkImplTraits>, ICommandQueueVk>; + using TRenderDeviceBase = RenderDeviceNextGenBase<RenderDeviceBase<EngineVkImplTraits>, ICommandQueueVk>; RenderDeviceVkImpl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, diff --git a/Graphics/GraphicsEngineVulkan/include/RenderPassVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/RenderPassVkImpl.hpp index ecad1df0..d155a0cd 100644 --- a/Graphics/GraphicsEngineVulkan/include/RenderPassVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/RenderPassVkImpl.hpp @@ -42,10 +42,10 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Render pass implementation in Vulkan backend. -class RenderPassVkImpl final : public RenderPassBase<IRenderPassVk, RenderDeviceVkImpl> +class RenderPassVkImpl final : public RenderPassBase<EngineVkImplTraits> { public: - using TRenderPassBase = RenderPassBase<IRenderPassVk, RenderDeviceVkImpl>; + using TRenderPassBase = RenderPassBase<EngineVkImplTraits>; RenderPassVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pDevice, diff --git a/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.hpp index 24f1af24..5821e02e 100644 --- a/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/SamplerVkImpl.hpp @@ -42,10 +42,10 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Sampler object object implementation in Vulkan backend. -class SamplerVkImpl final : public SamplerBase<ISamplerVk, RenderDeviceVkImpl> +class SamplerVkImpl final : public SamplerBase<EngineVkImplTraits> { public: - using TSamplerBase = SamplerBase<ISamplerVk, RenderDeviceVkImpl>; + using TSamplerBase = SamplerBase<EngineVkImplTraits>; SamplerVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pRenderDeviceVk, const SamplerDesc& SamplerDesc); ~SamplerVkImpl(); diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderBindingTableVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/ShaderBindingTableVkImpl.hpp index 375163fa..5291f857 100644 --- a/Graphics/GraphicsEngineVulkan/include/ShaderBindingTableVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/ShaderBindingTableVkImpl.hpp @@ -41,10 +41,10 @@ namespace Diligent { -class ShaderBindingTableVkImpl final : public ShaderBindingTableBase<IShaderBindingTableVk, PipelineStateVkImpl, TopLevelASVkImpl, RenderDeviceVkImpl> +class ShaderBindingTableVkImpl final : public ShaderBindingTableBase<EngineVkImplTraits> { public: - using TShaderBindingTableBase = ShaderBindingTableBase<IShaderBindingTableVk, PipelineStateVkImpl, TopLevelASVkImpl, RenderDeviceVkImpl>; + using TShaderBindingTableBase = ShaderBindingTableBase<EngineVkImplTraits>; ShaderBindingTableVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pRenderDeviceVk, diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp index c0e012a2..e77da610 100644 --- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp @@ -45,10 +45,10 @@ class PipelineResourceSignatureVkImpl; /// Implementation of the Diligent::IShaderResourceBindingVk interface // sizeof(ShaderResourceBindingVkImpl) == 64 (x64, msvc, Release) -class ShaderResourceBindingVkImpl final : public ShaderResourceBindingBase<IShaderResourceBindingVk, PipelineResourceSignatureVkImpl> +class ShaderResourceBindingVkImpl final : public ShaderResourceBindingBase<EngineVkImplTraits> { public: - using TBase = ShaderResourceBindingBase<IShaderResourceBindingVk, PipelineResourceSignatureVkImpl>; + using TBase = ShaderResourceBindingBase<EngineVkImplTraits>; ShaderResourceBindingVkImpl(IReferenceCounters* pRefCounters, PipelineResourceSignatureVkImpl* pPRS); diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.hpp index 804a1c84..f8b63b95 100644 --- a/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/ShaderVkImpl.hpp @@ -43,10 +43,10 @@ class ResourceMapping; class FixedBlockMemoryAllocator; /// Shader object object implementation in Vulkan backend. -class ShaderVkImpl final : public ShaderBase<IShaderVk, RenderDeviceVkImpl> +class ShaderVkImpl final : public ShaderBase<EngineVkImplTraits> { public: - using TShaderBase = ShaderBase<IShaderVk, RenderDeviceVkImpl>; + using TShaderBase = ShaderBase<EngineVkImplTraits>; ShaderVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pRenderDeviceVk, const ShaderCreateInfo& CreationAttribs); ~ShaderVkImpl(); diff --git a/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.hpp index c1feb1b9..67806c8b 100644 --- a/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/TextureViewVkImpl.hpp @@ -42,10 +42,10 @@ namespace Diligent class FixedBlockMemoryAllocator; /// Texture view implementation in Vulkan backend. -class TextureViewVkImpl final : public TextureViewBase<ITextureViewVk, RenderDeviceVkImpl> +class TextureViewVkImpl final : public TextureViewBase<EngineVkImplTraits> { public: - using TTextureViewBase = TextureViewBase<ITextureViewVk, RenderDeviceVkImpl>; + using TTextureViewBase = TextureViewBase<EngineVkImplTraits>; TextureViewVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pDevice, diff --git a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.hpp index f9958832..9f5cfb84 100644 --- a/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/TextureVkImpl.hpp @@ -40,13 +40,11 @@ namespace Diligent { -class FixedBlockMemoryAllocator; - /// Texture object implementation in Vulkan backend. -class TextureVkImpl final : public TextureBase<ITextureVk, RenderDeviceVkImpl, TextureViewVkImpl, FixedBlockMemoryAllocator> +class TextureVkImpl final : public TextureBase<EngineVkImplTraits> { public: - using TTextureBase = TextureBase<ITextureVk, RenderDeviceVkImpl, TextureViewVkImpl, FixedBlockMemoryAllocator>; + using TTextureBase = TextureBase<EngineVkImplTraits>; using ViewImplType = TextureViewVkImpl; // Creates a new Vk resource diff --git a/Graphics/GraphicsEngineVulkan/include/TopLevelASVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/TopLevelASVkImpl.hpp index deba84cc..7f34104d 100644 --- a/Graphics/GraphicsEngineVulkan/include/TopLevelASVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/TopLevelASVkImpl.hpp @@ -40,10 +40,10 @@ namespace Diligent { -class TopLevelASVkImpl final : public TopLevelASBase<ITopLevelASVk, BottomLevelASVkImpl, RenderDeviceVkImpl> +class TopLevelASVkImpl final : public TopLevelASBase<EngineVkImplTraits> { public: - using TTopLevelASBase = TopLevelASBase<ITopLevelASVk, BottomLevelASVkImpl, RenderDeviceVkImpl>; + using TTopLevelASBase = TopLevelASBase<EngineVkImplTraits>; TopLevelASVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImpl* pRenderDeviceVk, |
