#! /bin/bash # Mesa with Xorg # Source: https://archive.mesa3d.org//mesa-22.0.1.tar.xz # # $BUILD = Directory to temporarily install # $PKGS = Directory to store built packages # # DEPS # Required: LLVM, libdrm, Mako # Recommended: Libva, libvdpau(for Xorg), wayland-protocols, libglvnd, spirv-headers # Optional: libgcrypt, lm-sensors, nettle, valgrind, libunwind, vulkan-headers (vulkan support/driver) # Optional: libxcb(for Xorg), libX11(for Xorg), libxshmfence(for Xorg), libXxf86vm(for Xorg), # Optional: libXrandr(for Xorg), libclc(vulkan-support) # As of version 22.x.x, Mesa's classic OpenGL drivers (non-Gallium3D) have been removed. These are the # old Radeon R100 and R200 drivers, the original Nouveau code, and the Intel i915 and i965 drivers. # More info at https://www.phoronix.com/scan.php?page=news_item&px=Mesa-Classic-Retired # Apply patches based on Alpine Linux patch -Np1 -i ../patches/mesa-22.0.1-mlfs/radeonsi-On-Aarch64-force-persistent-buffers-to-GTT.patch patch -Np1 -i ../patches/mesa-22.0.1-mlfs/musl-fix-includes.patch patch -Np1 -i ../patches/mesa-22.0.1-mlfs/disable-rgb10-by-default.patch # Not sure if "initial-exec TLS" works now with mesa 22.x.x. Enabling for now #patch -Np1 -i ../patches/mesa-alpine-21.2.1/add-use-elf-tls.patch # If optimizing, use these flags # LTO is not recommended export CFLAGS="-march=native -mtune=native " export CFLAGS+="-Ofast -falign-functions=32 -fno-lto " export CFLAGS+="-fno-semantic-interposition -mprefer-vector-width=256 " export CFLAGS="$CFLAGS -D_XOPEN_SOURCE=700" && case $(uname -m) in i686|x86_64) export GLL_DRV="i915,nouveau,radeonsi,svga,swrast,r600,iris,crocus" #export DRI_DRIVERS="i965,nouveau" export V_DRIVERS="amd,swrast,intel" ;; arm*) export GLL_DRV="vc4,panfrost,nouveau,tegra,swrast" #export DRI_DRIVERS="nouveau" export V_DRIVERS="swrast" ;; esac export MESA_GIT_SHA1_OVERRIDE=53b2b224dc2de982c37915a0ad218e33365ff75e && python3 bin/git_sha1_gen.py --output include/git_sha1.h && # Set configure flags export BUILDOPT="-Dbuildtype=release " export BUILDOPT+="-Dllvm=enabled " export BUILDOPT+="-Dshared-llvm=enabled " export BUILDOPT+="-Dosmesa=true " export BUILDOPT+="-Dvalgrind=false " export GFXOPT="-Dglx=dri " export GFXOPT+="-Dglx-read-only-text=true " export GFXOPT+="-Dxlib-lease=enabled " export GFXOPT+="-Ddri3=enabled " export GFXOPT+="-Dopengl=true " export GFXOPT+="-Degl=enabled " export GFXOPT+="-Dgles2=enabled " export GFXOPT+="-Dgles1=enabled " export GFXOPT+="-Dshared-glapi=enabled " export DRVROPT="-Degl-native-platform=wayland " export GALLIUMOPT="-Dgallium-va=enabled " export GALLIUMOPT+="-Dgallium-xa=true " export GALLIUMOPT+="-Dgallium-xvmc=true " export GALLIUMOPT+="-Dgallium-nine=true " export GALLIUMOPT+="-Dgallium-vdpau=true " # if libclc is installed: export XTRA_OPTS="-Dgallium-opencl=icd " # if libglvnd is installed export XTRA_OPTS+="-Dglvnd=true " # Classic OpenGL drivers, such as the i965/i915, were retired to amber branch # Crocus driver will handle i965 chipsets #export XTRA_OPTS+="-Dprefer-crocus=true " #export XTRA_OPTS+="-Ddri-drivers=\"${DRI_DRIVERS}\" " # For intel graphics only (i.e. intergrated graphics on some laptops) # then only enable these drivers: #export DRI_DRIVERS="i965" export GLL_DRV="i915,svga,swrast,iris,crocus" export V_DRIVERS="swrast,intel" # If glslang is installed, vulkan layers an be built export V_LAYERS="-Dvulkan-layers=device-select,overlay,intel-nullhw " meson --prefix=/usr \ -Dvulkan-drivers="${V_DRIVERS}" -Dgallium-drivers="${GLL_DRV}" \ -Dplatforms=wayland,x11 -Dtools=xvmc,glsl \ $BUILDOPT $GFXOPT $DRVROPT $GALLIUMOPT $V_LAYERS $XTRA_OPTS OUT read -p "Compile?" && ninja -C OUT -j2 && sudo -S DESTDIR=$BUILD ninja -C OUT install && unset CFLAGS GLL_DRV DRI_DRIVERS MESA_GIT_SHA1_OVERRIDE V_DRIVERS && cd $BUILD && sudo -S mkdir -v ${BUILD}/install && cat > /tmp/slack-desc << "EOF" # HOW TO EDIT THIS FILE: # The "handy ruler" below makes it easier to edit a package description. Line # up the first '|' above the ':' following the base package name, and the '|' # on the right side marks the last column you can put a character in. You must # make exactly 11 lines for the formatting to be correct. It's also # customary to leave one space after the ':' except on otherwise blank lines. |-----handy-ruler------------------------------------------------------| mesa: mesa (a 3-D graphics library) mesa: mesa: Mesa is a 3-D graphics library with an API very similar to that of mesa: another well-known 3-D graphics library. The Mesa libraries are used mesa: by X to provide both software and hardware accelerated graphics. mesa: mesa: Mesa was written by Brian Paul. mesa: mesa: Homepage: https://www.mesa3d.org mesa: mesa: EOF sudo -S mv -v /tmp/slack-desc install/ && sudo -S makepkg -l y -c n $PKGS/mesa-22.0.1-$(uname -m)-mlfs.txz && sudo -S rm -rf ${BUILD}/*