From 4f5a4499cf0eee3761788eb6a422cd25e02ace40 Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 4 Mar 2021 12:46:21 -0800 Subject: Refactored passing template arguments to base classes --- .../GraphicsEngine/include/BottomLevelASBase.hpp | 15 +- Graphics/GraphicsEngine/include/BufferBase.hpp | 27 ++- Graphics/GraphicsEngine/include/BufferViewBase.hpp | 20 +- .../GraphicsEngine/include/DeviceContextBase.hpp | 262 ++++++++++----------- Graphics/GraphicsEngine/include/FenceBase.hpp | 15 +- .../GraphicsEngine/include/FramebufferBase.hpp | 16 +- .../include/PipelineResourceSignatureBase.hpp | 15 +- .../GraphicsEngine/include/PipelineStateBase.hpp | 17 +- Graphics/GraphicsEngine/include/QueryBase.hpp | 15 +- .../GraphicsEngine/include/RenderDeviceBase.hpp | 42 ++-- Graphics/GraphicsEngine/include/RenderPassBase.hpp | 16 +- Graphics/GraphicsEngine/include/SamplerBase.hpp | 17 +- Graphics/GraphicsEngine/include/ShaderBase.hpp | 17 +- .../include/ShaderBindingTableBase.hpp | 21 +- .../include/ShaderResourceBindingBase.hpp | 18 +- Graphics/GraphicsEngine/include/TextureBase.hpp | 59 ++--- .../GraphicsEngine/include/TextureViewBase.hpp | 17 +- Graphics/GraphicsEngine/include/TopLevelASBase.hpp | 28 ++- 18 files changed, 342 insertions(+), 295 deletions(-) (limited to 'Graphics/GraphicsEngine') 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 BottomLevelASBase : public DeviceObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class BottomLevelASBase : public DeviceObjectBase { 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; /// \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 BufferBase : public DeviceObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class BufferBase : public DeviceObjectBase { 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; /// \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 BufferViewBase : public DeviceObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class BufferViewBase : public DeviceObjectBase { 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; /// \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 -class DeviceContextBase : public ObjectBase +template +class DeviceContextBase : public ObjectBase { public: + using BaseInterface = typename EngineImplTraits::DeviceContextInterface; using TObjectBase = ObjectBase; - 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 -inline void DeviceContextBase::SetVertexBuffers( +template +inline void DeviceContextBase::SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer** ppBuffers, @@ -476,16 +476,16 @@ inline void DeviceContextBase::SetVertexBuf m_VertexStreams[m_NumVertexStreams--] = VertexStreamInfo{}; } -template -inline void DeviceContextBase::SetPipelineState( +template +inline void DeviceContextBase::SetPipelineState( PipelineStateImplType* pPipelineState, int /*Dummy*/) { m_pPipelineState = pPipelineState; } -template -inline bool DeviceContextBase::CommitShaderResources( +template +inline bool DeviceContextBase::CommitShaderResources( IShaderResourceBinding* pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, int) @@ -505,17 +505,17 @@ inline bool DeviceContextBase::CommitShader return true; } -template -inline void DeviceContextBase::InvalidateState() +template +inline void DeviceContextBase::InvalidateState() { if (m_pActiveRenderPass != nullptr) LOG_ERROR_MESSAGE("Invalidating context inside an active render pass. Call EndRenderPass() to finish the pass."); - DeviceContextBase::ClearStateCache(); + DeviceContextBase::ClearStateCache(); } -template -inline void DeviceContextBase::SetIndexBuffer( +template +inline void DeviceContextBase::SetIndexBuffer( IBuffer* pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) @@ -539,8 +539,8 @@ inline void DeviceContextBase::SetIndexBuff } -template -inline void DeviceContextBase::GetPipelineState(IPipelineState** ppPSO, float* BlendFactors, Uint32& StencilRef) +template +inline void DeviceContextBase::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::GetPipelineS StencilRef = m_StencilRef; }; -template -inline bool DeviceContextBase::SetBlendFactors(const float* BlendFactors, int) +template +inline bool DeviceContextBase::SetBlendFactors(const float* BlendFactors, int) { bool FactorsDiffer = false; for (Uint32 f = 0; f < 4; ++f) @@ -571,8 +571,8 @@ inline bool DeviceContextBase::SetBlendFact return FactorsDiffer; } -template -inline bool DeviceContextBase::SetStencilRef(Uint32 StencilRef, int) +template +inline bool DeviceContextBase::SetStencilRef(Uint32 StencilRef, int) { if (m_StencilRef != StencilRef) { @@ -582,8 +582,8 @@ inline bool DeviceContextBase::SetStencilRe return false; } -template -inline void DeviceContextBase::SetViewports( +template +inline void DeviceContextBase::SetViewports( Uint32 NumViewports, const Viewport* pViewports, Uint32& RTWidth, @@ -614,8 +614,8 @@ inline void DeviceContextBase::SetViewports } } -template -inline void DeviceContextBase::GetViewports(Uint32& NumViewports, Viewport* pViewports) +template +inline void DeviceContextBase::GetViewports(Uint32& NumViewports, Viewport* pViewports) { NumViewports = m_NumViewports; if (pViewports) @@ -625,8 +625,8 @@ inline void DeviceContextBase::GetViewports } } -template -inline void DeviceContextBase::SetScissorRects( +template +inline void DeviceContextBase::SetScissorRects( Uint32 NumRects, const Rect* pRects, Uint32& RTWidth, @@ -649,8 +649,8 @@ inline void DeviceContextBase::SetScissorRe } } -template -inline bool DeviceContextBase::SetRenderTargets( +template +inline bool DeviceContextBase::SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil) @@ -768,8 +768,8 @@ inline bool DeviceContextBase::SetRenderTar return bBindRenderTargets; } -template -inline bool DeviceContextBase::SetSubpassRenderTargets() +template +inline bool DeviceContextBase::SetSubpassRenderTargets() { VERIFY_EXPR(m_pBoundFramebuffer); VERIFY_EXPR(m_pActiveRenderPass); @@ -828,8 +828,8 @@ inline bool DeviceContextBase::SetSubpassRe } -template -inline void DeviceContextBase::GetRenderTargets( +template +inline void DeviceContextBase::GetRenderTargets( Uint32& NumRenderTargets, ITextureView** ppRTVs, ITextureView** ppDSV) @@ -864,8 +864,8 @@ inline void DeviceContextBase::GetRenderTar } } -template -inline void DeviceContextBase::ClearStateCache() +template +inline void DeviceContextBase::ClearStateCache() { for (Uint32 stream = 0; stream < m_NumVertexStreams; ++stream) m_VertexStreams[stream] = VertexStreamInfo{}; @@ -903,8 +903,8 @@ inline void DeviceContextBase::ClearStateCa m_pBoundFramebuffer = nullptr; } -template -bool DeviceContextBase::CheckIfBoundAsRenderTarget(TextureImplType* pTexture) +template +bool DeviceContextBase::CheckIfBoundAsRenderTarget(TextureImplType* pTexture) { if (pTexture == nullptr) return false; @@ -920,8 +920,8 @@ bool DeviceContextBase::CheckIfBoundAsRende return false; } -template -bool DeviceContextBase::CheckIfBoundAsDepthStencil(TextureImplType* pTexture) +template +bool DeviceContextBase::CheckIfBoundAsDepthStencil(TextureImplType* pTexture) { if (pTexture == nullptr) return false; @@ -929,8 +929,8 @@ bool DeviceContextBase::CheckIfBoundAsDepth return m_pBoundDepthStencil && m_pBoundDepthStencil->GetTexture() == pTexture; } -template -bool DeviceContextBase::UnbindTextureFromFramebuffer(TextureImplType* pTexture, bool bShowMessage) +template +bool DeviceContextBase::UnbindTextureFromFramebuffer(TextureImplType* pTexture, bool bShowMessage) { VERIFY(m_pActiveRenderPass == nullptr, "State transitions are not allowed inside a render pass."); @@ -983,8 +983,8 @@ bool DeviceContextBase::UnbindTextureFromFr return bResetRenderTargets; } -template -void DeviceContextBase::ResetRenderTargets() +template +void DeviceContextBase::ResetRenderTargets() { for (Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt) m_pBoundRenderTargets[rt].Release(); @@ -1006,8 +1006,8 @@ void DeviceContextBase::ResetRenderTargets( // be a subpass without any render target attachments. } -template -inline void DeviceContextBase::BeginRenderPass(const BeginRenderPassAttribs& Attribs) +template +inline void DeviceContextBase::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::BeginRenderP SetSubpassRenderTargets(); } -template -inline void DeviceContextBase::NextSubpass() +template +inline void DeviceContextBase::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::NextSubpass( SetSubpassRenderTargets(); } -template -inline void DeviceContextBase::UpdateAttachmentStates(Uint32 SubpassIndex) +template +inline void DeviceContextBase::UpdateAttachmentStates(Uint32 SubpassIndex) { if (m_RenderPassAttachmentsTransitionMode != RESOURCE_STATE_TRANSITION_MODE_TRANSITION) return; @@ -1098,8 +1098,8 @@ inline void DeviceContextBase::UpdateAttach } } -template -inline void DeviceContextBase::EndRenderPass() +template +inline void DeviceContextBase::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::EndRenderPas } -template -inline bool DeviceContextBase::ClearDepthStencil(ITextureView* pView) +template +inline bool DeviceContextBase::ClearDepthStencil(ITextureView* pView) { if (pView == nullptr) { @@ -1165,8 +1165,8 @@ inline bool DeviceContextBase::ClearDepthSt return true; } -template -inline bool DeviceContextBase::ClearRenderTarget(ITextureView* pView) +template +inline bool DeviceContextBase::ClearRenderTarget(ITextureView* pView) { if (pView == nullptr) { @@ -1219,8 +1219,8 @@ inline bool DeviceContextBase::ClearRenderT return true; } -template -inline bool DeviceContextBase::BeginQuery(IQuery* pQuery, int) +template +inline bool DeviceContextBase::BeginQuery(IQuery* pQuery, int) { if (pQuery == nullptr) { @@ -1248,8 +1248,8 @@ inline bool DeviceContextBase::BeginQuery(I return true; } -template -inline bool DeviceContextBase::EndQuery(IQuery* pQuery, int) +template +inline bool DeviceContextBase::EndQuery(IQuery* pQuery, int) { if (pQuery == nullptr) { @@ -1271,8 +1271,8 @@ inline bool DeviceContextBase::EndQuery(IQu return true; } -template -inline void DeviceContextBase::UpdateBuffer( +template +inline void DeviceContextBase::UpdateBuffer( IBuffer* pBuffer, Uint32 Offset, Uint32 Size, @@ -1291,8 +1291,8 @@ inline void DeviceContextBase::UpdateBuffer #endif } -template -inline void DeviceContextBase::CopyBuffer( +template +inline void DeviceContextBase::CopyBuffer( IBuffer* pSrcBuffer, Uint32 SrcOffset, RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, @@ -1314,8 +1314,8 @@ inline void DeviceContextBase::CopyBuffer( #endif } -template -inline void DeviceContextBase::MapBuffer( +template +inline void DeviceContextBase::MapBuffer( IBuffer* pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, @@ -1372,8 +1372,8 @@ inline void DeviceContextBase::MapBuffer( } } -template -inline void DeviceContextBase::UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType) +template +inline void DeviceContextBase::UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType) { VERIFY(pBuffer, "pBuffer must not be null"); #ifdef DILIGENT_DEBUG @@ -1387,8 +1387,8 @@ inline void DeviceContextBase::UnmapBuffer( } -template -inline void DeviceContextBase::UpdateTexture( +template +inline void DeviceContextBase::UpdateTexture( ITexture* pTexture, Uint32 MipLevel, Uint32 Slice, @@ -1403,8 +1403,8 @@ inline void DeviceContextBase::UpdateTextur ValidateUpdateTextureParams(pTexture->GetDesc(), MipLevel, Slice, DstBox, SubresData); } -template -inline void DeviceContextBase::CopyTexture(const CopyTextureAttribs& CopyAttribs) +template +inline void DeviceContextBase::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::CopyTexture( ValidateCopyTextureParams(CopyAttribs); } -template -inline void DeviceContextBase::MapTextureSubresource( +template +inline void DeviceContextBase::MapTextureSubresource( ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice, @@ -1427,8 +1427,8 @@ inline void DeviceContextBase::MapTextureSu ValidateMapTextureParams(pTexture->GetDesc(), MipLevel, ArraySlice, MapType, MapFlags, pMapRegion); } -template -inline void DeviceContextBase::UnmapTextureSubresource( +template +inline void DeviceContextBase::UnmapTextureSubresource( ITexture* pTexture, Uint32 MipLevel, Uint32 ArraySlice) @@ -1438,8 +1438,8 @@ inline void DeviceContextBase::UnmapTexture DEV_CHECK_ERR(ArraySlice < pTexture->GetDesc().ArraySize, "Array slice is out of range"); } -template -inline void DeviceContextBase::GenerateMips(ITextureView* pTexView) +template +inline void DeviceContextBase::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::GenerateMips } -template -void DeviceContextBase::ResolveTextureSubresource( +template +void DeviceContextBase::ResolveTextureSubresource( ITexture* pSrcTexture, ITexture* pDstTexture, const ResolveTextureSubresourceAttribs& ResolveAttribs) @@ -1473,8 +1473,8 @@ void DeviceContextBase::ResolveTextureSubre } -template -bool DeviceContextBase::BuildBLAS(const BuildBLASAttribs& Attribs, int) const +template +bool DeviceContextBase::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::BuildBLAS(const Bui return true; } -template -bool DeviceContextBase::BuildTLAS(const BuildTLASAttribs& Attribs, int) const +template +bool DeviceContextBase::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::BuildTLAS(const Bui return true; } -template -bool DeviceContextBase::CopyBLAS(const CopyBLASAttribs& Attribs, int) const +template +bool DeviceContextBase::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::CopyBLAS(const Copy return true; } -template -bool DeviceContextBase::CopyTLAS(const CopyTLASAttribs& Attribs, int) const +template +bool DeviceContextBase::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::CopyTLAS(const Copy return true; } -template -bool DeviceContextBase::WriteBLASCompactedSize(const WriteBLASCompactedSizeAttribs& Attribs, int) const +template +bool DeviceContextBase::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::WriteBLASCompactedS return true; } -template -bool DeviceContextBase::WriteTLASCompactedSize(const WriteTLASCompactedSizeAttribs& Attribs, int) const +template +bool DeviceContextBase::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::WriteTLASCompactedS return true; } -template -bool DeviceContextBase::TraceRays(const TraceRaysAttribs& Attribs, int) const +template +bool DeviceContextBase::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::TraceRays(const Tra #ifdef DILIGENT_DEVELOPMENT -template -inline bool DeviceContextBase::DvpVerifyDrawArguments(const DrawAttribs& Attribs) const +template +inline bool DeviceContextBase::DvpVerifyDrawArguments(const DrawAttribs& Attribs) const { if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0) return true; @@ -1691,8 +1691,8 @@ inline bool DeviceContextBase::DvpVerifyDra return VerifyDrawAttribs(Attribs); } -template -inline bool DeviceContextBase::DvpVerifyDrawIndexedArguments(const DrawIndexedAttribs& Attribs) const +template +inline bool DeviceContextBase::DvpVerifyDrawIndexedArguments(const DrawIndexedAttribs& Attribs) const { if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0) return true; @@ -1719,8 +1719,8 @@ inline bool DeviceContextBase::DvpVerifyDra return VerifyDrawIndexedAttribs(Attribs); } -template -inline bool DeviceContextBase::DvpVerifyDrawMeshArguments(const DrawMeshAttribs& Attribs) const +template +inline bool DeviceContextBase::DvpVerifyDrawMeshArguments(const DrawMeshAttribs& Attribs) const { if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0) return true; @@ -1747,8 +1747,8 @@ inline bool DeviceContextBase::DvpVerifyDra return VerifyDrawMeshAttribs(m_pDevice->GetProperties().MaxDrawMeshTasksCount, Attribs); } -template -inline bool DeviceContextBase::DvpVerifyDrawIndirectArguments( +template +inline bool DeviceContextBase::DvpVerifyDrawIndirectArguments( const DrawIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const { @@ -1779,8 +1779,8 @@ inline bool DeviceContextBase::DvpVerifyDra return VerifyDrawIndirectAttribs(Attribs, pAttribsBuffer); } -template -inline bool DeviceContextBase::DvpVerifyDrawIndexedIndirectArguments( +template +inline bool DeviceContextBase::DvpVerifyDrawIndexedIndirectArguments( const DrawIndexedIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const { @@ -1816,8 +1816,8 @@ inline bool DeviceContextBase::DvpVerifyDra return VerifyDrawIndexedIndirectAttribs(Attribs, pAttribsBuffer); } -template -inline bool DeviceContextBase::DvpVerifyDrawMeshIndirectArguments( +template +inline bool DeviceContextBase::DvpVerifyDrawMeshIndirectArguments( const DrawMeshIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const { @@ -1846,8 +1846,8 @@ inline bool DeviceContextBase::DvpVerifyDra return VerifyDrawMeshIndirectAttribs(Attribs, pAttribsBuffer); } -template -inline bool DeviceContextBase::DvpVerifyRenderTargets() const +template +inline bool DeviceContextBase::DvpVerifyRenderTargets() const { if (!m_pPipelineState) { @@ -1907,8 +1907,8 @@ inline bool DeviceContextBase::DvpVerifyRen -template -inline bool DeviceContextBase::DvpVerifyDispatchArguments(const DispatchComputeAttribs& Attribs) const +template +inline bool DeviceContextBase::DvpVerifyDispatchArguments(const DispatchComputeAttribs& Attribs) const { if (!m_pPipelineState) { @@ -1932,8 +1932,8 @@ inline bool DeviceContextBase::DvpVerifyDis return VerifyDispatchComputeAttribs(Attribs); } -template -inline bool DeviceContextBase::DvpVerifyDispatchIndirectArguments( +template +inline bool DeviceContextBase::DvpVerifyDispatchIndirectArguments( const DispatchComputeIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const { @@ -1960,14 +1960,14 @@ inline bool DeviceContextBase::DvpVerifyDis } -template -bool DeviceContextBase::DvpVerifyStateTransitionDesc(const StateTransitionDesc& Barrier) const +template +bool DeviceContextBase::DvpVerifyStateTransitionDesc(const StateTransitionDesc& Barrier) const { return VerifyStateTransitionDesc(m_pDevice, Barrier); } -template -bool DeviceContextBase::DvpVerifyTextureState( +template +bool DeviceContextBase::DvpVerifyTextureState( const TextureImplType& Texture, RESOURCE_STATE RequiredState, const char* OperationName) const @@ -1983,8 +1983,8 @@ bool DeviceContextBase::DvpVerifyTextureSta return true; } -template -bool DeviceContextBase::DvpVerifyBufferState( +template +bool DeviceContextBase::DvpVerifyBufferState( const BufferImplType& Buffer, RESOURCE_STATE RequiredState, const char* OperationName) const @@ -2000,8 +2000,8 @@ bool DeviceContextBase::DvpVerifyBufferStat return true; } -template -bool DeviceContextBase::DvpVerifyBLASState( +template +bool DeviceContextBase::DvpVerifyBLASState( const BottomLevelASType& BLAS, RESOURCE_STATE RequiredState, const char* OperationName) const @@ -2017,8 +2017,8 @@ bool DeviceContextBase::DvpVerifyBLASState( return true; } -template -bool DeviceContextBase::DvpVerifyTLASState( +template +bool DeviceContextBase::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 FenceBase : public DeviceObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class FenceBase : public DeviceObjectBase { 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 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 FramebufferBase : public DeviceObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class FramebufferBase : public DeviceObjectBase { 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; /// \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 PipelineResourceSignatureBase : public DeviceObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class PipelineResourceSignatureBase : public DeviceObjectBase { 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; /// \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 PipelineStateBase : public DeviceObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class PipelineStateBase : public DeviceObjectBase { 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; /// \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 QueryBase : public DeviceObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class QueryBase : public DeviceObjectBase { 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 -class RenderDeviceBase : public ObjectBase +template +class RenderDeviceBase : public ObjectBase { public: - using BaseInterface = typename RenderDeviceImplTraits::BaseInterface; + using BaseInterface = typename EngineImplTraits::RenderDeviceInterface; using TObjectBase = ObjectBase; - 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(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 RenderPassBase : public DeviceObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class RenderPassBase : public DeviceObjectBase { 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; /// \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 SamplerBase : public DeviceObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class SamplerBase : public DeviceObjectBase { 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; /// \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 ShaderBase : public DeviceObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class ShaderBase : public DeviceObjectBase { 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; /// \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 ShaderBindingTableBase : public DeviceObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class ShaderBindingTableBase : public DeviceObjectBase { 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; /// \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 ShaderResourceBindingBase : public ObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class ShaderResourceBindingBase : public ObjectBase { public: - typedef ObjectBase 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; /// \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 TextureBase : public DeviceObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class TextureBase : public DeviceObjectBase { public: - using TDeviceObjectBase = DeviceObjectBase; + // 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; /// \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(TexViewObjAllocator)}, - m_pDefaultRTV{nullptr, STDDeleter(TexViewObjAllocator)}, - m_pDefaultDSV{nullptr, STDDeleter(TexViewObjAllocator)}, - m_pDefaultUAV{nullptr, STDDeleter(TexViewObjAllocator)} + m_pDefaultSRV{nullptr, STDDeleter(TexViewObjAllocator)}, + m_pDefaultRTV{nullptr, STDDeleter(TexViewObjAllocator)}, + m_pDefaultDSV{nullptr, STDDeleter(TexViewObjAllocator)}, + m_pDefaultUAV{nullptr, STDDeleter(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(pView); + return static_cast(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> m_pDefaultSRV; + std::unique_ptr> m_pDefaultSRV; /// Default RTV addressing the most detailed mip level - std::unique_ptr> m_pDefaultRTV; + std::unique_ptr> m_pDefaultRTV; /// Default DSV addressing the most detailed mip level - std::unique_ptr> m_pDefaultDSV; + std::unique_ptr> m_pDefaultDSV; /// Default UAV addressing the entire texture - std::unique_ptr> m_pDefaultUAV; + std::unique_ptr> 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 TextureViewBase : public DeviceObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class TextureViewBase : public DeviceObjectBase { 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; 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 TopLevelASBase : public DeviceObjectBase +/// \tparam EngineImplTraits - Engine implementation type traits. +template +class TopLevelASBase : public DeviceObjectBase { 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 pBLAS; + Uint32 ContributionToHitGroupIndex = 0; + Uint32 InstanceIndex = 0; + RefCntAutoPtr 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(Inst.pBLAS); + Desc.pBLAS = ValidatedCast(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(Inst.pBLAS); + Desc.pBLAS = ValidatedCast(Inst.pBLAS); Desc.ContributionToHitGroupIndex = Inst.ContributionToHitGroupIndex; //Desc.InstanceIndex = i; // keep Desc.InstanceIndex unmodified CalculateHitGroupIndex(Desc, InstanceOffset, HitGroupStride, BindingMode); -- cgit v1.2.3