From ea25e99aaca4dd9c4a442d9ce39a5365aaf72bc1 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Thu, 28 Feb 2019 00:29:49 -0800 Subject: Fixed some issues in Vk backend --- Graphics/GraphicsEngine/include/PipelineStateBase.h | 3 ++- .../include/ShaderResourceLayoutVk.h | 2 +- .../GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp | 18 +++++++++--------- .../src/ShaderResourceLayoutVk.cpp | 7 ++++--- 4 files changed, 16 insertions(+), 14 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.h b/Graphics/GraphicsEngine/include/PipelineStateBase.h index 3dde7b85..fbc492e3 100644 --- a/Graphics/GraphicsEngine/include/PipelineStateBase.h +++ b/Graphics/GraphicsEngine/include/PipelineStateBase.h @@ -79,7 +79,7 @@ public: for (Uint32 i=0; i < SrcLayout.NumStaticSamplers; ++i) StringPoolSize += strlen(SrcLayout.StaticSamplers[i].SamplerOrTextureName) + 1; } - m_StringPool.Allocate(StringPoolSize); + m_StringPool.Reserve(StringPoolSize, GetRawAllocator()); auto& DstLayout = this->m_Desc.Layout; if (SrcLayout.Variables != nullptr) @@ -164,6 +164,7 @@ public: if (GraphicsPipeline.pHS) m_ppShaders[m_NumShaders++] = GraphicsPipeline.pHS; if (GraphicsPipeline.pDS) m_ppShaders[m_NumShaders++] = GraphicsPipeline.pDS; } + VERIFY(m_NumShaders > 0, "There must be at least one shader in the Pipeline State"); const auto& InputLayout = PSODesc.GraphicsPipeline.InputLayout; for (size_t Elem = 0; Elem < InputLayout.NumElements; ++Elem) diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h index b4712d70..c3dd9146 100644 --- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h +++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h @@ -142,7 +142,7 @@ public: std::vector SPIRVs[], class PipelineLayout& PipelineLayout); - // sizeof(VkResource) == 24 (x64) - TODO: Verify + // sizeof(VkResource) == 24 (x64) struct VkResource { VkResource (const VkResource&) = delete; diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp index 14f4c962..443076df 100644 --- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp @@ -625,31 +625,31 @@ void PipelineStateVkImpl::BindStaticResources(IResourceMapping* pResourceMapping Uint32 PipelineStateVkImpl::GetStaticVariableCount(SHADER_TYPE ShaderType) const { - const auto ShaderTypeInd = GetShaderTypeIndex(ShaderType); - if (ShaderTypeInd < 0) + const auto LayoutInd = m_ResourceLayoutIndex[GetShaderTypeIndex(ShaderType)]; + if (LayoutInd < 0) return 0; - auto& StaticVarMgr = GetStaticVarMgr(ShaderTypeInd); + auto& StaticVarMgr = GetStaticVarMgr(LayoutInd); return StaticVarMgr.GetVariableCount(); } IShaderResourceVariable* PipelineStateVkImpl::GetStaticShaderVariable(SHADER_TYPE ShaderType, const Char* Name) { - const auto ShaderTypeInd = GetShaderTypeIndex(ShaderType); - if (ShaderTypeInd < 0) + const auto LayoutInd = m_ResourceLayoutIndex[GetShaderTypeIndex(ShaderType)]; + if (LayoutInd < 0) return nullptr; - auto& StaticVarMgr = GetStaticVarMgr(ShaderTypeInd); + auto& StaticVarMgr = GetStaticVarMgr(LayoutInd); return StaticVarMgr.GetVariable(Name); } IShaderResourceVariable* PipelineStateVkImpl::GetStaticShaderVariable(SHADER_TYPE ShaderType, Uint32 Index) { - const auto ShaderTypeInd = GetShaderTypeIndex(ShaderType); - if (ShaderTypeInd < 0) + const auto LayoutInd = m_ResourceLayoutIndex[GetShaderTypeIndex(ShaderType)]; + if (LayoutInd < 0) return nullptr; - auto& StaticVarMgr = GetStaticVarMgr(ShaderTypeInd); + auto& StaticVarMgr = GetStaticVarMgr(LayoutInd); return StaticVarMgr.GetVariable(Index); } diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp index a0835334..201fadc6 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceLayoutVk.cpp @@ -154,7 +154,8 @@ void ShaderResourceLayoutVk::AllocateMemory(std::shared_ptrGetShaderType(); - const auto* CombinedSamplerSuffix = pSrcResources->GetCombinedSamplerSuffix(); + const auto ShaderType = m_pResources->GetShaderType(); + const auto* CombinedSamplerSuffix = m_pResources->GetCombinedSamplerSuffix(); m_pResources->ProcessResources( [&](const SPIRVShaderResourceAttribs& Attribs, Uint32) -- cgit v1.2.3