lavapipe is a CPU driver for Vulkan. It is included with the Mesa graphics drivers for Linux, but can be compiled and used on Windows as well.
This guide contains step-by-step instructions on how to compile and install lavapipe.
To build Mesa, some additional programs are required.
First of all, a C/C++ compiler is needed. MSVC works in Visual Studio 2015 or higher.
Mesa uses the Meson build system. Releases are available at https://github.com/mesonbuild/meson/releases.
CMake is also required in order to build LLVM.
Python and the Mako module are required as well.
Also, Win Flex-Bison is required. It can be downloaded at https://sourceforge.net/projects/winflexbison/. The downloaded ZIP file needs to be extracted and the extracted folder needs to be added to the PATH variable.
The first step is rather simple: We need to clone the Mesa repository. To clone the repo, enter:
git clone https://gitlab.freedesktop.org/mesa/mesa.git mesa
lavapipe depends on LLVM, so LLVM also needs to be cloned:
git clone https://github.com/llvm/llvm-project.git llvm
As the next step, we need to compile LLVM.
First, we cd into the cloned directory:
cd llvm
We will build into the build folder, which we need to create beforehand:
mkdir build
LLVM includes multiple backends; we only need the x86 backend, so we specify -DLLVM_TARGETS_TO_BUILD=X86 as a CMake option.
If you want, you can also change the install location using the CMAKE_INSTALL_PREFIX variable.
If you don't change the install prefix, the files will be installed to C:\Program Files (x86)\LLVM. You will need to run your generator as administrator so it can write to this folder.
We'd also like to optimize the code, so we add -DCMAKE_BUILD_TYPE=Release.
The main CMakeLists.txt file is in the llvm subdirectory of the cloned directory. An example command line could therefore look like this:
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_INSTALL_PREFIX=C:\path\to\llvm\install -S llvm -B build
After the build files have generated, build the INSTALL target with your generator.
Meson now needs to find the LLVM binaries in order to link them. We provide the path to llvm-config (which was built as part of LLVM) via a Meson native file.
Switch to the cloned Mesa directory and create a new file named LLVM_location.ini. The file should contain the following:
[binaries]
llvm-config = 'C:\path\to\llvm\install\bin\llvm-config.exe'
Now we have everything set up to build lavapipe.
Again, we create a build directory, and switch to it:
mkdir build && cd build
We build lavapipe using meson. We again specify a Release build type. Also, we specifically select that we want to build lavapipe only and disable building OpenGL drivers. We also specify the native file we just created. You can again choose an install prefix, here it is kept in the root of the cloned Mesa repo.
meson --prefix=C:\path\to\mesa\install -Dbuildtype=release -Dopengl=false -Dvulkan-drivers=swrast .. --native-file ../LLVM_location.ini
To compile, enter
meson compile -C .
To install the compiled binaries to the directory specified in the prefix, enter
meson install
Now, lavapipe needs to be registered as an ICD for the Vulkan loader to recognize and load it when a Vulkan application launches.
A JSON file that identifies the ICD and specifies the location of the driver DLL.
For that, we need to modify the registry, so we launch regedit.exe.
Go to HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\Drivers and create a new DWORD-key.
The name of the new key should be the path to the ICD JSON file. The ICD JSON is contained in the install directory. With the settings used here, it is located in C:\path\to\mesa\install\share\vulkan\icd.d\lvp_icd.x86_64.json.
The value of the new key should be 0.
With that, lavapipe should be running. If vulkaninfo doesn't detect lavapipe running (and a loader error message doesn't reveal the error right away), you can try looking for hints by enabling more verbose debug output by setting the environment variable VK_LOADER_DEBUG=all. Also, the Vulkan Installation analyzer (vkvia) in the Vulkan SDK might show information about if the driver was found and if there were errors loading it.