- It is highly recommended that you read terminology first.
- 💻 Hardware Acceleration in Termux (Proot & Chroot)
- 💻 Hardware Acceleration in Termux Native
- 🪲 Troubleshooting and fixes
Note
I would like to include here all the information I got while I am still researching the subject as the world of hardware acceleration is huge.. If you find any errors or misconceptions, please comment on Youtube, Telegram or open an issue on this Github
🔥[Video] Hardware Acceleration Part 1 - What it is, how it is used (VIRGL AND ZINK)
🔥[Video] Hardware Acceleration Part 2 - (VIRGL, ZINK, TURNIP) - how can you use them
🔥[Video] Hardware Acceleration Part 3 - How to run a full Desktop with Hardware Acceleration
You need to install the following packages in Termux:
pkg install mesa-zink virglrenderer-mesa-zink vulkan-loader-android virglrenderer-android
Before login to proot and use hardware acceleration you need to start the graphical server:
- Vulkan (ZINK):
MESA_NO_ERROR=1 MESA_GL_VERSION_OVERRIDE=4.3COMPAT MESA_GLES_VERSION_OVERRIDE=3.2 GALLIUM_DRIVER=zink ZINK_DESCRIPTORS=lazy virgl_test_server --use-egl-surfaceless --use-gles &
- OpenGL (VIRGL):
virgl_test_server_android &
-
Turnip (Adreno GPU 6XX/7XX compatible only) It is not needed to initialize any graphical server. Follow the steps described in the reddit post. As as summary:
- Download Turnip Driver: mesa-vulkan-kgsl_23.3.0-devel-20230905_arm64.deb
- Install it in proot-distro (for example in Debian the command is as follows)
sudo dpkg -i mesa-vulkan-kgsl_23.3.0-devel-20230905_arm64.deb
In case you want to remove the driver:
sudo dpkg -r mesa-vulkan-drivers:arm64
Run the Desktop with my script (if you do manually instead of using my script, take in to account that you need to share the tmp dir to make it work):
./startxfce4_debian.sh
Once in the Desktop when you want to run a program with hardware acceleration use this before:
- For VIRGL and ZINK (depending on the graphic server you started in Termux it will use ZINK or VIRGL):
GALLIUM_DRIVER=virpipe MESA_GL_VERSION_OVERRIDE=4.0 program
- For TURNIP:
MESA_LOADER_DRIVER_OVERRIDE=zink TU_DEBUG=noconform program
Device used: Lenovo Legion Y700 2022 model (Snapdragon 870 - Adreno 650)
To install glmark2:
# In Termux: pkg install glmark2
# In proot-distro (Debian): sudo apt install glmark2
Important
The following tests were done in a proot distro environment with Debian and a XFCE4 desktop.
DEBIAN PROOT (GLMARK2 SCORE - the higher the number the better the performance) | |||||
---|---|---|---|---|---|
RUN | LLVMPIPE | VIRGL | VIRGL ZINK | TURNIP | ZINK |
1 | 93 | 70 | 66 | 198 | Error |
2 | 93 | 77 | 66 | 198 | Error |
3 | 72 | 70 | 71 | 198 | Error |
4 | 94 | 76 | 66 | 197 | Error |
5 | 93 | 75 | 67 | 198 | Error |
Initialize server | Not needed | virgl_test_server_android & |
MESA_NO_ERROR=1 MESA_GL_VERSION_OVERRIDE=4.3COMPAT MESA_GLES_VERSION_OVERRIDE=3.2 GALLIUM_DRIVER=zink ZINK_DESCRIPTORS=lazy virgl_test_server --use-egl-surfaceless --use-gles & |
Not needed | MESA_NO_ERROR=1 MESA_GL_VERSION_OVERRIDE=4.3COMPAT MESA_GLES_VERSION_OVERRIDE=3.2 GALLIUM_DRIVER=zink ZINK_DESCRIPTORS=lazy virgl_test_server --use-egl-surfaceless --use-gles & |
Command used | glmark2 |
GALLIUM_DRIVER=virpipe MESA_GL_VERSION_OVERRIDE=4.0 glmark2 |
GALLIUM_DRIVER=virpipe MESA_GL_VERSION_OVERRIDE=4.0 glmark2 |
MESA_LOADER_DRIVER_OVERRIDE=zink TU_DEBUG=noconform glmark2 |
GALLIUM_DRIVER=zink MESA_GL_VERSION_OVERRIDE=4.0 glmark2 |
GLMARK GPU Info | llvmpipe | virgl (Adreno) | virgl (zink Adreno) | virgl (Turnip Adreno) | zink (Adreno) |
Important
The following tests were done in Termux (NOT in proot-distro) and a XFCE4 desktop.
TERMUX NO PROOT (GLMARK2 SCORE - the higher the number the better the performance) | |||||
---|---|---|---|---|---|
RUN | LLVMPIPE | VIRGL | VIRGL ZINK | ZINK | TURNIP |
1 | 69 | Error | 92 | 121 | Doesn't apply |
2 | 70 | Error | 92 | 122 | Doesn't apply |
3 | 69 | Error | 93 | 121 | Doesn't apply |
4 | 69 | Error | 93 | 124 | Doesn't apply |
5 | 69 | Error | 93 | 123 | Doesn't apply |
Initialize server | Not needed | virgl_test_server_android & |
MESA_NO_ERROR=1 MESA_GL_VERSION_OVERRIDE=4.3COMPAT MESA_GLES_VERSION_OVERRIDE=3.2 GALLIUM_DRIVER=zink ZINK_DESCRIPTORS=lazy virgl_test_server --use-egl-surfaceless --use-gles & |
MESA_NO_ERROR=1 MESA_GL_VERSION_OVERRIDE=4.3COMPAT MESA_GLES_VERSION_OVERRIDE=3.2 GALLIUM_DRIVER=zink ZINK_DESCRIPTORS=lazy virgl_test_server --use-egl-surfaceless --use-gles & |
Doesn't apply |
Command used | glmkar2 |
GALLIUM_DRIVER=virpipe MESA_GL_VERSION_OVERRIDE=4.0 glmark2 |
GALLIUM_DRIVER=virpipe MESA_GL_VERSION_OVERRIDE=4.0 glmark2 |
GALLIUM_DRIVER=zink MESA_GL_VERSION_OVERRIDE=4.0 glmark2 |
Doesn't apply |
GLMARK GPU Info | llvmpipe | virgl (Adreno) | virgl (zink Adreno) | zink (Adreno) | Doesn't apply |
Note
You need to enable WebGL in Firefox to use the GPU
DEBIAN PROOT (FIREFOX-ESR WEBGL AQUARIUM FPS - the higher the number the better the performance) | |||
---|---|---|---|
LLVMPIPE | VIRGL | VIRGL ZINK | TURNIP |
4 | 20 | 17 | Web page crash |
TERMUX NOT PROOT (FIREFOX-ESR WEBGL AQUARIUM FPS - the higher the number the better the performance) | ||||
---|---|---|---|---|
LLVMPIPE | VIRGL | VIRGL ZINK | ZINK | TURNIP |
2 | Error | 24 | 40 | Doesn't apply |
Other tests I did:
(Freedreno and Turnip are only compatible with Adreno 610 and above with exceptions like 710, 642L, etc)
- Install
apt install mesa-vulkan-icd-freedreno-dri3
- To run programs with turnip:
MESA_LOADER_DRIVER_OVERRIDE=zink PROGRAM
Warning
This is still being tested, installing it will break your xfce4 desktop environment. Install at your own risk!
apt update
apt install python3 bison
pip install PyYAML
wget https://gitlab.freedesktop.org/Pipetto-crypto/mesa/-/archive/freedreno/mesa-freedreno.tar.gz
meson build --prefix $PREFIX -Dlibdir=$PREFIX/lib -D platforms=x11 -Dgallium-drivers=freedreno -Dfreedreno-kmds=kgsl,msm -D vulkan-drivers= -D dri3=enabled -D egl=enabled -D gles2=disabled -D glvnd=disabled -D glx=dri -D libunwind=disabled -D shared-glapi=enabled -Dshared-llvm=disabled -D microsoft-clc=disabled -D valgrind=disabled -D gles1=disabled
If these files exist, then remove them(this will break your zink turnip installation!)
rm /data/data/com.termux/files/usr/lib/libgbm.so
rm /data/data/com.termux/files/usr/lib/libglapi.so
ninja -C build install
MESA_LOADER_DRIVER_OVERRIDE=kgsl PROGRAM
To fix it
Termux:X11 -> Preferences -> Turn on "Prefer scancodes when possible"
(another wordaround is to hold CTRL while pressing the qwerty keys although the solution above is more convenient and permanently fixes the issue)