[llvm] [DXIL] Add support for root signature flag element in DXContainer (PR #123147)

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 12 21:09:06 PST 2025


================
@@ -144,6 +150,39 @@ void DXContainerGlobals::addSignature(Module &M,
   Globals.emplace_back(buildSignature(M, OutputSig, "dx.osg1", "OSG1"));
 }
 
+void DXContainerGlobals::addRootSignature(Module &M,
+                                          SmallVector<GlobalValue *> &Globals) {
+
+  dxil::ModuleMetadataInfo &MMI =
+      getAnalysis<DXILMetadataAnalysisWrapperPass>().getModuleMetadata();
+
+  // Root Signature in Library shaders are different,
+  // since they don't use DXContainer to share it.
+  if (MMI.ShaderProfile == llvm::Triple::Library)
+    return;
+
+  assert(MMI.EntryPropertyVec.size() == 1);
+
+  auto &RSA = getAnalysis<RootSignatureAnalysisWrapper>();
+  const Function *&EntryFunction = MMI.EntryPropertyVec[0].Entry;
+
+  if (!RSA.hasForFunction(EntryFunction))
+    return;
+
+  const ModuleRootSignature &MRS = RSA.getForFunction(EntryFunction);
+  SmallString<256> Data;
+  raw_svector_ostream OS(Data);
+
+  RootSignatureHeader RSH;
+  RSH.Flags = MRS.Flags;
----------------
bogner wrote:

Why do we have an auxilliary structure that we simply copy through here? Could RootSignatureAnalysis just provide us with a `RootSignatureHeader` directly? Is `ModuleRootSignature` going to grow into something that just duplicates `RootSignatureHeader`'s fields?

aside: Both `ModuleRootSignature` and `RootSignatureHeader` feel kind of poorly named - `ModuleRootSignature` has nothing to do with the module AFAICT, and `RootSignatureHeader` is the object that derives the whole root signature, not just the header....

https://github.com/llvm/llvm-project/pull/123147


More information about the llvm-commits mailing list