Wayland + KDE 6 + Optimus Nvidia

Hey,

Im using newly installed EndevourOS + KDE 6 + Wayland + Nvidia optimus (550 drivers) over DisplayPort. (same happens via HDMI)

Is it a known issue that the external monitor has much worse performance on wayland?

I can log in to Plasma 6 with x11 and it works super smooth, but on wayland it is horribly capped.

If I pick 60Hz it displays in 30Hz. 165Hz is being rendered in 80.

I can move window on my laptop screen and there it runs smoothly.

Using envycontrol does not change anything.

It might be helpful if you post your hardware. Post the url if the command works.

inxi -Faz | eos-sendlog

Edit: Also cables matter. The quality and spec of cables make a difference.

https://0x0.st/Xs-G.txt - X11
https://0x0.st/Xs-5.txt - Wayland

Not sure if I follow you on that cable theory.
So how would cable matter depending on windowing system? Why would it work on X11 but not on Wayland?
That theory does not hold up, because if running 80Hz on 165Hz relates to the bandwidth being too small, it should be enough to keep 60Hz if I set such refresh rate, but then it drops to 30Hz.

Anyway, I completely agree - cable matters. But I don’t think that this is the case now, it’s not the cheapest cable I use.

I can also feel a significant lag in the input, like moving mouse cursor is a bit delayed, hard to maneuver. (again, only on Wayland)

I’m just reporting that cables sometimes can cause issues. There are differences in the standards and quality of cables. Not saying this has anything to do with your issue with any certainty only just to be aware as it can some times be an issue. Some cables that come with monitors are not very good quality and spec. DP is obviously better in my opinion but HDMI is okay also.

Do you have the Intel driver xf86-video-intel installed?

Edit: Also does this HP Omen have any GPU settings in the bios such as integrated, dedicated or hybrid?

Does this happen on wayland when using Intel or Nvidia GPU? On Wayland hardware info you sent it is rendering on Intel.

API: OpenGL v: 4.6.0 compat-v: 4.5 vendor: intel mesa v: 24.0.3-arch1.2
    glx-v: 1.4 direct-render: yes renderer: Mesa Intel Graphics (ADL GT2)
    device-ID: 8086:46a6 memory: 30.29 GiB unified: yes display-ID: :1.0

May be, but how do I even change it?

Why would X11 render on Nvidia, and Wayland on Intel? Is there any switch?
I run envycontrol -q while logged in into Wayland Plasma and it returns nvidia, I would guess that it should use nvidia, right?
What else should I do?

Edit: yeah I can confirm that it uses Intel.
When I run glxinfo on Wayland it return Intel,
when I run glxinfo on X11 it returns NVIDIA Corporation

I missed your previous message.

Do you have the Intel driver xf86-video-intel installed?

No, I will install it.

Edit: Installed → No changes at all.

Also does this HP Omen have any GPU settings in the bios such as integrated, dedicated or hybrid?

There is one option in BIOS and there are two selectable items, either:
Nvidia Advanced Optimus
Discrete

And Nvidia Advanced Optimus is set from the beginning, I don’t think that there is a reason to change it.

I just wanted to know if you had it installed and was going to suggest to remove it.

It seems from what info i can garner that you should be using prime render offload on this laptop since it has Nvidia Advanced Optimus built in. If you have anything else installed such as envy-control or optimus-manager i would remove that. I’m not an expert on these Hybrid laptops and they all seem to work a little differently. Also being that it’s on Wayland I’m not sure. I myself have no issues on my desktop running Wayland with Nvidia on a GTX 1060 with Kde.

https://download.nvidia.com/XFree86/Linux-x86_64/435.17/README/primerenderoffload.html

Edit: You could also try this:

https://wiki.archlinux.org/title/Supergfxctl

I installed that supergfxctl but it was already set to “Hybrid” and there are only 2 options, Hybrid and Integrated, and I knew that Integrated is a bad idea anyway, but wanted to give a try.
After reboot screen was blinking and the greeter was not loading, so I set it back to Hybrid and uninstalled the app.

Anyway, after setting some environment variables I think that I was able to start NVIDIA driver for Wayland:
https://0x0.st/XsKZ.txt

#/etc/environment
DRI_PRIME=pci-0000_01_00_0
__VK_LAYER_NV_optimus=NVIDIA_only
__GLX_VENDOR_LIBRARY_NAME=nvidia
WLR_NO_HARDWARE_CURSORS=1
GBM_BACKEND=nvidia-drm

and also dracut modules:

