Skip to content

Latest commit

 

History

History
372 lines (329 loc) · 11 KB

HardwareAcceleration.md

File metadata and controls

372 lines (329 loc) · 11 KB
  • It is highly recommended that you read terminology first.

📚 Index





Hardware Acceleration in Termux (Proot & Chroot)

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

1. Install packages

You need to install the following packages in Termux:

pkg install mesa-zink virglrenderer-mesa-zink vulkan-loader-android virglrenderer-android

2. Initialize graphical server in Termux:

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

3. In proot distro

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

Performance results

Device used: Lenovo Legion Y700 2022 model (Snapdragon 870 - Adreno 650)

GLMARK2

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

WEB GL Aquarium on Firefox


Other tests I did:

  • SuperTuxKart tested during 30 seconds SUPERTUXKART comparison

Hardware Acceleration in Native Termux

(Freedreno and Turnip are only compatible with Adreno 610 and above with exceptions like 710, 642L, etc)

Turnip

  • Install
    apt install mesa-vulkan-icd-freedreno-dri3
    
  • To run programs with turnip:
    MESA_LOADER_DRIVER_OVERRIDE=zink PROGRAM
    

Freedreno(Experimental)

Warning

This is still being tested, installing it will break your xfce4 desktop environment. Install at your own risk!

Download freedreno & Build

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

Remove existing files

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

Install

ninja -C build install

To run programs with freedreno kgsl:

MESA_LOADER_DRIVER_OVERRIDE=kgsl PROGRAM

Troubleshooting and fixes

Games not registering qwerty/WASD keys

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)