From 0ff1a30ef5cf13d3047daf4a9522324e01fa2c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berkay=20K=C3=B6sebay?= Date: Tue, 1 Dec 2026 23:16:40 +0100 Subject: [PATCH] mesa: build the Apple SGX543 GLES driver and probe for armv7h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use one OrchardLinux/mesa archive for both architectures. Build SGX and softpipe on armv7h, and verify the corresponding driver after install. Probe the connected display mode while holding DRM master. The armv7h container can run under ARM32 emulation where uname already reports armv7l. Assisted-by: LLM Signed-off-by: Berkay Kösebay --- README.md | 2 +- ci/container | 5 ++ ci/container-verify | 9 +++- packages/mesa/arch/PKGBUILD | 98 ++++++++++++++++++++++++------------- packages/mesa/gpu-probe.c | 56 ++++++++++++++++----- packages/mesa/source.json | 9 ++-- tests/test_pkgrepo.py | 4 +- 7 files changed, 127 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 6a63904..08628cf 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ built for both. | Package | aarch64 | armv7h | What | |---|---|---|---| -| `mesa` | yes | - | Mesa from [OrchardLinux/mesa](https://github.com/OrchardLinux/mesa): OpenGL through Zink or in software, the Vulkan driver for the Apple PowerVR GPUs, and `gpu-probe`. Pinned to a commit of the fork's `main` until the fork tags its first release; then it follows releases. Replaces Arch's `mesa`. | +| `mesa` | yes | yes | Mesa from [OrchardLinux/mesa](https://github.com/OrchardLinux/mesa), with Zink, LLVMpipe and PowerVR Vulkan on aarch64, SGX GLES2 on armv7h, and the desktop GPU probe on both. Replaces Arch's `mesa`. | | `wlroots0.20` | yes | yes | Arch's wlroots 0.20 with fast rotated software compositing and a GLES2 renderer that reads shared-memory buffers in place. Replaces Arch's `wlroots0.20`. | | `labwc` | yes | yes | Labwc with the tablet patches: touch input fixes, bottom-edge swipe, session transitions, the overview. Replaces Arch's `labwc`. | | `libva-v4l2-request` | yes | - | VA-API on orchard's hardware video decoders. | diff --git a/ci/container b/ci/container index 6ddebc7..1895933 100755 --- a/ci/container +++ b/ci/container @@ -48,5 +48,10 @@ case "$arch" in alpine-armv7) platform=linux/arm/v7; wrap=(linux32) ;; *) echo "ci/container: unknown architecture $arch" >&2; exit 2 ;; esac +# Under ARM32 emulation the process already reports armv7l, and linux32 +# cannot set its personality. Keep linux32 for native AArch64 kernels. +if (( ${#wrap[@]} )) && [[ $("$engine" run --rm --platform "$platform" "$image" uname -m) == armv7l ]]; then + wrap=() +fi exec "$engine" run --rm --platform "$platform" -e ORCHARD_ARCH="${arch#alpine-}" -e RANK_MIRRORS_ARCH="$arch" \ "${options[@]}" "$image" "${wrap[@]}" "$@" diff --git a/ci/container-verify b/ci/container-verify index 15dbe9a..d1a48bd 100755 --- a/ci/container-verify +++ b/ci/container-verify @@ -34,8 +34,13 @@ pacman -Sl orchard pacman -Dk pacman -Qk "${ours[@]}" [[ " ${ours[*]} " != *" labwc "* ]] || { [[ $(pacman -Qoq /usr/bin/labwc) == labwc ]]; labwc --version; } -[[ " ${ours[*]} " != *" mesa "* ]] || - [[ $(pacman -Qoq /usr/lib/libEGL_mesa.so.0 /usr/lib/libgbm.so.1 /usr/lib/libvulkan_powervr_mesa.so /usr/lib/orchard/gpu-probe | sort -u) == mesa ]] +if [[ " ${ours[*]} " == *" mesa "* ]]; then + driver=/usr/lib/libvulkan_powervr_mesa.so + [[ $ORCHARD_ARCH != armv7h ]] || driver=/usr/lib/dri/apple_sgx_dri.so + for file in /usr/lib/libEGL_mesa.so.0 /usr/lib/libgbm.so.1 /usr/lib/orchard/gpu-probe "$driver"; do + [[ $(pacman -Qoq "$file") == mesa ]] + done +fi # A kernel package installs, and on a system the Orchard installer did not set up # (no /etc/orchard/boot-entry) its hooks write and keep nothing. pacman -Rdd --noconfirm wireless-regdb 2>/dev/null || true diff --git a/packages/mesa/arch/PKGBUILD b/packages/mesa/arch/PKGBUILD index c06138f..14eadcc 100644 --- a/packages/mesa/arch/PKGBUILD +++ b/packages/mesa/arch/PKGBUILD @@ -1,5 +1,5 @@ # Mesa from OrchardLinux's fork, in the place of Arch's mesa package on every -# 64-bit board. Two builds of one source: +# board. On the 64-bit boards (aarch64), two builds of one source: # # - the Vulkan driver for the Apple PowerVR GPUs orchard's powervr kernel # driver runs (the A10's and the A9's), built as it was before this package @@ -9,6 +9,14 @@ # (software OpenGL, on every board and wherever the GPU is not used), built # as a release like Arch's. # +# On the 32-bit boards (armv7h), one build: OpenGL, GLES 2, EGL, GBM and GLX +# with the Gallium driver for the PowerVR SGX543 of the A5 and A6 (sgx, Project +# Cascadia's, on orchard's apple-sgx kernel driver; GLES 2 is what it draws) +# and softpipe (software OpenGL wherever the GPU is not used). No LLVM: the +# SGX's shaders compile without it and llvmpipe is too big for a 1 GB phone. +# The SGX driver takes Apple's command templates from the board's own files, +# installed separately at /usr/local/lib/sgx2d or the SGX_PACK directory. +# # Zink comes from the fork so that its changes for the A9 reach the tablet; # they act only on a device whose Vulkan driver names itself the A9's, and # one of them is a default in this package's 00-mesa-defaults.conf (S3TC @@ -23,41 +31,59 @@ # depends on a mesa version, and a tablet that still has Arch's mesa, both # compare against 1:. tools/pkgrepo bump writes _commit, pkgver, pkgrel and the # archive's checksum when OrchardLinux/mesa moves (see ../source.json). - +# pkgname=mesa -_commit=1c4e55e5f36efe07dd063d9704067cfab11a33f6 +_commit=2b8b3d20201a4754820b037f870e436e4296de30 epoch=1 # Mesa's version, the commit's number on the fork's main branch (so that a # newer commit is a newer package), and the commit. pkgver=27.0.0.4 -pkgrel=1 -pkgdesc="Mesa from the OrchardLinux fork: OpenGL through Zink or in software, the Vulkan driver for the Apple PowerVR GPUs, and the desktop's GPU probe" +pkgrel=5 +pkgdesc="Mesa from the OrchardLinux fork: OpenGL through Zink or in software, PowerVR Vulkan on aarch64, SGX GLES on armv7h, and the desktop's GPU probe" url="https://github.com/OrchardLinux/mesa" license=('MIT') -arch=('aarch64') +arch=('aarch64' 'armv7h') options=('!lto' '!debug') +depends=('expat' 'gcc-libs' 'glibc' 'libdrm' 'libglvnd' 'libx11' 'libxcb' 'libxext' 'libxshmfence' 'libxxf86vm' + 'wayland' 'zlib') # libLLVM.so: llvmpipe runs on the LLVM this was built with; makepkg records its version. -depends=('expat' 'gcc-libs' 'glibc' 'libdisplay-info' 'libdrm' 'libglvnd' 'libLLVM.so' 'libx11' 'libxcb' - 'libxext' 'libxshmfence' 'libxxf86vm' 'spirv-tools' 'systemd-libs' 'vulkan-icd-loader' 'wayland' 'zlib' - 'zstd') +depends_aarch64=('libdisplay-info' 'libLLVM.so' 'spirv-tools' 'systemd-libs' 'vulkan-icd-loader' 'zstd') +makedepends=('bison' 'flex' 'libxfixes' 'libxkbcommon' 'libxrandr' 'meson' 'ninja' 'pkgconf' 'python-mako' + 'python-packaging' 'python-ply' 'python-yaml' 'wayland-protocols' 'xorgproto') # Clang and libclc compile the Vulkan driver's internal shaders at build time only. -makedepends=('bison' 'clang' 'flex' 'glslang' 'libclc' 'libxfixes' 'libxkbcommon' 'libxrandr' 'llvm' 'meson' 'ninja' - 'pkgconf' 'python-mako' 'python-packaging' 'python-ply' 'python-yaml' 'spirv-llvm-translator' - 'vulkan-headers' 'wayland-protocols' 'xorgproto') +makedepends_aarch64=('clang' 'glslang' 'libclc' 'llvm' 'spirv-llvm-translator' 'vulkan-headers') # mesa-orchard: this package's name while omarchy-a built it. -provides=("mesa-libgl=${epoch}:${pkgver}-${pkgrel}" 'opengl-driver' 'vulkan-driver' - "mesa-orchard=${pkgver}-${pkgrel}" "vulkan-powervr-orchard=${pkgver}-${pkgrel}") -conflicts=('mesa-libgl' 'mesa-orchard' 'vulkan-powervr' 'vulkan-powervr-orchard') -replaces=('mesa-orchard' 'vulkan-powervr-orchard') +provides=("mesa-libgl=${epoch}:${pkgver}-${pkgrel}" 'opengl-driver' "mesa-orchard=${pkgver}-${pkgrel}") +provides_aarch64=('vulkan-driver' "vulkan-powervr-orchard=${pkgver}-${pkgrel}") +conflicts=('mesa-libgl' 'mesa-orchard') +conflicts_aarch64=('vulkan-powervr' 'vulkan-powervr-orchard') +replaces=('mesa-orchard') +replaces_aarch64=('vulkan-powervr-orchard') source=("mesa-${_commit}.tar.gz::${url}/archive/${_commit}.tar.gz" gpu-probe.c) -sha256sums=('3cd0a985ee428de98eadd6ae6e1d6fefa0df4ca0ebd58aaedc34a7778f26af30' - '8b6622bdd9bba6f8bdcc7bf407e98078517e8823a7ce22416774ca88481864f2') +sha256sums=('ebeda0bf072f97b725699a3b5504e6342fd93e1a77df0e71c3ec1cfb4240a9d2' + '92d3101149a4fa6ebf3777466ffadb133b77d69e0e9bdf254b04df5ebe14190b') build() { # Not arch-meson: its --auto-features=enabled turns on Mesa features this # package leaves out. - local common=(--prefix=/usr --wrap-mode=nodownload -Db_lto=false -Dllvm=enabled -Dgles1=disabled + local common=(--prefix=/usr --wrap-mode=nodownload -Db_lto=false -Dgles1=disabled -Dvideo-codecs= -Dtools= -Dvulkan-layers= -Dbuild-tests=false) + if [[ $CARCH == armv7h ]]; then + # The SGX driver with the options it flew with on the iPhone 5 (Alpine, + # musl), but for Arch's: /usr, libglvnd in front, X11 and GLX for + # Xwayland as in Arch's mesa, and softpipe for software OpenGL. + meson setup "mesa-${_commit}" build-gl "${common[@]}" --buildtype=release -Db_ndebug=true \ + -Dllvm=disabled -Dplatforms=x11,wayland -Dvulkan-drivers= -Dgallium-drivers=sgx,softpipe \ + -Dopengl=true -Dgles2=enabled -Degl=enabled -Dgbm=enabled -Dglx=dri -Dglvnd=enabled \ + -Dgallium-va=disabled -Dgallium-rusticl=false -Dgallium-extra-hud=false -Dlmsensors=disabled \ + -Dvalgrind=disabled -Dlibunwind=disabled -Dteflon=false -Dzstd=disabled -Dshader-cache=disabled \ + -Dmicrosoft-clc=disabled -Dspirv-tools=disabled + ninja -C build-gl + cc ${CFLAGS} -Wall -Wextra -I"mesa-${_commit}/src/gbm/main" gpu-probe.c -o gpu-probe ${LDFLAGS} \ + -Lbuild-gl/src/gbm -lgbm $(pkg-config --cflags --libs egl glesv2 libdrm) + return + fi + common+=(-Dllvm=enabled) # The Vulkan driver, with the options it has been tested with on the tablets. meson setup "mesa-${_commit}" build-vulkan "${common[@]}" --buildtype=debugoptimized \ -Dplatforms=x11,wayland -Dvulkan-drivers=imagination -Dgallium-drivers= \ @@ -79,24 +105,30 @@ build() { package() { DESTDIR="${pkgdir}" meson install -C build-gl --no-rebuild # The drivers that make this package what the image needs. - local gallium=("${pkgdir}"/usr/lib/libgallium-*.so) + local gallium=("${pkgdir}"/usr/lib/libgallium-*.so) drivers=(zink llvmpipe softpipe) + local files=(lib/dri/zink_dri.so lib/dri/swrast_dri.so lib/dri/kms_swrast_dri.so) + if [[ $CARCH == armv7h ]]; then + drivers=(sgx softpipe) files=(lib/dri/apple_sgx_dri.so lib/dri/swrast_dri.so) + fi [[ ${#gallium[@]} == 1 ]] - for driver in zink llvmpipe softpipe; do grep -q "${driver}" "${gallium[0]}"; done - for file in lib/libEGL_mesa.so.0 lib/libGLX_mesa.so.0 lib/libgbm.so.1 lib/gbm/dri_gbm.so lib/dri/zink_dri.so \ - lib/dri/swrast_dri.so lib/dri/kms_swrast_dri.so share/glvnd/egl_vendor.d/50_mesa.json; do + for driver in "${drivers[@]}"; do grep -q "${driver}" "${gallium[0]}"; done + for file in lib/libEGL_mesa.so.0 lib/libGLX_mesa.so.0 lib/libgbm.so.1 lib/gbm/dri_gbm.so "${files[@]}" \ + share/glvnd/egl_vendor.d/50_mesa.json; do [[ -e ${pkgdir}/usr/${file} ]] done - # The A9's Zink default, S3TC textures transcoded to ETC2, is in this file. - grep -A 3 '' "${pkgdir}/usr/share/drirc.d/00-mesa-defaults.conf" | - grep -q '