Skip to content

Instantly share code, notes, and snippets.

@Venemo Venemo/
Last active Jul 31, 2019

What would you like to do?
How to build and use mesa from source

Building mesa

Let's assume that you are using an x86_64 system.

Install dependencies

dnf install meson ninja-build cmake bison flex libvdpau-devel.x86_64 libvdpau-devel.i686 llvm-devel.x86_64 llvm-devel.i686 elfutils-libelf-devel.x86_64 elfutils-libelf-devel.i686 libva-devel.x86_64 libva-devel.i686 libomxil-bellagio-devel.x86_64 libomxil-bellagio-devel.i686 bison-devel.x86_64 bison-devel.i686 valgrind-devel.x86_64 valgrind-devel.i686 flex-devel.x86_64 flex-devel.i686 wayland-devel.x86_64 wayland-devel.i686 wayland-protocols-devel libxshmfence-devel.x86_64 libxshmfence-devel.i686 lm_sensors-devel.x86_64 lm_sensors-devel.i686 zlib-devel.x86_64 zlib-devel.i686 pkgconf-pkg-config.x86_64 pkgconf-pkg-config.i686 expat-devel.x86_64 expat-devel.i686 glib-devel.x86_64 glib-devel.i686 libdrm-devel.x86_64 libdrm-devel.i686 libX*-devel.x86_64 libX*-devel.i686 libunwind-devel.x86_64 libxcb-devel.x86_64 libxcb-devel.i686 

64-bit build

We're assuming that your distro uses lib64 for the 64-bit libraries. If not, adjust the meson command below. The compiled libraries will go into ~/mesa for the sake of simplicity.

cd mesa
meson build64 --libdir lib64 --prefix $HOME/mesa -Ddri-drivers= -Dgallium-drivers=radeonsi,swrast,iris -Dvulkan-drivers=intel,amd -Dgallium-nine=true -Dosmesa=gallium -Dtools=nir -Dbuildtype=release
ninja -C build64 install

32-bit build on an x86_64 system

If you don't use Fedora (or another Red Hat family distro), replace i686-redhat-linux-gnu-pkg-config with the correct 32-bit pkg-config executable for your distro. Create a meson cross file here: ~/.local/share/meson/cross/gcc-i686 with the following content:


c_args=['-m32', '-march=native']
cpp_args=['-m32', '-march=native']


Now you can use it to build 32-bit mesa libs:

cd mesa
meson build32 --cross-file gcc-i686 --libdir lib --prefix $HOME/mesa -Ddri-drivers= -Dgallium-drivers=radeonsi,swrast,iris -Dvulkan-drivers=intel,amd -Dgallium-nine=true -Dosmesa=gallium -Dtools=nir -Dbuildtype=release
ninja -C build32 install

Note that you can build both the x86_64 and the i686 libraries together and they can all go to ~/mesa, and then you can use all of that with either 32-bit or 64-bit games.

Using the compiled mesa

Create a script at ~/ with the following content:



export LIBGL_DRIVERS_PATH=$MESA/lib64/dri:$MESA/lib/dri
export VK_ICD_FILENAMES=$MESA/share/vulkan/icd.d/radeon_icd.x86_64.json:$MESA/share/vulkan/icd.d/radeon_icd.i686.json
export D3D_MODULE_PATH=$MESA/lib64/d3d/$MESA/lib/d3d/

Now you can just source and then anything launched from that terminal will use the mesa libs you just built.

Running Starcraft 2

Assuming that you completed all the steps so far, and you use a Wine prefix ~/.wineSC2 the following will launch SC2 using the specified mesa version:

source ~/
WINEDEBUG=-all NIR_VALIDATE=0 WINEPREFIX=/home/Timur/.wineSC2 wine64 "C:\Program Files (x86)\StarCraft II\Support64\SC2Switcher_x64.exe"

If you want to use iris:

source ~/
MESA_LOADER_DRIVER_OVERRIDE=iris WINEDEBUG=-all NIR_VALIDATE=0 WINEPREFIX=/home/Timur/.wineSC2 wine64 "C:\Program Files (x86)\StarCraft II\Support64\SC2Switcher_x64.exe"

Using NIR with radeonsi

Assuming you don't have a drirc file yet, create ~/.drirc with the following content:

    <device driver="radeonsi">
        <application name="all">
            <option name="radeonsi_enable_nir" value="true"/>

As of mesa master, the above will also make Gallium Nine use NIR with radeonsi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.