如何Build Mesa Perfetto

1.ENV Setup

1.1 Install Ubuntu 20.04

 

1.2 Upgrade Kernel to 5.10.9

$ wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.10.9/amd64/linux-headers-5.10.9-051009-generic_5.10.9-051009.202101191835_amd64.deb

$ wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.10.9/amd64/linux-headers-5.10.9-051009_5.10.9-051009.202101191835_all.deb

$ wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.10.9/amd64/linux-image-unsigned-5.10.9-051009-generic_5.10.9-051009.202101191835_amd64.deb

$ wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.10.9/amd64/linux-modules-5.10.9-051009-generic_5.10.9-051009.202101191835_amd64.deb

$ 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.

 

1.3 Download latest meson

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

 

1.4 Check libdrm_intel

$ 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

 

1.5 Download latest mesa code and compile with perfetto

$ 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

 

2.Run Perfetto

To capture a trace with perfetto you need to take the following steps:

  1. Build perfetto from sources available at subprojects/perfetto following this guide.

  2. Create a trace config, which is a json formatted text file with extension .cfg, or use one of the config files under the src/tool/pps/cfg directory. More examples of config files can be found in subprojects/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.

  3. 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
  4. Start other producers you may need, e.g. pps-producer.

    $ sudo ~/Perfetto/mesa/build/src/tool/pps/pps-producer
  5. Start perfetto under the tmux session initiated in step 3.

  6. 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.

  7. 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

posted @ 2022-04-29 14:49  青山牧云人  阅读(282)  评论(0编辑  收藏  举报