bayasdev / envycontrol

Easy GPU switching for Nvidia Optimus laptops under Linux
MIT License
1.22k stars 62 forks source link

[BUG] Nvidia mode not fully working in Wayland #178

Open Reonu opened 1 month ago

Reonu commented 1 month ago

Describe the bug When using Nvidia mode, I expect every piece of software to only see and use the Nvidia GPU. However, many pieces of software, such as Blender (!), GPU Screen Recorder, Firefox, etc, as well as Wayland itself, run on the Intel GPU unless I launch them with the __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia env vars. I wouldn't expect these env vars to ever be necessary when using Nvidia mode. This doesn't seem to be the case in X11.

To Reproduce Steps to reproduce the behavior:

  1. Use Nvidia mode on Wayland
  2. Launch Blender or any other non-game app where you still want to use the Nvidia GPU.

Expected behavior All software should be running on the Nvidia GPU

Screenshots Not applicable

System Information:

Reonu commented 1 month ago

I've been looking at other issues and it seems that the reason Nvidia mode is not supported on Wayland is Nvidia not having proper Wayland support? This is no longer the case however, as Nvidia drivers starting from driver version 555 have proper Wayland support now. So could this be reconsidered? Is it possible to add Nvidia mode support now?

iriusas commented 3 weeks ago

I have the same problem, version 555 driver, I use wayland and envycontrol, but the applications use embedded graphics, although nvidia mode is set

bayasdev commented 3 weeks ago

Wayland is not supported as it requires a DE/WM specific logic to override the primary GPU.

I remember GNOME has a setting for that but at the time I tested Nvidia had completely broken Wayland support (only external screens worked and it was prone to crashes). For KDE I’m not sure.

dec05eba commented 3 weeks ago

On kde plasma wayland you can choose which device to use as the primary device by using the KWIN_DRM_DEVICES environment variable. You do it like this KWIN_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0 and it will prioritize card1 over card0. I tested it on an intel laptop with dedicated nvidia gpu and it works and it can display both the laptops monitor (powered by the intel iGPU) and the external monitor (powered by the nvidia dedicated gpu). You also need to have the nvidia-drm.modeset=1 kernel option set as you would expect

Impeta commented 2 weeks ago

On kde plasma wayland you can choose which device to use as the primary device by using the KWIN_DRM_DEVICES environment variable. You do it like this KWIN_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0 and it will prioritize card1 over card0. I tested it on an intel laptop with dedicated nvidia gpu and it works and it can display both the laptops monitor (powered by the intel iGPU) and the external monitor (powered by the nvidia dedicated gpu). You also need to have the nvidia-drm.modeset=1 kernel option set as you would expect

Bit off-topic but whereas this works like a charm and all, unfortunately Firefox of all, least on my end, refuses to just still keep using my Intel iGPU for hardware acceleration as long you keep your discrete NVIDIA card as your main graphic displays. Says this on my about:support: image Tried already MOZ_DRM_DEVICE=/dev/dri/renderD128, but that didn't seem to do any difference. So far, this seems to be the only drawback from switching to NVIDIA Wayland KWin. I'm sure there's a command to make it run on iGPU only, but to my research, there's none really. DRI_PRIME doesn't work.