summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h2
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h5
-rw-r--r--Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp31
3 files changed, 30 insertions, 8 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h
index 062a5340..9377ef39 100644
--- a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.h
@@ -123,7 +123,7 @@ private:
AdaptiveFixedBlockAllocator *m_pAllocators[5] = {};
}m_ResLayoutDataAllocators; // Allocators must be defined before default SRB
- ShaderResourceLayoutVk* m_pShaderResourceLayouts[6] = {};
+ std::array<ShaderResourceLayoutVk*, 6> m_pShaderResourceLayouts = {};
AdaptiveFixedBlockAllocator m_ResourceCacheDataAllocator; // Use separate allocator for every shader stage
std::array<VulkanUtilities::ShaderModuleWrapper, 6> m_ShaderModules;
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h
index 7b79d268..fb968b43 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceLayoutVk.h
@@ -273,6 +273,11 @@ public:
IObject& GetOwner(){return m_Owner;}
+ Uint32 GetResourceCount(SHADER_VARIABLE_TYPE VarType)const
+ {
+ return m_NumResources[VarType];
+ }
+
private:
void InitVariablesHashMap();
diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
index 71db4fe1..8e3a5219 100644
--- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
@@ -372,9 +372,26 @@ PipelineStateVkImpl :: PipelineStateVkImpl(IReferenceCounters *pRefCounters, Ren
if(PipelineDesc.SRBAllocationGranularity > 1)
m_ResLayoutDataAllocators.Init(m_NumShaders, PipelineDesc.SRBAllocationGranularity);
- auto &SRBAllocator = pDeviceVk->GetSRBAllocator();
- // Default shader resource binding must be initialized after resource layouts are parsed!
- m_pDefaultShaderResBinding.reset( NEW_RC_OBJ(SRBAllocator, "ShaderResourceBindingVkImpl instance", ShaderResourceBindingVkImpl, this)(this, true) );
+ bool HasStaticResources = false;
+ bool HasNonStaticResources = false;
+ for (auto *pLayout : m_pShaderResourceLayouts)
+ {
+ if (pLayout != nullptr)
+ {
+ HasStaticResources = pLayout->GetResourceCount(SHADER_VARIABLE_TYPE_STATIC) != 0;
+ HasNonStaticResources = pLayout->GetResourceCount(SHADER_VARIABLE_TYPE_MUTABLE) != 0 ||
+ pLayout->GetResourceCount(SHADER_VARIABLE_TYPE_DYNAMIC) != 0;
+ }
+ }
+
+ // If there are only static resources, create default shader resource binding
+ if(HasStaticResources && !HasNonStaticResources)
+ {
+ auto &SRBAllocator = pDeviceVk->GetSRBAllocator();
+ // Default shader resource binding must be initialized after resource layouts are parsed!
+ m_pDefaultShaderResBinding.reset( NEW_RC_OBJ(SRBAllocator, "ShaderResourceBindingVkImpl instance", ShaderResourceBindingVkImpl, this)(this, true) );
+ }
+
#if 0
m_ShaderResourceLayoutHash = m_RootSig.GetHash();
#endif
@@ -397,12 +414,12 @@ PipelineStateVkImpl::~PipelineStateVkImpl()
}
auto &ShaderResLayoutAllocator = GetRawAllocator();
- for(Int32 l = 0; l < _countof(m_pShaderResourceLayouts); ++l)
+ for (auto *pLayout : m_pShaderResourceLayouts)
{
- if (m_pShaderResourceLayouts[l] != nullptr)
+ if (pLayout != nullptr)
{
- m_pShaderResourceLayouts[l]->~ShaderResourceLayoutVk();
- ShaderResLayoutAllocator.Free(m_pShaderResourceLayouts[l]);
+ pLayout->~ShaderResourceLayoutVk();
+ ShaderResLayoutAllocator.Free(pLayout);
}
}
}