As reported by Phoronix, Nvidia has added render offloading to the beta 435.17 driver.
Official documentation: http://download.nvidia.com/XFree86/Linux-x86_64/435.17/README/primerenderoffload.html
What does this mean?
No more fudging around with optirun, xrun or switching GPUs to play games on Optimus notebooks.
[WIP] How do I get it?
You need to install some packages from AUR:
yay -Syu xorg-server-git nvidia-full-beta-all nvidia-utils-full-beta-all lib32-nvidia-utils-full-beta-all opencl-nvidia-full-beta-all
The opencl package isn't really necessary, unless you use some program that requires it.
I was using optimus manager, so remove it first:
yay -R optimus-manager
Allow nvidia-drm to load on boot by commenting stuff on
sudo nano /etc/modprobe.d/mhwd-nvidia.conf
Now add some lines to xorg.conf
sudo nano /etc/X11/xorg.conf.d/01-nvidia-offloading.conf
Section "ServerFlags" Option "IgnoreABI" "1" EndSection Section "ServerLayout" Identifier "layout" Option "AllowNVIDIAGPUScreens" Screen 0 "iGPU" EndSection Section "Device" Identifier "iGPU" Driver "modesetting" BusID "PCI:0:2:0" EndSection Section "Screen" Identifier "iGPU" Device "iGPU" EndSection Section "Device" Identifier "nvidia" Driver "nvidia" BusID "PCI:1:0:0" EndSection
In the documentation it says it should work out of the box, but I had to add the ignoreabi flag or the driver would refuse to load, after that the desktop would render to the dGPU, so I added the rest with the PCI ids to force to render the desktop on the iGPU.
If everything goes well it should be working already after a reboot. You can run vulkan programs on the dGPU with:
And openGL programs with:
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo
For wine, even if it uses dxvk, it's best to use both.
The only problem I found is that it doesn't power down the GPU, from what I read this only works on Turing (I have a 1050 Pascal).