I am a little confused about the existence of the ID3D12GraphicsCommandList::SetGraphicsRootSignature
method. From what I understand of this MSDN page, it seems that the only valid usage of it is to always call it after SetPipelineState
, giving it the same root signature as was provided when creating the pipeline state object. If that's so, what benefit is there to it not being implicit? Are there other ways to use this method?
It is CPU optimisation, internally it is possible to prepare part of a mapping from the root signature slots to the actual binding. If you share a root signature between different pipeline state objects, then this work can be done once per root signature instead of once per pipeline state object.
You are likely to call SetGraphicsRootSignature
less often then SetGraphicPipelineState
. This is why.
The "root signature" in DirectX 12 provides the common layout information for sharing data between the CPU data structures and the GPU shader language execution. DirectX 12 makes the programmer decide how many root signatures they want to use, when to use them, and which pipeline state objects need which root signature. In Direct3D 11, there's essentially one "root signature" active at all times which is quite large.
Root signatures can be changed fairly often without a major penalty, but the assumption is that you will have a few root signatures and many PSOs rather than a 1:1 correspondence.
For simplicity in DirectX Tool Kit for DirectX 12, we set the root signature every time we set the PSO in the
IEffect::Apply
method, even though we only use a few different root signatures.
@Chuck Walbourn
"Root signatures can be changed fairly often without a major penalty"
https://developer.nvidia.com/dx12-dos-and-donts#roots
- Minimize the number of Root Signature changes
- The problem is not the change of the RS but there is usually a follow up cost of initializing the root signature entries after such a change
© 2022 - 2024 — McMap. All rights reserved.
SetGraphicsRootSignature
is called beforeSetPipelineState
. – Lava