Forked From Mesa - The 3D Graphics Library
A Mesa build for containers on Android (Proot, Chroot, LXC, etc.), to support hardware acceleration with Adreno or Mali GPU.
- Directly compiled from the modified official Mesa repository source code in a Debian 13 Linux arm64 Chroot container, it is backward compatible with Debian 12. The Mesa drivers compiled by this project can be used in Proot, Chroot, and LXC containers hosted on Android.
- For some Adreno 6xx/7xx GPUs, the Freedreno driver can be used for OpenGL, OpenGL ES, and Vulkan, eliminating the need for Zink for graphics API call translation and significantly improving GPU utilization.
- Only drivers relevant to the vast majority of Android devices are compiled to reduce the package size.
GPU | OpenGL | OpenGL ES | Vulkan |
---|---|---|---|
Adreno GPU | ✅Supported | ✅Supported | ✅Supported |
Mali GPU | ❔Untested | ❔Untested | ❔Untested |
ℹ️Note: Currently, the releases for this project only provide .tar.gz
installation packages. These can only overwrite existing Mesa drivers and cannot be uninstalled directly. They are intended for testing purposes only.
- Go to the Releases page to download an installation package. Please note the Linux distribution suffix in the filename, such as
debian_arm64
. You can only install the package that matches your distribution. - Extract the installation package directly to the root directory.
sudo tar -zxvf mesa-for-android-container_25.3.0-devel-20250725_debian_arm64.tar.gz -C /
- Refresh the dynamic linker cache.
sudo ldconfig
Specify the environment variables MESA_LOADER_DRIVER_OVERRIDE
and TU_DEBUG
when running a specific program, as follows:
MESA_LOADER_DRIVER_OVERRIDE=kgsl TU_DEBUG=noconform glmark2
Alternatively, add them to the /etc/environment
file so they are loaded automatically when the container starts:
MESA_LOADER_DRIVER_OVERRIDE=kgsl
TU_DEBUG=noconform
ℹ️Note: This driver has not yet been tested on Mali GPUs, so the following methods may not work.
- For newer Mali GPUs (based on the Midgard and Bifrost microarchitectures), specify the environment variable
GALLIUM_DRIVER=panfrost
. - For older Mali GPUs (based on the Utgard architecture), specify the environment variable
GALLIUM_DRIVER=lima
.
This project is built in a Debian 13 arm64 environment. For detailed building procedures, please refer to the official Mesa documentation (Compilation and Installation Using Meson — The Mesa 3D Graphics Library latest documentation). The key steps are as follows:
- Check if the source code repositories are enabled. If you are using the traditional format for software sources (
/etc/apt/sources.list
), check for a configuration similar to the following.
deb-src https://deb.debian.org/debian trixie main contrib non-free non-free-firmware
- Install the dependencies required to build Mesa.
sudo apt build-dep mesa
- Clone this project's repository.
git clone https://github.com/lfdevs/mesa-for-android-container.git
- Switch to the branch where the relevant patches have been applied, such as
adreno-main
.
cd mesa-for-android-container
git checkout adreno-main
- Initialize the build directory.
meson setup build/
- Modify the build options. You can refer to the meson.options file to see all available build options.
meson configure build/ \
--prefix=/usr \
-Dplatforms=x11,wayland \
-Dgallium-drivers=freedreno,panfrost,lima,virgl,zink,llvmpipe \
-Dvulkan-drivers=freedreno,panfrost \
-Degl=enabled \
-Dgles2=enabled \
-Dglvnd=enabled \
-Dglx=dri \
-Dlibunwind=disabled \
-Dmicrosoft-clc=disabled \
-Dvalgrind=disabled \
-Dgles1=disabled \
-Dfreedreno-kmds=kgsl \
-Dbuildtype=release
- Start the build.
ninja -C build/
- To install directly on the build device, run the following command:
ninja -C build/ install
- If you need to package the built Mesa drivers for installation on other devices with the same distribution, refer to the following commands:
sudo mkdir /tmp/mesa-install-tmp
sudo DESTDIR=/tmp/mesa-install-tmp meson install -C build/
sudo tar -zcvf mesa-for-android-container_25.3.0-devel-20250725_debian_arm64.tar.gz -C /tmp/mesa-install-tmp .
sudo chown $USER:$USER mesa-for-android-container_25.3.0-devel-20250725_debian_arm64.tar.gz
chmod 644 mesa-for-android-container_25.3.0-devel-20250725_debian_arm64.tar.gz
sudo rm -rf /tmp/mesa-install-tmp
Detailed test results: benchmark-result
Device | Model | SoC | GPU | glmark2 | glmark2-es2 | vkmark |
---|---|---|---|---|---|---|
Redmi K40 Pro | M2012K11G | Qualcomm Snapdragon 888 | Adreno 660 | 842 | 771 | 1170 |
Xiaomi Pad 6 Pro | 23046RP50C | Qualcomm Snapdragon 8+ Gen 1 | Adreno 730 | 1169 | 1143 | Not working |
- Lucas Fryzek: Author of the KGSL backend code for the Mesa Freedreno driver.
- xMeM: For porting the Freedreno driver's KGSL backend to Termux:X11.
- robertkirkman: For integrating and improving xMeM's patches.