For devices with Imagination Technologies GPUs, there are many tools available in their SDK. The ones most interesting to us here are
- CPU/GPU profiler - called PVRTune
GL API tracer & analyser - called PVRTrace
To use these, you must download and install the ImgTec SDK by following the links on this page:
Run the installer - you can select only to install PVRTune and PVRTrace.
PVRTune - performance monitoring
This tool is great for getting an overall perspective of what your device is doing. It gathers statistics from your device on CPU usage (per application), GPU usage (direct-from-GPU performance stats), Memory, I/O and much more.
You need to download this file: https://people.canonical.com/~gerboland/libPVRScopeServices.so to have PVRTune work correctly on the Meizu MX4 - it matches the driver on the device. Other devices should not need this. Also note that the reported GPU clock rates are incorrect, but are proportional to reality, so can give you a clue what is happening.
Then need to push files onto the device:
adb push /opt/Imagination/PowerVR_Graphics/PowerVR_Tools/PVRTuneDeveloper/PVRPerfServer/Android/CLI/armeabi-v7a/PVRPerfServerDeveloper /home/phablet adb push libPVRScopeServices.so /home/phablet
and launch the following command on the device:
adb shell sudo LD_PRELOAD=libPVRScopeServices.so ./PVRPerfServerDeveloper
This command will block.
On your PC, need to forward the right port
adb forward tcp:6520 tcp:6520
Launch PVRTune. Connect to "pvrtune://localhost" and hit "Go". The UI should fill up with live performance metrics immediately.
PVRTrace -- GL API tracing
This tool causes a trace file with all the GL traffic to be saved on the device, which you can read and analyse in the PVRTrace application.
We need to copy a daemon, a GL interceptor library and a configuration file on to the device.
Fetch https://people.canonical.com/~gerboland/pvrtraceconfig.json and copy onto the device
adb push pvrtraceconfig.json /home/phablet
On host from SDK directory:
adb push Imagination/PowerVR_Graphics/PowerVR_Tools/PVRTrace/Recorder/Linux_armv7hf /home/phablet/libs/
Then on device in /home/phablet/libs:
ln -s libEGL.so libEGL.so.1 ln -s libGLESv2.so libGLESv2.so.2
On the device, to trace an executable, set the following environment variable for the executable:
and run your executable. The PVR interceptor library should print messages, detailing where it writes the profile file, and prints for each frame it records.
When you have finished, you should find a new trace file in /home/phablet. Copy this to your PC.
On your PC, run PVRTrace and open the trace file you just generated.
The configuration file
The pvrtraceconfig.json file contains options you should be familiar with. It addresses both Profiling and Tracing. For Tracing, it is configured only to capture the first 100 frames. You can customize this, and have PVRTrace remotely turn on & off tracing, by digging into the Network section.