From 7c3ab28bb6757078cee5d8716ad2093723e27964 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Fri, 26 Oct 2018 22:18:31 -0700 Subject: Moved all HLSL definitions to premable when using glslang; not exposing separate samplers in VK backend when HLSL-style combined image samplers are used --- .../GraphicsEngineVulkan/src/ShaderVariableVk.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderVariableVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderVariableVk.cpp index 0751cd50..289fad3e 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderVariableVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderVariableVk.cpp @@ -37,7 +37,22 @@ size_t ShaderVariableManagerVk::GetRequiredMemorySize(const ShaderResourceLayout Uint32 AllowedTypeBits = GetAllowedTypeBits(AllowedVarTypes, NumAllowedTypes); for(SHADER_VARIABLE_TYPE VarType = SHADER_VARIABLE_TYPE_STATIC; VarType < SHADER_VARIABLE_TYPE_NUM_TYPES; VarType = static_cast(VarType+1)) { - NumVariables += IsAllowedType(VarType, AllowedTypeBits) ? Layout.GetResourceCount(VarType) : 0; + if (IsAllowedType(VarType, AllowedTypeBits)) + { + auto NumResources = Layout.GetResourceCount(VarType); + if (Layout.IsUsingSeparateSamplers()) + NumVariables += NumResources; + else + { + // When using HLSL-style combined image samplers, we need to skip separate samplers + for( Uint32 r=0; r < NumResources; ++r ) + { + const auto& SrcRes = Layout.GetResource(VarType, r); + if (SrcRes.SpirvAttribs.Type != SPIRVShaderResourceAttribs::ResourceType::SeparateSampler) + ++NumVariables; + } + } + } } return NumVariables*sizeof(ShaderVariableVkImpl); @@ -75,7 +90,10 @@ void ShaderVariableManagerVk::Initialize(const ShaderResourceLayoutVk& SrcLayout Uint32 NumResources = SrcLayout.GetResourceCount(VarType); for( Uint32 r=0; r < NumResources; ++r ) { - const auto &SrcRes = SrcLayout.GetResource(VarType, r); + const auto& SrcRes = SrcLayout.GetResource(VarType, r); + if (!SrcLayout.IsUsingSeparateSamplers() && SrcRes.SpirvAttribs.Type == SPIRVShaderResourceAttribs::ResourceType::SeparateSampler) + continue; + ::new (m_pVariables + VarInd) ShaderVariableVkImpl(*this, SrcRes ); ++VarInd; } -- cgit v1.2.3