Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down
5 changes: 5 additions & 0 deletions ci/container
Original file line number Diff line number Diff line change
Expand Up @@ -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[@]}" "$@"
9 changes: 7 additions & 2 deletions ci/container-verify
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
98 changes: 65 additions & 33 deletions packages/mesa/arch/PKGBUILD
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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= \
Expand All @@ -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 '<device driver="zink" device="g5p">' "${pkgdir}/usr/share/drirc.d/00-mesa-defaults.conf" |
grep -q '<option name="transcode_s3tc" value="1" />'
if [[ $CARCH == aarch64 ]]; then
# The A9's Zink default, S3TC textures transcoded to ETC2, is in this file.
grep -A 3 '<device driver="zink" device="g5p">' "${pkgdir}/usr/share/drirc.d/00-mesa-defaults.conf" |
grep -q '<option name="transcode_s3tc" value="1" />'

install -Dm 755 build-vulkan/src/imagination/vulkan/libvulkan_powervr_mesa.so \
"${pkgdir}/usr/lib/libvulkan_powervr_mesa.so"
# The build tree's manifest names the library by its build path.
sed 's#"library_path": "[^"]*"#"library_path": "/usr/lib/libvulkan_powervr_mesa.so"#' \
build-vulkan/src/imagination/vulkan/powervr_mesa_icd.*.json > powervr_mesa_icd.json
grep -q '"library_path": "/usr/lib/libvulkan_powervr_mesa.so"' powervr_mesa_icd.json
install -Dm 644 powervr_mesa_icd.json "${pkgdir}/usr/share/vulkan/icd.d/powervr_mesa_icd.json"
install -Dm 755 build-vulkan/src/imagination/vulkan/libvulkan_powervr_mesa.so \
"${pkgdir}/usr/lib/libvulkan_powervr_mesa.so"
# The build tree's manifest names the library by its build path.
sed 's#"library_path": "[^"]*"#"library_path": "/usr/lib/libvulkan_powervr_mesa.so"#' \
build-vulkan/src/imagination/vulkan/powervr_mesa_icd.*.json > powervr_mesa_icd.json
grep -q '"library_path": "/usr/lib/libvulkan_powervr_mesa.so"' powervr_mesa_icd.json
install -Dm 644 powervr_mesa_icd.json "${pkgdir}/usr/share/vulkan/icd.d/powervr_mesa_icd.json"
fi
install -Dm 755 gpu-probe "${pkgdir}/usr/lib/orchard/gpu-probe"
# Where omarchy-a's login session looks for it.
install -d "${pkgdir}/usr/lib/omarchy-a"
Expand Down
56 changes: 43 additions & 13 deletions packages/mesa/gpu-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* Does what Labwc's GLES2 renderer does for one frame, without modesetting:
* opens EGL on the render node, allocates one output buffer of the display's
* size there, draws into it and reads it back. Exits 0 only if all of that
* worked and the renderer is not a software one. It then also offers the
* worked and the renderer is not a software one (and is Zink where the
* caller set MESA_LOADER_DRIVER_OVERRIDE=zink). It then also offers the
* buffer to the display controller as a framebuffer and says so in a
* "GPU-PROBE NOTE" when the controller does not take it: that does not fail
* the probe, because wlroots copies to the display where direct import is
Expand All @@ -22,6 +23,7 @@
#include <fcntl.h>
#include <gbm.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <xf86drm.h>
Expand Down Expand Up @@ -84,23 +86,42 @@ int main(int argc, char **argv)
int render = open(argv[1], O_RDWR | O_CLOEXEC);
int kms = open(argv[2], O_RDWR | O_CLOEXEC);
CHECK(render >= 0 && kms >= 0);
/* The first to open a card becomes its DRM master. Nothing here needs
* that, and Labwc must get it even if this process were to get stuck. */
drmDropMaster(kms);

