You are not logged in.

#1 2021-10-16 10:06:11

michelesr
Member
Registered: 2016-02-04
Posts: 64

[SOLVED] FPS half the refresh rate with Xwayland offloading (NVIDIA)

NVIDIA drivers recently introduced PRIME offloading support on XWayland. In practice, that means that you can run a Wayland compositor (such as Sway) with the iGPU and then use the discrete NVIDIA graphic card when launching X11 clients on XWayland (running them using the prime-run wrapper which sets relevant environment variables).

I'm using prime-run on Sway to run 3D applications with the NVIDIA card, however, when they are fullscreen, Sway uses direct scan-out, which from my understanding means disabling the composition and giving full control of the screen buffer to the application. If you have the nvidia_drm module loaded, that will attempt to perform vertical synchronization, removing tearing, but that seems to lock the framerate to half the screen refresh rate. Obvious workaround is not to run the app in fullscreen (and emulating fullscreen e.g. by hiding windows borders/decorations and tray bar). When the app is not fullscreen, the framerate is correctly capped to the screen refresh rate.

Another weird artifact I've sometimes noticed when running non fullscreen is a sort of diagonal tearing (a diagonal line diving the screen in half), so I thought somehow there something on the hardware/buffer level that is expecting half the rate to be properly synchronized?

Did someone experience this issue? Is it specific to Sway or other compositors with direct scan-out as well? Any solution?

EDIT: I tried to reproduce the issue on GNOME and KDE and I couldn't, even though on the paper they seem to support direct scan-out for fullscreen applications... so maybe it's Sway after all.

Last edited by michelesr (2023-04-27 10:17:21)

Offline

#2 2021-10-17 00:53:47

gnox
Member
Registered: 2013-05-18
Posts: 81

Re: [SOLVED] FPS half the refresh rate with Xwayland offloading (NVIDIA)

What HW do you have? ..

I've got and amdgpu+nvidia laptop and my tests with Prime Offload are a bit different also using sway and kde:

- When I dont load the nvidia_drm only nvidia, nvidia_modeset, nvidia_uvm, the fps are 60-70% of what I expect running on xorg (reverse prime or prime-offload)
- If I load nvidia_drm I've got better fps and sync but  a lot of stutter or small corrupted glitches in the image

I think is not yet fully implemented the prime-offload on xwayland looking at this comments :
- This is not yet merged https://gitlab.freedesktop.org/xorg/xse … quests/766
- https://github.com/NVIDIA/egl-wayland/i … -931575699

Offline

#3 2021-10-25 00:01:00

michelesr
Member
Registered: 2016-02-04
Posts: 64

Re: [SOLVED] FPS half the refresh rate with Xwayland offloading (NVIDIA)

gnox wrote:

What HW do you have? ..

Dell XPS 9570, Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz, Intel(R) UHD Graphics 630, NVIDIA GeForce GTX 1050 Ti

Offline

#4 2022-01-12 22:12:53

jotch
Member
Registered: 2022-01-12
Posts: 1

Re: [SOLVED] FPS half the refresh rate with Xwayland offloading (NVIDIA)

After asking on the #sway IRC, I found a potential solution (works for me on a Dell XPS 9500, 1650 Ti): `max_render_time`. The man page for `sway-output` says to set it to 1 and increase until things run smoothly (testing via `swaymsg`). For me value of 5 had no dropped frames for windowed/fullscreen.

Offline

#5 2022-01-12 23:19:26

michelesr
Member
Registered: 2016-02-04
Posts: 64

Re: [SOLVED] FPS half the refresh rate with Xwayland offloading (NVIDIA)

jotch wrote:

After asking on the #sway IRC, I found a potential solution (works for me on a Dell XPS 9500, 1650 Ti): `max_render_time`. The man page for `sway-output` says to set it to 1 and increase until things run smoothly (testing via `swaymsg`). For me value of 5 had no dropped frames for windowed/fullscreen.

Glad you managed to make it work. I was advised to do the same some time ago in the #sway IRC channel, but it didn't work for me.

I've run `prime-run glxgears` fullscreen and I still get 30 FPS, regardless of the value of `max_render_time` (60 FPS in windowed mode)

Just to double check:

