Skip to content

Commit 28c6dfa

Browse files
committed
add support for DescriptorTableClauses
1 parent d02cb55 commit 28c6dfa

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-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: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,15 @@ MDNode *MetadataBuilder::BuildDescriptorTable(const DescriptorTable &Table) {
6868
}
6969

7070
MDNode *MetadataBuilder::BuildDescriptorTableClause(const DescriptorTableClause &Clause) {
71-
return MDNode::get(Ctx, {ClauseTypeToName(Ctx, Clause.Type)});
71+
IRBuilder<> B(Ctx);
72+
return MDNode::get(Ctx, {
73+
ClauseTypeToName(Ctx, Clause.Type),
74+
ConstantAsMetadata::get(B.getInt32(Clause.NumDescriptors)),
75+
ConstantAsMetadata::get(B.getInt32(Clause.Register.Number)),
76+
ConstantAsMetadata::get(B.getInt32(Clause.Space)),
77+
ConstantAsMetadata::get(B.getInt32(llvm::to_underlying(Clause.Offset))),
78+
ConstantAsMetadata::get(B.getInt32(llvm::to_underlying(Clause.Flags))),
79+
});
7280
}
7381

7482
} // namespace root_signature

0 commit comments

Comments
 (0)