1# Using External Benchmarks with ANGLE
2
3This document contains instructions on how to run external benchmarks on ANGLE as the GLES renderer.
4There is a section for each benchmark with subsections for each platform.  The general theme is to
5make the benchmark application pick ANGLE's `libGLESv2.so` and `libEGL.so` files instead of the
6system ones.
7
8On Linux, this is generally achieved with setting `LD_LIBRARY_PATH`.  On Windows, ANGLE dlls may
9need to be copied to the benchmark's executable directory.
10
11## glmark2
12
13This benchmark can be found on [github](https://github.com/glmark2/glmark2).  It's written against
14GLES 2.0 and supports Linux and Android.  It performs tens of tests and reports the framerate for
15each test.
16
17### glmark2 on Linux
18
19To build glmark2 on Linux:
20
21```
22$ git clone https://github.com/glmark2/glmark2.git
23$ cd glmark2
24$ ./waf configure --with-flavors=x11-glesv2 --data-path=$PWD/data/
25$ ./waf
26```
27
28To run glmark2 using the native implementation of GLES:
29
30```
31$ cd build/src
32$ ./glmark2-es2
33```
34
35To run glmark2 using ANGLE, we need to first create a few links in the build directory of ANGLE:
36
37```
38$ cd /path/to/angle/out/release
39$ ln -s libEGL.so libEGL.so.1
40$ ln -s libGLESv2.so libGLESv2.so.2
41```
42
43Back in glmark2, we need to make sure these shared objects are picked up:
44
45```
46$ cd /path/to/glmark2/build/src
47$ LD_LIBRARY_PATH=/path/to/angle/out/release/ ldd ./glmark2-es2
48```
49
50With `ldd`, you can verify that `libEGL.so.1` and `libGLESv2.so.2` are correctly picked up from
51ANGLE's build directory.
52
53To run glmark2 on the default back-end of ANGLE:
54
55```
56$ LD_LIBRARY_PATH=/path/to/angle/out/release/ ./glmark2-es2
57```
58
59To run glmark2 on a specific back-end of ANGLE:
60
61```
62$ ANGLE_DEFAULT_PLATFORM=vulkan LD_LIBRARY_PATH=/path/to/angle/out/release/ ./glmark2-es2
63```
64
65### glmark2 on Linux for Android
66
67**Prerequisites**
68
69Below steps are set up to use version 26.0.1 of build-tools, which can be downloaded here:
70
71[https://dl.google.com/android/repository/build-tools_r26.0.1-linux.zip](https://dl.google.com/android/repository/build-tools_r26.0.1-linux.zip)
72
73Tested with r19 of NDK, which can be downloaded here:
74
75[https://dl.google.com/android/repository/android-ndk-r19-linux-x86_64.zip](https://dl.google.com/android/repository/android-ndk-r19-linux-x86_64.zip)
76
77Tested with OpenJDK 8:
78
79```
80sudo apt-get install openjdk-8-jdk
81```
82
83Note: This is built from a branch that has fixes for Android.  It only supports
8432-bit ARM (armeabi-v7a).  Supporting other ABIs requires more work, possibly
85including a move to cmake instead of ndk-build.
86
87**Setup**
88
89```
90export ANDROID_SDK=<path_to_Android_SDK>
91export ANDROID_NDK=<path_to_Android_NDK>
92export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
93```
94
95**Build**
96
97```
98git clone https://github.com/cnorthrop/glmark2.git
99cd glmark2/android
100git checkout android_fixes
101./build.sh
102```
103
104**Install**
105
106```
107adb install --abi armeabi-v7a glmark2.apk
108```
109
110**Run**
111
112To select ANGLE as the driver on Android (requires Android Q):
113
114```
115adb shell settings put global angle_gl_driver_selection_pkgs org.linaro.glmark2
116adb shell settings put global angle_gl_driver_selection_values angle
117```
118
119To switch back to native GLES driver:
120
121```
122adb shell settings delete global angle_gl_driver_selection_values
123adb shell settings delete global angle_gl_driver_selection_pkgs
124```
125