One of the best feature of DirectX 11 is multithreaded rendering, that is to say divide your scene into different parts that will be rendered “at the same time”. All my research was made in the context of my job in 3D R&D at Daneel.
Multithreaded rendering, a new feature of DirectX 11
To be able to have a multithreaded rendering, you should really understand how work deferred contexts and immediate context.
Environment setup for multithreading
Secondly, you should check for driver support. Here is a how-to that explains it step by step.
Rendering algorithm
After recording command lists, we have to execute them. This job is ONLY the immediate context's. When we want to execute command lists (for instance, at the end of your render function), we just have to call ID3D11DeviceContext::ExecuteCommandList() with the immediate context. That's it, we have a multithreaded rendering.
Example
My configuration was the next one: Windows 8, NVIDIA GeForce GTX950, 16Go RAM, up to 12 threads, Release x64. Here are the results I had:
Limitations/best practices
Here are best practices that can help you have better performance:
- be careful about command lists size: not too small, not too big
- use multithreading only if you have lots of objects to draw or if you have CPU overhead
- find the good number of threads to use, too many threads can create a bottleneck and be a lot worse than with a single-threaded program
Binary
mt-dx11.zip |
References
- Practical rendering and computation with Direct3D 11 by Jason Zink, Matt Pettineo & Jack Hoxley
- Direct3D11 multithreading micro-benchmark in C# with SharpDX by Alexandre MUTEL
- All documentation about multithreaded rendering on MSDN
- Introduction to Multithreaded rendering and the usage of Deferred Contexts in DirectX 11 by Rodrigo B. Pinheiro, Alexandre Valdetaro, Gustavo B. Nunes, Bruno Feijo & Alberto Raposo