Skip to content

Commit 2d41af2

Browse files
ResourceSignatureD3D12: initialize root constants (#672)
1 parent 5e188f0 commit 2d41af2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@ void PipelineResourceSignatureD3D12Impl::AllocateRootParameters(const bool IsSer
267267
// Normal resources go into space 0.
268268
Space = 0;
269269
Register = NumResources[d3d12DescriptorRangeType];
270-
NumResources[d3d12DescriptorRangeType] += ResDesc.ArraySize;
270+
NumResources[d3d12DescriptorRangeType] += (ResDesc.Flags & PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS) != 0 ?
271+
1 : // For inline constants, count only one resource as the ArraySize is the number of 4-byte constants.
272+
ResDesc.ArraySize;
271273
}
272274

273275
const PIPELINE_RESOURCE_FLAGS dbgValidResourceFlags = GetValidPipelineResourceFlags(ResDesc.ResourceType);
@@ -283,7 +285,15 @@ void PipelineResourceSignatureD3D12Impl::AllocateRootParameters(const bool IsSer
283285
{
284286
case SHADER_RESOURCE_TYPE_CONSTANT_BUFFER:
285287
VERIFY(!IsFormattedBuffer, "Constant buffers can't be labeled as formatted. This error should've been caught by ValidatePipelineResourceSignatureDesc().");
286-
d3d12RootParamType = UseDynamicOffset && !IsArray ? D3D12_ROOT_PARAMETER_TYPE_CBV : D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
288+
if ((ResDesc.Flags & PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS) != 0)
289+
{
290+
VERIFY(UseDynamicOffset, "NO_DYNAMIC_BUFFERS flag is not compatible with INLINE_CONSTANTS. This error should've been caught by ValidatePipelineResourceSignatureDesc().");
291+
d3d12RootParamType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
292+
}
293+
else
294+
{
295+
d3d12RootParamType = UseDynamicOffset && !IsArray ? D3D12_ROOT_PARAMETER_TYPE_CBV : D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
296+
}
287297
break;
288298

289299
case SHADER_RESOURCE_TYPE_BUFFER_SRV:

0 commit comments

Comments
 (0)