#### Beyond Linux® From Scratch (systemd Edition) - Version 11.1

### Chapter 24. Graphical Environments

- Prev

  xcb-util-cursor-0.1.3

- Next

  xbitmaps-1.1.2

- Up
- Home

# Mesa-21.3.6

## Introduction to Mesa

Mesa is an OpenGL compatible 3D graphics library.

### Note

Mesa is updated relatively often. You may want to use the latest available 21.3.x mesa version.

This package is known to build and work properly using an LFS-11.1 platform.

### Package Information

- Download (HTTP): https://mesa.freedesktop.org/archive/mesa-21.3.6.tar.xz

- Download (FTP): ftp://ftp.freedesktop.org/pub/mesa/mesa-21.3.6.tar.xz

- Download MD5 sum: 3177e69362d2be742596967e7f87298e

- Download size: 16 MB

- Estimated disk space required: 756 MB (with docs, add 389 MB for tests)

- Estimated build time: 3.6 SBU (Using parallelism=4; with docs, add 0.5 SBU for tests)

### Additional Downloads

- Recommended patch: https://www.linuxfromscratch.org/patches/blfs/11.1/mesa-21.3.6-add_xdemos-1.patch (installs 2 demo programs for testing Mesa - not needed if you install the mesa-demos package)

- Required patch (for systems with NVIDIA GPUs): https://www.linuxfromscratch.org/patches/blfs/11.1/mesa-21.3.6-nouveau_fixes-1.patch

### Mesa Dependencies

#### Required

Xorg Libraries, libdrm-2.4.110, and Mako-1.1.6

#### Recommended

