AMD/NVIDIA Laptop GPU's on Wayland: Almost Perfect

Hi,

It’s great to be able to use Wayland with switchable graphics: I have a laptop with a AMD Ryzen 5 5600H CPU (with integrated graphics) and a RTX 3060. This is the first distribution I’ve used which has this working almost “right out the box”.

It’s pretty good, although scrolling in Firefox can be sluggish, as well as video playback (when watching Widevine protected content). After I login, I only get output on my external monitor, when I run sudo modprobe nvidia-drm.

Is there anything I can do improve the performance, and how can I ensure nvidia-drm is being loaded automatically?

I had very janky scrolling in Firefox and found that going into about:config and disabling kinetic scrolling improved it a lot. It’s still not perfect but liveable.

I do not have thati ssue with firefox and i have a comparable setup.

If memory serves (granted might be out of date) firefox does not out of the box support native wayland, it needs to be explicitly told to run on native wayland. Launch command would be: MOZ_ENABLE_WAYLAND=1 firefox

Run echo $MOZ_ENABLE_WAYLAND to see if it’s set by default or not for you. I have it automatically set in my hyprland config which is possibly why i never had any issues.

You’re supposed to use prime-run to run things on the nvidia gpu, but it only really affects opengl applications by default (vulkan applications will by default just use the nvidia gpu)

You can use mangohud to check if the nvidia gpu is being used or not.

Did you install using systemd-boot or grub?
Edit: You can add nvidia-drm.modeset=1 to the command line in grub or the kernel command line for systemd-boot and then run the appropriate command to either update grub or reinstll kernels for systemd-boot.

If using grub you add it to /etc/default/grub and then run the grub update command sudo grub-mkconfig -o /boot/grub/grub.cfg

If running systemd-boot you add it to /etc/kernel/cmdline and then run sudo reinstall-kernels

I’m using systemd-boot. To my surprise, nvidia-drm.modeset=1 was already there. It still works as well as before.

I’ve added export MOZ_ENABLE_WAYLAND=1 to my ~/.bash_profile. Firefox seems a little more responsive, in terms of window management and scrolling.

I’m also noticing that the dedicated GPU memory usage is quite low, according to some output from nvidia-smi:

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A       783      G   /usr/lib/Xorg                                   4MiB |
|    0   N/A  N/A       928      G   /usr/bin/kwin_wayland                           2MiB |
+-----------------------------------------------------------------------------------------+

if it’s not on the list, it’s not being run on the nvidia gpu.

You can also use nvtop to see what is running on what gpu.

According the output from nvtop, It looks like most of the memory for the processor graphics is being used (I’m sorry this is a picture, couldn’t figure out how best to capture the output):

I’m also noticing this appearing ~30 times from “journalctl -xef”, when resizing the main window of Firefox:

kwin_scene_opengl: 0x3: GL_INVALID_OPERATION in glDrawBuffers(unsupported buffer GL_BACK_LEFT)

I wish I knew of a way to understand the cause of the graphical lag, whether it’s in kwin, the NVIDIA driver, or something else in between Firefox and the hardware. I’ve got some debugging experience, but mostly in user space with gdb.

Disabling kinetic scrolling may have had some effect, but only when the window is not maximized.

Your bios might have an igpu memory allocation setting, you might be able to increase it to 1GB.

I’ve just installed the GNOME desktop, and it seems to run much quicker with a X server, which I will stick with. EndeavourOS has made Wayland work as well as they can, with dual graphics cards, but, I think NVIDIA’s driver isn’t there yet. Thanks anyway though.

Well. I’m surprised. After installing OBS, and then while recording, Mutter and Firefox runs about as smoothly as it would under X11. Must be putting the GPU into high performance mode, somehow.

Using this test: https://testufo.com/framerates#count=1&background=stars&pps=960, I went from 30fps to 60fps.

I used this as a guide: https://forums.developer.nvidia.com/t/stutering-and-low-fps-scrolling-in-browsers-on-wayland-when-gsp-firmware-is-enabled/311127.

Oh the amd gpu performance mode can be manually manipulated, I remember having an issue where it didn’t ramp up correctly, that is supposed to be (in this context) up to the compositor (so gnome/kde)

Here’s how you can manually control it:
https://wiki.archlinux.org/title/AMDGPU#Performance_levels