Note: This tutorial used this wiki article as a base.
https://www.paraview.org/Wiki/ParaView/ParaView_And_Mesa_3D
Before getting into details of Mesa graphics hardware drivers, a disclaimer. If you have graphics hardware Mesa is not your best option. To get the best performance from your graphics card you’ll need to install the vendor provided driver. Vendor provided OpenGL drivers are typically much faster of a much higher quality than Mesa’s which can be quite buggy. Many distros now provide third-party non-opensource source drivers through specialized package repositories. The details of installing vendor provided drivers in beyond the scope of this document. Please consult distro and/or vendor-specific documentation.
If you’re running a Linux OS with X11 and graphics hardware and have not installed any OpenGL libraries you’re probably already using Mesa or Nouveau! Note that the windowing system, in this case X11, is required for on-screen interactive rendering. On Linux systems the easiest way to install Mesa is through your distro’s package manager. Most distros also provide packages for Mesa’s software-based renderers as well. Unfortunately, some OpenGL features may be disabled by your distro’s package maintainers to avoid patent or other licensing restrictions. If you find that this is the case and if for some reason you do not want to use your graphics hardware vendor software then you’ll likely want to build Mesa from source.
1. Download, Build and Install LLVM
$ wget http://releases.llvm.org/7.0.1/llvm-7.0.1.src.tar.xz
$ mkdir llvm
$ cd llvm
$ tar -xvf /path/to/llvm-7.0.1.src.tar.xz
$ mkdir llvm_build
$ mkdir llvm_install
$ cd llvm_build
$ cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=/path/to/llvm_install \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_INSTALL_UTILS=ON \
-DLLVM_TARGETS_TO_BUILD:STRING=X86 \
../llvm-7.0.1.src
$ make -j8 install
2. Download, Build and Install Mesa
Mesa download usually contains llvm-dependent preprocessed files. We do not want that, as they may rely on another version of llvm so we download a specific version without these.
$ wget https://gitlab.freedesktop.org/mesa/mesa/-/archive/mesa-18.3.3/mesa-mesa-18.3.3.tar.bz2
$ mkdir mesa
$ cd mesa
$ tar -xvf /path/to/mesa-mesa-18.3.3.tar.bz2
$ cd mesa-mesa-18.3.3
$ autoreconf --force --verbose --install
$ cd ../
$ mkdir mesa_build
$ mkdir mesa_install
$ cd mesa_build
$ ../mesa-mesa-18.3.3/configure --prefix=/path/to/mesa_install \
--enable-opengl --disable-osmesa --disable-gallium-osmesa \
--enable-glx --with-platforms=x11 --disable-gles1 --disable-gles2 \
--disable-va --disable-gbm --disable-xvmc --disable-vdpau \
--disable-shared-glapi --disable-dri --with-dri-drivers= \
--enable-llvm --with-llvm-prefix=/path/to/llvm_install \
--with-gallium-drivers=swrast,swr --with-swr-archs=avx,avx2 --disable-egl
$ make -j8 install
In more recent version, mesa switched to meson build system, here is how to build it:
$ wget https://gitlab.freedesktop.org/mesa/mesa/-/archive/mesa-18.3.3/mesa-mesa-20.2.3.tar.bz2
$ mkdir mesa
$ cd mesa
$ tar -xvf /path/to/mesa-mesa-18.3.3.tar.bz2
$ mkdir mesa_install
$ cd mesa-mesa-20.2.3
$ meson -Dopengl=true -Dosmesa=none -Dglx=gallium-xlib -Dplatforms=x11 -Dgles1=disabled \
-Dgles2=disabled -Dgbm=disabled -Dshared-glapi=disabled -Ddri-drivers= -Dllvm=enabled \
-Dgallium-drivers=swrast,swr -Dswr-arches=avx,avx2 -Degl=disabled build \
-Dprefix=/path/to/mesa/intall .
$ ninja -C build/
$ ninja -C build/ install
3. Download and Build ParaView with mesa
Note : a glx related warning may be seen, that’s ok.
https://gitlab.kitware.com/paraview/paraview/issues/18777
$ mkdir paraview
$ cd paraview
$ git clone https://gitlab.kitware.com/paraview/paraview
$ cd paraview
$ git submodule update --init --recursive
$ cd ../
$ mkdir paraview_build
$ cd paraview_build
$ cmake -GNinja -DOPENGL_gl_LIBRARY=/path/to/mesa/install/lib/libGL.so \
-DOPENGL_INCLUDE_DIR=/path/to/mesa/install/include/GL \
-DOPENGL_EGL_INCLUDE_DIR= -DOPENGL_GLES2_INCLUDE_DIR= \
-DOPENGL_GLES3_INCLUDE_DIR= -DOPENGL_GLX_INCLUDE_DIR= \
-DOPENGL_egl_LIBRARY= -DOPENGL_gles2_LIBRARY= \
-DOPENGL_gles3_LIBRARY= -DOPENGL_glu_LIBRARY= \
-DOPENGL_glx_LIBRARY= -DOPENGL_opengl_LIBRARY= ../paraview
$ LD_LIBRARY_PATH=/path/to/llvm_install/lib ninja
Note : depending of your version of ParaView, some cmake options may be ignored. This is ok.
4. Run ParaView (5.6.0 and earlier versions)
To Run it with mesa :
$ LD_LIBRARY_PATH=/path/to/llvm_install/lib:/path/to/mesa_install/lib ./bin/paraview
Help -> About : OpenGL : Mesa, llvmpipe...
If you have your GPU hardware vendor driver installed and module loaded, you can still use it :
LD_LIBRARY_PATH= ./bin/paraview
Help->About : OpenGL : Nvidia ...
5. Run ParaView (master version)
Note : This may change fast, see here :
https://gitlab.kitware.com/paraview/paraview/issues/18780
To Run it with mesa :
$ LD_LIBRARY_PATH=/path/to/llvm_install/lib:/path/to/mesa_install/lib ./bin/paraview
Help -> About : OpenGL : Mesa, llvmpipe...
If you have your GPU hardware vendor driver installed and module loaded, you can still use it :
LD_LIBRARY_PATH=/path/to/llvm/install/lib/:/path/to/mesa/install/lib LD_PRELOAD=/usr/lib/libGL.so ./bin/paraview
Help->About : OpenGL : Nvidia ...