Skip to content

Commit 98c8cda

Browse files
ResourceSignatureD3D12: use correct array size for inline constants when remapping resources (#672)
1 parent 24e9fdd commit 98c8cda

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Graphics/GraphicsEngine/interface/PipelineResourceSignature.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ struct PipelineResourceDesc
285285
SHADER_TYPE ShaderStages DEFAULT_INITIALIZER(SHADER_TYPE_UNKNOWN);
286286

287287
/// Resource array size (must be 1 for non-array resources).
288+
///
289+
/// For inline constants (see PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS),
290+
/// this member specifies the number of 4-byte values.
288291
Uint32 ArraySize DEFAULT_INITIALIZER(1);
289292

290293
/// Resource type, see Diligent::SHADER_RESOURCE_TYPE.

Graphics/GraphicsEngineD3D12/src/PipelineResourceSignatureD3D12Impl.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,12 +730,18 @@ void PipelineResourceSignatureD3D12Impl::UpdateShaderResourceBindingMap(Resource
730730

731731
if ((ResDesc.ShaderStages & ShaderStage) != 0)
732732
{
733+
VERIFY((ResDesc.Flags & PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS) == 0 || ResDesc.ResourceType == SHADER_RESOURCE_TYPE_CONSTANT_BUFFER,
734+
"Only constant buffers can be marked as INLINE_CONSTANTS. This error should've been caught by ValidatePipelineResourceSignatureDesc().");
735+
const Uint32 ArraySize = (ResDesc.Flags & PIPELINE_RESOURCE_FLAG_INLINE_CONSTANTS) ?
736+
1 : // For inline constants, ArraySize is the number of 4-byte constants
737+
ResDesc.ArraySize;
738+
733739
ResourceBinding::BindInfo BindInfo //
734740
{
735741
Attribs.Register,
736742
Attribs.Space + BaseRegisterSpace,
737-
ResDesc.ArraySize,
738-
ResDesc.ResourceType //
743+
ArraySize,
744+
ResDesc.ResourceType,
739745
};
740746
bool IsUnique = ResourceMap.emplace(HashMapStringKey{ResDesc.Name}, BindInfo).second;
741747
VERIFY(IsUnique, "Shader resource '", ResDesc.Name,

0 commit comments

Comments
 (0)