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 /Graphics/GraphicsEngine | |
| parent | Minor updates to ValidatePipelineResourceSignatureDesc (diff) | |
| download | DiligentCore-4f5a4499cf0eee3761788eb6a422cd25e02ace40.tar.gz DiligentCore-4f5a4499cf0eee3761788eb6a422cd25e02ace40.zip | |
Refactored passing template arguments to base classes
Diffstat (limited to 'Graphics/GraphicsEngine')
18 files changed, 342 insertions, 295 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); |
