Compile Mesa from source (note: doing this makes it difficult to get back to a clean package install):
- Allow sources to be installed via apt:
- Bookworm and earlier: Uncomment the
deb-srcline inside/etc/apt/sources.list.d/raspi.listand save it - Trixie and later: Edit
/etc/apt/sources.list.d/raspi.sourcesand add set Types toTypes: deb deb-srcand save it
- Bookworm and earlier: Uncomment the
- Install build dependencies:
sudo apt update && sudo apt build-dep mesa -ysudo apt install python3-pycparser
- Install later version of meson:
sudo apt remove meson -ysudo pip3 install meson --break-system-packages
- Clone mesa source:
git clone --depth=1 --branch mesa-25.2.4 https://gitlab.freedesktop.org/mesa/mesa/ - Build and install Mesa:
cd mesameson setup --prefix=/usr --libdir=/usr/lib/aarch64-linux-gnu buildmeson compile -C build(takes a while; 25 min on Pi 5)sudo meson install -C build
Note: You might want to clone a different tag/branch depending on your needs. mesa-25.2.4 was the latest version as of October 2025, and mesa-25.0.7 was the version that shipped with Pi OS Trixie at that time.
Also, if you'd like to override defaults for the build, you can run meson configure build/ to see available options, and set them when running meson setup build like meson setup --prefix=/usr --libdir=/usr/lib/aarch64-linux-gnu -D gallium-drivers=iris,llvmpipe,v3d,vc4 -D vulkan-drivers=broadcom,intel build.