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