Skip to main content

virglrenderer: Termux GPU hardware acceleration tutorial

Categories   Smartphone Termux Tutorial
Tags   Wine Termux
Table of Contents

🇹🇼 中文版

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.

SuperTuxKart, Glxgears

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.

  1. Install virglrenderer-android
pkg install virglrenderer-android
  1. 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.

  1. Install virglrenderer with zink
pkg install tur-repo
pkg update -y && pkg upgrade -y
pkg install mesa-zink virglrenderer-mesa-zink vulkan-loader-android
  1. You can start virgl server by executing this command. While using GALLIUM_DRIVER variable in proot, replace virpipe with zink.
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

  1. Start virgl server in Termux.

  2. Launch Termux X11 app, keep it opening in the background. Go back to Termux, start Termux X11

export DISPLAY=:0
termux-x11 :0 &
  1. Swipe from left edge, clcik New Session to open a new terminal. Log into proot-distro as user and mount Termux’s /tmp to proot.
proot-distro login debian --user user --shared-tmp
  1. Then start XFCE session
export DISPLAY=:0
dbus-launch --exit-with-session startxfce4 &
  1. 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 when MESA_GL_VERSION_OVERRIDE=4.0 is used.

  2. For instance, to run Minetest with virgl:


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

  1. Setup a chroot environment, for exmaple chroot Ubuntu with XFCE4

  2. Set SELinux to Permissive

sudo setenforce 0
  1. Start Termux X11 APP. Go back to Termux, execute:
XDG_RUNTIME_DIR=${TMPDIR} termux-x11 :0 -ac &
  1. 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
  1. Log into chroot. Start XFCE4
sudo chmod -R 777 /tmp
dbus-launch --exit-with-session startxfce4 &
  1. Run apps with virgl

4.3. Run Windows games

Install Box86 + Wine in proot-distro.

Start virgl server in Termux.

Run box86 with GALLIUM_DRIVER parameters:


“Undertale” works well with virgl enabled.

Also visual novel “Air”



[Root] Install Ubuntu in chroot on Android without Linux Deploy
Categories   Smartphone Termux Tutorial
Tags   Linux Android Ubuntu Termux
How to install proot Debian in Termux on Android phone (XFCE desktop + Audio + One-click starter)
Categories   Smartphone Termux Tutorial
Tags   Termux Debian
Installing Anaconda on Android (aarch64) devices
Categories   Smartphone Termux Tutorial
Tags   Termux

Leave a comment

Choose the comment system you like. Giscus for codes, Disqus for anonymous comments.

Please login to your Github account to leave a comment. You can post codes here for discussion. For images, please upload to Imgur and copy links. Your comments would be visible to everyone on Github Discussions.

This comment system is provided by Disqus, you may see forcing Disqus ADs on this page. Sometimes your comment may need to be reviewed, resulting in delayed display. Thank you for your understanding.