Jump to content
  • Advertisement
Sign in to follow this  
ZachBethel

DX11 Creating deferred contexts in DX11

This topic is 2534 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!