Files
RedBear-OS/recipes/libs/mesa/recipe.toml
T
vasilito 73877d5a3a feat: Mesa virgl DRI driver builds — virtio_gpu_dri.so (80MB pkgar)
Mesa now builds with -Dgallium-drivers=swrast,virgl for Redox target.

Fixes:
- CFLAGS: -Dstatic_assert(...)= nullifies Linux-drm.h static_assert
  calls that conflict with Mesa util/macros.h redefinition on Redox
- virgl_screen.c: disk cache disabled for Redox (dl_iterate_phdr unavailable)
- bits/safamily-t.h: provided to cross-compiler toolchain sysroot

Build output:
- usr/lib/dri/virtio_gpu_dri.so — virgl DRI driver
- usr/lib/dri/swrast_dri.so — llvmpipe software renderer
- usr/lib/dri/kms_swrast_dri.so — KMS software renderer
- libEGL.so, libGLESv2.so, libgbm.so — with virgl support
- 80MB stage.pkgar (vs 63MB swrast-only)

This enables hardware-accelerated 3D rendering in QEMU via
-device virtio-vga-gl with virgl, using the virtio-gpu display
driver in redox-drm. The full stack for QEMU testing is now:

QEMU -device virtio-vga-gl
  → redox-drm virtio driver (KMS/GEM/pageflip)
  → Mesa virtio_gpu_dri.so (virgl gallium)
  → libEGL/libGLES2
  → Wayland compositor
  → KDE Plasma
2026-05-01 00:39:03 +01:00

59 lines
1.9 KiB
TOML

[source]
git = "https://gitlab.redox-os.org/redox-os/mesa.git"
upstream = "https://gitlab.freedesktop.org/mesa/mesa"
branch = "redox-24.0"
shallow_clone = true
[build]
template = "custom"
dependencies = [
"expat",
"libdrm",
"liborbital",
"llvm21",
"zlib",
]
dev-dependencies = [
"llvm21.dev",
]
script = """
DYNAMIC_INIT
#TODO: Should be CPPFLAGS but cookbook_meson isn't reading it
export CFLAGS+=" -DHAVE_PTHREAD=1 -I${COOKBOOK_SYSROOT}/include/libdrm"
export LLVM_CONFIG="${TARGET}-llvm-config"
if [ -x "${HOME}/.redoxer/${TARGET}/toolchain/bin/llvm-config" ]; then
export COOKBOOK_HOST_SYSROOT="${HOME}/.redoxer/${TARGET}/toolchain"
fi
export LDFLAGS+=" -lorbital"
mkdir -p .cookbook-tools
ln -sf "$(command -v "${LLVM_CONFIG}")" .cookbook-tools/llvm-config
export PATH="$(pwd)/.cookbook-tools:${PATH}"
if [ "${COOKBOOK_DYNAMIC}" == "1" ]; then
COOKBOOK_MESON_FLAGS+=(-Dshared-llvm=enabled)
else
COOKBOOK_MESON_FLAGS+=(-Dshared-llvm=disabled)
fi
cookbook_meson \
-Ddri-drivers-path=/usr/lib/dri \
-Degl=enabled \
-Dgbm=enabled \
-Dglx=disabled \
-Dgallium-drivers=swrast,virgl \
-Dllvm=enabled \
-Dosmesa=true \
-Dplatforms=redox \
-Dshader-cache=disabled \
-Dc_args="['-Wno-error=implicit-function-declaration','-Wno-error','-std=gnu11','-Dstatic_assert=_Static_assert']" \
-Dcpp_args="['-Wno-error=implicit-function-declaration','-Wno-error']" \
-Dvulkan-drivers=swrast \
-Dshared-glapi=enabled
# Hack to add LLVM libs, the list can be seen from meson log and check for matches $("${LLVM_CONFIG}" --libs)
LLVMLIBS="-lLLVMBitReader -lLLVMCore -lLLVMExecutionEngine -lLLVMInstCombine -lLLVMMCDisassembler"
LLVMLIBS+=" -lLLVMMCJIT -lLLVMScalarOpts -lLLVMTransformUtils -lLLVMCoroutines -lLLVMLTO"
sed -i "s/ -lOSMesa / -lOSMesa ${LLVMLIBS} -lstdc++ /" "${COOKBOOK_STAGE}/usr/lib/pkgconfig/osmesa.pc"
"""