From 1236220647276ad81692becafa32ee9d374d269e Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 8 Mar 2021 00:13:00 -0800 Subject: ShaderResourceBinding{D3D12, Vk, GL} - removed the remaining duplicate code --- .../include/ShaderResourceBindingBase.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp b/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp index 64c31e9d..3dc62905 100644 --- a/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp +++ b/Graphics/GraphicsEngine/include/ShaderResourceBindingBase.hpp @@ -31,6 +31,7 @@ /// Implementation of the Diligent::ShaderResourceBindingBase template class #include +#include #include "PrivateConstants.h" #include "ShaderResourceBinding.h" @@ -103,6 +104,25 @@ public: // It is important to construct all objects before initializing them because if an exception is thrown, // destructors will be called for all objects + + pPRS->InitSRBResourceCache(m_ShaderResourceCache); + + auto& SRBMemAllocator = pPRS->GetSRBMemoryAllocator(); + for (Uint32 s = 0; s < NumShaders; ++s) + { + const auto ShaderType = pPRS->GetActiveShaderStageType(s); + const auto ShaderInd = GetShaderTypePipelineIndex(ShaderType, pPRS->GetPipelineType()); + const auto MgrInd = m_ActiveShaderStageIndex[ShaderInd]; + VERIFY_EXPR(MgrInd >= 0 && MgrInd < static_cast(NumShaders)); + + auto& VarDataAllocator = SRBMemAllocator.GetShaderVariableDataAllocator(s); + + // Create shader variable manager in place + // Initialize vars manager to reference mutable and dynamic variables + // Note that the cache has space for all variable types + const SHADER_RESOURCE_VARIABLE_TYPE VarTypes[] = {SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE, SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}; + m_pShaderVarMgrs[MgrInd].Initialize(*pPRS, VarDataAllocator, VarTypes, _countof(VarTypes), ShaderType); + } } ~ShaderResourceBindingBase() -- cgit v1.2.3