From ef1e1c02e4f44b3a37c6bb683090b4f661aadcdc Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 18 Mar 2021 15:05:18 -0700 Subject: Removed duplicate code from unbinding incompatible signatures logic in D3D11, GL and Vk --- .../GraphicsEngine/include/DeviceContextBase.hpp | 55 +++++++++++++++++----- 1 file changed, 43 insertions(+), 12 deletions(-) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp index 769f8f01..1e791845 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp @@ -105,18 +105,19 @@ template class DeviceContextBase : public ObjectBase { public: - using BaseInterface = typename EngineImplTraits::DeviceContextInterface; - using TObjectBase = ObjectBase; - 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; + using BaseInterface = typename EngineImplTraits::DeviceContextInterface; + using TObjectBase = ObjectBase; + using DeviceImplType = typename EngineImplTraits::RenderDeviceImplType; + using BufferImplType = typename EngineImplTraits::BufferImplType; + using TextureImplType = typename EngineImplTraits::TextureImplType; + using PipelineStateImplType = typename EngineImplTraits::PipelineStateImplType; + using ShaderResourceBindingImplType = typename EngineImplTraits::ShaderResourceBindingImplType; + 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. @@ -311,6 +312,8 @@ protected: bool DvpVerifyBufferState (const BufferImplType& Buffer, RESOURCE_STATE RequiredState, const char* OperationName) const; bool DvpVerifyBLASState (const BottomLevelASType& BLAS, RESOURCE_STATE RequiredState, const char* OperationName) const; bool DvpVerifyTLASState (const TopLevelASType& TLAS, RESOURCE_STATE RequiredState, const char* OperationName) const; + + Uint32 DvpGetCompatibleSignatureCount(ShaderResourceBindingImplType* pBoundSRBs[])const; #else bool DvpVerifyDrawArguments (const DrawAttribs& Attribs)const {return true;} bool DvpVerifyDrawIndexedArguments (const DrawIndexedAttribs& Attribs)const {return true;} @@ -2121,6 +2124,34 @@ bool DeviceContextBase::DvpVerifyTLASState( return true; } +template +Uint32 DeviceContextBase::DvpGetCompatibleSignatureCount(ShaderResourceBindingImplType* pBoundSRBs[]) const +{ + VERIFY_EXPR(m_pPipelineState); + const auto SignCount = m_pPipelineState->GetResourceSignatureCount(); + + Uint32 sign = 0; + for (; sign < SignCount; ++sign) + { + const auto* pPSOSign = m_pPipelineState->GetResourceSignature(sign); + const auto* pSRBSign = pBoundSRBs[sign] != nullptr ? pBoundSRBs[sign]->GetSignature() : nullptr; + + if ((pPSOSign == nullptr || pPSOSign->IsEmpty()) != (pSRBSign == nullptr || pSRBSign->IsEmpty())) + { + // One signature is null or empty while the other is not - SRB is not compatible with the PSO. + break; + } + + if (pPSOSign != nullptr && pSRBSign != nullptr && pPSOSign->IsIncompatibleWith(*pSRBSign)) + { + // Signatures are incompatible + break; + } + } + + return sign; +} + #endif // DILIGENT_DEVELOPMENT } // namespace Diligent -- cgit v1.2.3