summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
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/GraphicsEngineD3D12
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/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.hpp6
-rw-r--r--Graphics/GraphicsEngineD3D12/include/RootSignature.hpp4
-rw-r--r--Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.hpp6
-rw-r--r--Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp21
-rw-r--r--Graphics/GraphicsEngineD3D12/src/RootSignature.cpp6
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp22
6 files changed, 45 insertions, 20 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.hpp
index c248a7b1..a53a625d 100644
--- a/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.hpp
+++ b/Graphics/GraphicsEngineD3D12/include/PipelineStateD3D12Impl.hpp
@@ -128,8 +128,10 @@ private:
ShaderResourceLayoutD3D12* m_pShaderResourceLayouts = nullptr;
ShaderResourceCacheD3D12* m_pStaticResourceCaches = nullptr;
ShaderVariableManagerD3D12* m_pStaticVarManagers = nullptr;
- // Resource layout index in m_ResourceLayouts[] array for every shader stage
- std::array<Int8, MAX_SHADERS_IN_PIPELINE> m_ResourceLayoutIndex;
+
+ // Resource layout index in m_pShaderResourceLayouts 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};
};
} // namespace Diligent
diff --git a/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp b/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp
index 9a70e486..2bf6d0b3 100644
--- a/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp
+++ b/Graphics/GraphicsEngineD3D12/include/RootSignature.hpp
@@ -475,9 +475,9 @@ private:
// in m_RootParams (NOT the Root Index!), for every variable type
// (static, mutable, dynamic) and every shader type,
// or -1, if the table is not yet assigned to the combination
- std::array<Uint8, SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES * MAX_SHADERS_IN_PIPELINE> m_SrvCbvUavRootTablesMap;
+ std::array<Uint8, SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES* MAX_SHADERS_IN_PIPELINE> m_SrvCbvUavRootTablesMap = {};
// This array contains the same data for Sampler root table
- std::array<Uint8, SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES * MAX_SHADERS_IN_PIPELINE> m_SamplerRootTablesMap;
+ std::array<Uint8, SHADER_RESOURCE_VARIABLE_TYPE_NUM_TYPES* MAX_SHADERS_IN_PIPELINE> m_SamplerRootTablesMap = {};
RootParamsManager m_RootParams;
diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.hpp
index 5af1fb12..846cb329 100644
--- a/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.hpp
+++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourceBindingD3D12Impl.hpp
@@ -80,8 +80,10 @@ public:
private:
ShaderResourceCacheD3D12 m_ShaderResourceCache;
ShaderVariableManagerD3D12* m_pShaderVarMgrs = nullptr;
- // Resource layout index in m_ResourceLayouts[] 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;
const Uint8 m_NumShaders = 0;
diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
index bc23c7da..138b6b3d 100644
--- a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
@@ -618,22 +618,31 @@ void PipelineStateD3D12Impl::BindStaticResources(Uint32 ShaderFlags, IResourceMa
Uint32 PipelineStateD3D12Impl::GetStaticVariableCount(SHADER_TYPE ShaderType) const
{
const auto LayoutInd = GetStaticVariableCountHelper(ShaderType, m_ResourceLayoutIndex);
- VERIFY_EXPR(LayoutInd < 0 || static_cast<Uint32>(LayoutInd) <= m_NumShaders);
- return LayoutInd >= 0 ? m_pStaticVarManagers[LayoutInd].GetVariableCount() : 0;
+ if (LayoutInd < 0)
+ return 0;
+
+ VERIFY_EXPR(static_cast<Uint32>(LayoutInd) < m_NumShaders);
+ return m_pStaticVarManagers[LayoutInd].GetVariableCount();
}
IShaderResourceVariable* PipelineStateD3D12Impl::GetStaticVariableByName(SHADER_TYPE ShaderType, const Char* Name)
{
const auto LayoutInd = GetStaticVariableByNameHelper(ShaderType, Name, m_ResourceLayoutIndex);
- VERIFY_EXPR(LayoutInd < 0 || static_cast<Uint32>(LayoutInd) <= m_NumShaders);
- return LayoutInd >= 0 ? m_pStaticVarManagers[LayoutInd].GetVariable(Name) : nullptr;
+ if (LayoutInd < 0)
+ return nullptr;
+
+ VERIFY_EXPR(static_cast<Uint32>(LayoutInd) < m_NumShaders);
+ return m_pStaticVarManagers[LayoutInd].GetVariable(Name);
}
IShaderResourceVariable* PipelineStateD3D12Impl::GetStaticVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index)
{
const auto LayoutInd = GetStaticVariableByIndexHelper(ShaderType, Index, m_ResourceLayoutIndex);
- VERIFY_EXPR(LayoutInd < 0 || static_cast<Uint32>(LayoutInd) <= m_NumShaders);
- return LayoutInd >= 0 ? m_pStaticVarManagers[LayoutInd].GetVariable(Index) : nullptr;
+ if (LayoutInd < 0)
+ return nullptr;
+
+ VERIFY_EXPR(static_cast<Uint32>(LayoutInd) < m_NumShaders);
+ return m_pStaticVarManagers[LayoutInd].GetVariable(Index);
}
} // namespace Diligent
diff --git a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp
index 43fc21ac..bba639f8 100644
--- a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp
@@ -168,10 +168,8 @@ RootSignature::RootSignature() :
m_MemAllocator{GetRawAllocator()},
m_StaticSamplers(STD_ALLOCATOR_RAW_MEM(StaticSamplerAttribs, GetRawAllocator(), "Allocator for vector<StaticSamplerAttribs>"))
{
- for (size_t i = 0; i < m_SrvCbvUavRootTablesMap.size(); ++i)
- m_SrvCbvUavRootTablesMap[i] = InvalidRootTableIndex;
- for (size_t i = 0; i < m_SamplerRootTablesMap.size(); ++i)
- m_SamplerRootTablesMap[i] = InvalidRootTableIndex;
+ m_SrvCbvUavRootTablesMap.fill(InvalidRootTableIndex);
+ m_SamplerRootTablesMap.fill(InvalidRootTableIndex);
}
// clang-format off
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp
index 64bdb722..257a4688 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp
@@ -107,7 +107,9 @@ void ShaderResourceBindingD3D12Impl::BindResources(Uint32 ShaderFlags, IResource
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);
}
@@ -118,19 +120,31 @@ void ShaderResourceBindingD3D12Impl::BindResources(Uint32 ShaderFlags, IResource
IShaderResourceVariable* ShaderResourceBindingD3D12Impl::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 ShaderResourceBindingD3D12Impl::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* ShaderResourceBindingD3D12Impl::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);
}