Live GPU Profiling

Hi there,

I would like to know what is the best way to do GPU profiling (get the time-stamp between two point in time during the rendering)…

For DirectX11 I found the following function in the CommandList.Direct3D.cs (in SiliconStudio.Xenko.Graphics):

/// <summary>
/// Begins profiling.
/// </summary>
/// <param name="profileColor">Color of the profile.</param>
/// <param name="name">The name.</param>
public unsafe void BeginProfile(Color4 profileColor, string name)
    if (nativeDeviceProfiler != null)

I am guessing that this is for hooking an external perf analyser like PIX, however I would really like to get the time-stamps directly in the game and display it in the HUD instead…

Thanks in advance.

There is a profiler script that you can create by default in the Add Asset -> Script -> Profiler
You can toggle it on with ctrl + alt + P in the game.

It does not give the most details, but it’ll give you batches etc etc…

How does it work for timing GPU commands in a deferred context (when the commands are not executed immediately but submitted at once to the graphics device) ?

I’m afraid I cannot answer that. Since I do not know this in depth. :slight_smile:

We have some work in progress that make those BeginProfile calls also read back the GPU timings (using GPU queries), and use them with the existing Profiler system.

If I understood correctly, that’s what you want, right?

Yes that’s exactly what I want to do, but I ended up implementing it myself, was not so hard to do GPU queries with Xenko and I only use DX11 so it took me very little time.

If you are guys are interested I could share the code with you, do you guys accept pull requests ?