-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[DirectX] Adding root constant documentation #129569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e26ef18
Adding root constant documentation
joaosaffran 4f3930a
Removing union, fix typos
joaosaffran 8fae269
Wrapping text
joaosaffran 7ad5d2b
Removing redundant byte offset reference
joaosaffran 93116c0
Try fix test
joaosaffran e1d385a
Fix git error
joaosaffran 3da10bd
Addressing comments
joaosaffran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,7 +111,7 @@ FXC are marked with \*. | |
#. `PSV0`_ - Stores Pipeline State Validation data. | ||
#. RDAT† - Stores Runtime Data. | ||
#. RDEF\* - Stores resource definitions. | ||
#. RTS0 - Stores compiled root signature. | ||
#. `RTS0`_ - Stores compiled root signature. | ||
#. `SFI0`_ - Stores shader feature flags. | ||
#. SHDR\* - Stores compiled DXBC bytecode. | ||
#. SHEX\* - Stores compiled DXBC bytecode. | ||
|
@@ -400,3 +400,100 @@ SFI0 Part | |
The SFI0 part encodes a 64-bit unsigned integer bitmask of the feature flags. | ||
This denotes which optional features the shader requires. The flag values are | ||
defined in `llvm/include/llvm/BinaryFormat/DXContainerConstants.def <https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/BinaryFormat/DXContainerConstants.def>`_. | ||
|
||
|
||
Root Signature (RTS0) Part | ||
-------------------------- | ||
.. _RTS0: | ||
|
||
The Root Signature defines the interface between the shader and the pipeline, | ||
specifying which resources are bound to the shader and how they are accessed. | ||
This structure serves as a contract between the application and the GPU, | ||
establishing a layout for resource binding that both the shader compiler and | ||
the runtime can understand. | ||
|
||
The Root Signature consists of a header followed by a collection of root parameters | ||
and static samplers. The structure uses a versioned design with offset-based references | ||
to allow for flexible serialization and deserialization. | ||
|
||
Root Signature Header | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. code-block:: c | ||
|
||
struct RootSignatureHeader { | ||
uint32_t Version; | ||
uint32_t NumParameters; | ||
uint32_t ParametersOffset; | ||
uint32_t NumStaticSamplers; | ||
uint32_t StaticSamplerOffset; | ||
uint32_t Flags; | ||
} | ||
|
||
|
||
The `RootSignatureHeader` structure contains the top-level information about a root signature: | ||
|
||
#. **Version**: Specifies the version of the root signature format. This allows for backward | ||
compatibility as the format evolves. | ||
#. **NumParameters**: The number of root parameters contained in this root signature. | ||
#. **ParametersOffset**: Byte offset from the beginning of RST0 section to the array of root | ||
parameters header. | ||
#. **NumStaticSamplers**: The number of static samplers defined in the root signature. | ||
#. **StaticSamplerOffset**: Byte offset to the array of static samplers. | ||
#. **Flags**: Bit flags that define global behaviors for the root signature, such as whether | ||
to deny vertex shader access to certain resources. | ||
|
||
This header allows readers to navigate the binary representation of the root signature by | ||
providing counts and offsets to locate each component within the serialized data. | ||
|
||
Root Parameter Header | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. code-block:: c | ||
|
||
struct RootParameterHeader { | ||
dxbc::RootParameterType ParameterType; | ||
dxbc::ShaderVisibility ShaderVisibility; | ||
uint32_t ParameterOffset; | ||
}; | ||
|
||
|
||
Each root parameter in the signature is preceded by a `RootParameterHeader` that describes | ||
the parameter's basic attributes: | ||
|
||
#. **ParameterType**: Enumeration indicating what type of parameter this is (e.g., descriptor | ||
table, constants, CBV, SRV, UAV). | ||
#. **ShaderVisibility**: Specifies which shader stages can access this parameter (e.g., all stages, | ||
vertex shader only, pixel shader only). | ||
#. **ParameterOffset**: Byte offset to the specific parameter data structure | ||
for this entry. | ||
|
||
The header uses a parameter type field rather than encoding the version of the parameter through | ||
size, allowing for a more explicit representation of the parameter's nature. | ||
|
||
Root Parameters | ||
~~~~~~~~~~~~~~~ | ||
|
||
The Root Parameters section contains structured definitions for each type of root parameter that can | ||
be included in a root signature. Each structure corresponds to a specific parameter type as identified | ||
by the ``ParameterType`` field in the ``RootParameterHeader``. | ||
|
||
Root Constants | ||
~~~~~~~~~~~~~~ | ||
|
||
.. code-block:: cpp | ||
|
||
struct RootConstants { | ||
uint32_t ShaderRegister; | ||
uint32_t RegisterSpace; | ||
uint32_t Num32BitValues; | ||
}; | ||
|
||
The ``RootConstants`` structure represents inline root constants that are directly embedded in the root | ||
signature and passed to the shader without requiring a constant buffer resource: | ||
|
||
#. **ShaderRegister**: The shader register (b#) where these constants are bound. | ||
#. **RegisterSpace**: The register space used for the binding. | ||
#. **Num32BitValues**: The number of 32-bit values included in this constant buffer. | ||
|
||
Root constants provide a fast way to pass small amounts of data directly to the shader without the overhead of creating and binding a constant buffer resource. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: do we also enforce 80 char lines here? |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the two lines used here and elsewhere creates a different formatting from the rest of the document