diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-02-27 17:05:39 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-02-27 17:05:39 +0000 |
| commit | db55aa475fb2c13118e29c4ece91b99d20ab798a (patch) | |
| tree | a2b1e599999cc23e3206d35194e0905bf7386f63 /Graphics/GraphicsEngineVulkan | |
| parent | Updated ShaderResourceLayoutVk (diff) | |
| download | DiligentCore-db55aa475fb2c13118e29c4ece91b99d20ab798a.tar.gz DiligentCore-db55aa475fb2c13118e29c4ece91b99d20ab798a.zip | |
Updated ShaderVariableVk and ShaderResourceBindingVk
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
4 files changed, 25 insertions, 24 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.h b/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.h index 451ddcb8..b3933747 100644 --- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.h @@ -52,11 +52,11 @@ public: virtual void BindResources(Uint32 ShaderFlags, IResourceMapping* pResMapping, Uint32 Flags)override final; - virtual IShaderVariable* GetVariable(SHADER_TYPE ShaderType, const char* Name)override final; + virtual IShaderResourceVariable* GetVariable(SHADER_TYPE ShaderType, const char* Name)override final; virtual Uint32 GetVariableCount(SHADER_TYPE ShaderType) const override final; - virtual IShaderVariable* GetVariable(SHADER_TYPE ShaderType, Uint32 Index)override final; + virtual IShaderResourceVariable* GetVariable(SHADER_TYPE ShaderType, Uint32 Index)override final; virtual void InitializeStaticResources(const IPipelineState* pPipelineState)override final; diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.h b/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.h index 92af69a3..5f7a0628 100644 --- a/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.h +++ b/Graphics/GraphicsEngineVulkan/include/ShaderVariableVk.h @@ -73,11 +73,11 @@ public: {} ~ShaderVariableManagerVk(); - void Initialize(const ShaderResourceLayoutVk& Layout, - IMemoryAllocator& Allocator, - const SHADER_VARIABLE_TYPE* AllowedVarTypes, - Uint32 NumAllowedTypes, - ShaderResourceCacheVk& ResourceCache); + void Initialize(const ShaderResourceLayoutVk& Layout, + IMemoryAllocator& Allocator, + const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, + Uint32 NumAllowedTypes, + ShaderResourceCacheVk& ResourceCache); void Destroy(IMemoryAllocator& Allocator); ShaderVariableVkImpl* GetVariable(const Char* Name); @@ -85,10 +85,10 @@ public: void BindResources( IResourceMapping* pResourceMapping, Uint32 Flags); - static size_t GetRequiredMemorySize(const ShaderResourceLayoutVk& Layout, - const SHADER_VARIABLE_TYPE* AllowedVarTypes, - Uint32 NumAllowedTypes, - Uint32& NumVariables); + static size_t GetRequiredMemorySize(const ShaderResourceLayoutVk& Layout, + const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, + Uint32 NumAllowedTypes, + Uint32& NumVariables); Uint32 GetVariableCount()const { return m_NumVariables; } @@ -117,7 +117,7 @@ private: }; // sizeof(ShaderVariableVkImpl) == 24 (x64) -class ShaderVariableVkImpl final : public IShaderVariable +class ShaderVariableVkImpl final : public IShaderResourceVariable { public: ShaderVariableVkImpl(ShaderVariableManagerVk& ParentManager, @@ -153,16 +153,16 @@ public: return; *ppInterface = nullptr; - if (IID == IID_ShaderVariable || IID == IID_Unknown) + if (IID == IID_ShaderResourceVariable || IID == IID_Unknown) { *ppInterface = this; (*ppInterface)->AddRef(); } } - virtual SHADER_VARIABLE_TYPE GetType()const override final + virtual SHADER_RESOURCE_VARIABLE_TYPE GetType()const override final { - return m_Resource.SpirvAttribs.VarType; + return m_Resource.GetVariableType(); } virtual void Set(IDeviceObject *pObject)override final diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp index 02a98d11..342f5ae6 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp @@ -64,7 +64,7 @@ ShaderResourceBindingVkImpl::ShaderResourceBindingVkImpl( IReferenceCounters* pR // Initialize vars manager to reference mutable and dynamic variables // Note that the cache has space for all variable types - std::array<SHADER_VARIABLE_TYPE, 2> VarTypes = {{SHADER_VARIABLE_TYPE_MUTABLE, SHADER_VARIABLE_TYPE_DYNAMIC}}; + std::array<SHADER_RESOURCE_VARIABLE_TYPE, 2> VarTypes = {{SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE, SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC}}; m_pShaderVarMgrs[s].Initialize(SrcLayout, VarDataAllocator, VarTypes.data(), static_cast<Uint32>(VarTypes.size()), m_ShaderResourceCache); m_ResourceLayoutIndex[ShaderInd] = static_cast<Int8>(s); @@ -101,7 +101,7 @@ void ShaderResourceBindingVkImpl::BindResources(Uint32 ShaderFlags, IResourceMap } } -IShaderVariable* ShaderResourceBindingVkImpl::GetVariable(SHADER_TYPE ShaderType, const char *Name) +IShaderResourceVariable* ShaderResourceBindingVkImpl::GetVariable(SHADER_TYPE ShaderType, const char *Name) { auto ShaderInd = GetShaderTypeIndex(ShaderType); auto ResLayoutInd = m_ResourceLayoutIndex[ShaderInd]; @@ -125,7 +125,7 @@ Uint32 ShaderResourceBindingVkImpl::GetVariableCount(SHADER_TYPE ShaderType) con return m_pShaderVarMgrs[ResLayoutInd].GetVariableCount(); } -IShaderVariable* ShaderResourceBindingVkImpl::GetVariable(SHADER_TYPE ShaderType, Uint32 Index) +IShaderResourceVariable* ShaderResourceBindingVkImpl::GetVariable(SHADER_TYPE ShaderType, Uint32 Index) { auto ShaderInd = GetShaderTypeIndex(ShaderType); auto ResLayoutInd = m_ResourceLayoutIndex[ShaderInd]; diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderVariableVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderVariableVk.cpp index 485ca318..22acaf5c 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderVariableVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderVariableVk.cpp @@ -24,18 +24,19 @@ #include "pch.h" #include "ShaderVariableVk.h" +#include "ShaderResourceVariableBase.h" namespace Diligent { size_t ShaderVariableManagerVk::GetRequiredMemorySize(const ShaderResourceLayoutVk& Layout, - const SHADER_VARIABLE_TYPE* AllowedVarTypes, + const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, Uint32 NumAllowedTypes, Uint32& NumVariables) { NumVariables = 0; Uint32 AllowedTypeBits = GetAllowedTypeBits(AllowedVarTypes, NumAllowedTypes); - for(SHADER_VARIABLE_TYPE VarType = SHADER_VARIABLE_TYPE_STATIC; VarType < SHADER_VARIABLE_TYPE_NUM_TYPES; VarType = static_cast<SHADER_VARIABLE_TYPE>(VarType+1)) + for(SHADER_RESOURCE_VARIABLE_TYPE VarType = SHADER_RESOURCE_VARIABLE_TYPE_STATIC; VarType < SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES; VarType = static_cast<SHADER_RESOURCE_VARIABLE_TYPE>(VarType+1)) { if (IsAllowedType(VarType, AllowedTypeBits)) { @@ -61,7 +62,7 @@ size_t ShaderVariableManagerVk::GetRequiredMemorySize(const ShaderResourceLayout // Creates shader variable for every resource from SrcLayout whose type is one AllowedVarTypes void ShaderVariableManagerVk::Initialize(const ShaderResourceLayoutVk& SrcLayout, IMemoryAllocator& Allocator, - const SHADER_VARIABLE_TYPE* AllowedVarTypes, + const SHADER_RESOURCE_VARIABLE_TYPE* AllowedVarTypes, Uint32 NumAllowedTypes, ShaderResourceCacheVk& ResourceCache) { @@ -82,7 +83,7 @@ void ShaderVariableManagerVk::Initialize(const ShaderResourceLayoutVk& SrcLayout m_pVariables = reinterpret_cast<ShaderVariableVkImpl*>(pRawMem); Uint32 VarInd = 0; - for(SHADER_VARIABLE_TYPE VarType = SHADER_VARIABLE_TYPE_STATIC; VarType < SHADER_VARIABLE_TYPE_NUM_TYPES; VarType = static_cast<SHADER_VARIABLE_TYPE>(VarType+1)) + for(SHADER_RESOURCE_VARIABLE_TYPE VarType = SHADER_RESOURCE_VARIABLE_TYPE_STATIC; VarType < SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES; VarType = static_cast<SHADER_RESOURCE_VARIABLE_TYPE>(VarType+1)) { if (!IsAllowedType(VarType, AllowedTypeBits)) continue; @@ -186,10 +187,10 @@ void ShaderVariableManagerVk::BindResources( IResourceMapping* pResourceMapping, const auto& Res = Var.m_Resource; // Skip immutable separate samplers - if (Res.SpirvAttribs.Type == SPIRVShaderResourceAttribs::ResourceType::SeparateSampler && Res.SpirvAttribs.IsImmutableSamplerAssigned()) + if (Res.SpirvAttribs.Type == SPIRVShaderResourceAttribs::ResourceType::SeparateSampler && Res.IsImmutableSamplerAssigned()) continue; - if ( (Flags & (1 << Res.SpirvAttribs.VarType)) == 0 ) + if ( (Flags & (1 << Res.GetVariableType())) == 0 ) continue; for (Uint32 ArrInd = 0; ArrInd < Res.SpirvAttribs.ArraySize; ++ArrInd) |
