From 6e54a0840da780c3b208bc72294aa33eecc64738 Mon Sep 17 00:00:00 2001 From: assiduous Date: Wed, 10 Mar 2021 20:58:49 -0800 Subject: Moved duplicate shader variable functionality to ShaderVariableBase --- .../include/ShaderVariableManagerVk.hpp | 44 +++------------------- .../src/ShaderVariableManagerVk.cpp | 13 +------ 2 files changed, 6 insertions(+), 51 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') 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; + using ResourceAttribs = PipelineResourceAttribsVk; Uint32 GetVariableIndex(const ShaderVariableVkImpl& Variable); @@ -146,15 +148,14 @@ private: }; // sizeof(ShaderVariableVkImpl) == 24 (x64) -class ShaderVariableVkImpl final : public ShaderVariableBase +class ShaderVariableVkImpl final : public ShaderVariableBase { public: - using TBase = ShaderVariableBase; + using TBase = ShaderVariableBase; 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(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 { -- cgit v1.2.3