[llvm] [Doc][DirectX backend] Add documentation for root signature (PR #88795)

Damyan Pepper via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 15 16:10:26 PDT 2024


================
@@ -0,0 +1,190 @@
+===================================
+Root Signature Serialization format
+===================================
+
+.. contents::
+   :local:
+
+Serialized format
+=================
+
+The root signature will be serialized into a binary format and saved in 'RTS0'
+part of DXContainer.
+The binary format is a sequence of bytes that can be used to create a root 
+signature object in the Direct3D 12 API. The binary format is defined by the
+`D3D12_ROOT_SIGNATURE_DESC (for rootsig_1_0)
+<https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_root_signature_desc>`_
+or `D3D12_ROOT_SIGNATURE_DESC1 (for rootsig_1_1)
+<https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_root_signature_desc1>`_
+structure in the Direct3D 12 API. (With the pointers translated to offsets.)
+
+It will be look like this:
+
+.. code-block:: c++
+
+  namespace dxbc {
+    namespace SerializedRootSignature {
+      namespace v_1_0 {
+
+        struct DxilContainerDescriptorRange {
+          uint32_t RangeType;
+          uint32_t NumDescriptors;
+          uint32_t BaseShaderRegister;
+          uint32_t RegisterSpace;
+          uint32_t OffsetInDescriptorsFromTableStart;
+        };
+
+        struct ContainerRootDescriptor {
+          uint32_t ShaderRegister;
+          uint32_t RegisterSpace;
+        };
+      }
+      namespace v_1_1 {
+
+        struct ContainerDescriptorRange {
+          uint32_t RangeType;
+          uint32_t NumDescriptors;
+          uint32_t BaseShaderRegister;
+          uint32_t RegisterSpace;
+          uint32_t Flags;
+          uint32_t OffsetInDescriptorsFromTableStart;
+        };
+
+        struct ContainerRootDescriptor {
+          uint32_t ShaderRegister;
+          uint32_t RegisterSpace;
+          uint32_t Flags;
+        };
+      }
+
+      struct ContainerRootDescriptorTable {
+        uint32_t NumDescriptorRanges;
+        uint32_t DescriptorRangesOffset;
+      };
+
+      struct RootConstants {
+        uint32_t ShaderRegister;
+        uint32_t RegisterSpace = 0;
+        uint32_t Num32BitValues;
+      };
+
+      struct ContainerRootParameter {
+        uint32_t ParameterType;
+        uint32_t ShaderVisibility;
+        uint32_t PayloadOffset;
+      };
+
+      struct StaticSamplerDesc {
+        Filter Filter = Filter::ANISOTROPIC;
+        TextureAddressMode AddressU = TextureAddressMode::Wrap;
+        TextureAddressMode AddressV = TextureAddressMode::Wrap;
+        TextureAddressMode AddressW = TextureAddressMode::Wrap;
+        float MipLODBias = 0.f;
+        uint32_t MaxAnisotropy = 16;
+        ComparisonFunc ComparisonFunc = ComparisonFunc::LessEqual;
+        StaticBorderColor BorderColor = StaticBorderColor::OpaqueWhite;
+        float MinLOD = 0.f;
+        float MaxLOD = MaxLOD;
+        uint32_t ShaderRegister;
+        uint32_t RegisterSpace = 0;
+        ShaderVisibility ShaderVisibility = ShaderVisibility::All;
+      };
+
+      struct ContainerRootSignatureDesc {
+        uint32_t Version;
+        uint32_t NumParameters;
+        uint32_t RootParametersOffset;
+        uint32_t NumStaticSamplers;
+        uint32_t StaticSamplersOffset;
+        uint32_t Flags;
+      };
+    }
+  }
+
+
+The binary representation begins with a **ContainerRootSignatureDesc**
+object.
+
+The object is succeeded by an array of **ContainerRootParameter** objects
----------------
damyanp wrote:

```suggestion
The object is followed by an array of **ContainerRootParameter** objects
```

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


More information about the llvm-commits mailing list