Advertisement

Creating deferred contexts in DX11

Started by January 07, 2012 02:55 PM
1 comment, last by ZachBethel 12 years, 10 months ago
I have a quick question that should be pretty easy. I've looked through the MSDN articles and I see a few methods for creating device contexts in DirectX 11. There's the popular D3D11CreateDevice and D3D11CreateDeviceAndSwapChain methods, which return an immediate context. Then, there's the D3D11CreateDeferredContext method which simply returns a new deferred context. Great, that's simple enough. So my question is: why am I required to create an immediate context no matter what when creating the device itself? Is it valid to have an immediate context as well as any number of deferred ones? Can they both be used in the same application? Should I just keep a copy of the immediate context and ignore it?

Thanks!
Zach.
Hi!

A couple of years ago Matt Lee gave a talk at Gamefest on multithreaded rendering. You can download the slides and audio track at MSDN. He explains nicely what the immediate and deferred contexts are meant to be used for.

To summarize it for short: Deferred contexts are used to create command lists and to update resources. Deferred contexts are single threaded so you should use one deferred context per thread. You cannot read back data in them from the GPU (queries etc). But you can update resources as long you map them with the discard flag (that’s nice). You must have exactly one immediate context. It builds up the command buffer the GPU is eventually executing. Among those commands is the execution of the command lists, created with the deferred contexts. (Someone needs to tell the GPU in which order the command lists should be executed, which you have created in parallel on multiple threads, right?) Well, and the immediate context can still do everything else (Drawing, Queries, Reading data from the GPU etc.)

So, yes you always have one immediate context in the main thread and for each additional thread a deferred context.

Although it is a nice feature that makes the design of a resource loading system more fun, it seems not to be beneficial yet.
Hope that was helpful. smile.png
Advertisement
Thanks Tsus, that cleared things up. :)

This topic is closed to new replies.

Advertisement