What is the point of D3D12's SetGraphicsRootSignature?
Asked Answered
B

3

8

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?

Battue answered 22/7, 2016 at 21:48 Comment(1)
Note that the MSDN link provides an example where SetGraphicsRootSignature is called before SetPipelineState.Lava
Y
9

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.

Ynez answered 23/7, 2016 at 4:0 Comment(1)
Ok, I can buy that, though I would have expected multiple graphics pipeline states to be able to internally reference the same root signature they were built with anyways.Battue
M
4

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.

Miltonmilty answered 26/7, 2016 at 1:43 Comment(0)
N
4

@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
Nonessential answered 9/1, 2019 at 9:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.