Graphics Reference
In-Depth Information
Another potential optimization for this technique is provided by the fact that deferred
contexts can also consume command lists. This means that it is possible to build larger
command lists from a group of smaller ones to minimize the number of command lists
needed to be executed on the immediate context. Depending on the implementation of this
feature in drivers, this could also be used to reduce the overall cost associated with render-
ing a frame with low-level command lists.
Per-Material Command Lists
The final solution that we will consider is to process a scene in per-material chunks. When
it is time to render a frame, some preprocessing of the scene is required to group objects
that share common materials, so that they can be processed together as a group by a single
worker thread. Then, each newly generated command list is passed on to the main render-
ing thread for processing by the immediate context. This type of object sorting was a fairly
standard practice in D3D9 programs, due to the relatively high CPU cost for each API call.
By sorting objects, the total number of state changes could be reduced by finding a more
optimal sequence to render them in. Thus, this technique could draw upon some of these
existing routines for grouping suitable objects together.
This model strikes somewhat of a balance between the two prior methods. The size
of the groups of objects that are rendered depends solely on how common a given material
is, so this method provides the potential to handle the largest number of objects within a
single rendering batch. Since the per-material command lists encompass more objects with
a relatively small number of state changes between them, they provide better performance
than the per-object command lists since there would be fewer lists to submit to the im-
mediate context. However, there is also the additional cost of having to sort the objects by
material before creating the command list, so the benefits of this technique will vary with
the scene complexity and variations in material types. For scenes that contain relatively
homogeneous rendering materials, this technique can provide a good way to efficiently
process and submit them to the GPU.
7.6 Practical Considerations and Tips
We will conclude this chapter with a section devoted to providing some general design ad-
vice that should be useful when you start to build an application or framework that will use
the multithreading features of Direct3D 11. Due to the typical complexity of multithreaded
programming, it is best to minimize potential issues from the beginning to avoid trying to
find (and fix) them later on.
Search WWH ::




Custom Search