Skip to content

Commit a931947

Browse files
committed
add support for DescriptorTableClauses
1 parent bdbf47c commit a931947

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang/test/CodeGenHLSL/RootSignature.hlsl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
[numthreads(1,1,1)]
66
void FirstEntry() {}
77

8+
// CHECK-DAG: ![[#CBV:]] = !{!"CBV", i32 1, i32 0, i32 0, i32 -1, i32 4}
89
// CHECK-DAG: ![[#TABLE:]] = !{!"DescriptorTable"}
910
// CHECK-DAG: ![[#SECOND_RS:]] = !{![[#TABLE]]}
1011

1112
#define SampleDescriptorTable \
1213
"DescriptorTable( " \
14+
" CBV(b0) " \
1315
")"
1416
[shader("compute"), RootSignature(SampleDescriptorTable)]
1517
[numthreads(1,1,1)]

llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,16 @@ MDNode *MetadataBuilder::BuildDescriptorTable(const DescriptorTable &Table) {
200200
}
201201

202202
MDNode *MetadataBuilder::BuildDescriptorTableClause(const DescriptorTableClause &Clause) {
203-
return MDNode::get(Ctx, {ClauseTypeToName(Ctx, Clause.Type)});
203+
IRBuilder<> B(Ctx);
204+
return MDNode::get(Ctx, {
205+
ClauseTypeToName(Ctx, Clause.Type),
206+
ConstantAsMetadata::get(B.getInt32(Clause.NumDescriptors)),
207+
ConstantAsMetadata::get(B.getInt32(Clause.Reg.Number)),
208+
ConstantAsMetadata::get(B.getInt32(Clause.Space)),
209+
ConstantAsMetadata::get(B.getInt32(Clause.Offset)),
210+
ConstantAsMetadata::get(
211+
B.getInt32(llvm::to_underlying(Clause.Flags))),
212+
});
204213
}
205214

206215
} // namespace rootsig

0 commit comments

Comments
 (0)