Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the point of D3D12's SetGraphicsRootSignature?

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?

like image 295
Trillian Avatar asked Jul 22 '16 21:07

Trillian


2 Answers

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.

like image 99
galop1n Avatar answered Sep 29 '22 07:09

galop1n


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.

like image 20
Chuck Walbourn Avatar answered Sep 29 '22 08:09

Chuck Walbourn