Daemon icon indicating copy to clipboard operation
Daemon copied to clipboard

Tool for headless OpenGL compilation

Open slipher opened this issue 4 years ago • 12 comments

The test-compile-glsl program creates an OSMesa (offscreen Mesa) context, compiles the GLSL shaders, and exits. This could be used in a CI script to ensure shaders compile as suggest by @illwieckz. On Debian I was able to get OSMesa by sudo apt install libosmesa6-dev. Enable in CMake by -DBUILD_TEST_COMPILE_GLSL.

GLEW supposedly has a linux-osmesa flavor. I built that and tried to use it, but it just returned null pointers for the functions (in the same way as that crashing bug with 0.51 on Mac). So I had to disable GLEW for this binary. I wonder if we could get rid of GLEW altogether? Just get the extension function pointers and store them in the glconfig2 struct. It doesn't seem like GLEW does anything that difficult, but I'm probably missing something.

For testing against an old version of GLSL, the GLSL compiler directives seem to be the key. #version at the beginning determines what version of the shading language is allowed, and additional #extension directives can enable more functions. Bitwise operators in GLSL<1.3 are controlled with one of these directives. The OpenGL version doesn't seem to be important, so I didn't request a specific version for the context. Anyway the lowest "core profile" is 3.1 so it's not possible to restrict yourself to 2.1.

slipher avatar Jul 23 '21 08:07 slipher

Hmm, I was more thinking about running the engine in an headless X11, so we can do everything an user can do, testing any OpenGL version or extension provided by Mesa llvmpipe software OpenGL driver to catch regressions like the GLSL 1.20 one, to load a nexe game (to catch compatibility breakage) or also run a demo (to catch crashes like the particle one), etc.

Of course this would make the CI much more complex, as may need to download the actual Unvanquished release, but that would be more reusable and less intrusive to the daemon code itself.

illwieckz avatar Jul 23 '21 17:07 illwieckz

Hmm, I was more thinking about running the engine in an headless X11, so we can do everything an user can do, testing any OpenGL version or extension provided by Mesa llvmpipe software OpenGL driver to catch regressions like the GLSL 1.20 one, to load a nexe game (to catch compatibility breakage) or also run a demo (to catch crashes like the particle one), etc.

Catching the particle one could already be done by running the ttyclient, as that crash happens in the cgame. The ttyclient includes pretty much everything except rendering and input code.

This tool may be useful to have a cross-platform way to test the shaders instead of depending on the CI or a special environment. As an alternative, we could try just adding a cvar to force the shading language #version directive, and perhaps a script that sets the version and other cvars to disable extensions, to simulate a minimal supported environment. However, this depends on GL vendors reliably implementing language versioning; I'm not sure if they all do that or if some will be like the Microsoft C++ compiler in not having any support for specific standard versions.

The tool could also be used to test combinations of different extensions being enabled (in case starting the whole renderer is too slow). Not sure if there are any interesting interactions or if an all on/all off test would be good enough.

slipher avatar Jul 23 '21 19:07 slipher

Catching the particle one could already be done by running the ttyclient, as that crash happens in the cgame. The ttyclient includes pretty much everything except rendering and input code.

Oh that's good to know! We may want to run a demo with the tty at CI time.

This tool may be useful to have a cross-platform way to test […]

Yeah, sure.

The tool could also be used to test combinations of different extensions being enabled (in case starting the whole renderer is too slow). Not sure if there are any interesting interactions or if an all on/all off test would be good enough.

There are some cases with old hardware able to compile shaders for low presets but not able to compiler shaders for higher presets…

illwieckz avatar Jul 23 '21 20:07 illwieckz

Anyway, I also now have a script to run the game on Linux on an headless X server, I wrote it today and it already helped me to catch and fix one regression from #478 by running a 16-bit desktop, and even catch and revert a compat breaking change in the same PR. I got them at the first run of my script… This is so useful. I don't know where I can store that file, maybe on Dæmon repository because that would make it available to Unvanquished as well and from CI tools for both engine and game.

illwieckz avatar Jul 23 '21 20:07 illwieckz

Besides extensions (and extension-disabling cvars) there are some cvars which control whether certain shaders are compiled at all, including:

r_dynamicLight
r_reflectionMapping
r_bloom
r_liquidMapping
r_ssao
r_FXAA

slipher avatar Jul 23 '21 23:07 slipher