This article is about how to enable GPU hardware acceleration in Termux proot-distro by installing and running virgl server in Termux.
By enabling VirGL in proot, we will be able to play 4K60p videos and run 3D Linux games or Windows games (via Box86 + Wine) in proot.
No root permission is required.
Testing device: Sony Xperia 5 II. Android 12. Snapdragon 865 (Adreno 650). RAM 8GB.
If you are confused, watch this video demonstration first (with subtitles) to see how virglrenderer improve the graphical performance of Termux X11.
1. Install Termux and Termux X11#
Install Termux from F-droid
And setup Termux X11
2. Install proot-distro#
Install a proot-distro with desktop environment.
I use Debian.
3. Install virglrenderer#
Choose one method to install virglrenderer.
Method 1: Install virglrenderer-Android#
virglrenderer-android uses Android GL/ES. It should work on most Android devices.
- Install virglrenderer-android
pkg install virglrenderer-android
- You can start virgl server by executing this command
virgl_test_server_android &
Method 2: Install virglrenderer with Zink#
Zink is the OpenGL on Vulkan translation layer. The performance might be better than virglrenderer-android. It only works on Qualcomm devices.
- Install virglrenderer with zink
pkg install tur-repo
pkg update -y && pkg upgrade -y
pkg install mesa-zink virglrenderer-mesa-zink vulkan-loader-android
- You can start virgl server by executing this command. While using
GALLIUM_DRIVER
variable in proot, replacevirpipe
withzink
.
MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink ZINK_DESCRIPTORS=lazy virgl_test_server --use-egl-surfaceless &
4. How to run applications with virgl#
4.1. In proot#
Start virgl server in Termux.
Launch Termux X11 app, keep it opening in the background. Go back to Termux, start Termux X11
export DISPLAY=:0
termux-x11 :0 &
- Swipe from left edge, clcik
New Session
to open a new terminal. Log into proot-distro asuser
and mount Termux’s/tmp
to proot.
proot-distro login debian --user user --shared-tmp
- Then start XFCE session
export DISPLAY=:0
dbus-launch --exit-with-session startxfce4 &
- Open terminal emulator in XFCE desktop. Run applications with two parameters:
GALLIUM_DRIVER=virpipe MESA_GL_VERSION_OVERRIDE=4.0
to use virgl. Note some applications may crash whenMESA_GL_VERSION_OVERRIDE=4.0
is used.\
You may replace GALLIUM_DRIVER=virpipe
with GALLIUM_DRIVER=virgl
.
- For instance, to run Minetest with virgl:
GALLIUM_DRIVER=virpipe MESA_GL_VERSION_OVERRIDE=4.0 minetest
The FPS of glxgears is higher when virgl enabled.
After enabling virgl, Minetest FPS grows from 10 FPS up to 20 FPS.
VLC with virgl is capable of playing 4K60p videos.
SueprTuxKart becomes playable after enabling vrigl.
The FPS of WebGL Aquarium doubled after enabling virgl. (You need to force enable WebGL in about:config
)
You can also consider using the GALIUM_DRIVER=virpipe startxfce4
command to start the desktop environment so that all programs will be rendered using virpipe by default. And it could increase the smoothness of the desktop environment. If a program crashes when virpipe is enabled, use GALIUM_DRIVER=llvmpipe <program name>
to fallback to CPU rendering.
4.2. In chroot#
Setup a chroot environment, for exmaple chroot Ubuntu with XFCE4
Set SELinux to Permissive
sudo setenforce 0
- Start Termux X11 APP. Go back to Termux, execute:
XDG_RUNTIME_DIR=${TMPDIR} termux-x11 :0 -ac &
- Mount Termux’s tmp to chroot’s tmp directory
export CHROOT_DIR=/data/local/tmp/chrootubuntu
sudo busybox mount --bind $PREFIX/tmp $CHROOT_DIR/tmp
- Log into chroot. Start XFCE4
sudo chmod -R 777 /tmp
export DISPLAY=:0 PULSE_SERVER=tcp:127.0.0.1:4713
dbus-launch --exit-with-session startxfce4 &
- Run apps with virgl
GALLIUM_DRIVER=virpipe MESA_GL_VERSION_OVERRIDE=4.0 minetest
4.3. Run Windows games#
Install Box86 + Wine in proot-distro.
Start virgl server in Termux.
Run box86 with GALLIUM_DRIVER
parameters:
GALLIUM_DRIVER=virpipe MESA_GL_VERSION_OVERRIDE=4.0 box86 wine AIR.exe
“Undertale” works well with virgl enabled.
Also visual novel “Air”