summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-09-18 23:07:26 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-09-18 23:07:26 +0000
commit28521eb517f26af909a56222cb586a07b8245d80 (patch)
tree41d6fe074db7f8869f285ec767cdda66a54d7cbd /Graphics/GraphicsEngineVulkan
parentUpdated ShaderResourceBindingBase: using PSO implementation type for the poin... (diff)
downloadDiligentCore-28521eb517f26af909a56222cb586a07b8245d80.tar.gz
DiligentCore-28521eb517f26af909a56222cb586a07b8245d80.zip
Few minor (mostly cosmetic) updates to SRB and PSO implementations
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.hpp6
-rw-r--r--Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp5
-rw-r--r--Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp8
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp24
4 files changed, 30 insertions, 13 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.hpp
index 43ae0456..d1732211 100644
--- a/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/PipelineStateVkImpl.hpp
@@ -150,12 +150,14 @@ private:
// SRB memory allocator must be declared before m_pDefaultShaderResBinding
SRBMemoryAllocator m_SRBMemAllocator;
- std::array<VulkanUtilities::ShaderModuleWrapper, MAX_SHADERS_IN_PIPELINE> m_ShaderModules;
+ std::array<VulkanUtilities::ShaderModuleWrapper, MAX_SHADERS_IN_PIPELINE> m_ShaderModules = {};
VulkanUtilities::PipelineWrapper m_Pipeline;
PipelineLayout m_PipelineLayout;
- std::array<Int8, MAX_SHADERS_IN_PIPELINE> m_ResourceLayoutIndex = {};
+ // Resource layout index in m_ShaderResourceLayouts array for every shader stage,
+ // indexed by the shader type pipeline index (returned by GetShaderTypePipelineIndex)
+ std::array<Int8, MAX_SHADERS_IN_PIPELINE> m_ResourceLayoutIndex = {-1, -1, -1, -1, -1};
bool m_HasStaticResources = false;
bool m_HasNonStaticResources = false;
diff --git a/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp
index 55c65757..026bb9da 100644
--- a/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp
+++ b/Graphics/GraphicsEngineVulkan/include/ShaderResourceBindingVkImpl.hpp
@@ -79,8 +79,9 @@ private:
ShaderResourceCacheVk m_ShaderResourceCache;
ShaderVariableManagerVk* m_pShaderVarMgrs = nullptr;
- // Shader variable manager index in m_pShaderVarMgrs[] array for every shader stage
- std::array<Int8, MAX_SHADERS_IN_PIPELINE> m_ResourceLayoutIndex;
+ // Resource layout index in m_ShaderResourceCache array for every shader stage,
+ // indexed by the shader type pipeline index (returned by GetShaderTypePipelineIndex)
+ std::array<Int8, MAX_SHADERS_IN_PIPELINE> m_ResourceLayoutIndex = {-1, -1, -1, -1, -1};
bool m_bStaticResourcesInitialized = false;
Uint8 m_NumShaders = 0;
diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
index 0f824d41..5c165e32 100644
--- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp
@@ -171,7 +171,7 @@ PipelineStateVkImpl::PipelineStateVkImpl(IReferenceCounters* pRefCoun
for (Uint32 s = 0; s < m_NumShaders; ++s)
{
- new (m_ShaderResourceLayouts + s) ShaderResourceLayoutVk(LogicalDevice);
+ new (m_ShaderResourceLayouts + s) ShaderResourceLayoutVk{LogicalDevice};
auto* pShaderVk = GetShader<const ShaderVkImpl>(s);
ShaderResources[s] = pShaderVk->GetShaderResources();
ShaderSPIRVs[s] = pShaderVk->GetSPIRV();
@@ -180,11 +180,11 @@ PipelineStateVkImpl::PipelineStateVkImpl(IReferenceCounters* pRefCoun
const auto ShaderTypeInd = GetShaderTypePipelineIndex(ShaderType, m_Desc.PipelineType);
m_ResourceLayoutIndex[ShaderTypeInd] = static_cast<Int8>(s);
- auto* pStaticResLayout = new (m_ShaderResourceLayouts + m_NumShaders + s) ShaderResourceLayoutVk(LogicalDevice);
- auto* pStaticResCache = new (m_StaticResCaches + s) ShaderResourceCacheVk(ShaderResourceCacheVk::DbgCacheContentType::StaticShaderResources);
+ auto* pStaticResLayout = new (m_ShaderResourceLayouts + m_NumShaders + s) ShaderResourceLayoutVk{LogicalDevice};
+ auto* pStaticResCache = new (m_StaticResCaches + s) ShaderResourceCacheVk{ShaderResourceCacheVk::DbgCacheContentType::StaticShaderResources};
pStaticResLayout->InitializeStaticResourceLayout(ShaderResources[s], ShaderResLayoutAllocator, m_Desc.ResourceLayout, m_StaticResCaches[s]);
- new (m_StaticVarsMgrs + s) ShaderVariableManagerVk(*this, *pStaticResLayout, GetRawAllocator(), nullptr, 0, *pStaticResCache);
+ new (m_StaticVarsMgrs + s) ShaderVariableManagerVk{*this, *pStaticResLayout, GetRawAllocator(), nullptr, 0, *pStaticResCache};
}
ShaderResourceLayoutVk::Initialize(pDeviceVk, m_NumShaders, m_ShaderResourceLayouts, ShaderResources.data(), GetRawAllocator(),
m_Desc.ResourceLayout, ShaderSPIRVs.data(), m_PipelineLayout,
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp
index efbdc006..6e6c142f 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceBindingVkImpl.cpp
@@ -78,7 +78,7 @@ ShaderResourceBindingVkImpl::ShaderResourceBindingVkImpl(IReferenceCounters* pR
// Initialize vars manager to reference mutable and dynamic variables
// Note that the cache has space for all variable types
const SHADER_RESOURCE_VARIABLE_TYPE VarTypes[] = {SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE, SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC};
- new (m_pShaderVarMgrs + s) ShaderVariableManagerVk(*this, SrcLayout, VarDataAllocator, VarTypes, _countof(VarTypes), m_ShaderResourceCache);
+ new (m_pShaderVarMgrs + s) ShaderVariableManagerVk{*this, SrcLayout, VarDataAllocator, VarTypes, _countof(VarTypes), m_ShaderResourceCache};
}
#ifdef DILIGENT_DEBUG
m_ShaderResourceCache.DbgVerifyResourceInitialization();
@@ -108,7 +108,9 @@ void ShaderResourceBindingVkImpl::BindResources(Uint32 ShaderFlags, IResourceMap
auto ResLayoutInd = m_ResourceLayoutIndex[ShaderInd];
if (ResLayoutInd >= 0)
{
- if (ShaderFlags & GetShaderTypeFromPipelineIndex(ShaderInd, PipelineType))
+ // ShaderInd is the shader type pipeline index here
+ const auto ShaderType = GetShaderTypeFromPipelineIndex(ShaderInd, PipelineType);
+ if (ShaderFlags & ShaderType)
{
m_pShaderVarMgrs[ResLayoutInd].BindResources(pResMapping, Flags);
}
@@ -119,19 +121,31 @@ void ShaderResourceBindingVkImpl::BindResources(Uint32 ShaderFlags, IResourceMap
IShaderResourceVariable* ShaderResourceBindingVkImpl::GetVariableByName(SHADER_TYPE ShaderType, const char* Name)
{
auto ResLayoutInd = GetVariableByNameHelper(ShaderType, Name, m_ResourceLayoutIndex);
- return ResLayoutInd >= 0 ? m_pShaderVarMgrs[ResLayoutInd].GetVariable(Name) : nullptr;
+ if (ResLayoutInd < 0)
+ return nullptr;
+
+ VERIFY_EXPR(static_cast<Uint32>(ResLayoutInd) < Uint32{m_NumShaders});
+ return m_pShaderVarMgrs[ResLayoutInd].GetVariable(Name);
}
Uint32 ShaderResourceBindingVkImpl::GetVariableCount(SHADER_TYPE ShaderType) const
{
auto ResLayoutInd = GetVariableCountHelper(ShaderType, m_ResourceLayoutIndex);
- return ResLayoutInd >= 0 ? m_pShaderVarMgrs[ResLayoutInd].GetVariableCount() : 0;
+ if (ResLayoutInd < 0)
+ return 0;
+
+ VERIFY_EXPR(static_cast<Uint32>(ResLayoutInd) < Uint32{m_NumShaders});
+ return m_pShaderVarMgrs[ResLayoutInd].GetVariableCount();
}
IShaderResourceVariable* ShaderResourceBindingVkImpl::GetVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index)
{
auto ResLayoutInd = GetVariableByIndexHelper(ShaderType, Index, m_ResourceLayoutIndex);
- return ResLayoutInd >= 0 ? m_pShaderVarMgrs[ResLayoutInd].GetVariable(Index) : 0;
+ if (ResLayoutInd < 0)
+ return nullptr;
+
+ VERIFY_EXPR(static_cast<Uint32>(ResLayoutInd) < Uint32{m_NumShaders});
+ return m_pShaderVarMgrs[ResLayoutInd].GetVariable(Index);
}
void ShaderResourceBindingVkImpl::InitializeStaticResources(const IPipelineState* pPipelineState)