From f509aa98dc993ed9ca8d8b836181def35e2ef695 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Thu, 7 Jun 2018 00:02:56 -0700 Subject: Updated static shader resource cache to use one descriptor set instead of individual descriptor set for every resource type --- .../src/ShaderResourceLayoutVk.cpp | 45 +++++----------------- 1 file changed, 9 insertions(+), 36 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp index fe0c98b5..288270b0 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp @@ -124,7 +124,7 @@ void ShaderResourceLayoutVk::Initialize(const std::shared_ptr CurrResInd = {}; - std::array StaticResCacheSetSizes = {}; + Uint32 StaticResCacheSize = 0; auto AddResource = [&](const SPIRVShaderResourceAttribs &Attribs) { @@ -145,22 +145,13 @@ void ShaderResourceLayoutVk::Initialize(const std::shared_ptrInitializeSets(GetRawAllocator(), static_cast(StaticResCacheSetSizes.size()), StaticResCacheSetSizes.data()); + pStaticResourceCache->InitializeSets(GetRawAllocator(), 1, &StaticResCacheSize); InitializeResourceMemoryInCache(*pStaticResourceCache); -#ifdef _DEBUG - for(SPIRVShaderResourceAttribs::ResourceType ResType = SPIRVShaderResourceAttribs::ResourceType::UniformBuffer; - ResType < SPIRVShaderResourceAttribs::ResourceType::NumResourceTypes; - ResType = static_cast(ResType +1)) - { - VERIFY_EXPR(pStaticResourceCache->GetDescriptorSet(ResType).GetSize() == StaticResCacheSetSizes[ResType]); - } -#endif } } @@ -571,23 +554,13 @@ void ShaderResourceLayoutVk::InitializeStaticResources(const ShaderResourceLayou VERIFY(NumStaticResources == SrcLayout.m_NumResources[SHADER_VARIABLE_TYPE_STATIC], "Inconsistent number of static resources"); VERIFY(SrcLayout.m_pResources->GetShaderType() == m_pResources->GetShaderType(), "Incosistent shader types"); - // Static shader resources are stored as follows: - // Uniform buffers at index SPIRVShaderResourceAttribs::ResourceType::UniformBuffer (0) - // Storage buffers at index SPIRVShaderResourceAttribs::ResourceType::StorageBuffer (1) - // Unifrom txl buffs at index SPIRVShaderResourceAttribs::ResourceType::UniformTexelBuffer (2) - // Storage txl buffs at index SPIRVShaderResourceAttribs::ResourceType::StorageTexelBuffer (3) - // Storage images at index SPIRVShaderResourceAttribs::ResourceType::StorageImage (4) - // Sampled images at index SPIRVShaderResourceAttribs::ResourceType::SampledImage (5) - // Atomic counters at index SPIRVShaderResourceAttribs::ResourceType::AtomicCounter (6) - // Separate images at index SPIRVShaderResourceAttribs::ResourceType::SeparateImage (7) - // Separate samplers at index SPIRVShaderResourceAttribs::ResourceType::SeparateSampler (8) - + // Static shader resources are stored in one large continuous descriptor set for(Uint32 r=0; r < NumStaticResources; ++r) { // Get resource attributes auto &DstRes = GetResource(SHADER_VARIABLE_TYPE_STATIC, r); const auto &SrcRes = SrcLayout.GetResource(SHADER_VARIABLE_TYPE_STATIC, r); - VERIFY(SrcRes.Binding == r, "Unexpected binding"); + VERIFY(SrcRes.Binding == SrcRes.SpirvAttribs.Type, "Unexpected binding"); VERIFY(SrcRes.SpirvAttribs.ArraySize == DstRes.SpirvAttribs.ArraySize, "Inconsistent array size"); if(DstRes.SpirvAttribs.Type == SPIRVShaderResourceAttribs::ResourceType::SeparateSampler && -- cgit v1.2.3