diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2021-03-11 04:58:49 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2021-03-19 00:38:20 +0000 |
| commit | 6e54a0840da780c3b208bc72294aa33eecc64738 (patch) | |
| tree | 2b3cd3d88cf89a3fb7e16a73692c25af15f2273a /Graphics/GraphicsEngineVulkan | |
| parent | Vk backend: moved resource binding logic to variable manager and cache (diff) | |
| download | DiligentCore-6e54a0840da780c3b208bc72294aa33eecc64738.tar.gz DiligentCore-6e54a0840da780c3b208bc72294aa33eecc64738.zip | |
Moved duplicate shader variable functionality to ShaderVariableBase
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
| -rw-r--r-- | Graphics/GraphicsEngineVulkan/include/ShaderVariableManagerVk.hpp | 44 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineVulkan/src/ShaderVariableManagerVk.cpp | 13 |
2 files changed, 6 insertions, 51 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderVariableManagerVk.hpp b/Graphics/GraphicsEngineVulkan/include/ShaderVariableManagerVk.hpp index 06db6075..3869e64d 100644 --- a/Graphics/GraphicsEngineVulkan/include/ShaderVariableManagerVk.hpp +++ b/Graphics/GraphicsEngineVulkan/include/ShaderVariableManagerVk.hpp @@ -115,6 +115,8 @@ public: private: friend ShaderVariableVkImpl; + friend ShaderVariableBase<ShaderVariableVkImpl, ShaderVariableManagerVk, IShaderResourceVariable>; + using ResourceAttribs = PipelineResourceAttribsVk; Uint32 GetVariableIndex(const ShaderVariableVkImpl& Variable); @@ -146,15 +148,14 @@ private: }; // sizeof(ShaderVariableVkImpl) == 24 (x64) -class ShaderVariableVkImpl final : public ShaderVariableBase<ShaderVariableManagerVk, IShaderResourceVariable> +class ShaderVariableVkImpl final : public ShaderVariableBase<ShaderVariableVkImpl, ShaderVariableManagerVk, IShaderResourceVariable> { public: - using TBase = ShaderVariableBase<ShaderVariableManagerVk, IShaderResourceVariable>; + using TBase = ShaderVariableBase<ShaderVariableVkImpl, ShaderVariableManagerVk, IShaderResourceVariable>; ShaderVariableVkImpl(ShaderVariableManagerVk& ParentManager, Uint32 ResIndex) : - TBase{ParentManager}, - m_ResIndex{ResIndex} + TBase{ParentManager, ResIndex} {} // clang-format off @@ -164,43 +165,11 @@ public: ShaderVariableVkImpl& operator= (ShaderVariableVkImpl&&) = delete; // clang-format on - virtual SHADER_RESOURCE_VARIABLE_TYPE DILIGENT_CALL_TYPE GetType() const override final - { - return GetDesc().VarType; - } - - virtual void DILIGENT_CALL_TYPE Set(IDeviceObject* pObject) override final - { - BindResource(pObject, 0); - } - - virtual void DILIGENT_CALL_TYPE SetArray(IDeviceObject* const* ppObjects, - Uint32 FirstElement, - Uint32 NumElements) override final; - - virtual void DILIGENT_CALL_TYPE GetResourceDesc(ShaderResourceDesc& ResourceDesc) const override final - { - const auto& Desc = GetDesc(); - ResourceDesc.Name = Desc.Name; - ResourceDesc.Type = Desc.ResourceType; - ResourceDesc.ArraySize = Desc.ArraySize; - } - - virtual Uint32 DILIGENT_CALL_TYPE GetIndex() const override final - { - return m_ParentManager.GetVariableIndex(*this); - } - virtual bool DILIGENT_CALL_TYPE IsBound(Uint32 ArrayIndex) const override final { return m_ParentManager.IsBound(ArrayIndex, m_ResIndex); } - const PipelineResourceDesc& GetDesc() const - { - return m_ParentManager.GetResourceDesc(m_ResIndex); - } - void BindResource(IDeviceObject* pObj, Uint32 ArrayIndex) const { return m_ParentManager.BindResource(pObj, ArrayIndex, m_ResIndex); @@ -210,9 +179,6 @@ private: using ResourceAttribs = PipelineResourceAttribsVk; const ResourceAttribs& GetAttribs() const { return m_ParentManager.GetAttribs(m_ResIndex); } - -private: - const Uint32 m_ResIndex; // Index in Signatures' m_Desc.Resources }; } // namespace Diligent diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderVariableManagerVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderVariableManagerVk.cpp index a159b8b9..5f4bd8d6 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderVariableManagerVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderVariableManagerVk.cpp @@ -198,21 +198,10 @@ void ShaderVariableManagerVk::BindResources(IResourceMapping* pResourceMapping, for (Uint32 v = 0; v < m_NumVariables; ++v) { - m_pVariables[v].BindResources<ShaderVariableVkImpl>(pResourceMapping, Flags); + m_pVariables[v].BindResources(pResourceMapping, Flags); } } -void ShaderVariableVkImpl::SetArray(IDeviceObject* const* ppObjects, - Uint32 FirstElement, - Uint32 NumElements) -{ - const auto& ResDesc = GetDesc(); - VerifyAndCorrectSetArrayArguments(ResDesc.Name, ResDesc.ArraySize, FirstElement, NumElements); - - for (Uint32 Elem = 0; Elem < NumElements; ++Elem) - BindResource(ppObjects[Elem], FirstElement + Elem); -} - namespace { |
