summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D11
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/GraphicsEngineD3D11
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/GraphicsEngineD3D11')
-rw-r--r--Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.hpp4
-rw-r--r--Graphics/GraphicsEngineD3D11/include/ShaderResourceBindingD3D11Impl.hpp10
-rw-r--r--Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp16
-rw-r--r--Graphics/GraphicsEngineD3D11/src/ShaderResourceBindingD3D11Impl.cpp27
4 files changed, 40 insertions, 17 deletions
diff --git a/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.hpp
index 6040dc31..02f922a6 100644
--- a/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.hpp
+++ b/Graphics/GraphicsEngineD3D11/include/PipelineStateD3D11Impl.hpp
@@ -142,7 +142,9 @@ private:
// SRB memory allocator must be defined before the default shader res binding
SRBMemoryAllocator m_SRBMemAllocator;
- std::array<Int8, MAX_SHADERS_IN_PIPELINE> m_ResourceLayoutIndex;
+ // Resource layout index in m_pStaticResourceLayouts 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};
std::array<Uint16, MAX_SHADERS_IN_PIPELINE + 1> m_StaticSamplerOffsets = {};
struct StaticSamplerInfo
diff --git a/Graphics/GraphicsEngineD3D11/include/ShaderResourceBindingD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/ShaderResourceBindingD3D11Impl.hpp
index de92785b..eb97dfdc 100644
--- a/Graphics/GraphicsEngineD3D11/include/ShaderResourceBindingD3D11Impl.hpp
+++ b/Graphics/GraphicsEngineD3D11/include/ShaderResourceBindingD3D11Impl.hpp
@@ -90,7 +90,7 @@ public:
Uint32 GetNumActiveShaders() const
{
- return static_cast<Uint32>(m_NumActiveShaders);
+ return Uint32{m_NumActiveShaders};
}
SHADER_TYPE GetActiveShaderType(Uint32 s) const
@@ -106,9 +106,11 @@ private:
std::array<SHADER_TYPE, MAX_SHADERS_IN_PIPELINE> m_ShaderTypes = {};
- // Resource layout index in m_ResourceLayouts[] array for every shader stage
- std::array<Int8, MAX_SHADERS_IN_PIPELINE> m_ResourceLayoutIndex;
- Uint8 m_NumActiveShaders = 0;
+ // Resource layout index in m_pResourceLayouts 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};
+
+ Uint8 m_NumActiveShaders = 0;
bool m_bIsStaticResourcesBound = false;
};
diff --git a/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp
index f4b7268b..39a6ca4a 100644
--- a/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/PipelineStateD3D11Impl.cpp
@@ -156,8 +156,10 @@ PipelineStateD3D11Impl::PipelineStateD3D11Impl(IReferenceCounters* pR
std::array<size_t, MAX_SHADERS_IN_PIPELINE> ShaderResCacheDataSizes = {};
for (Uint32 s = 0; s < m_NumShaders; ++s)
{
- auto* pShader = GetShader<const ShaderD3D11Impl>(s);
+ const auto* pShader = GetShader<const ShaderD3D11Impl>(s);
+ const auto& ShaderDesc = pShader->GetDesc();
const auto& ShaderResources = *pShader->GetD3D11Resources();
+ VERIFY_EXPR(ShaderDesc.ShaderType == ShaderResources.GetShaderType());
new (m_pStaticResourceCaches + s) ShaderResourceCacheD3D11;
// Do not initialize the cache as this will be performed by the resource layout
@@ -197,12 +199,16 @@ PipelineStateD3D11Impl::PipelineStateD3D11Impl(IReferenceCounters* pR
if (m_Desc.SRBAllocationGranularity > 1)
{
- const SHADER_RESOURCE_VARIABLE_TYPE SRBVarTypes[] = {SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE, SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC};
- ShaderResLayoutDataSizes[s] = ShaderResourceLayoutD3D11::GetRequiredMemorySize(ShaderResources, ResourceLayout, SRBVarTypes, _countof(SRBVarTypes));
- ShaderResCacheDataSizes[s] = ShaderResourceCacheD3D11::GetRequriedMemorySize(ShaderResources);
+ const SHADER_RESOURCE_VARIABLE_TYPE SRBVarTypes[] = //
+ {
+ SHADER_RESOURCE_VARIABLE_TYPE_MUTABLE,
+ SHADER_RESOURCE_VARIABLE_TYPE_DYNAMIC //
+ };
+ ShaderResLayoutDataSizes[s] = ShaderResourceLayoutD3D11::GetRequiredMemorySize(ShaderResources, ResourceLayout, SRBVarTypes, _countof(SRBVarTypes));
+ ShaderResCacheDataSizes[s] = ShaderResourceCacheD3D11::GetRequriedMemorySize(ShaderResources);
}
- auto ShaderInd = GetShaderTypePipelineIndex(pShader->GetDesc().ShaderType, m_Desc.PipelineType);
+ auto ShaderInd = GetShaderTypePipelineIndex(ShaderDesc.ShaderType, m_Desc.PipelineType);
m_ResourceLayoutIndex[ShaderInd] = static_cast<Int8>(s);
}
diff --git a/Graphics/GraphicsEngineD3D11/src/ShaderResourceBindingD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/ShaderResourceBindingD3D11Impl.cpp
index 521e3504..62fd2df7 100644
--- a/Graphics/GraphicsEngineD3D11/src/ShaderResourceBindingD3D11Impl.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/ShaderResourceBindingD3D11Impl.cpp
@@ -92,11 +92,12 @@ ShaderResourceBindingD3D11Impl::ShaderResourceBindingD3D11Impl(IReferenceCounter
};
// clang-format on
- const auto ShaderType = pShaderD3D11->GetDesc().ShaderType;
- const auto ResLayoutInd = GetShaderTypePipelineIndex(ShaderType, PSODesc.PipelineType);
- m_ShaderTypes[s] = ShaderType;
+ const auto ShaderType = pShaderD3D11->GetDesc().ShaderType;
+ const auto ShaderInd = GetShaderTypePipelineIndex(ShaderType, PSODesc.PipelineType);
+ VERIFY_EXPR(ShaderType == m_pResourceLayouts[s].GetShaderType());
+ m_ShaderTypes[s] = ShaderType;
- m_ResourceLayoutIndex[ResLayoutInd] = s;
+ m_ResourceLayoutIndex[ShaderInd] = s;
}
}
@@ -186,19 +187,31 @@ void ShaderResourceBindingD3D11Impl::InitializeStaticResources(const IPipelineSt
IShaderResourceVariable* ShaderResourceBindingD3D11Impl::GetVariableByName(SHADER_TYPE ShaderType, const char* Name)
{
auto ResLayoutInd = GetVariableByNameHelper(ShaderType, Name, m_ResourceLayoutIndex);
- return ResLayoutInd >= 0 ? m_pResourceLayouts[ResLayoutInd].GetShaderVariable(Name) : nullptr;
+ if (ResLayoutInd < 0)
+ return nullptr;
+
+ VERIFY_EXPR(static_cast<Uint32>(ResLayoutInd) < Uint32{m_NumActiveShaders});
+ return m_pResourceLayouts[ResLayoutInd].GetShaderVariable(Name);
}
Uint32 ShaderResourceBindingD3D11Impl::GetVariableCount(SHADER_TYPE ShaderType) const
{
auto ResLayoutInd = GetVariableCountHelper(ShaderType, m_ResourceLayoutIndex);
- return ResLayoutInd >= 0 ? m_pResourceLayouts[ResLayoutInd].GetTotalResourceCount() : 0;
+ if (ResLayoutInd < 0)
+ return 0;
+
+ VERIFY_EXPR(static_cast<Uint32>(ResLayoutInd) < Uint32{m_NumActiveShaders});
+ return m_pResourceLayouts[ResLayoutInd].GetTotalResourceCount();
}
IShaderResourceVariable* ShaderResourceBindingD3D11Impl::GetVariableByIndex(SHADER_TYPE ShaderType, Uint32 Index)
{
auto ResLayoutInd = GetVariableByIndexHelper(ShaderType, Index, m_ResourceLayoutIndex);
- return ResLayoutInd >= 0 ? m_pResourceLayouts[ResLayoutInd].GetShaderVariable(Index) : nullptr;
+ if (ResLayoutInd < 0)
+ return nullptr;
+
+ VERIFY_EXPR(static_cast<Uint32>(ResLayoutInd) < Uint32{m_NumActiveShaders});
+ return m_pResourceLayouts[ResLayoutInd].GetShaderVariable(Index);
}
} // namespace Diligent