- is sync enabled in your setup? (I think it's the nvidia_drm module providing the PRIME sync functionality, which in turns ensures FPS are in sync with refresh rate) 
- can you give me the exact steps to reproduce the issue and the workaround? (e.g. what you get before, and what you do, and what you get after)

Thanks for your help!

Offline

#6 2022-01-13 00:06:32

gnox
Member
Registered: 2013-05-18
Posts: 81

Re: [SOLVED] FPS half the refresh rate with Xwayland offloading (NVIDIA)

its the driver: https://forums.developer.nvidia.com/t/g … /185278/13

Still not fixed with latest  beta driver 510.x ..

Offline

#7 2022-02-03 19:12:37

NGStaph
Member
Registered: 2021-04-11
Posts: 34

Re: [SOLVED] FPS half the refresh rate with Xwayland offloading (NVIDIA)

Fixed on 42 beta + nvidia 510

Edit: spoke too soon, following issue here: https://gitlab.freedesktop.org/xorg/xse … ssues/1317

Last edited by NGStaph (2022-05-15 16:47:24)

Offline

#8 2022-02-14 15:20:22

michelesr
Member
Registered: 2016-02-04
Posts: 64

Re: [SOLVED] FPS half the refresh rate with Xwayland offloading (NVIDIA)

Fixed on 42 beta + nvidia 510

Still having this issue with nvidia 510.47.03

Offline

#9 2022-02-14 15:28:24

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,657

Re: [SOLVED] FPS half the refresh rate with Xwayland offloading (NVIDIA)

Literally "half the refresh rate" means you have issues with vsync and missing the sync interval. Since Wayland basically mandates VSync, make sure it is disabled in your game if you have the explicit option to disable it.

Offline

#10 2022-02-14 19:05:07

michelesr
Member
Registered: 2016-02-04
Posts: 64

Re: [SOLVED] FPS half the refresh rate with Xwayland offloading (NVIDIA)

Literally "half the refresh rate" means you have issues with vsync and missing the sync interval. Since Wayland basically mandates VSync, make sure it is disabled in your game if you have the explicit option to disable it.

Disabling V-Sync doesn't help unfortunately. When the app is fullscreen it stills syncs to half screen refresh rate, and when in window mode, it runs unlimited (instead of syncing to the actual refresh rate as when V-Sync is enabled.)

Even simple apps such as glxgears have this problem.

Offline

#11 2022-03-03 10:38:37

michelesr
Member
Registered: 2016-02-04
Posts: 64

Re: [SOLVED] FPS half the refresh rate with Xwayland offloading (NVIDIA)

Looks like an issue has been opened to track this specific problem here: https://gitlab.freedesktop.org/xorg/xse … ssues/1317

Last edited by michelesr (2022-03-03 10:38:48)

Offline

#12 2022-12-07 19:26:15

NGStaph
Member
Registered: 2021-04-11
Posts: 34

Re: [SOLVED] FPS half the refresh rate with Xwayland offloading (NVIDIA)

Resolved?

Last edited by NGStaph (2022-12-07 19:26:41)

Offline

#13 2022-12-07 22:53:53

michelesr
Member
Registered: 2016-02-04
Posts: 64

Re: [SOLVED] FPS half the refresh rate with Xwayland offloading (NVIDIA)

Partly: the diagonal tearing is gone, but using fullscreen with direct scan-out on Sway with nvidia_drm loaded still caps the FPS to half the refresh rate of the screen, only workaround being either disabling the direct scan-out or using a maximized window and hiding the tray bar.

Offline

#14 2023-04-27 08:33:42

michelesr
Member
Registered: 2016-02-04
Posts: 64

Re: [SOLVED] FPS half the refresh rate with Xwayland offloading (NVIDIA)

I've been testing on GNOME again, with direct scanout (I've verified that the fullscreen app is bypassing the compositor using debug painting of damage regions and also logging of KMS on the journal), and the problem is not reproducible. I can only reproduce with sway/wlroots.

Offline

#15 2023-04-27 10:16:52

michelesr
Member
Registered: 2016-02-04
Posts: 64

Re: [SOLVED] FPS half the refresh rate with Xwayland offloading (NVIDIA)

jotch wrote:

After asking on the #sway IRC, I found a potential solution (works for me on a Dell XPS 9500, 1650 Ti): `max_render_time`. The man page for `sway-output` says to set it to 1 and increase until things run smoothly (testing via `swaymsg`). For me value of 5 had no dropped frames for windowed/fullscreen.

I've tried this again now and it seems to make the trick. Setting the output max_render_time to something like 10ms seems to give correct framerate both in fullscreen and windowed mode. Depending on the graphical application that you run, you could set this even lower.

Closing this now, as it's not an hardware or driver issue, and can be tweaked using Sway options.

Offline

Board footer

Powered by FluxBB