Game Development Reference
In-Depth Information
TGE has two major systems: animation and rendering. The example is based
on the DirectX SDK's DXUT framework. It is designed to illustrate the tasking
system-related issues I have observed while working with game developers.
Depending on the CPU and GPU the example runs on, it may be either CPU or
GPU bound. If the example is GPU bound, any improvements in CPU throughput
will not be visible in the frame rate. That does not mean that the optimizations
are not worth it. When more powerful GPUs become available, the already shipped
game will scale, and there are more opportunities to add features to future titles
based on the same engine. For the rest of the chapter, we will optimize the example
for CPU performance.
17.3.4 Decorating Tasks and Other Important Work
Sampling profilers use function names to give context to reported execution time.
For example, a sampling profiler might show that you spent 80% of the total ex-
ecution time on a particular function. This approach works well when a function
encompasses the interesting work and when the set of interesting functions are
small. With a task-based game engine, there are many different tasksets executing
potentially from different frames at once. During optimization, we want to improve
the execution time of tasksets to increase framerate. However, we can also refactor
tasksets so the throughput of tasksets increases, even if that increases overall exe-
cution. Remember the goal of optimizing a task-based game engine is to increase
the framerate. Using idle CPU cores to do more work is a win if that work reduces
the total time it takes to compute a frame.
GPA provides a simple, generic, hierarchical API for adding context to a section
of code. The macros BeginTask/EndTask are used to decorate code with a name
that is meaningful to the game. Although the macros contain the word “Task,”
there is no requirement that the work decorated be a task. Any code can be
decorated.
In the example the highest-level decoration in the hierarchy are the DXUT
callback functions MoveFrame() and OnD3D11FrameRender() . The TaskMgr will
automatically decorate tasks created using the name specified during the call to
TaskMgr::Createtask set. With decorated code, GPA provides unique insights
into what is happening in the code.
For a step-by-step guide to running the example and gathering the data used
in the rest of the chapter, please refer to the example code on the website.
17.3.5 Comparing Single-Threaded versus
Task-Based Animation
Running the example with all animation on the main thread and with tasking
enabled, then disabled, produces the following results. The model count is set to
maximum, and the sample is set to be CPU bound. The data was gathered on an
Search WWH ::




Custom Search