Playing with EGL+OpenGL Off-screen Multi-Card

So I've now spent the last day and a half playing with getting EGL offscreen rendering working on Linux. There are two major ways to do off-screen rendering with EGL and OpenGL. In the first, you use a pbuffer surface, that surface is basically a purpose-defined surface-type for off-screen backing of a renderer. When I use the EGL enumeration API we always seem to get pbuffer compatible visuals (and *not* window compatible ones).

On Ubuntu 18.04 the enumeration API seems to be... problematic, lots of segfaults, particularly with the VirtualBox driver that shows up in the enumerations. On Ubuntu 19.10 the behaviour is much more reliable, with all 3 GPUs in my prime-based nVidia/Intel laptop (including the VirtualBox GPU) completing the OpenGL query for version, extensions, etc. The missing bit is being able to specify which GPU to use, as the EGL query API doesn't seem to have a way to get a "name" that a user would recognise to describe the card.

The second way to do EGL offscreen is to use a GBM device, which does *not* seem to work with nVidia binary drivers, but does seem to run on Intel and VirtualBox GPUs. The nice thing about the GBM devices is that you can tell which device you are selecting, so you can say "run with /dev/dri/card1" and know that we should wind up running on that particular GPU. Weirdly, the Intel card seems to support pbuffer when run via EGL device query, but only window when run with gbm. Because the Intel device doesn't seem to run with the query on Ubuntu 18.04, the gbm device is still useful (it may also have a performance benefit, but I haven't looked at that).

You can see the work in the develop branch of PyOpenGL on github. If you have an exotic platform which should support EGL+OpenGL, feel free to check out the branch and see what fails. One thing I should note is that I'm using "multi gpu" here more to mean "targetting a particular GPU" not "running two GPUs at once", as I expect there are function pointer caches in PyOpenGL which would mean that running two different OpenGL implementations in the same process would result in segfaults and/or rendering on the wrong context.

Comments

Comments are closed.

Pingbacks

Pingbacks are closed.