如何Build Mesa Perfetto
1.ENV Setup
$ sudo dpkg -i *.deb
$ sudo reboot
$ uname -a # to check the kernel version.
#5.10.9 is ok, not sure whether it is the lowest workable version.
latest mesa build need llvm version >= 11, the llvm 11 will not be detected if meson's version is too old.
$ mkdir ~/Tools/ && cd ~/Tools
$ git clone https://github.com/mesonbuild/meson.git
$ sudo ln -n ~/Tools/meson/meson.py /usr/bin/meson //or just use the ~/Tools/meson/meson.py to build the mesa directly
$ pkg-config --modversion libdrm_intel
Check the libdrm_intel version, 107 is the required vesion.
You can clone the source code and install latest drm to update the version by https://gitlab.freedesktop.org/mesa/drm
$ git clone https://gitlab.freedesktop.org/mesa/mesa.git
$ sudo apt-get install -y libelf-dev libwayland-egl-backend-dev libxcb-glx0-dev libx11-xcb-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-present-dev libxshmfence-dev llvm-11 tmux libpciaccess-dev
$ cd mesa
$ mkdir build && cd build
$ meson .. -Dperfetto=True
$ sudo ninja install
To capture a trace with perfetto you need to take the following steps:
-
Build perfetto from sources available at
subprojects/perfetto
following this guide. -
Create a trace config, which is a json formatted text file with extension
.cfg
, or use one of the config files under thesrc/tool/pps/cfg
directory. More examples of config files can be found insubprojects/perfetto/test/configs
. In this Wiki, we choose ~/Perfetto/mesa/src/tool/pps/cfg/gpu.cfg to get gpu information. For now, need to delete all counter_ids in gpu.cfg, otherwise will have an error "No field named counter_ids: 0 in proto DataSourceConfig". Will investigate why the counter id is in valid in next work. -
Change directory to
subprojects/perfetto
and run a convenience script to start the tracing service:$ cd subprojects/perfetto $ CONFIG=../../src/tool/pps/cfg/gpu.cfg OUT=out/linux_clang_release ./tools/tmux -n
-
Start other producers you may need, e.g.
$ sudo ~/Perfetto/mesa/build/src/tool/pps/pps-producerpps-producer
. -
Start
perfetto
under the tmux session initiated in step 3. -
Once tracing has finished, you can detach from tmux with Ctrl+b, d, and the convenience script should automatically copy the trace files into
$HOME/Downloads
. -
Go to ui.perfetto.dev and upload
$HOME/Downloads/trace.protobuf
by clicking on Open trace file.
Android利用perfetto抓取trace: https://zhuanlan.zhihu.com/p/508526020