I want to be able to run tests for openscad, but its tests require opengl to render figures and compare them, and it cannot correctly initialize the opengl context in checkPhase. I wonder if it is possible to have some sort of software renderer during package testing?
Mesa has llvmpipe which is a SW OGL renderer.
I’m not very familiar with how GL loading works but the usual flow is that the app is linked against against libGL and it in turn loads a suitable driver from /run/opengl-driver/lib/
at runtime.
To have a useful package at runtime, you must have it linked against libGL. I’d start by doing that and then setting "LD_LIBRARY_PATH=${mesa.drivers}/lib"
for the tests.
sadly this doesn’t work, I think maybe EGL offscreen rendering require some patching, but I am not familiar with graphics related stuffs.
Hm, yeah right, I do remember OGL having some odd dependence on an Xorg session in most Linux tooling.
Perhaps try xvfb_run
?
Thanks, I tried (with xvfb-run -d
) but it still doesn’t work regardless of whether EGL or GLX is used. I think I will just leave it until we found a way in the upstream to make headless rendering work without X or GPU. Maybe osmesa or something…
Are you able to run something simple inside the Nix drv like glxinfo or glxgears?
no, the command xvfb-run -d glxinfo
gives
name of display: :0
Error: couldn't find RGB GLX visual or fbconfig
update: I managed to get it working with mesa swrast by:
export LIBGL_DRIVERS_PATH=${mesa.drivers}/lib:${mesa.drivers}/lib/dri
export __EGL_VENDOR_LIBRARY_FILENAMES=${mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json
The __EGL_VENDOR_LIBRARY_FILENAMES
variable seems to be needed to let EGL find mesa loader, otherwise mesa will not be loaded. Perhaps because the egl_vendor.d
folder is not in known position when building?
LIBGL_DRIVERS_PATH
is for mesa loader to find its driver, by default it expects /run/opengl-driver/lib
.
With this, there is no need to run xvfb_run
, at least for my usecase. There are still a few test failures but I can probably find them out.