WIP: Add org.freedesktop.Platform.GL{,32}.bumblebee
Description
This MR adds an extension that mounts the primus
package in the sandbox when a host Bumblebee daemon is detected by Flatpak. The primusrun
script can then be used to offload GLX rendering to the discrete GPU in Optimus laptops. At the moment a few manual additions to flatpak run
are required, so this is still work-in-progress.
TODO
-
Package primus
as a Flatpak extension for org.freedesktop.Platform.GL{,32}. – DONE -
Get primusrun
to offload GLX rendering for 64-bit and 32-bit executables. – DONE (see example below) -
Get primusrun
to offload GLX rendering for 32-bit executables relying on multilib libraries - DONE -
Add primusrun
to PATH for easier execution. – still need to figure out how. -
Add a debug build. -
Add support in Flatpak to detect inactive NVIDIA drivers. – done in side-branch. -
Add support in Flatpak to detect the Bumblebee daemon and expose its socket and X display. -
Figure out why --network
and--device=all
permissions are required to make this work. -
Bonus: investigate using EGL for rendering to eliminate X11 permission requirements.
Example
Prerequisites
- Optimus laptop with the integrated GPU used as default.
- NVIDIA drivers installed on the host and the same driver version installed in Flatpak.
- Bumblebee daemon running on the host.
Procedure
- Install the Bumblebee extensions:
$ flatpak install repo org.freedesktop.Platform.GL{,32}.bumblebee
- Run a Flatpak which relies on GLX rendering. I chose
org.freedesktop.GlxInfo
for this example, butcom.valvesoftware.Steam
would work as well:$ FLATPAK_GL_DRIVERS='nvidia-396-54:bumblebee' flatpak run \ --command=bash \ --device=all --share=network --filesystem=/run/bumblebee.socket --filesystem=/tmp/.X11-unix \ org.freedesktop.GlxInfo
modinfo nvidia -F version
to find the correct version, but make sure to replace.
with-
in the version string. - You can now offload GLX rendering using primusrun inside the sandbox:
bash-4.4$ /usr/lib/x86_64-linux-gnu/GL/bumblebee/bin/primusrun -- glxgears -info | grep RENDERER GL_RENDERER = GeForce GT 750M/PCIe/SSE2
com.valvesoftware.Steam
, edit a game's launch options as described in this support page. Make sure to specify the full path toprimusrun
as shown above.
CC: @valentindavid
Edited by Dor Askayo