User Tools

Site Tools


wiki:development:glx-xlib-workaround

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
wiki:development:glx-xlib-workaround [2020/01/23 18:28]
uli42 [Mesa 19 and newer]
wiki:development:glx-xlib-workaround [2021/10/25 21:01] (current)
uli42 [Usage]
Line 11: Line 11:
 Use a wrapper/proxy library provided by Mesa. The applications will use the supplied libGL.so, which in turn uses the lib interface to talk to the X server (nxagent) rather than the GLX interface. From the applications' perspective, they have GLX 1.4. Use a wrapper/proxy library provided by Mesa. The applications will use the supplied libGL.so, which in turn uses the lib interface to talk to the X server (nxagent) rather than the GLX interface. From the applications' perspective, they have GLX 1.4.
  
 +==== Compile ====
 +The general way to build the required library is this (see also https://mesa3d.org/llvmpipe.html):
 +  * download and extract tarball from mesa3d.org. Try with the newest and go down to older versions if you have problems with the newer one
 +  * ''cd mesa-<the version you downloaded>''
 +  * ''mkdir build''
 +  * ''cd build''
 +  * ''meson -D glx=gallium-xlib -D gallium-drivers=swrast -D platforms=x11 -D dri3=false -D dri-drivers="" -D vulkan-drivers="" -D buildtype=release -D optimization=3''
 +  * ''ninja''
  
 +==== Wrappers ===
 +Now you should find a libGL.so in ''src/gallium/targets/libgl-xlib''. This is the lib the your program need to load instead of the libGL of the system.
 +
 +Copy ''the src/gallium/targets/libgl-xlib'' directory to a place of your preference. Create two wrapper scripts ''~/x2goglx'' and ''~/x2goglx2''
 +
 +''x2goglx'':
 +<code>
 +#!/bin/sh
 +LD_LIBRARY_PATH=<your directory>/libgl-xlib:${LD_LIBRARY_PATH} exec "$@"
 +</code>
 +
 +''x2goglx2'':
 +<code>
 +#!/bin/sh
 +LD_PRELOAD=<your directory>/libgl-xlib/libGL.so.1 exec "$@"
 +</code>
 +
 +Make them executable and test them:
 +<code>
 +$ chmod u+rx x2goglx*
 +$ x2goglx glxinfo
 +$ x2goglx2 glxinfo
 +</code>
 +
 +Watch the output of the two glxinfo calls. You should see references to your mesa version and you should also see it reporting "GLX version: 1.4", e.g. (shortened):
 +<code>
 +...
 +server glx vendor string: Brian Paul
 +server glx version string: 1.4 Mesa 18.0.5
 +...
 +client glx vendor string: Brian Paul
 +client glx version string: 1.4 Mesa 18.0.5
 +...
 +GLX version: 1.4
 +...
 +OpenGL vendor string: VMware, Inc.
 +OpenGL renderer string: llvmpipe (LLVM 3.8, 128 bits)
 +OpenGL core profile version string: 3.3 (Core Profile) Mesa 18.0.5
 +...
 +</code>
 +
 +
 +Instead of creating the scripts mentioned above you can also add this to your .bashrc (or the config of your favourite shell):
 +<code>
 +export LD_LIBRARY_PATH=<your directory>/libgl-xlib:${LD_LIBRARY_PATH}
 +</code>
 +
 +==== Usage ===
 +Now you can use one of these created wrapper scripts to run your application: ''x2goglx <your application>''. Some apps modify ''LD_LIBRARY_PATH'' so the ''x2goglx'' could have no effect. In that case try ''x2goglx2''.
 +
 +If you still cannot succeed, you need to elaborate if your application needs some special treatment. If so, please add the solution to the end of this page or post it to the mailinglist for someone to add it here.
 +
 +
 +===== Versions / Platforms =====
 +The following chapters give some hints on how to compile the library on various combinations of platforms and mesa versions.
 ==== Mesa 19 and newer ==== ==== Mesa 19 and newer ====
-Please note: the instructions below are not current anymore since Mesa now mainly uses meson for building. Please consult https://mesa3d.org/llvmpipe.html for a basic compilation instruction. Since those instructions will not work out of the box (Error: "gallium-xlib conflicts +Please note: the instructions below are valid for older Mesa releases. In Mesa 19 //meson// is recommended for building. Please consult https://mesa3d.org/llvmpipe.html for a basic compilation instruction. Since those instructions will not work out of the box (Error: "gallium-xlib conflicts 
-with any dri driver") as of Mesa 19.3.2 you need to call meson with some further parameters like this:+with any dri driver") as of Mesa 19.3.2 you need to call //meson// with some further parameters like this:
 <code> <code>
 $ meson -D glx=gallium-xlib -D gallium-drivers=swrast -D platforms=x11 -D dri3=false -D dri-drivers="" -D vulkan-drivers="" -D buildtype=release -D optimization=3 $ meson -D glx=gallium-xlib -D gallium-drivers=swrast -D platforms=x11 -D dri3=false -D dri-drivers="" -D vulkan-drivers="" -D buildtype=release -D optimization=3
Line 29: Line 92:
 $ meson -D glx=gallium-xlib -D gallium-drivers=swrast -D platforms=x11 -D dri3=false -D dri-drivers="" -D vulkan-drivers="" -D buildtype=release -D optimization=3 $ meson -D glx=gallium-xlib -D gallium-drivers=swrast -D platforms=x11 -D dri3=false -D dri-drivers="" -D vulkan-drivers="" -D buildtype=release -D optimization=3
 $ ninja $ ninja
-$ LD_LIBRARY_PATH=`pwd`/build/linux-x86_64-debug/gallium/targets/libgl-xlib/:${LD_LIBRARY_PATH} glxinfo | grep 'GLX version:'+$ LD_LIBRARY_PATH=`pwd`/src/gallium/targets/libgl-xlib/:${LD_LIBRARY_PATH} glxinfo | grep 'GLX version:'
 </code> </code>
 +
  
 ==== Ubuntu 14.04 ==== ==== Ubuntu 14.04 ====
Line 83: Line 147:
 ebuild "/usr/portage/media-libs/mesa/mesa-${mesa_version}.ebuild" clean ebuild "/usr/portage/media-libs/mesa/mesa-${mesa_version}.ebuild" clean
 </code> </code>
 +
 +
 +===== NVidia driver / libGL =====
 +
 +On systems with a current (as of 2021) nvidia driver (including nvidia's libGL) instead of the above workaround you can try to run your application like this:
 +
 +<code>
 +__GLX_VENDOR_LIBRARY_NAME=mesa LIBGL_ALWAYS_SOFTWARE=1 <your application>
 +</code>
 +
 +===== Applications =====
 +==== Matlab 2019b ====
 +
 +Compile like this:
 +<code>
 +meson -D glx=gallium-xlib -D gallium-drivers=swrast -D platforms=x11 -D dri3=false -D dri-drivers="" -D vulkan-drivers="" -D buildtype=release -D optimization=3 -Dprefix=/usr/local/mesa-20.1.0/
 +</code>
 +
 +To make Matlab load the new driver modify Matlab's lib search path:
 +cp $MATLAB_DIRECTORY/bin/.matlab7rc.sh ~
 +
 +Edit the file ~/.matlab7rc.sh, find the glnxa* section and add ''/usr/local/mesa-20.1.0/lib/x86_64-linux-gnu'' to LDPATH_PREFIX
 +
 +Add to your .profile: export MESA_GL_VERSION_OVERRIDE=3.0
wiki/development/glx-xlib-workaround.1579804125.txt.gz · Last modified: 2020/01/23 18:28 by uli42