@@ -119,11 +119,18 @@ GlobalVariable *replaceBuffer(CGHLSLRuntime::Buffer &Buf) {
119119 return CBGV;
120120}
121121
122- void addRootSignature (llvm::Function *Fn, llvm::Module &M) {
122+ void addRootSignature (
123+ ArrayRef<llvm::hlsl::root_signature::RootElement> Elements,
124+ llvm::Function *Fn, llvm::Module &M) {
123125 auto &Ctx = M.getContext ();
124- IRBuilder<> B (M.getContext ());
125126
126- MDNode *ExampleRootSignature = MDNode::get (Ctx, {});
127+ SmallVector<Metadata *> GeneratedMetadata;
128+ for (auto Element : Elements) {
129+ MDNode *ExampleRootElement = MDNode::get (Ctx, {});
130+ GeneratedMetadata.push_back (ExampleRootElement);
131+ }
132+
133+ MDNode *ExampleRootSignature = MDNode::get (Ctx, GeneratedMetadata);
127134
128135 MDNode *ExamplePairing = MDNode::get (Ctx, {ValueAsMetadata::get (Fn),
129136 ExampleRootSignature});
@@ -471,8 +478,8 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl *FD,
471478 // Add and identify root signature to function, if applicable
472479 const AttrVec &Attrs = FD->getAttrs ();
473480 for (const Attr *Attr : Attrs) {
474- if (isa <HLSLRootSignatureAttr>(Attr))
475- addRootSignature (EntryFn, M);
481+ if (const auto *RSAttr = dyn_cast <HLSLRootSignatureAttr>(Attr))
482+ addRootSignature (RSAttr-> getElements (), EntryFn, M);
476483 }
477484}
478485
0 commit comments