xref: /aosp_15_r20/external/mesa3d/docs/gpuvis.rst (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1Gpuvis Tracing Annotations
2==========================
3
4`Gpuvis <https://github.com/mikesart/gpuvis>`__ is a tool to visualize ftrace
5traces, with support for most GPU drivers to show GPU activity.
6
7Mesa can emit trace markers to be displayed in Gpuvis, which is useful for
8figuring out why e.g. stalls are happening.
9
10Run on Linux
11------------
12
13Any traces can be made with trace-cmd. The Gpuvis repository contains
14`scripts <https://github.com/mikesart/gpuvis/tree/master/sample>`__ for
15configuring the markers needed for GPU events. To start tracing:
16
17.. code-block:: sh
18
19   sh trace-cmd-setup.sh && sh trace-cmd-start-tracing.sh
20   # Start your game etc. Then to capture a trace
21   sh trace-cmd-capture.sh
22   # and to finally stop
23   sh trace-cmd-stop-tracing.sh
24
25The resulting trace file can be opened with Gpuvis.
26
27Run on SteamOS
28--------------
29
30SteamOS includes a script (`gpu-trace <https://github.com/lostgoat/gpu-trace>`__)
31to capture traces.
32
33.. code-block:: sh
34
35   sudo gpu-trace
36   # Press Ctrl+C to stop capture and open report in gpuvis
37
38Note that on SteamOS gpuvis is actually not installed by default, but the
39script does write a gpu-trace.zip file in the current working directory. To
40open it you'll want to do the following on your development machine:
41
42.. code-block:: sh
43
44   scp sd-host:gpu-trace.zip ./
45   unzip gpu-trace.zip
46   ./trace-cmd convert -i *.dat -o converted.dat --compression none --file-version 6
47   gpuvis *.json converted.dat
48
49The main advantage of the gpu-trace script is that it has an integration with
50perf, so Gpuvis can also visualize perf samples in the timeline. Note that the
51perf file is preprocessed before being put into the zip file, so the trace is
52portable between machines.
53
54
55Annotations in Steam games
56--------------------------
57
58Steam games are run in a container, and need the environment variable
59PRESSURE_VESSEL_DEVEL=1 to set up the tracing filesystem so the trace marker
60can be written. This can e.g. be done by going to the game properties in
61Steam and setting the command line to
62
63.. code-block:: sh
64
65   PRESSURE_VESSEL_DEVEL=1 %command%
66
67Then you can run the game as usual, and the driver will write trace annotations.