headless and non-headless OpenGL at the same time

Hello -
I have written a QT gui application that can also be run in a command-line server mode.
My workstation is configured for normal desktop gui usage and the application works fine when launched from the X desktop session, running the app in either gui mode or server mode.

But I want to optionally run my app remotely, from an ssh terminal, in its server mode.
I’m beginning to think I need to do some custom nvidia-xsession tweaking.

The qt app launches in my ssh session using the qt -platform offscreen arguments but can not initialize opengl.
I have been able to run the app using xvfb-run (without -platform offscreen) which then initializes OpenGL ES but reports that GLSL 3.30 is supported. I am looking to get the full capabilities of OpenGL 4.x drivers on my Pascal (1080) gpu.

Is xvfb-run an appropriate path for this use case or have I hit a dead end at GL ES?
Is there some lower level config that will enable my app to run in this mode?

xvfb is a virtual framebuffer xserver which will always use mesa software rendering. To have nvidia gl you’ll have to connect to a real xserver running on the nvidia gpu, e.g.
DISPLAY=:0
which requires that your user has access rights to the xserver running on :0
Though I don’t really get why you’re using the offscreen plugin, which is meant for testing purposes, i.e. creating a gui without actually drawing it.

My app decides based on its own command line args whether to display a gui or not. In the “server mode” case, I still depend on QT libraries but don’t present any windows. The app is doing opengl 4.x rendering tasks (needless to say?).

I was only using the QT offscreen plugin to confirm whether I could get the app to launch at all.
If I run in the ssh terminal with the default QT platform plugin (seems to be xcb) I get this error:

qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

Do I need to start a headless x server within that ssh session and then run my app? If so, can I do that without changing the behavior of the regular desktop x sessions that run on the same computer?

VirtualGL might be an option, but it’s hard to say with the limited information you’ve given. What exactly does your app do when in server mode as compared to gui mode?

I initialize OpenGL the same way in both modes, before any windows are created:
Using QT for cross-platform context creation, I do a sequence like

  • create a QSurfaceFormat
  • create a QOpenGLContext
  • create a QOffscreenSurface
  • call makeCurrent on the new context with the new offscreen surface.
    Then I do my own opengl api function pointer loading using the glad library.

The differences arise after this code has already run, in which I create a QMainWindow if in gui mode but not when in server mode.

I was more interested in the usage patterns of gui and server mode. Would you be satisfied if gui mode worked from an ssh session? This could be achieved with VirtualGL. Or are there other reasons for server mode? It’s possible for some time now to use OpenGL without X (offscreen context is created via EGL and OpenGL is provided by the new LibOpenGL.so that came with GLVND), but I think Qt cannot do this yet.