force_drivers+=" nvidia nvidia_modeset nvidia_uvm nvidia_drm "

Now glxinfo returns different info:

❯ glxinfo | grep 'OpenGL renderer'
OpenGL renderer string: NVIDIA GeForce RTX 3080 Ti Laptop GPU/PCIe/SSE2

But anyway, no changes, screen continues to be laggy.
Probably I’m still missing something.

Oh god, nvidia… here we go again.

EDIT:

glxgears run at 30FPS on Wayland - 165FPS on X11 - both DMs have 165Hz set.

Ya it’s just so odd because i have my desktop running on Wayland with Nvidia GTX 1060 and have no issues. I don’t need all those environmental variables or some of the things in dracut either. The only thing i have installed extra for nvidia is one file or package but i’ll have to check what it is on that machine. Also i only have a 60 Hz monitor. lol

Do you own Intel + Nvidia GPU or just Nvidia?

This is the third time I’ve been duped into buying a laptop with Optimus. I won’t make that mistake again… It’s the same every time, this hardware never works properly.

I have the same issue on my Lenovo Legion 5 Slim 2023 with Optimus (i7-13700h/nvidia 4060), also on wayland + plasma 6. When I connect the external monitor via HDMI with the system in hybrid mode, framerates of my display get almost halved.

Boring technical problem summary

Ironically, the issue here is the iGPU (or kwin_wayland usage of the iGPU), because it needs to copy the frame buffer twice, as the HDMI output is connected to the nvidia dGPU, and it’s not fast enough to do it.

This is a “well-known” issue and it’s really noticable on mixed frequency displays (my laptop screen is at 165 and monitor at 144hz).

There are some merge requests for KWin to support dynamic DMA-fence deadline (boost GPU clock speed to complete render on time, https://www.phoronix.com/news/KDE-KWin-DMA-Fence-Deadline), and support for triple buffering to prevent framerate issues. KDE 6.1 should be released with these improvements merged (hopefully we also get improved Optimus support in nvidia drivers by then).

You can try to set NVIDIA as the primary GPU for your KWin compositor on wayland, with this in your environment

KWIN_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0

This works well for me and apps on both my displays run with their native 165/144 hz without any frame drops.

Thanks, does not really work for me.
Not sure if because I did all of the changes, or simply due to my laptop’s specification, and it uses Intel and still 40FPS in glxgears.

I removed other env variables but still no luck.

I don’t mind using X11, but there is still plenty of work to make Wayland work as expected.

Indeed, I am another user with the infamous optimus, reverse what-have-you setup :slight_smile:
My challenge is that I need to run both cards in parallel so the Intel GPU powers external monitor 1, and nVidia external monitor 2.
After some troubleshooting and a bit of reading up, it looks likethat this setup requires some sort of “reverse” protocol which isn’t implemented on Wayland yet.

Good thing is that the recent fixes in Plasma 6.0.2 fixed an issue where the system would freeze when coming out of powersafe which means my X11 setup works as stable as pre Plasma 6x.
So all is good for me with X11.

It should work™. Check if the kwin_drm_devices environment variable is applied correctly in your kwin_wayland process, this oneliner should help you (run it inside your plasma wayland session)

cat /proc/$(pidof kwin_wayland)/environ | tr '\0' '\n' | grep -i kwin

To make sure your variable is appled correctly (before kwin_wayland starts), you can export it in the global profile. Create a file /etc/profile.d/kde.sh with just this content

export KWIN_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0

and reboot.

If the variable is applied correctly, it could happen that simple drm device messed up the DRI nodes order, then you can show us what is the output of

ls -l /dev/dri/by-path/

if card0 is mapped to nvidia, and card1 to intel, then you would need to switch that in KWIN_DRM_DEVICES variable, too.

2 Likes

Holy J!
I reinstalled my whole system ( again :upside_down_face: ) to check this out. But I anyway prefer KDE over Gnome which I installed after this wireplumber drama.

So, I was this close to run Wayland KDE over Nvidia card yesterday.
In my case the cards are in the opposite order.

KWIN_DRM_DEVICES=/dev/dri/card0:/dev/dri/card1

And it generates 165 Hz output, I didn’t even have to log in again after saving /etc/environment.
I owe you! I can give you a coffee tip if you’re willing to take it.

Thanks!

1 Like

It’s a desktop so the Intel Cpu has onboard graphics and i have an Nvidia Gpu. Glad to see someone was able to help you get it working. I don’t have any laptops with Hybrid graphics.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.