From abb6f8c12bdb7639ee4a200fa1243b1e6fb96dac Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 19 Feb 2021 16:08:39 -0800 Subject: Unified static resource methods in PipelineResourceSignatureVkImpl and PipelineResourceSignatureD3D12Impl --- .../include/ShaderVariableD3D12.hpp | 4 +-- .../src/PipelineResourceSignatureD3D12Impl.cpp | 36 +++------------------- .../src/ShaderVariableD3D12.cpp | 4 +-- 3 files changed, 8 insertions(+), 36 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderVariableD3D12.hpp b/Graphics/GraphicsEngineD3D12/include/ShaderVariableD3D12.hpp index 3e6428af..9c0b3ad0 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderVariableD3D12.hpp +++ b/Graphics/GraphicsEngineD3D12/include/ShaderVariableD3D12.hpp @@ -99,8 +99,8 @@ public: void Destroy(IMemoryAllocator& Allocator); - ShaderVariableD3D12Impl* GetVariable(const Char* Name); - ShaderVariableD3D12Impl* GetVariable(Uint32 Index); + ShaderVariableD3D12Impl* GetVariable(const Char* Name) const; + ShaderVariableD3D12Impl* GetVariable(Uint32 Index) const; void BindResources(IResourceMapping* pResourceMapping, Uint32 Flags); diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp index 4eb6bc1e..e61dd9fd 100644 --- a/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp @@ -428,52 +428,24 @@ void PipelineResourceSignatureD3D12Impl::CreateShaderResourceBinding(IShaderReso Uint32 PipelineResourceSignatureD3D12Impl::GetStaticVariableCount(SHADER_TYPE ShaderType) const { - const auto VarMngrInd = GetStaticVariableCountHelper(ShaderType); - if (VarMngrInd < 0) - return 0; - - auto& StaticVarMgr = m_StaticVarsMgrs[VarMngrInd]; - return StaticVarMgr.GetVariableCount(); + return GetStaticVariableCountImpl(ShaderType, m_StaticVarsMgrs); } IShaderResourceVariable* PipelineResourceSignatureD3D12Impl::GetStaticVariableByName(SHADER_TYPE ShaderType, const Char* Name) { - const auto VarMngrInd = GetStaticVariableByNameHelper(ShaderType, Name); - if (VarMngrInd < 0) - return nullptr; - - auto& StaticVarMgr = m_StaticVarsMgrs[VarMngrInd]; - return StaticVarMgr.GetVariable(Name); + return GetStaticVariableByNameImpl(ShaderType, Name, m_StaticVarsMgrs); } IShaderResourceVariable* PipelineResourceSignatureD3D12Impl::GetStaticVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index) { - const auto VarMngrInd = GetStaticVariableByIndexHelper(ShaderType, Index); - if (VarMngrInd < 0) - return nullptr; - - auto& StaticVarMgr = m_StaticVarsMgrs[VarMngrInd]; - return StaticVarMgr.GetVariable(Index); + return GetStaticVariableByIndexImpl(ShaderType, Index, m_StaticVarsMgrs); } void PipelineResourceSignatureD3D12Impl::BindStaticResources(Uint32 ShaderFlags, IResourceMapping* pResMapping, Uint32 Flags) { - const auto PipelineType = GetPipelineType(); - for (Uint32 ShaderInd = 0; ShaderInd < m_StaticResStageIndex.size(); ++ShaderInd) - { - const auto VarMngrInd = m_StaticResStageIndex[ShaderInd]; - if (VarMngrInd >= 0) - { - // ShaderInd is the shader type pipeline index here - const auto ShaderType = GetShaderTypeFromPipelineIndex(ShaderInd, PipelineType); - if (ShaderFlags & ShaderType) - { - m_StaticVarsMgrs[VarMngrInd].BindResources(pResMapping, Flags); - } - } - } + BindStaticResourcesImpl(ShaderFlags, pResMapping, Flags, m_StaticVarsMgrs); } size_t PipelineResourceSignatureD3D12Impl::CalculateHash() const diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderVariableD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderVariableD3D12.cpp index fb71679d..08000a6e 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderVariableD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderVariableD3D12.cpp @@ -135,7 +135,7 @@ void ShaderVariableManagerD3D12::Destroy(IMemoryAllocator& Allocator) } } -ShaderVariableD3D12Impl* ShaderVariableManagerD3D12::GetVariable(const Char* Name) +ShaderVariableD3D12Impl* ShaderVariableManagerD3D12::GetVariable(const Char* Name) const { ShaderVariableD3D12Impl* pVar = nullptr; for (Uint32 v = 0; v < m_NumVariables; ++v) @@ -152,7 +152,7 @@ ShaderVariableD3D12Impl* ShaderVariableManagerD3D12::GetVariable(const Char* Nam } -ShaderVariableD3D12Impl* ShaderVariableManagerD3D12::GetVariable(Uint32 Index) +ShaderVariableD3D12Impl* ShaderVariableManagerD3D12::GetVariable(Uint32 Index) const { if (Index >= m_NumVariables) { -- cgit v1.2.3