Xorg uses nvidia gpu resources during wayland session on hybrid graphics laptop instead of XWayland

Hi!
I’m currently using KDE Plasma on Wayland with a Hybrid GPU Setup. At first, I was using the basic drivers and everything was smooth. Then, when I installed the nvdia drivers through ;nvidia-inst --conf on my hybrid graphics laptops, I saw some latency when typing and moving the mouse. Blender and Threejs do not run at more than 30 FPS. The GPU do not seems to be properly used.

If I used nvidia-inst --nouveau, it seems to be smooth, but then, the GPU is not being used. When I’m doing `nvidia-sim, it seems that the GPU is using Xorg instead of XWayland and that might be the problem.

System Settings:
Operating System: EndeavourOS
KDE Plasma Version: 5.27.1
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8
Kernel Version: 6.1.12-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 20 × 12th Gen Intel® Core™ i7-12700H
Memory: 15,4 GiB of RAM
Graphics Processor: Mesa Intel® Graphics
Manufacturer: LENOVO
Product Name: 82RF
System Version: Legion 5 Pro 16IAH7H

nvidia-smi

https://community.kde.org/Plasma/Wayland/Nvidia

cat /sys/module/nvidia_drm/parameters/modeset

basically if you are running Nvidia drivers and drm modesetting is enabled the default is that Optimus systems running on the igpu (intel) and you can switch Nvidia GPU on manually … or install one of the 23 (9 in real :wink: )implementations for switching:

https://wiki.archlinux.org/title/NVIDIA_Optimus#Available_methods

Or you go to enable the Nvidia GPU to be loaded on per default:
https://wiki.archlinux.org/title/NVIDIA_Optimus#Use_NVIDIA_graphics_only

In addition you need to check if the current issue with 12th Gen Intel CPU and the Nvidia Driver may affecting your system:

nvidia may not boot on Linux 5.18 (or later) on systems with Intel CPUs (likely only of 11th Gen and onward) due to FS#74886/FS#74891. Until this is fixed, a workaround is disabling the Indirect Branch Tracking CPU security feature by setting the ibt=off kernel parameter from the bootloader. This security feature is responsible for mitigating a class of exploit techniques, but is deemed safe as a temporary stopgap solution.

SOURCE