Building ParaView with EGL MESA

Note: This tutorial is inspired by Building ParaView with GPU accelerated MESA and relatively recent mesa improvements.

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 want to build ParaView with EGL on Linux but you do not have access to a vendored EGL to use, you may want to use Mesa EGL for that !
You probably already have access to Mesa EGL through your package manager and you can probably use that to build ParaView with EGL.
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. Clone, Build and Install Mesa

mkdir mesa
cd mesa
git clone https://gitlab.freedesktop.org/mesa/mesa.git src
mkdir build install
cd src
meson setup ../build \
  -D egl=enabled     \ 
  -D gles1=enabled   \
  -D gles2=enabled   \
  -D platforms=x11   \
  -Dprefix=/absolute/path/to/mesa/install/ 
cd ../build
ninja install

2. Download and Build ParaView with mesa

mkdir paraview
cd paraview
git clone https://gitlab.kitware.com/paraview/paraview src
mkdir build
cd src
git submodule update --init --recursive
cd ../build
cmake -GNinja 
-DOPENGL_gl_LIBRARY=/home/glow/dev/vtk/deps/mesa/install/lib/libGL.so          \
-DOPENGL_INCLUDE_DIR=/home/glow/dev/vtk/deps/mesa/install/include/GL           \
-DOPENGL_EGL_INCLUDE_DIR=/home/glow/dev/vtk/deps/mesa/install/include/EGL/     \
-DOPENGL_GLES2_INCLUDE_DIR=/home/glow/dev/vtk/deps/mesa/install/include/GLES2/ \
-DOPENGL_GLES3_INCLUDE_DIR=/home/glow/dev/vtk/deps/mesa/install/include/GLES3/ \
-DOPENGL_GLX_INCLUDE_DIR=                                                      \
-DOPENGL_egl_LIBRARY=/home/glow/dev/vtk/deps/mesa/install/lib/libEGL.so        \
-DOPENGL_opengl_LIBRARY=/home/glow/dev/vtk/deps/mesa/install/lib/libGL.so      \
-DOPENGL_gles2_LIBRARY=/home/glow/dev/vtk/deps/mesa/install/lib/libGLESv2.so   \ 
-DOPENGL_gles3_LIBRARY=                                                        \
-DOPENGL_glu_LIBRARY=                                                          \
-DOPENGL_glx_LIBRARY=                                                          \
-DOPENGL_opengl_LIBRARY=                                                       \
-DVTK_OPENGL_HAS_EGL=ON                                                        \
-DVTK_USE_X=OFF                                                                \
-DVTK_DEFAULT_RENDER_WINDOW_HEADLESS=ON                                        \
-DPARAVIEW_USE_QT=OFF                                                          \
-DPARAVIEW_USE_PYTHON=ON
../src

Note : depending of your version of ParaView, some cmake options may be ignored. This is ok.

3. Run pvpython to check rendering

script.py:

Sphere()
Show()
SaveScreenshot("shot.png")

openGLInfo = GetOpenGLInformation()
openGLInfo.GetVendor()
openGLInfo.GetVersion()
openGLInfo.GetRenderer()
openGLInfo.GetCapabilities()
 LD_LIBRARY_PATH=/path/to/mesa/install/lib  LD_PRELOAD=/path/to/mesa/mesa/install/lib/libGL.so ./bin/pvpython script.py

You may have a warning about issues finding the right EGL device, you can select it by using the VTK_EGL_DEVICE_INDEX env var.

4. Run pvserver

LD_LIBRARY_PATH=/path/to/mesa/install/lib  LD_PRELOAD=/path/to/mesa/mesa/install/lib/libGL.so  ./bin/pvserver

Then just connect to it with another build of ParaView.

@jourdain

Thanks Mathieu, this is great. I will pass it around here at Sandia.

The common-superbuild now has a standalone-mesa project for building “just” Mesa. We use it to build Mesa SDKs for use in VTK wheel builds mainly, but if we can distill this down to a few flags there, that’d be great too.

I may give it a go

Here is a draft MR to add it, I will not spend more time on it I’m afraid.

https://gitlab.kitware.com/paraview/common-superbuild/-/merge_requests/562