libva-2.13.0 (to provide VA-API support for some gallium drivers, note that there is a circular dependency. You must build libva first without EGL and GLX support, install this package, and rebuild libva), libvdpau-1.4 (to build VDPAU drivers), LLVM-13.0.1 (required for Gallium3D, nouveau, r300, and radeonsi drivers and for swrast, the software rasterizer which is sometimes referred to as llvmpipe. See https://docs.mesa3d.org/systems.html for more information), and wayland-protocols-1.25 (required for Plasma-5.24.0, GNOME, and recommended for GTK+-3.24.31)

#### Optional

libgcrypt-1.10.0, lm-sensors-3-6-0 , Nettle-3.7.3, Valgrind-3.18.1, mesa-demos (provides more than 300 extra demos to test Mesa; this includes the same programs added by the patch above), Bellagio OpenMAX Integration Layer (for mobile platforms), libunwind, libtizonia, and libvulkan (for the zink driver)

### Note

The instructions below assume that LLVM with the r600/amdgpu and host backends and run-time type information (RTTI - needed for nouveau) are installed. You will need to modify the instructions if you choose not to install all of these. For an explanation of Gallium3D see https://en.wikipedia.org/wiki/Gallium3D.

User Notes: https://wiki.linuxfromscratch.org/blfs/wiki/mesalib

## Installation of Mesa

If you have downloaded the xdemos patch (needed if testing the Xorg installation per BLFS instructions), apply it by running the following command:

    patch -Np1 -i ../mesa-21.3.6-add_xdemos-1.patch

### Note

The measurements above, and the Contents below, are for a full build. Many people will not wish to install drivers they cannot use, so the following paragraphs explain how to limit the drivers, and give an example which can be be reduced or amended as necessary.

Now, select the drivers you wish to install. For the X86 architecture, the available gallium drivers are auto (in 21.2.1 this does not select crocus ), or alternatively a choice from crocus, i915, iris, nouveau, r300, r600, radeonsi, svga, swrast, and virgl. The latter can provide acceleration in qemu-6.2.0 if that has been linked against virglrenderer (you will need a freedesktop.org account to get to that page, you can download the 0.9.1 release without an account from virglrenderer-0.9.1).

The (non-gallium) DRI drivers available in X86 are auto, or alternatively a choice from i915, i965, nouveau, r100, r200, and swrast. Use 'auto' to build all available DRI drivers, or use an empty string (DRI_DRIVERS="") if you wish to only build gallium drivers.

The platforms ("window systems") available for X86 linux are x11, wayland, and surfaceless. By not specifying anything, the meson build-system will build for all these platforms if you have the dependencies, identical to if you had specified '-Dplatforms=auto'.

Modify the commands below for your desired drivers. The drivers listed below will cover most modern video cards and virtual machines. For help in selecting drivers see https://docs.mesa3d.org/systems.html. For intel drivers, specify crocus for i965 gen 4 through to haswell, iris for broadwell and later.

### Note

Although the nouveau drivers can be built for both gallium and dri, the i915 driver can only be built for one or the other.

    GALLIUM_DRV="crocus,i915,iris,nouveau,r600,radeonsi,svga,swrast,virgl"
    DRI_DRIVERS="i965,nouveau"

### Note

If you are using a NVIDIA GPU in your system, a special patch has been created that allows for proper multi-threading in the Mesa driver. This fixes issues with multi-threaded Qt applications, as well as with starting some GNOME Applications. This patch is also essential if you plan to use KDE Plasma. Apply the patch using the following command:

    patch -Np1 -i ../mesa-21.3.6-nouveau_fixes-1.patch

Install Mesa by running the following commands:

    mkdir build &&
    cd    build &&

    meson --prefix=$XORG_PREFIX          \
          --buildtype=release            \
          -Ddri-drivers=$DRI_DRIVERS     \
          -Dgallium-drivers=$GALLIUM_DRV \
          -Dgallium-nine=false           \
          -Dglx=dri                      \
          -Dvalgrind=disabled            \
          -Dlibunwind=disabled           \
          ..                             &&

    unset GALLIUM_DRV DRI_DRIVERS &&

    ninja

If you built the tests (see 'Command Explanations'), to run them issue: ninja test. One test, mesa: intel/anv_state_pool, is known to fail.

Now, as the `root` user:

    ninja install

If desired, install the optional documentation by running the following commands as the `root` user:

    install -v -dm755 /usr/share/doc/mesa-21.3.6 &&
    cp -rfv ../docs/* /usr/share/doc/mesa-21.3.6

## Command Explanations

`--buildtype=release`: This switch ensures a fully-optimized build, and disables debug assertions which will severely slow down the libraries in certain use-cases. Without this switch, build sizes can span into the 2GB range.

`-Ddri-drivers="..."`: This parameter controls which (non-gallium) dri drivers should be built.

`-Dgallium-drivers="..."`: This parameter controls which Gallium3D drivers should be built.

`-Dgallium-nine=false`: Prevents building support for (MS Windows) games designed for DX9. Set it to true if this support is desired.

`-Dvalgrind=disabled`: This parameter disables the usage of Valgrind during the build process. Remove this parameter if you have Valgrind installed, and wish to check for memory leaks.

`-Dlibunwind=disabled`: This parameter disables the usage of libunwind.

`-Dbuild-tests=true`: This option will cause the test code to be enabled. To run the tests, issue: ninja test.

`-Dvulkan-drivers=...`: This option allows choosing which Vulkan drivers are built. Since those drivers depend on the corresponding Gallium3D drivers, do not enable drivers that are not enabled in Gallium3D drivers. Furthermore, since BLFS does not use Vulkan, it is safe to leave the list of Vulkan drivers empty.

## Contents

Installed Programs: glxgears and glxinfo
Installed Libraries: libEGL.so, libGL.so, libGLESv1_CM.so, libGLESv2.so, libXvMCnouveau.so, libXvMCr600.so, libgbm.so, libglapi.so, libvulkan_intel.so, libvulkan_lvp.so, libvulkan_radeon.so, and libxatracker.so,
Installed Drivers: d3dadapter9.so (optional), crocus_dri.so, i915_dri.so, i965_dri.so, iris_dri.so, kms_swrast_dri.so, nouveau_dri.so, nouveau_drv_video.so, nouveau_vieux_dri.so, r200_dri.so (optional), r300_dri.so (optional), r600_dri.so, r600_drv_video.so, radeon_dri.so (optional), radeonsi_dri.so, radeonsi_drv_video.so, swrast_dri.so, virtio_gpu_dri.so, vmwgfx_dri.so, libvdpau_nouveau.so, libvdpau_r300.so (optional), libvdpau_r600.so, and libvdpau_radeonsi.so (Many of these drivers are hard-linked).
Installed Directories: $XORG_PREFIX/{include/{EGL,GL,GLES,GLES2,GLES3,KHR},lib/{dri,vdpau}}, $XORG_PREFIX/include/d3adapter (optional), $XORG_PREFIX/lib/d3d (optional), $XORG_PREFIX/share/drirc.d (contains workarounds for various applications, particularly browsers and games), $XORG_PREFIX/share/vulkan, and /usr/share/doc/mesa-21.3.6 (optional)

### Short Descriptions

glxgears | is a GL demo useful for troubleshooting graphics problems
glxinfo | is a diagnostic program that displays information about the graphics hardware and installed GL libraries
`libEGL.so` | provides a native platform graphics interface as defined by the EGL-1.4 specification
`libgbm.so` | is the Mesa Graphics Buffer Manager library
`libGLESv1_CM.so` | is the Mesa OpenGL ES 1.1 library
`libGLES2.so` | is the Mesa OpenGL ES 2.0 library
`libGL.so` | is the main Mesa OpenGL library

Last updated on

- Prev

  xcb-util-cursor-0.1.3

- Next

  xbitmaps-1.1.2

- Up
- Home