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/ShaderVariableManagerD3D12.hpp | 7 --- .../src/ShaderVariableManagerD3D12.cpp | 51 ++++++++-------------- 2 files changed, 18 insertions(+), 40 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderVariableManagerD3D12.hpp b/Graphics/GraphicsEngineD3D12/include/ShaderVariableManagerD3D12.hpp index a67b977c..7fc3c6dc 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderVariableManagerD3D12.hpp +++ b/Graphics/GraphicsEngineD3D12/include/ShaderVariableManagerD3D12.hpp @@ -120,13 +120,6 @@ private: const PipelineResourceDesc& GetResourceDesc(Uint32 Index) const; const ResourceAttribs& GetResourceAttribs(Uint32 Index) const; - template - static void ProcessSignatureResources(const PipelineResourceSignatureD3D12Impl& Signature, - const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, - Uint32 NumAllowedTypes, - SHADER_TYPE ShaderStages, - HandlerType Handler); - private: PipelineResourceSignatureD3D12Impl const* m_pSignature = nullptr; diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderVariableManagerD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderVariableManagerD3D12.cpp index 9078debb..b8e33cb0 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderVariableManagerD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderVariableManagerD3D12.cpp @@ -37,40 +37,25 @@ namespace Diligent { template -void ShaderVariableManagerD3D12::ProcessSignatureResources(const PipelineResourceSignatureD3D12Impl& Signature, - const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, - Uint32 NumAllowedTypes, - SHADER_TYPE ShaderStages, - HandlerType Handler) +void ProcessSignatureResources(const PipelineResourceSignatureD3D12Impl& Signature, + const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, + Uint32 NumAllowedTypes, + SHADER_TYPE ShaderStages, + HandlerType Handler) { - const Uint32 AllowedTypeBits = GetAllowedTypeBits(AllowedVarTypes, NumAllowedTypes); - const bool UsingCombinedSamplers = Signature.IsUsingCombinedSamplers(); - - for (SHADER_RESOURCE_VARIABLE_TYPE VarType = SHADER_RESOURCE_VARIABLE_TYPE_STATIC; VarType < SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES; VarType = static_cast(VarType + 1)) - { - if (IsAllowedType(VarType, AllowedTypeBits)) - { - const auto ResIdxRange = Signature.GetResourceIndexRange(VarType); - for (Uint32 r = ResIdxRange.first; r < ResIdxRange.second; ++r) - { - const auto& Res = Signature.GetResourceDesc(r); - const auto& Attr = Signature.GetResourceAttribs(r); - VERIFY_EXPR(Res.VarType == VarType); - - if (!(Res.ShaderStages & ShaderStages)) - continue; - - if (Res.ResourceType == SHADER_RESOURCE_TYPE_SAMPLER && - (UsingCombinedSamplers || Attr.IsImmutableSamplerAssigned())) - { - // Skip samplers combined with textures and immutable samplers - continue; - } - - Handler(r); - } - } - } + const bool UsingCombinedSamplers = Signature.IsUsingCombinedSamplers(); + Signature.ProcessResources(AllowedVarTypes, NumAllowedTypes, ShaderStages, + [&](const PipelineResourceDesc& ResDesc, Uint32 Index) // + { + const auto& ResAttr = Signature.GetResourceAttribs(Index); + + // Skip samplers combined with textures and immutable samplers + if (ResDesc.ResourceType == SHADER_RESOURCE_TYPE_SAMPLER && + (UsingCombinedSamplers || ResAttr.IsImmutableSamplerAssigned())) + return; + + Handler(Index); + }); } size_t ShaderVariableManagerD3D12::GetRequiredMemorySize(const PipelineResourceSignatureD3D12Impl& Signature, -- cgit v1.2.3