Game Development Reference
In-Depth Information
Another issue to take into consideration, which is more of a design concern, is the
fact that a device automatically creates an implicit swap chain when it is created.
Swap chains can be queried from a device by an indexer, where the implicit swap
chain starts at 0 and the other swap chains increment by 1 thereafter. A common
approach is to assign the swap chain indexer to the child window associated with
it and release the swap chain when the window closes. The problem lies in assign-
ing the implicit swap chain to a child window and trying to release it when the
window closes. One solution to this problem is covered in the next section, “The
Proposed Solution.”
As mentioned earlier, swap chains have the benefit of sharing data from a single
device, requiring a single location in memory. While this feature can offer signifi-
cant memory and performance gains, it can also lead to some headaches. Swap
chains do not have their own collection of device settings, so each swap chain must
be responsible for the management of settings, such as textures, view state, and
render states. It is important that you remain careful and attentive when using
swap chains so that you do not end up with settings that transfer over from one
swap chain to another by forgetting to set new values.
There are increased render state changes that happen through the use of swap
chains, so batching and minimization of changes are important so that perfor-
mance is not impacted. Swap chains are still much more efficient than using mul-
tiple devices, so the performance issues go with the territory of rendering to multiple
Multiple windows are hard to maintain and track, especially when swap chains are
associated to them. Luckily, .NET makes MDI application development a breeze,
so there is no real concern for this solution.
The Proposed Solution
In this chapter, I present a manager that handles the construction, usage, and
destruction of swap chains within either an MDI or SDI application. The manag-
er correctly handles the resizing of child windows to prevent artifacts and aliasing,
and it transparently wraps a lot of the swap chain calls into a reusable and exten-
sible framework.
Each child window within the MDI application will be responsible for handling its
own rendering, but the swap chain manager must have a way to inform the child
window that it should render a frame. The following interface is extremely sim-
plistic but will provide a common mechanism that the manager can call, depending
Search Nedrilad ::

Custom Search