MesaLlvmpipe: Difference between revisions
(Created page with "How to build Mesa for software rendering with llvmpipe on Windows with Visual Studio 2015 These are the official instructions for building opengl32sw.dll which is shipped wit...") |
No edit summary |
||
Line 44: | Line 44: | ||
</pre> | </pre> | ||
Step 2: Get and build Mesa 11.2.2 | Step 2: Get and build Mesa 11.2.2 (or newer) | ||
<pre> | <pre> | ||
Line 63: | Line 63: | ||
Identification: | Identification: | ||
<pre> | |||
GL_VENDOR: VMware, Inc. | GL_VENDOR: VMware, Inc. | ||
GL_RENDERER: Gallium 0.4 on llvmpipe (LLVM 3.6, 128 bits) | GL_RENDERER: Gallium 0.4 on llvmpipe (LLVM 3.6, 128 bits) | ||
GL_VERSION: 3.0 Mesa 11.2.2 | GL_VERSION: 3.0 Mesa 11.2.2 | ||
</pre> | |||
Additional notes: | Additional notes: |
Revision as of 11:23, 11 November 2016
How to build Mesa for software rendering with llvmpipe on Windows with Visual Studio 2015
These are the official instructions for building opengl32sw.dll which is shipped with the binary Qt packages and are also available at http://download.qt.io/development_releases/prebuilt/llvmpipe/windows/
Based on http://qt-project.org/wiki/Cross-compiling-Mesa-for-Windows but without any special requirements for cross-compiling or tools and with some additional patches.
Note that the pre-compiled binaries provided on that wiki page are not able to run many Quick applications due to problems in the LLVM optimization passes. Hence we make our own build. This also gives us the ability to debug and fix/enhance things, if needed.
Prerequisites:
- Visual Studio 2015 (Update 2). All the steps below assume you are in a Visual Studio command prompt (32 or 64 bit, depending on the target DLL you want, but note that some of the configuration shown below may need adjustments accordingly)
- Python 2.7 (from python.org, not the ActiveState one, due to issues with installing libxml2 on the latter (update: not sure if this issue is still valid, the AS one may work now too, but not tested))
- scons 2.4.1 (the regular Windows installer from scons.org is fine) - Note that 2.5.0 is not compatible with Mesa 11.2, use an older version!
- cmake (Windows installer from the cmake website)
- flex, bison, m4
Note that Bison 2.7 seems to crash. Use 3.0 or the old 2.4.1 instead (available from gnuwin32).
Make sure all tools are available in the PATH.
Then install python packages:
- libxml2 for Python: Get the wheel file libxml2_python-2.9.3-cp27-none-ARCH.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs and run pip install <file>
- The Mako templating engine: pip install mako
Step 1: Get and build LLVM 3.6
wget http://llvm.org/releases/3.6.2/llvm-3.6.2.src.tar.xz
May need a win32 build of xz-utils to decompress it: http://tukaani.org/xz/
Configure it:
cmake -G "Visual Studio 14 Win64" -DLLVM_USE_CRT_RELEASE=MT -DLLVM_USE_CRT_DEBUG=MTd -DCMAKE_INSTALL_PREFIX=c:/work/mesa/llvm/bin .
This means the static libraries and other tools will be installed to c:\work\mesa\llvm\bin Leave out Win64 from the generator name when making 32-bit builds and having the x86 developer command prompt open.
Build it:
msbuild /p:Configuration=Release INSTALL.vcxproj
Step 2: Get and build Mesa 11.2.2 (or newer)
wget ftp://ftp.freedesktop.org/pub/mesa/11.2.2/mesa-11.2.2.tar.xz
Build it:
set LLVM=c:/work/mesa/llvm/bin scons build=release platform=windows machine=x86_64 libgl-gdi
Change to build=debug to get a debug build, but note that both LLVM and Mesa must be built in the same configuration. Change to machine=x86 to generate 32-bit builds.
The result is an opengl32.dll in build\windows-x86[_64][-debug]\gallium\targets\libgl-gdi. This provides a WGL and desktop OpenGL 3.0 implementation and is a drop-in replacement for the system's own opengl32.dll. There are two ways to use it: Copy it to a Qt executable's directory (since that is searched first when looking for DLLs) and launch the app. - OR - The modern way: ship it as opengl32sw.dll and set QT_OPENGL=software (or setAttribute(AA_UseSoftwareOpenGL in main()) to force it (this needs a -opengl dynamic build of Qt of course).
Identification:
GL_VENDOR: VMware, Inc. GL_RENDERER: Gallium 0.4 on llvmpipe (LLVM 3.6, 128 bits) GL_VERSION: 3.0 Mesa 11.2.2
Additional notes:
- Using opengl32sw.dll will trigger using a non-threaded render loop in Qt Quick, similarly to ANGLE. This is intentional. However, apps may want to set QSG_RENDER_LOOP=basic to prevent animations from running too fast! The default on Windows is "windows", which is not ideal for a non-throttled software rasterizer.
- The output is not really vsynced so native and naive OpenGL apps will run at random speed (although it is throttled to some extent). For Quick apps this is less of an issue, at least when the 'basic' render loop is in use.
- Run with QT_LOGGING_RULES=qt.qpa.gl=true and QSG_INFO=1 to verify what is going on.