@@ -68,11 +68,18 @@ void addDxilValVersion(StringRef ValVersionStr, llvm::Module &M) {
6868 DXILValMD->addOperand (Val);
6969}
7070
71- void addRootSignature (llvm::Function *Fn, llvm::Module &M) {
71+ void addRootSignature (
72+ ArrayRef<llvm::hlsl::rootsig::RootElement> Elements,
73+ llvm::Function *Fn, llvm::Module &M) {
7274 auto &Ctx = M.getContext ();
73- IRBuilder<> B (M.getContext ());
7475
75- MDNode *ExampleRootSignature = MDNode::get (Ctx, {});
76+ SmallVector<Metadata *> GeneratedMetadata;
77+ for (auto Element : Elements) {
78+ MDNode *ExampleRootElement = MDNode::get (Ctx, {});
79+ GeneratedMetadata.push_back (ExampleRootElement);
80+ }
81+
82+ MDNode *ExampleRootSignature = MDNode::get (Ctx, GeneratedMetadata);
7683
7784 MDNode *ExamplePairing = MDNode::get (Ctx, {ValueAsMetadata::get (Fn),
7885 ExampleRootSignature});
@@ -441,8 +448,8 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl *FD,
441448 // Add and identify root signature to function, if applicable
442449 const AttrVec &Attrs = FD->getAttrs ();
443450 for (const Attr *Attr : Attrs) {
444- if (isa <RootSignatureAttr>(Attr))
445- addRootSignature (EntryFn, M);
451+ if (const auto *RSAttr = dyn_cast <RootSignatureAttr>(Attr))
452+ addRootSignature (RSAttr-> getSignatureDecl ()-> getRootElements (), EntryFn, M);
446453 }
447454}
448455
0 commit comments