[DO NOT MERGE] Android: Use perfetto.dev to trace GPU internal metrics
Meson within AOSP scripts can't be used to produce executables (they need some extensive rework to do it).
Therefore this patch is not for merging into mainline/mesa. User can cherry-pick it prior to debugging.
How to use (panfrost-specific example):
- Add pps-producer into your device.mk:
PRODUCT_PACKAGES += pps-producer
-
Build/deploy android.
-
Enable additional panfrost IOCTLs, run:
adb root
adb shell "echo Y > /sys/module/panfrost/parameters/unstable_ioctls"
- Run
adb root && adb shell pps-producer
, check output in terminal.
[557.448] pps_driver.cc:88 Driver selected: panfrost
[557.449] pps_datasource.cc:139 Waiting for start
Keep this daemon running, use another terminal for remaining stuff.
- Ensure data source is registered by pps-producer daemon
Run
adb shell perfetto --query
, check if output contains:
gpu.counters.panfrost pps-producer ()
- Open perfetto.dev in the browser. Click record new trace, enable all necessary events. I could not find any option to add custom dataset using perfetto web UI, therefore you have to click "Recording command", copy and paste it into any text editor and add the following section:
data_sources: {
config {
name: "gpu.counters.panfrost"
gpu_counter_config {
counter_period_ns: 1000000
}
}
}
-
Copy modified commands from the editor and paste them into separate terminal. After record complete check pps-producer is still running. It can fail time-to-time, in this case you have to restart it and repeat the procedure.
-
Pull the trace from the device:
adb pull /data/misc/perfetto-traces/trace ~/trace
-
Open the trace using https://perfetto.dev/ web UI
-
Have a fun with debugging.