[llvm-branch-commits] [llvm] [HLSL] Adding support for Root Constants in LLVM Metadata (PR #135085)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Apr 16 15:41:04 PDT 2025


================
@@ -94,10 +144,56 @@ static bool parse(LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD,
 
 static bool verifyRootFlag(uint32_t Flags) { return (Flags & ~0xfff) == 0; }
 
+static bool verifyShaderVisibility(dxbc::ShaderVisibility Flags) {
+  switch (Flags) {
+
+  case dxbc::ShaderVisibility::All:
+  case dxbc::ShaderVisibility::Vertex:
+  case dxbc::ShaderVisibility::Hull:
+  case dxbc::ShaderVisibility::Domain:
+  case dxbc::ShaderVisibility::Geometry:
+  case dxbc::ShaderVisibility::Pixel:
+  case dxbc::ShaderVisibility::Amplification:
+  case dxbc::ShaderVisibility::Mesh:
+    return true;
+  }
+
+  return false;
+}
+
+static bool verifyParameterType(dxbc::RootParameterType Flags) {
+  switch (Flags) {
+  case dxbc::RootParameterType::Constants32Bit:
----------------
joaosaffran wrote:

We are reusing the structures defined in `mcdxbc`, these structs are used to serialize the Root Signature into the binary format. This is used in `obj2yaml/yaml2obj` binary. Those require to be `uint32_t`, that is the value that will be actually encoded in the binary and, most importantly, `obj2yaml/yaml2obj` must be able to write invalid root signatures, and that is not possible using an enum, due to a limitation of the yaml infrastructure.

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


More information about the llvm-branch-commits mailing list