diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2021-03-08 04:06:24 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2021-03-19 00:38:17 +0000 |
| commit | 228f25373ba2f1678ddcccba101c43a4612e1919 (patch) | |
| tree | 0ddaaa757b527c25cc42610de5570f8a5eca6ccc /Graphics/GraphicsEngine | |
| parent | Vk backend: reorganized headers; removed PRS methods implemented in PipelineR... (diff) | |
| download | DiligentCore-228f25373ba2f1678ddcccba101c43a4612e1919.tar.gz DiligentCore-228f25373ba2f1678ddcccba101c43a4612e1919.zip | |
Unified implementation of InitializeStaticSRBResources in D3D12, Vk and GL backends
Diffstat (limited to 'Graphics/GraphicsEngine')
| -rw-r--r-- | Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp index 72423b51..ce849246 100644 --- a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp +++ b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp @@ -242,6 +242,31 @@ public: pResBindingImpl->QueryInterface(IID_ShaderResourceBinding, reinterpret_cast<IObject**>(ppShaderResourceBinding)); } + /// Implementation of IPipelineResourceSignature::InitializeStaticSRBResources. + virtual void DILIGENT_CALL_TYPE InitializeStaticSRBResources(IShaderResourceBinding* pSRB) const override final + { + DEV_CHECK_ERR(pSRB != nullptr, "SRB must not be null"); + + auto* const pSRBImpl = ValidatedCast<ShaderResourceBindingImplType>(pSRB); + if (pSRBImpl->StaticResourcesInitialized()) + { + LOG_WARNING_MESSAGE("Static resources have already been initialized in this shader resource binding object."); + return; + } + + const auto* const pThisImpl = static_cast<const PipelineResourceSignatureImplType*>(this); +#ifdef DILIGENT_DEVELOPMENT + { + const auto* pSRBSignature = pSRBImpl->GetPipelineResourceSignature(); + DEV_CHECK_ERR(pSRBSignature->IsCompatibleWith(pThisImpl), "Shader resource binding is not compatible with resource signature '", pThisImpl->m_Desc.Name, "'."); + } +#endif + + auto& ResourceCache = pSRBImpl->GetResourceCache(); + pThisImpl->CopyStaticResources(ResourceCache); + + pSRBImpl->SetStaticResourcesInitialized(); + } size_t GetHash() const { return m_Hash; } @@ -488,29 +513,6 @@ protected: #endif } - template <typename SRBImplType, typename InitResourcesHandler> - void InitializeStaticSRBResourcesImpl(SRBImplType* pSRB, InitResourcesHandler Handler) const - { - DEV_CHECK_ERR(pSRB != nullptr, "SRB must not be null"); - if (pSRB->StaticResourcesInitialized()) - { - LOG_WARNING_MESSAGE("Static resources have already been initialized in this shader resource binding object."); - return; - } - - const auto* const pSRBSignature = pSRB->GetPipelineResourceSignature(); -#ifdef DILIGENT_DEVELOPMENT - if (!pSRBSignature->IsCompatibleWith(this)) - { - LOG_ERROR_MESSAGE("Shader resource binding is not compatible with resource signature '", this->m_Desc.Name, "'."); - } -#endif - - Handler(pSRB); - - pSRB->SetStaticResourcesInitialized(); - } - // Finds a sampler that is assigned to texture Tex, when combined texture samplers are used. // Returns an index of the sampler in m_Desc.Resources array, or InvalidSamplerValue if there is // no such sampler, or if combined samplers are not used. |
