Game Development Reference
In-Depth Information
Figure 3.15. A data-holder structure.
To enable double buffering, we need to transfer all the data used for one cal-
culation. As shown in Figure 3.15, we prepare the array of a structure that holds
related indices (or pointers) of necessary data. Figure 3.16 then shows double
buffering with two phases. In the first phase, we transfer the data-holder array
with double buffering. Then, in the second phase, we calculate real addresses of
necessary data and call the Get DMA command to transfer data used in the fu-
ture to the local storage. We then continue to process in the same way as normal
double buffering.
Figure 3.16. Double buffering with two phases.
To solve dependencies between rigid bodies in double-buffering mode in one
batch, once the rigid body is stored in the local storage, we keep it and don't load
the same rigid body again. Updated rigid bodies are returned to main memory at
the last step of the processing of a batch. It works well because no SPU shares
the same rigid bodies in a group. Implementation of this algorithm is easy. We
prepare the reference table of rigid bodies in the local storage and always check
this table before transferring a rigid body. If a rigid body already exists in the
local storage, we don't need to transfer it again since we can just use the one in
the local storage. We can specify the number of rigid bodies in a batch so that all
rigid bodies in this batch can be stored in the local storage.
3.5 Conclusion
Finally, we check how much speed-up we were able to achieve through our im-
plementation. In the test scene, 3,000 boxes are dropped on the ground. The
Search Nedrilad ::

Custom Search