Graphics Reference
In-Depth Information
design—the immediate context should be used only from within one thread, but the other
threads in a multithreaded program can use a different type of context the deferred
context.
The Deferred Context
The deferred context provides much of the same functionality as the immediate context,
and it also serves as an interface to the pipeline. This includes the same multithreading
behavior, meaning that the deferred context should be used from a single thread. However,
as its name implies, all state changes and pipeline execution requests are deferred until a
later point in time. Instead of immediately executing each state change and each draw and
dispatch call, these are instead queued into what is called a command list. The command
list can then be executed either by the immediate context, which would apply the list to the
GPU immediately, or by another deferred context, which would insert the command list
into that context's current command list. This functionality provides a fairly simple and
intuitive introduction to generating a command list, since the deferred context is used in
the same way that the immediate context is used. The only difference is that the immediate
context applies the calls immediately, and the deferred context applies the calls to a com-
mand list. You can consider the deferred context to be a per-thread, per-core command list
generator.
There are a few other functionalities that don't apply to the deferred context that can
be used on the immediate context. The deferred context does not support directly perform-
ing queries—they must be performed on the immediate context instead. In addition, the de-
ferred context cannot read data back from resources. This makes sense when you consider
that the deferred context is creating a list of its instructions, instead of immediately doing
the work. However, the deferred context is allowed to write to the contents of resources,
as long as the resources are mapped with the D3Dll_MAP_WRITE_DISCARD flag. This also
makes sense, since this allows the command list to contain requests to write the entire con-
tents of the resource, further enforcing the concept that the deferred context may not access
the contents of a resource.
7.3.3 Command Lists
Since command lists play such an important role in the overall multithreading implementa-
tion of Direct3D 11, it is worth understanding precisely how they work. Command lists are
generated by calling the deferred context's FinishCommandList() method. This creates a
command list that includes all of the state change and draw/dispatch calls since the most
recent previous call to FinishCommandList(). Once a command list has been created, the
sequence of operations it contains cannot be changed—the object itself is immutable. The
Search WWH ::




Custom Search