Shawn Hargreaves Blog
The graphics debugging tool formerly known as PIX has been integrated into Visual Studio for a while now, and gets better in every release. But unlike Xbox PIX, the Windows incarnation of this technology has until now been only for debugging and not profiling. It provided lots of information about what happened, but none at all about how long things took.
For Windows Phone 8.1, my team (hi Adrian!) added the ability to measure and analyze GPU performance. I’m particularly proud of the fact that, thanks to our efforts to make the Windows and Phone graphics stacks as similar as possible, we were able to build this new feature focusing mostly on Phone, yet the resulting code works exactly the same on full Windows. Visual Studio is even able to reuse a single version of our GPU performance analysis DLL across both Windows 8.1 and Phone 8.1.
Rong’s talk at the Build conference shows this in action, and you can download Visual Studio 2013 Update 2 RC to try it out for yourself.
Here’s how it works. I opened the default D3D project template, which gives me an oh-so-exciting spinning cube plus a framerate counter in the bottom right corner:
To use the graphics diagnostics feature, open the Debug menu, click Graphics, and then Start Diagnostics:
This will run the app with D3D tracing enabled. Press the Print Screen (PrtSc) key one or more times to capture the frames you want to analyze. When you quit the app, Visual Studio will open its graphics debugger. This will look familiar if you have used PIX before, but the UI is considerably improved in this release, plus it now supports Phone as well as Windows:
So far so good, but where is this new profiling feature? Select the Frame Analysis tab, and click where it says Click here:
Our new analysis engine will whir and click for a while (the more complicated your rendering, the longer this will take). When everything has been measured it shows a report describing the GPU performance of every draw call in the frame:
This simple app only contains two draw calls. Event #117 (DrawIndexed) is the cube, while #137 (DrawIndexedInstanced) is the framerate counter. There would obviously be a lot more data if you analyzed something more complicated, in which case the ID3DUserDefinedAnnotation API can be used to organize and label different sections of your rendering.
The blue bars near the top (labeled Time) show how long each draw call took for the GPU to execute. Clearly our cube is much more expensive than the framerate text (although both are ridiculously quick – this template isn’t exactly stressing my GPU :-) The column titled Baseline shows the numeric duration of each draw, and the other columns show a series of experiments where we changed various things about the rendering and measured how much difference each one made to the GPU. For instance this data tells us that:
There are a couple of different forms of color highlighting going on in this report:
Move the mouse over any of these numbers to a view a hover tip showing more data about that particular measurement.
“Sounds great! So what types of device can I use this stuff on?”
Great work! Is this going to VS Express btw?
It would be nice for DirectX 11 desktop applications as well. They require just as much GPU debugging and profiling love.
Visual Studio supports desktop apps just the same as Store ones.
Yes, this feature is part of VS Express as well.
In VS 2013 Express for Desktop with Update 2 RC there is no Graphics sub-menu in the Debug menu.
Wow this looks fantastic, I will be using it to profile my game on all the platforms its on now!
Will it profile the directx calls in a desktop XNA 4.0 app? Most of my games are XNA 4.0 based for the foreseeable future.
Does it support (or will support) the Xbox One?
This tooling supports desktop as well as store apps, but it's only for D3D11 while XNA uses D3D9.
Xbox One has its own somewhat different version of PIX, which does many similar things but in a more hardware specific way (many things get easier, and some richer types of data can be obtained, when you don't have to worry about supporting more than one type of GPU with different drivers!)
This appears to work only in pure D3D apps. XAML and D3D apps can get graphics debugger to show, but capturing the current frame(s) never works. It is stuck on "waiting for DirectX to finish frame".
I have tried this feature and its a great performance analysis tool. But I am wondering why it shows timing for only draw calls and not dispatch calls from DirectCompute. This should be something you could add in the coming updates. I have also tried recently released update RC 3 it won't have this feature either.
Thanks for the feedback Khantil!
We didn't support compute shader profiling mostly due to lack of time, but also prioritization as this feature was initially focused mostly on Windows Phone, which doesn't support compute shaders at all! Would definitely be a good thing to add in the future, though, and thanks for sharing your input on this.