diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2021-02-13 06:53:13 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2021-03-19 00:31:37 +0000 |
| commit | b355b0979f0feb8a37d2b4c72a6d48d7bfa20858 (patch) | |
| tree | 04b084cb0cb09e67d53a760cbc25dd303c019743 /Graphics/GraphicsEngineD3D12 | |
| parent | Refactored RootParamsManager: added RootParamsBuilder (diff) | |
| download | DiligentCore-b355b0979f0feb8a37d2b4c72a6d48d7bfa20858.tar.gz DiligentCore-b355b0979f0feb8a37d2b4c72a6d48d7bfa20858.zip | |
RootParamsBuilder: minor improvement to AllocateResourceSlot
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
3 files changed, 17 insertions, 7 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/RootParamsManager.hpp b/Graphics/GraphicsEngineD3D12/include/RootParamsManager.hpp index c6b24a95..f9d1b214 100644 --- a/Graphics/GraphicsEngineD3D12/include/RootParamsManager.hpp +++ b/Graphics/GraphicsEngineD3D12/include/RootParamsManager.hpp @@ -175,9 +175,9 @@ public: // Allocates root parameter slot for the given resource. void AllocateResourceSlot(SHADER_TYPE ShaderStages, SHADER_RESOURCE_VARIABLE_TYPE VariableType, + D3D12_ROOT_PARAMETER_TYPE RootParameterType, D3D12_DESCRIPTOR_RANGE_TYPE RangeType, Uint32 ArraySize, - bool IsRootView, Uint32 Register, Uint32 Space, Uint32& RootIndex, diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp index 19848b61..948398ae 100644 --- a/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp @@ -285,7 +285,10 @@ void PipelineResourceSignatureD3D12Impl::CreateLayout() } else { - ParamsBuilder.AllocateResourceSlot(ResDesc.ShaderStages, ResDesc.VarType, DescriptorRangeType, ResDesc.ArraySize, IsRootView, Register, FirstSpace + Space, SRBRootIndex, SRBOffsetFromTableStart); + ParamsBuilder.AllocateResourceSlot(ResDesc.ShaderStages, ResDesc.VarType, + IsRootView ? D3D12_ROOT_PARAMETER_TYPE_CBV : D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE, + DescriptorRangeType, ResDesc.ArraySize, Register, FirstSpace + Space, SRBRootIndex, + SRBOffsetFromTableStart); } new (m_pResourceAttribs + i) ResourceAttribs // diff --git a/Graphics/GraphicsEngineD3D12/src/RootParamsManager.cpp b/Graphics/GraphicsEngineD3D12/src/RootParamsManager.cpp index 0202d906..7cd54a41 100644 --- a/Graphics/GraphicsEngineD3D12/src/RootParamsManager.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RootParamsManager.cpp @@ -250,9 +250,9 @@ inline ROOT_PARAMETER_GROUP VariableTypeToRootParameterGroup(SHADER_RESOURCE_VAR void RootParamsBuilder::AllocateResourceSlot(SHADER_TYPE ShaderStages, SHADER_RESOURCE_VARIABLE_TYPE VariableType, + D3D12_ROOT_PARAMETER_TYPE RootParameterType, D3D12_DESCRIPTOR_RANGE_TYPE RangeType, Uint32 ArraySize, - bool IsRootView, Uint32 Register, Uint32 Space, Uint32& RootIndex, // Output parameter @@ -265,15 +265,19 @@ void RootParamsBuilder::AllocateResourceSlot(SHADER_TYPE Shade // Get the next available root index past all allocated tables and root views RootIndex = static_cast<Uint32>(m_RootTables.size() + m_RootViews.size()); - if (IsRootView) + if (RootParameterType == D3D12_ROOT_PARAMETER_TYPE_CBV || + RootParameterType == D3D12_ROOT_PARAMETER_TYPE_SRV || + RootParameterType == D3D12_ROOT_PARAMETER_TYPE_UAV) { + VERIFY(ArraySize == 1, "Only single descriptors can be added as root views"); + // Allocate single CBV directly in the root signature OffsetFromTableStart = 0; // Add new root view to existing root parameters - AddRootView(D3D12_ROOT_PARAMETER_TYPE_CBV, RootIndex, Register, Space, ShaderVisibility, ParameterGroup); // AZ TODO: add SRV & UAV + AddRootView(RootParameterType, RootIndex, Register, Space, ShaderVisibility, ParameterGroup); } - else + else if (RootParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE) { const bool IsSampler = (RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER); // Get the table array index (this is not the root index!) @@ -324,9 +328,12 @@ void RootParamsBuilder::AllocateResourceSlot(SHADER_TYPE Shade DbgValidateD3D12RootTable(d3d12RootParam.DescriptorTable); #endif } + else + { + UNSUPPORTED("Unsupported root parameter type"); + } } - void RootParamsBuilder::InitializeMgr(IMemoryAllocator& MemAllocator, RootParamsManager& ParamsMgr) { VERIFY(!ParamsMgr.m_pMemory, "Params manager has already been initialized!"); |
