# DX12 Single root signature

## Recommended Posts

I am porting a DX11 game engine to DX12, and have some questions about root signature usage. The engine clearly defines a global bind slot range for resources, to avoid using shader reflection. This means, that both the application, both the shaders explicitly know the binding slots for everything (constant buffers, textures, etc.). This would trivially translate to a global root signature in DX12, and I have created it as a big root signature like the following: There are 12 descriptor tables, so for every shader stage there are a sampler descriptor table and a CBV_SRV_UAV table. I though about keeping a "staging" descriptor heap, to which I would place descriptors at resource load time. Then when calling PSSetShaderResources(), which is a DX11-style function, the function would fill out a GPU-visible descriptor heap which is created to match the layout of the root signature tables. The nice thing about is that each frame I would only have a single call to set the root signature and to set root signature tables. The command list would just fill it with descriptors before rendering.

I've found out however, that filling out descriptor tables can only be done on the CPU timeline with ID3D12Device::CopyDescriptors(). This complicates things and I can only think of populating the GPU descriptor heap, and after each draw call, I would need to copy the whole table and CopyDescriptors() again when there is a new call to PSSetShaderResources(). Am I on the right path if I also want to keep DX11-style bindings?

I also thought about each shader having a custom root signature and only ever copying the descriptors which are required by the shader, but in this case I will need to rebind the whole root signature each time a shader changes. I would also have to do a shader reflection step and modify my shader-asset pipeline (because I don't want to depend on d3dcompiler when I run the engine) which I really want to avoid.

Which would be the preferred way? I read the Nvidia Do's and Don'ts but they say these which are contradicting in my case:

• Minimize the number of Root Signature changes
• Don’t bloat your root signature and descriptor tables to be able to reuse them

UPDATE: The second way (unique root signature with PSO) I would also have to bind resources strictly after I have set the right PSO, because the table is now unique.

Edited by turanszkij

##### Share on other sites

Hi!

There is a nice discussion here :

I think UE4 is using something like this ( a common root signature) so it may not be a bad approach.

Edited by piluve

## Create an account

Register a new account

• 15
• 9
• 13
• 41
• 15
• ### Similar Content

• I am basically brand new to the gaming industry business wise although I have been a gamer for years. I officially started my game publishing company, and being as though I am only 20, I have no connects to the gaming industry. Of course, I'm still going to do more internet research, but I thought why not ask folks who may have business hands in the gaming community? If anyone is questioning, my game prototype is basically done (I designed it myself) and its very detailed and I am going to start searching for a team to help me build it. Thank you.
• By Shtabbbe
I've had a game idea for a while, and I wanted to finally try to create it.
Its a 2D open-world tile-based MMO. The concept is it is one world and multiplayer only, so everyone shares one world no matter region, platform, etc.
I am having problems finding out what to use to start development, I tried Unity but saw some of the negatives and refrained and now im stuck, could anyone recommend some intermediate friendly 2D engines that can support what I am looking for? Preferably in languages that are or are somewhat like Java, C#, Python, JavaScript, Lua.
Thanks for your help, im very new at this if you cant tell

• Hi.
I wanted to experiment D3D12 development and decided to run some tutorials: Microsoft DirectX-Graphics-Samples, Braynzar Soft, 3dgep...Whatever sample I run, I've got the same crash.
All the initialization process is going well, no error, return codes ok, but as soon as the Present method is invoked on the swap chain, I'm encountering a crash with the following call stack:
The crash is an access violation to a null pointer ( with an offset of 0x80 )
I'm working on a notebook, a toshiba Qosmio x870 with two gpu's: an integrated Intel HD 4000 and a dedicated NVIDIA GTX 670M ( Fermi based ). The HD 4000 is DX11 only and as far as I understand the GTX 670M is DX12 with a feature level 11_0.
I checked that the good adapter was chosen by the sample, and when the D3D12 device is asked in the sample with a 11_0 FL, it is created with no problem. Same for all the required interfaces ( swap chain, command queue...).
I tried a lot of things to solve the problem or get some info, like forcing the notebook to always use the NVIDIA gpu, disabling the debug layer, asking for a different feature level ( by the way 11_0 is the only one that allows me to create the device, any other FL will fail at device creation )...
I have the latest NVIDIA drivers ( 391.35 ), the latest Windows 10 sdk ( 10.0.17134.0 ) and I'm working under
Visual Studio 2017 Community.
Thanks to anybody who can help me find the problem...

• A few questions about some c++ code
So I am starting to get back into c++ after about 12 - 14 years away from it (and even back then, my level of knowledge was maybe a little above beginner) to do some game / SDL programming. I was following a tutorial to get at least a basic starting point for an entity component system and it works however there was some code that I don't quite understand even after looking around little.
First pice of code is:
T* component(new T(std::forward<TArguments>(arguments)...)); This seems to be assigning the component with the results of what is in the parentheses though normally I would expect this:
T* component = new T(std::forward<TArguments>(arguments)...); Is this just syntax preference or does the compiler do something different with the parentheses (it is weird to me as when I see that, I think it is a function call)?
The second piece of code I think I understand the general idea of what it is doing but some of the specific are escaping me:
template <typename T, typename... TArguments> T& Entity::addComponent(TArguments&&... arguments) {   T* component = new T(std::forward<TArguments>(arguments)...); So from my understanding, the first line would basically take this:
entity->addComponent<TransformComponent, int, int, int, int>(x, y, width, height); and take of the first item in the template and assign the to T and then "group" (not sure the correct term) the rest of the items as a collection of some sort and then the ... on the second line would group the arguments (that would need to match the template group) that were passed in. Then the third line is effectively converting the template / passed in arguments to be called like this:
TransformComponent* component = new TransformComponent(x, y, width, height); The parts that are a bit confusing to me is first the &&. From what I have read (from stack overflow), that symbol means rvalue reference or reference to an argument that is about to be destroyed. Not quite sure what it means by it about to be destroyed.
The second part, which I think related to using &&, is the std::forward<TArguments>. The explainations that I have found so far as are bit confusing to me.
I will continue to try to find the answer to these confusions but I though maybe someone here might have an explanation that might make more sense to me. I would also consider it quite possible that there is some prerequisite knowledge that I might not have (I mean I think I have a decent understanding of pointers and references) so if there is other stuff I should looking into, that would be great too.

• Hello I am looking for advice to what I should do next as I just completed the Unreal Developer Course on Udemy and now am at a lost as what to do farther as practice and to expand my knowledge. My background is 2 years studying college in Videogame Design and 3 years working on 4 years studying Software Engineering in college. I am mainly focusing on using my C++ knowledge with Unreal Engine to make indie games but I do also know Java, and C# as well, but I do not know Unity. I am welcoming any advice that can help with my current situation with my current skill set