Skip to content

Commit e6c1c4f

Browse files
authored
[RDAT] Add mesh node signature elements to mesh node case for RDAT (#6499)
Previously, mesh nodes would be missing two details in the RDAT output: SigOutputElements and SigPrimOutputElements. The signature data was missing from RDAT because lib\DxilContainer\DxilContainerAssembler.cpp:AddShaderNodeInfo only added MeshOutputTopology, MaxOutputVertices, and MaxOutputPrimitives data to the RDAT. In this PR, more data gets added to RDAT, including the previously missing signature elements. A test was added that verifies that the RDAT includes these new signatue element details. Fixes #6495
1 parent 4eb40e0 commit e6c1c4f

4 files changed

Lines changed: 193 additions & 40 deletions

File tree

lib/DxilContainer/DxilContainerAssembler.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,9 +1657,25 @@ class DxilRDATWriter : public DxilPartWriter {
16571657
}
16581658

16591659
if (props.Node.LaunchType == NodeLaunchType::Mesh) {
1660+
const DxilEntrySignature &sig = entryProps.sig;
16601661
nAttrib = {};
16611662
nAttrib.AttribKind = (uint32_t)RDAT::NodeFuncAttribKind::MeshShaderInfo;
16621663
RDAT::MSInfo info = {};
1664+
uint32_t shaderFlags = 0;
1665+
info.SigOutputElements = AddSigElements(sig.OutputSignature, shaderFlags);
1666+
funcInfo.ShaderFlags |=
1667+
(uint16_t)(shaderFlags &
1668+
(uint16_t)DxilShaderFlags::OutputPositionPresent);
1669+
info.SigPrimOutputElements =
1670+
AddSigElements(sig.PatchConstOrPrimSignature, shaderFlags);
1671+
// TODO: Fill in ViewID related masks
1672+
info.NumThreads =
1673+
Builder.InsertArray(&props.numThreads[0], &props.numThreads[0] + 3);
1674+
info.GroupSharedBytesUsed = tgsmSizeInBytes;
1675+
info.GroupSharedBytesDependentOnViewID =
1676+
(uint32_t)0; // TODO: same thing (note: this isn't filled in for PSV!)
1677+
info.PayloadSizeInBytes =
1678+
(uint32_t)props.ShaderProps.MS.payloadSizeInBytes;
16631679
info.MeshOutputTopology = (uint8_t)props.ShaderProps.MS.outputTopology;
16641680
info.MaxOutputVertices = (uint16_t)props.ShaderProps.MS.maxVertexCount;
16651681
info.MaxOutputPrimitives =
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
// RUN: %dxc -T lib_6_9 %s | %D3DReflect %s | FileCheck %s
2+
3+
4+
// CHECK:DxilRuntimeData (size = {{[0-9]+}} bytes):
5+
// CHECK: StringBuffer (size = {{[0-9]+}} bytes)
6+
// CHECK: IndexTable (size = {{[0-9]+}} bytes)
7+
// CHECK: RawBytes (size = {{[0-9]+}} bytes)
8+
// CHECK: RecordTable (stride = {{[0-9]+}} bytes) FunctionTable[1] = {
9+
// CHECK: <0:RuntimeDataFunctionInfo{{.*}}> = {
10+
// CHECK: Name: "meshNodesLeaf"
11+
// CHECK: UnmangledName: "meshNodesLeaf"
12+
// CHECK: Resources: <RecordArrayRef<RuntimeDataResourceInfo>[0]> = {}
13+
// CHECK: FunctionDependencies: <string[0]> = {}
14+
// CHECK: ShaderKind: Node
15+
// CHECK: PayloadSizeInBytes: 0
16+
// CHECK: AttributeSizeInBytes: 0
17+
// CHECK: FeatureInfo1: 0
18+
// CHECK: FeatureInfo2: 0
19+
// CHECK: ShaderStageFlag: (Node)
20+
// CHECK: MinShaderTarget: 0xf0069
21+
// CHECK: MinimumExpectedWaveLaneCount: 0
22+
// CHECK: MaximumExpectedWaveLaneCount: 0
23+
// CHECK: ShaderFlags: (OutputPositionPresent)
24+
// CHECK: Node: <0:NodeShaderInfo> = {
25+
// CHECK: LaunchType: Mesh
26+
// CHECK: GroupSharedBytesUsed: 0
27+
// CHECK: Attribs: <12:RecordArrayRef<NodeShaderFuncAttrib>[4]> = {
28+
// CHECK: [0]: <0:NodeShaderFuncAttrib> = {
29+
// CHECK: AttribKind: ID
30+
// CHECK: ID: <0:NodeID> = {
31+
// CHECK: Name: "meshNodesLeaf"
32+
// CHECK: Index: 0
33+
// CHECK: }
34+
// CHECK: }
35+
// CHECK: [1]: <1:NodeShaderFuncAttrib> = {
36+
// CHECK: AttribKind: NumThreads
37+
// CHECK: NumThreads: <0:array[3]> = { 1, 1, 1 }
38+
// CHECK: }
39+
// CHECK: [2]: <2:NodeShaderFuncAttrib> = {
40+
// CHECK: AttribKind: MaxDispatchGrid
41+
// CHECK: MaxDispatchGrid: <4:array[3]> = { 8, 1, 1 }
42+
// CHECK: }
43+
// CHECK: [3]: <3:NodeShaderFuncAttrib> = {
44+
// CHECK: AttribKind: MeshShaderInfo
45+
// CHECK: MeshShaderInfo: <0:MSInfo> = {
46+
// CHECK: SigOutputElements: <{{[0-9]+}}:RecordArrayRef<SignatureElement>[1]> = {
47+
// CHECK: [0]: <0:SignatureElement> = {
48+
// CHECK: SemanticName: "SV_Position"
49+
// CHECK: SemanticIndices: <8:array[1]> = { 0 }
50+
// CHECK: SemanticKind: Position
51+
// CHECK: ComponentType: F32
52+
// CHECK: InterpolationMode: LinearNoperspective
53+
// CHECK: StartRow: 0
54+
// CHECK: ColsAndStream: 3
55+
// CHECK: UsageAndDynIndexMasks: 0
56+
// CHECK: }
57+
// CHECK: }
58+
// CHECK: SigPrimOutputElements: <{{[0-9]+}}:RecordArrayRef<SignatureElement>[1]> = {
59+
// CHECK: [0]: <1:SignatureElement> = {
60+
// CHECK: SemanticName: "CLR"
61+
// CHECK: SemanticIndices: <8:array[1]> = { 0 }
62+
// CHECK: SemanticKind: Arbitrary
63+
// CHECK: ComponentType: F32
64+
// CHECK: InterpolationMode: Constant
65+
// CHECK: StartRow: 0
66+
// CHECK: ColsAndStream: 3
67+
// CHECK: UsageAndDynIndexMasks: 0
68+
// CHECK: }
69+
// CHECK: }
70+
// CHECK: ViewIDOutputMask: <0:bytes[0]>
71+
// CHECK: ViewIDPrimOutputMask: <0:bytes[0]>
72+
// CHECK: NumThreads: <0:array[3]> = { 1, 1, 1 }
73+
// CHECK: GroupSharedBytesUsed: 0
74+
// CHECK: GroupSharedBytesDependentOnViewID: 0
75+
// CHECK: PayloadSizeInBytes: 0
76+
// CHECK: MaxOutputVertices: 3
77+
// CHECK: MaxOutputPrimitives: 1
78+
// CHECK: MeshOutputTopology: 2
79+
// CHECK: }
80+
// CHECK: }
81+
// CHECK: }
82+
// CHECK: Outputs: <RecordArrayRef<IONode>[0]> = {}
83+
// CHECK: Inputs: <{{[0-9]+}}:RecordArrayRef<IONode>[1]> = {
84+
// CHECK: [0]: <0:IONode> = {
85+
// CHECK: IOFlagsAndKind: 97
86+
// CHECK: Attribs: <{{[0-9]+}}:RecordArrayRef<NodeShaderIOAttrib>[3]> = {
87+
// CHECK: [0]: <0:NodeShaderIOAttrib> = {
88+
// CHECK: AttribKind: RecordSizeInBytes
89+
// CHECK: RecordSizeInBytes: 12
90+
// CHECK: }
91+
// CHECK: [1]: <1:NodeShaderIOAttrib> = {
92+
// CHECK: AttribKind: RecordDispatchGrid
93+
// CHECK: RecordDispatchGrid: <RecordDispatchGrid>
94+
// CHECK: ByteOffset: 0
95+
// CHECK: ComponentNumAndType: 23
96+
// CHECK: }
97+
// CHECK: [2]: <2:NodeShaderIOAttrib> = {
98+
// CHECK: AttribKind: RecordAlignmentInBytes
99+
// CHECK: RecordAlignmentInBytes: 4
100+
// CHECK: }
101+
// CHECK: }
102+
// CHECK: }
103+
// CHECK: }
104+
// CHECK: }
105+
// CHECK: }
106+
// CHECK: }
107+
// skip over the rest of the RDAT tables
108+
// CHECK:ID3D12LibraryReflection:
109+
// CHECK: D3D12_LIBRARY_DESC:
110+
// CHECK: Creator: <nullptr>
111+
// CHECK: Flags: 0
112+
// CHECK: FunctionCount: 1
113+
// CHECK: ID3D12FunctionReflection:
114+
// CHECK: D3D12_FUNCTION_DESC: Name: meshNodesLeaf
115+
// CHECK: Shader Version: <unknown> 6.9
116+
// CHECK: Creator: <nullptr>
117+
// CHECK: Flags: 0
118+
// CHECK: RequiredFeatureFlags: 0
119+
// CHECK: ConstantBuffers: 0
120+
// CHECK: BoundResources: 0
121+
// CHECK: FunctionParameterCount: 0
122+
// CHECK: HasReturn: FALSE
123+
124+
125+
struct meshNodesRecord
126+
{
127+
uint3 grid : SV_DispatchGrid;
128+
};
129+
130+
struct MS_OUT_POS
131+
{
132+
float4 pos : SV_POSITION;
133+
};
134+
135+
struct MS_OUT_CLR
136+
{
137+
float4 clr : CLR;
138+
};
139+
140+
[Shader("node")]
141+
[NodeLaunch("mesh")]
142+
[outputtopology("triangle")]
143+
[numthreads(1,1,1)]
144+
[NodeMaxDispatchGrid(8,1,1)]
145+
void meshNodesLeaf(
146+
DispatchNodeInputRecord<meshNodesRecord> inputData,
147+
out vertices MS_OUT_POS verts[3],
148+
out primitives MS_OUT_CLR prims[1],
149+
out indices uint3 idx[1]
150+
)
151+
{
152+
SetMeshOutputCounts(3,1);
153+
verts[0].pos = float4(-1, 1, 0, 1);
154+
verts[1].pos = float4(1, 1, 0, 1);
155+
verts[2].pos = float4(1, -1, 0, 1);
156+
prims[0].clr = float4(1,1,1,1);
157+
idx[0] = uint3(0,1,2);
158+
}
159+

tools/clang/test/HLSLFileCheck/hlsl/workgraph/mesh_node_attribs_rdat.hlsl

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -82,26 +82,18 @@ void node02_mesh_maxdispatch(DispatchNodeInputRecord<RECORD> input) {}
8282
// CHECK: [4]: <{{[0-9]+}}:NodeShaderFuncAttrib> = {
8383
// CHECK: AttribKind: MeshShaderInfo
8484
// CHECK: MeshShaderInfo: <0:MSInfo> = {
85-
// CHECK: SigOutputElements: <0:RecordArrayRef<SignatureElement>[3]> = {
86-
// CHECK: [0]: <1:SignatureElement> = <nullptr>
87-
// CHECK: [1]: <2:SignatureElement> = <nullptr>
88-
// CHECK: [2]: <3:SignatureElement> = <nullptr>
89-
// CHECK: }
90-
// CHECK: SigPrimOutputElements: <0:RecordArrayRef<SignatureElement>[3]> = {
91-
// CHECK: [0]: <1:SignatureElement> = <nullptr>
92-
// CHECK: [1]: <2:SignatureElement> = <nullptr>
93-
// CHECK: [2]: <3:SignatureElement> = <nullptr>
94-
// CHECK: }
95-
// CHECK: ViewIDOutputMask: <0:bytes[0]>
96-
// CHECK: ViewIDPrimOutputMask: <0:bytes[0]>
97-
// CHECK: NumThreads: <0:array[3]> = { 1, 2, 3 }
98-
// CHECK: GroupSharedBytesUsed: 0
99-
// CHECK: GroupSharedBytesDependentOnViewID: 0
100-
// CHECK: PayloadSizeInBytes: 0
101-
// CHECK: MaxOutputVertices: 0
102-
// CHECK: MaxOutputPrimitives: 0
85+
// CHECK: SigOutputElements: <RecordArrayRef<SignatureElement>[0]> = {}
86+
// CHECK: SigPrimOutputElements: <RecordArrayRef<SignatureElement>[0]> = {}
87+
// CHECK: ViewIDOutputMask: <0:bytes[0]>
88+
// CHECK: ViewIDPrimOutputMask: <0:bytes[0]>
89+
// CHECK: NumThreads: <0:array[3]> = { 1, 2, 3 }
90+
// CHECK: GroupSharedBytesUsed: 0
91+
// CHECK: GroupSharedBytesDependentOnViewID: 0
92+
// CHECK: PayloadSizeInBytes: 0
93+
// CHECK: MaxOutputVertices: 0
94+
// CHECK: MaxOutputPrimitives: 0
10395
// set by [OutputTopology("line")] (line == 1)
104-
// CHECK: MeshOutputTopology: 1
96+
// CHECK: MeshOutputTopology: 1
10597
// CHECK: }
10698
// CHECK: }
10799
// CHECK: }
@@ -161,19 +153,11 @@ void node02_mesh_maxdispatch(DispatchNodeInputRecord<RECORD> input) {}
161153
// CHECK: [4]: <4:NodeShaderFuncAttrib> = {
162154
// CHECK: AttribKind: MeshShaderInfo
163155
// CHECK: MeshShaderInfo: <0:MSInfo> = {
164-
// CHECK: SigOutputElements: <0:RecordArrayRef<SignatureElement>[3]> = {
165-
// CHECK: [0]: <1:SignatureElement> = <nullptr>
166-
// CHECK: [1]: <2:SignatureElement> = <nullptr>
167-
// CHECK: [2]: <3:SignatureElement> = <nullptr>
168-
// CHECK: }
169-
// CHECK: SigPrimOutputElements: <0:RecordArrayRef<SignatureElement>[3]> = {
170-
// CHECK: [0]: <1:SignatureElement> = <nullptr>
171-
// CHECK: [1]: <2:SignatureElement> = <nullptr>
172-
// CHECK: [2]: <3:SignatureElement> = <nullptr>
173-
// CHECK: }
156+
// CHECK: SigOutputElements: <RecordArrayRef<SignatureElement>[0]> = {}
157+
// CHECK: SigPrimOutputElements: <RecordArrayRef<SignatureElement>[0]> = {}
174158
// CHECK: ViewIDOutputMask: <0:bytes[0]>
175159
// CHECK: ViewIDPrimOutputMask: <0:bytes[0]>
176-
// CHECK: NumThreads: <0:array[3]> = { 1, 2, 3 }
160+
// CHECK: NumThreads: <15:array[3]> = { 3, 2, 1 }
177161
// CHECK: GroupSharedBytesUsed: 0
178162
// CHECK: GroupSharedBytesDependentOnViewID: 0
179163
// CHECK: PayloadSizeInBytes: 0
@@ -217,6 +201,8 @@ void node02_mesh_maxdispatch(DispatchNodeInputRecord<RECORD> input) {}
217201
// CHECK: }
218202
// CHECK: }
219203
// CHECK: }
204+
// Lots of intermediate RDAT output that is skipped,
205+
// we jump to checking for ID3D12Library Reflection here.
220206
// CHECK:ID3D12LibraryReflection:
221207
// CHECK: D3D12_LIBRARY_DESC:
222208
// CHECK: Creator: <nullptr>

tools/clang/test/HLSLFileCheck/hlsl/workgraph/noinput_rdat_mesh.hlsl

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,8 @@
4646
// CHECK: [3]: <{{[0-9]+}}:NodeShaderFuncAttrib> = {
4747
// CHECK: AttribKind: MeshShaderInfo
4848
// CHECK: MeshShaderInfo: <0:MSInfo> = {
49-
// CHECK: SigOutputElements: <0:RecordArrayRef<SignatureElement>[3]> = {
50-
// CHECK: [0]: <1:SignatureElement> = <nullptr>
51-
// CHECK: [1]: <1:SignatureElement> = <nullptr>
52-
// CHECK: [2]: <1:SignatureElement> = <nullptr>
53-
// CHECK: }
54-
// CHECK: SigPrimOutputElements: <0:RecordArrayRef<SignatureElement>[3]> = {
55-
// CHECK: [0]: <1:SignatureElement> = <nullptr>
56-
// CHECK: [1]: <1:SignatureElement> = <nullptr>
57-
// CHECK: [2]: <1:SignatureElement> = <nullptr>
58-
// CHECK: }
49+
// CHECK: SigOutputElements: <RecordArrayRef<SignatureElement>[0]> = {}
50+
// CHECK: SigPrimOutputElements: <RecordArrayRef<SignatureElement>[0]> = {}
5951
// CHECK: ViewIDOutputMask: <0:bytes[0]>
6052
// CHECK: ViewIDPrimOutputMask: <0:bytes[0]>
6153
// CHECK: NumThreads: <0:array[3]> = { 1, 1, 1 }

0 commit comments

Comments
 (0)