Windows Build Instructions
On Windows, OpenSWR is built using the SCons package as described in Mesa's installation page. OpenSWR also requires LLVM versions greater than 3.9.0 to build.
The instructions below describe how to build Mesa with OpenSWR support for Windows.
Mesa with OpenSWR requires the SCons package to build and install. SCons is available to download as an executable installer on SCons' download page. The latest version should be fine.
If you don't already have LLVM installed, you will need to install it first. LLVM requires CMake to build and install. CMake is available for Windows as an executable installer on CMake's download page. The latest version should be fine.
You will need a utility that can open and decompress
files. An easy-to-use (and free) graphical option for Windows is 7-zip, available on 7-zip's
Build and Install LLVM
Mesa with OpenSWR relies on LLVM, so you will need to build and install it first if you do not already have it. Please refer to the LLVM Windows build instructions with Visual Studio for a general overview, located here.
Once downloaded and decompressed, create a build directory to contain the built LLVM distribution. In this example, we build both the release and debug version of LLVM, though you can choose to only have one or the other.
Suppose we have LLVM extracted to
C:\LLVM\src with build directories
C:\LLVM\build-debug. We will install to
C:\LLVM\install-debug, respectively. Use
cmake to generate MSVC
.sln files, as follows:
cmake -D CMAKE_GENERATOR_PLATFORM=x64 ` -D LLVM_TARGETS_TO_BUILD=X86 ` -D LLVM_ENABLE_RTTI=1 ` -D LLVM_USE_CRT_DEBUG=MTd ` -D LLVM_USE_CRT_RELEASE=MT ` -D LLVM_ENABLE_TERMINFO=OFF ` -D CMAKE_INSTALL_PREFIX=C:\LLVM\install ` C:\LLVM\src
Note that, in theory, you only need to use one of
LLVM_USE_CRT_RELEASE, depending on whether you are building Debug or Release, but it
doesn't hurt to always include both in the cmake line.
The Mesa Windows SCons build has the peculiarity that you cannot mix debug and release versions of libs (see link error LNK2038). If you are planning of building both version of Mesa, you should also build both versions of LLVM. Below, I am assuming that we are building both.
Build both flavors of LLVM as shown below. The release version:
cd C:\LLVM\build-release cmake -D CMAKE_GENERATOR_PLATFORM=x64 ` -D LLVM_TARGETS_TO_BUILD=X86 ` -D LLVM_ENABLE_RTTI=1 ` -D LLVM_USE_CRT_DEBUG=MTd ` -D LLVM_USE_CRT_RELEASE=MT ` -D LLVM_ENABLE_TERMINFO=OFF ` -D CMAKE_INSTALL_PREFIX=C:\LLVM\install-release ` C:\LLVM\src cmake --build . --config Release cmake --build . --config Release --target install
and the debug version:
cd C:\LLVM\build-debug cmake -D CMAKE_GENERATOR_PLATFORM=x64 ` -D LLVM_TARGETS_TO_BUILD=X86 ` -D LLVM_ENABLE_RTTI=1 ` -D LLVM_USE_CRT_DEBUG=MTd ` -D LLVM_USE_CRT_RELEASE=MT ` -D LLVM_ENABLE_TERMINFO=OFF ` -D CMAKE_INSTALL_PREFIX=C:\LLVM\install-debug ` C:\LLVM\src cmake --build . --config Debug cmake --build . --config Debug --target install
Build Mesa with OpenSWR
First, clone the mesa repo. Full instructions are available on Mesa's repository page. In this case, you can simply clone the read-only repository.
git clone git://anongit.freedesktop.org/git/mesa/mesa
When building Mesa with OpenSWR, you must specify where LLVM is installed. In doing this, we can also specify which type of build we will do. For a debug Mesa build, link to the debug LLVM installation. Similarly, use a release LLVM for building release Mesa. For release builds:
set LLVM=C:\LLVM\install-release scons swr=1 libgl-gdi build=release
and for debug builds:
set LLVM=C:\LLVM\install-debug scons swr=1 libgl-gdi
Note that you have to modify the LLVM environment variable between debug and release builds.
If you want to compile OSMesa (for off-screen rendering support), simply add
SCons. For example:
set LLVM=C:\LLVM\install-release scons swr=1 libgl-gdi osmesa build=release
Using Mesa with OpenSWR
The build results in three DLL files:
opengl32.dllis located in
build\windows-x86_64\gallium\targets\libgl-gdi, and the SWR libraries are located in
build\windows-x86_64\gallium\drivers\swr. To make these libraries usable across the system, first make a backup of
C:\Windows\system32\opengl32.dll, then place the above DLLs in
C:\Windows\system32. If you plan to just run simple command line tests, you can simply place them in your current directory.
If you built with OSMesa, the libraries will be found under the
build\windows-x86_64\gallium\targets\osmesa directory. These can also be copied to
To use Mesa with OpenSWR, you will need to set OpenSWR as the gallium driver to use with the
GALLIUM_DRIVER environment variable:
Without this environmental variable set, the default Mesa
llvmpipe driver will be used.
When running with OpenSWR, you should see a message printed to the terminal stating that it found the appropriate architecture on your system:
SWR detected AVX2 instruction support (using: libswrAVX2.so).