[llvm] [Docs][DirectX] Add relevant documentation of Root Signature (PR #149608)

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 22 09:45:38 PDT 2025


================
@@ -0,0 +1,231 @@
+===============
+Root Signatures
+===============
+
+.. contents::
+   :local:
+
+.. toctree::
+   :hidden:
+
+Overview
+========
+
+A root signature is used to describe what resources a shader needs access to
+and how they're organized and bound in the pipeline. The DirectX Container
+(DXContainer) contains a root signature part (RTS0), which stores this
+information in a binary format. To assist with the construction of, and
+interaction with, a root signature is represented as metadata
+(``dx.rootsignatures`` ) in the LLVM IR. The metadata can then be converted to
+its binary form, as defined in
+`llvm/include/llvm/llvm/Frontend/HLSL/RootSignatureMetadata.h
+<https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h>`_.
+This document serves as a reference for the metadata representation of a root
+signature for users to interface with.
+
+Metadata Representation
+=======================
+
+Consider the reference root signature, then the following sections describe the
+metadata representation of this root signature and the corresponding operands.
+
+.. code-block:: C
+
+  #define DemoRootSignature                                                    \
+    "RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT),"                           \
+    "RootConstants(b0, space = 1, num32Constants = 3),"                        \
+    "CBV(b1, flags = 0),"                                                      \
+    "StaticSampler("                                                           \
+    "  filter = FILTER_MIN_MAG_POINT_MIP_LINEAR,"                              \
+    "  addressU = TEXTURE_ADDRESS_BORDER,"                                     \
+    "),"                                                                       \
+    "DescriptorTable("                                                         \
+    "  visibility = VISIBILITY_ALL,"                                           \
+    "  SRV(t0, flags = DATA_STATIC_WHILE_SET_AT_EXECUTE),"                     \
+    "  UAV("                                                                   \
+    "    numDescriptors = 5, u1, space = 10, offset = 5,"                      \
+    "    flags = DATA_VOLATILE"                                                \
+    "  )"                                                                      \
----------------
bogner wrote:

For the purposes of this document would it help readability to skip the define and the stringification and simply write the root signature elements out directly?

```
RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT),
RootConstants(b0, space = 1, num32Constants = 3),
CBV(b1, flags = 0),
StaticSampler(
  filter = FILTER_MIN_MAG_POINT_MIP_LINEAR,
  addressU = TEXTURE_ADDRESS_BORDER,
),
DescriptorTable(
  visibility = VISIBILITY_ALL,
  SRV(t0, flags = DATA_STATIC_WHILE_SET_AT_EXECUTE),
  UAV(
    numDescriptors = 5, u1, space = 10, offset = 5,
    flags = DATA_VOLATILE
  )
)
```

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


More information about the llvm-commits mailing list