From a615dcf84ce573e784e56a50bc8c2809f69c7ea7 Mon Sep 17 00:00:00 2001 From: assiduous Date: Tue, 9 Mar 2021 16:37:37 -0800 Subject: Moved ProcessSignatureResources method to PipelineResourceSignatureBase --- .../include/PipelineResourceSignatureBase.hpp | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp index db5cb061..c2f3e2bc 100644 --- a/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp +++ b/Graphics/GraphicsEngine/include/PipelineResourceSignatureBase.hpp @@ -376,6 +376,35 @@ public: return m_SRBMemAllocator; } + // Processes resources with the allowed variable types in the allowed shader stages + // and calls user-provided handler for each resource. + template + void ProcessResources(const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, + Uint32 NumAllowedTypes, + SHADER_TYPE AllowedStages, + HandlerType Handler) const + { + if (AllowedVarTypes == nullptr) + NumAllowedTypes = 1; + + for (Uint32 TypeIdx = 0; TypeIdx < NumAllowedTypes; ++TypeIdx) + { + const auto IdxRange = AllowedVarTypes != nullptr ? + GetResourceIndexRange(AllowedVarTypes[TypeIdx]) : + std::make_pair(0, GetTotalResourceCount()); + for (Uint32 ResIdx = IdxRange.first; ResIdx < IdxRange.second; ++ResIdx) + { + const auto& ResDesc = GetResourceDesc(ResIdx); + VERIFY_EXPR(AllowedVarTypes == nullptr || ResDesc.VarType == AllowedVarTypes[TypeIdx]); + + if ((ResDesc.ShaderStages & AllowedStages) != 0) + { + Handler(ResDesc, ResIdx); + } + } + } + } + protected: template FixedLinearAllocator AllocateInternalObjects(IMemoryAllocator& RawAllocator, -- cgit v1.2.3