/* The size Labwc's output buffers will have: the panel's mode. */
uint32_t width = 0, height = 0;
drmModeRes *resources = drmModeGetResources(kms);
for (int i = 0; resources && i < resources->count_connectors && !width; i++) {
drmModeConnector *connector = drmModeGetConnectorCurrent(kms, resources->connectors[i]);
if (connector && connector->connection == DRM_MODE_CONNECTED && connector->count_modes > 0) {
width = connector->modes[0].hdisplay;
height = connector->modes[0].vdisplay;
/* The cached state first; a connector nobody has probed yet in this boot
* (the probe runs before Labwc) has no modes there, so then probe it as
* wlroots does (as DRM master: the kernel probes only for the master),
* and last take a CRTC's current mode. */
for (int probe = 0; probe < 2 && !width; probe++) {
for (int i = 0; resources && i < resources->count_connectors && !width; i++) {
drmModeConnector *connector = probe ? drmModeGetConnector(kms, resources->connectors[i]) :
drmModeGetConnectorCurrent(kms, resources->connectors[i]);
if (connector && connector->connection == DRM_MODE_CONNECTED && connector->count_modes > 0) {
width = connector->modes[0].hdisplay;
height = connector->modes[0].vdisplay;
}
drmModeFreeConnector(connector);
}
}
for (int i = 0; resources && i < resources->count_crtcs && !width; i++) {
drmModeCrtc *crtc = drmModeGetCrtc(kms, resources->crtcs[i]);
if (crtc && crtc->mode_valid) {
width = crtc->mode.hdisplay;
height = crtc->mode.vdisplay;
}
drmModeFreeConnector(connector);
drmModeFreeCrtc(crtc);
}
drmModeFreeResources(resources);
if (!width || !height) { width = 2048; height = 1536; }
/* The first to open a card becomes its DRM master. The size above needs
* that (the kernel probes a connector for its modes only for the
* master); nothing below does, and Labwc must get it even if this
* process were to get stuck. */
drmDropMaster(kms);
if (!width || !height) {
width = 2048; height = 1536;
printf("GPU-PROBE NOTE: the display reports no mode; testing %ux%u\n", width, height);
}

struct gbm_device *gbm = gbm_create_device(render);
CHECK(gbm);
Expand All @@ -111,7 +132,16 @@ int main(int argc, char **argv)
CHECK(ctx != EGL_NO_CONTEXT);
const char *renderer = (const char *)glGetString(GL_RENDERER);
CHECK(renderer);
if (!strstr(renderer, "zink") || strstr(renderer, "llvmpipe") || strstr(renderer, "softpipe")) {
/* Never a software renderer (nor Zink on one). Zink is required only where
* the caller asked for it (MESA_LOADER_DRIVER_OVERRIDE=zink: OpenGL on the
* PowerVR's Vulkan driver); a GPU with its own Gallium driver (the SGX543's
* sgx) draws OpenGL ES itself. */
if (strstr(renderer, "llvmpipe") || strstr(renderer, "softpipe") || strstr(renderer, "swrast")) {
fprintf(stderr, "GPU-PROBE FAIL: a software renderer: renderer=%s\n", renderer);
return 1;
}
const char *override = getenv("MESA_LOADER_DRIVER_OVERRIDE");
if (override && !strcmp(override, "zink") && !strstr(renderer, "zink")) {
fprintf(stderr, "GPU-PROBE FAIL: not Zink on a GPU: renderer=%s\n", renderer);
return 1;
}
Expand Down
9 changes: 4 additions & 5 deletions packages/mesa/source.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"repository": "OrchardLinux/mesa",
"version": "27.0.0.4",
"commit": "1c4e55e5f36efe07dd063d9704067cfab11a33f6",
"url": "https://github.com/OrchardLinux/mesa/archive/1c4e55e5f36efe07dd063d9704067cfab11a33f6.tar.gz",
"sha256": "3cd0a985ee428de98eadd6ae6e1d6fefa0df4ca0ebd58aaedc34a7778f26af30",
"tag": "v27.0.0.4",
"track": "releases"
"commit": "2b8b3d20201a4754820b037f870e436e4296de30",
"url": "https://github.com/OrchardLinux/mesa/archive/2b8b3d20201a4754820b037f870e436e4296de30.tar.gz",
"sha256": "ebeda0bf072f97b725699a3b5504e6342fd93e1a77df0e71c3ec1cfb4240a9d2",
"track": "pr/n42-sgx-gallium"
}
4 changes: 2 additions & 2 deletions tests/test_pkgrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_versions_carry_the_epoch_of_the_arch_packages_they_replace(self):
self.assertTrue(pkgrepo.recipe(name)['version'].startswith('1:'), name)

def test_architectures(self):
self.assertEqual(pkgrepo.recipe('mesa')['arch'], ['aarch64'])
self.assertEqual(pkgrepo.recipe('mesa')['arch'], ['aarch64', 'armv7h'])
self.assertEqual(pkgrepo.recipe('omacalc')['arch'], ['armv7h'])
self.assertEqual(pkgrepo.recipe('labwc')['arch'], ['aarch64', 'armv7h'])

Expand Down Expand Up @@ -141,7 +141,7 @@ def test_an_empty_repository_builds_each_package_for_its_architectures(self):
result = self.plan({})
builds = {(b['package'], b['base'], b['arch']) for b in pkgrepo.json.loads(result['matrix'])['include']}
self.assertIn(('mesa', 'arch', 'aarch64'), builds)
self.assertNotIn(('mesa', 'arch', 'armv7h'), builds)
self.assertIn(('mesa', 'arch', 'armv7h'), builds)
self.assertIn(('omacalc', 'arch', 'armv7h'), builds)
self.assertNotIn(('omacalc', 'arch', 'aarch64'), builds)
self.assertNotIn(('mesa', 'alpine', 'aarch64'), builds)
Expand Down
Loading