Easy VSync with nvidia-xrun

I use nvidia-xrun to enable my optimus dGPU on demand, the only thing that was missing was actually working vsync.

After RTFM I finally found the solution: the nvidia-xrun script can be easily modified to enable vsync.

Just add modeset=1 to the line

 execute "sudo modprobe nvidia_drm"  

so it says

 execute "sudo modprobe nvidia_drm modeset=1"

I suggest making a user copy of the script for this.

That's it, working on-demand power with vsync.

If you are not using nvidia-xrun: that parameter can also be set as a kernel boot option: nvidia-drm.modeset=1

There is a guide on the arch wiki, this works too but you have to load the nvidia modules at boot for that. Arch and derivates make that easy via mkinitcpio, no clue how it works on other distros.

I use Manjaro with kernel 4.19 and nvidia 415.25.

Posted Dec 30, 2018, 9:31 AM UTC

34
_____frost___•
1
nonsensicalizationOP•

Hadn't seen that, good to see it's probably coming as a switch.

1
qgnox•

The only problem I get with modeset=1 in my optimus laptop is with some vulkan games (or using dxvk=vulkan) it freezes for a few seconds when trying to switch to another window or moving the mouse outside the game's window, I think is related to this report in nvidia forum.

1
comcastblowschunks•

Just a heads up, I think I ran into a bug with 4.15.0-43 and Nvidia 390

I was running "options nvidia_drm modeset=1" in /etc/modprobe.d and it was working great up until two days ago, then suddenly GDM refused to load at boot. The only thing I can tell that I did was a kernel update to 4.15.0-43.

Removing nvidia_drm modeset=1 and it worked again.

Edit: hmmm my optimus laptop is fine, maybe my problem is the old GT 640 that is in my poor desktop, guess I'll just have to tell the SO it is time for an upgrade!

1