A class for timing GPU operations in DirectX 10
Update - 22/02/2015: The source code for this project is no longer available. The blog post still remains for people who previously downloaded it.
My recent work in the field of GPGPU has lead me to require the time it takes to perform specific GPU tasks. I am using DirectX 10 (because part of my research considers the features added in DirectX 10 generation graphics cards). After looking at many ways of profiling the GPU, the best I have found so far has been to use the D3D10_QUERY_TIMESTAMP
and D3D10_QUERY_TIMESTAMP_DISJOINT
queries. As well as determining how long a GPU operation takes, it can also determine whether or not the timing has become disjointed (caused by some change in hardware state such as switching from AC/power to battery on a laptop).
I wrote a little class that encapsulates a GPU timer using the D3D10_QUERY
method. I thought this might be of some interest to other people wishing to profile the GPU in this way, so I have now made this available.
Here are some examples for how to use it: