summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-10-27 05:18:31 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-10-27 05:18:31 +0000
commit7c3ab28bb6757078cee5d8716ad2093723e27964 (patch)
tree2be6e9546ddcaf7ba236b235a18dce2d3f2d5234 /Graphics/GraphicsEngineVulkan
parentUpdated glslang + improved glslang messages for HLSL (diff)
downloadDiligentCore-7c3ab28bb6757078cee5d8716ad2093723e27964.tar.gz
DiligentCore-7c3ab28bb6757078cee5d8716ad2093723e27964.zip
Moved all HLSL definitions to premable when using glslang; not exposing separate samplers in VK backend when HLSL-style combined image samplers are used
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderVariableVk.cpp22
1 files changed, 20 insertions, 2 deletions
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<SHADER_VARIABLE_TYPE>(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;
}