gamescope icon indicating copy to clipboard operation
gamescope copied to clipboard

[NVIDIA] Mouse motion causes severe frame delays since linux_drm_syncobj implementation

Open ShadowApex opened this issue 1 year ago • 15 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Are you using any gamescope patches or a forked version of gamescope?

  • [X] The issue occurs on upstream gamescope without any modifications

Current Behavior

Using Nvidia GPUs with a 4k display, certain games like Cyberpunk 2077 and Black Myth: Wukong experience severe frame delays when there is mouse motion input. Keyboard or gamepad input does not cause issues. After bisecting, it appears this issue was introduced in commit dd77e4de10974bdbfe8252f6ec6f4c8723ac3305 with the introduction of the new linux_drm_syncobj implementation in v3.15.0.

From testing Cyberpunk 2077, it appears this issue only manifests when using a 4k display (tested with a 3840x2160 monitor) or when using a 1080p display and the in-game resolution is set to a value lower than 1080p. Enabling vsync in-game also appears to help with the frame stuttering, but is severe when it is disabled.

Steps To Reproduce

  1. Launch gamescope embedded session (with a 4K display 3840x2160)
  2. Launch Cyberpunk 2077
  3. Go to game settings and ensure that resolution is set to 1920x1080 and vsync is disabled
  4. Load or start a new game
  5. Move mouse cursor around

Hardware information

- **Distro**: Fedora Linux 41.20241106.0 (Silverblue)
- **CPU**: 16-core Intel(R) Core(TM) Ultra 7 155H
- **GPU**: NVIDIA Corporation AD107M [GeForce RTX 4060 Max-Q / Mobile]
- **Driver Version**: NVIDIA 565.57.01

Software information

- **Desktop environment**: None (gamescope-session)
- **Session type**: wayland
- **Gamescope version**: gamescope version v3.15.0+ (starting at commit [dd77e4de10974bdbfe8252f6ec6f4c8723ac3305](https://github.com/ValveSoftware/gamescope/commit/dd77e4de10974bdbfe8252f6ec6f4c8723ac3305))
- **Gamescope launch command(s)**: `/usr/bin/gamescope --prefer-output *,eDP-1 --xwayland-count 2 --default-touch-mode 4 --hide-cursor-delay 3000 --fade-out-duration 200 --steam -R /run/user/1000/gamescope.rhDOTtu/startup.socket -T /run/user/1000/gamescope.rhDOTtu/stats.pipe`

Which gamescope backends have the issue you are reporting?

  • [ ] Wayland (default for nested gamescope)
  • [X] DRM (default for embedded gamescope, i.e. gamescope-session)
  • [ ] SDL
  • [ ] OpenVR

Logging, screenshots, or anything else

gamescope version v3.15.0+ (dd77e4de10974bdbfe8252f6ec6f4c8723ac3305)

https://github.com/user-attachments/assets/4e295513-e620-4a12-8253-53a5f3b0b335

gamescope version v3.14.29

https://github.com/user-attachments/assets/ca089480-289f-453a-8f47-3a871c81bd4f

ShadowApex avatar Nov 12 '24 19:11 ShadowApex

I experience this issue at native 1080p with Senua's Sacrifice when using DirectX12, but not when using DirectX11. The GPU used for testing was an RTX 4060.

alkazar avatar Nov 12 '24 21:11 alkazar

Getting this on Cyberpunk as well (launch command: ENABLE_GAMESCOPE_WSI=0 gamescope -w 2560 -h 1440 --hdr-enabled --hdr-itm-enable --force-grab-cursor -- %command% --launcher-skip -skipStartScreen). Playing with a controller is perfectly fine, but as soon as I try moving my mouse, it stutters to hell and my terminal is spammed with [gamescope] [Warn] xwm: got the same buffer committed twice, ignoring. It's WAY MORE exaggerated than in OP's video, making the game impossible to play with a mouse for me

awsms avatar Nov 24 '24 03:11 awsms

can you try adding VKD3D_DISABLE_EXTENSIONS=VK_KHR_present_wait before %command% as well? this seems to work around the mouse issue for me in Cyberpunk 2077 on a 4090 with HDR enabled on Plasma 6 Wayland and in gamescope-session.

matte-schwartz avatar Nov 24 '24 07:11 matte-schwartz

can you try adding VKD3D_DISABLE_EXTENSIONS=VK_KHR_present_wait before %command% as well? this seems to work around the mouse issue for me in Cyberpunk 2077 on a 4090 with HDR enabled on Plasma 6 Wayland and in gamescope-session.

This reduces a lot the stutter duration, but still doesn't make it playable as the stutters are still there at every mouse move. edit: btw it adds input latency for me.

awsms avatar Dec 11 '24 15:12 awsms

https://github.com/NVIDIA/egl-wayland/issues/154 hmm, i wonder if this is possibly related? i'm not too familiar with the egl-wayland repo though but this looks similar

matte-schwartz avatar Dec 11 '24 18:12 matte-schwartz

NVIDIA/egl-wayland#154 hmm, i wonder if this is possibly related? i'm not too familiar with the egl-wayland repo though but this looks similar

Interesting, however he suffers of FPS drops and no stuttering, while my FPS are not affected at all (there is 0 difference in the frame time/framerate graphs displayed by mangohud when the stuttering occurs).

awsms avatar Dec 12 '24 13:12 awsms

can you try adding VKD3D_DISABLE_EXTENSIONS=VK_KHR_present_wait before %command% as well? this seems to work around the mouse issue for me in Cyberpunk 2077 on a 4090 with HDR enabled on Plasma 6 Wayland and in gamescope-session.

This resolved the issue for me in Marvel Rivals and Helldivers 2

drakon64 avatar Dec 16 '24 20:12 drakon64

I experience this issue at native 1080p with Senua's Sacrifice when using DirectX12, but not when using DirectX11. The GPU used for testing was an RTX 4060.

I can confirm this only happens on DX12 titles for me. Palworld with VKD3D stutters, while it doesn't at all with DXVK.

awsms avatar Dec 18 '24 00:12 awsms

I had another look at the original issue reported here today (Cyberpunk 2077, 4K display + 1920x1080p in-game resolution. here's what I found (note - this is all with explicit sync enabled on gamescope 3.16.1):

ENABLE_GAMESCOPE_WSI=1 %command% - mouse does not lag, VK_KHR_present_wait will cause it to freeze (separate issue) ENABLE_GAMESCOPE_WSI=1 VKD3D_DISABLE_EXTENSIONS=VK_KHR_present_wait %command% - mouse does not lag, game does not freeze

ENABLE_GAMESOPE_WSI=0 %command% - mouse lags severely when in-game ENABLE_GAMESCOPE_WSI=0 VKD3D_DISABLE_EXTENSIONS=VK_KHR_present_wait %command% - mouse only lags a little bit

this behavior in Cyberpunk only happens on NVIDIA, so a NVIDIA label would be warranted here as well cc @kisak-valve

nvidia-bug-report.log.gz

matte-schwartz avatar Dec 18 '24 20:12 matte-schwartz

Any updates?

cch000 avatar Jan 15 '25 11:01 cch000

Any updates?

None yet. But feel free to upload your bug report on the dedicated driver feedback thread: https://forums.developer.nvidia.com/t/565-release-feedback-discussion/310777

awsms avatar Jan 15 '25 16:01 awsms

Is it possible to disable explicit sync support in gamescope? games run fine on drivers without an explicit sync implementation e.g. 550.x

cch000 avatar Feb 03 '25 13:02 cch000

You can flip https://github.com/ValveSoftware/gamescope/blob/ef1e8dbe49da7ee87120c243f7d1d6935590cc76/src/Backends/DRMBackend.cpp#L72 to true and re-compile

I think there's a way to do it with a Gamescope convar at runtime as well with a config file, but tbh I have not figured out how to get that working yet.

matte-schwartz avatar Feb 03 '25 17:02 matte-schwartz

That fixed the issue for me on driver 565. For runtime it seems that it can be done through gamescopectl, but it would be nice to have it in a config file.

cch000 avatar Feb 03 '25 18:02 cch000

function info(text)
    gamescope.log(gamescope.log_priority.info, text)
end


info("Enabling explicit sync: " .. tostring(gamescope.convars.drm_debug_disable_explicit_sync.value) .. " -> " .. tostring(true))
gamescope.convars.drm_debug_disable_explicit_sync.value = true

this code in $XDG_CONFIG_DIR/gamescope/scripts/something.lua does the trick for me in Cyberpunk 2077. I'll go play my game now but later I'll try to make it autodetect proprietary NVidia drivers and auto apply only then.

MagicRB avatar Feb 05 '25 13:02 MagicRB

I'm unable to reproduce this anymore as of the latest NVIDIA Vulkan developer beta driver, 570.123.07. My display is set to 3840x2160p@120p in Gamescope-session, in-game resolution set to 1080p and mouse motion is fine and my game never drops from 120 fps even with no workarounds. Could've been the same fix as the WSI present wait issue maybe?

Aforementioned fix is not in a stable Nvidia driver yet but hopefully soon.

matte-schwartz avatar Mar 29 '25 02:03 matte-schwartz

i am having similar issues in Minecraft (not with Steam) with the Wayland backend. 3072x1920 native resolution, 1280x800 game resolution. NVIDIA 570.133.07. are there any workarounds for the Wayland backend?

Waoweens avatar Apr 25 '25 05:04 Waoweens

i am having similar issues in Minecraft (not with Steam) with the Wayland backend. 3072x1920 native resolution, 1280x800 game resolution. NVIDIA 570.133.07. are there any workarounds for the Wayland backend?

yeah switch to the X11 one :/ unset WAYLAND_DISPLAY

MagicRB avatar Apr 25 '25 10:04 MagicRB

function info(text) gamescope.log(gamescope.log_priority.info, text) end

info("Enabling explicit sync: " .. tostring(gamescope.convars.drm_debug_disable_explicit_sync.value) .. " -> " .. tostring(true)) gamescope.convars.drm_debug_disable_explicit_sync.value = true this code in $XDG_CONFIG_DIR/gamescope/scripts/something.lua does the trick for me in Cyberpunk 2077. I'll go play my game now but later I'll try to make it autodetect proprietary NVidia drivers and auto apply only then.

I can confirm that this Lua script for disabling explicit sync also fixes the major mouse lag issues I've been experiencing on NVIDIA.

Here are my package versions in case it matters:

  • Gamescope 3.16.4
  • NVIDIA 575.64.03
  • Wayland 1.23.0
  • Xwayland 24.1.8

LukeShortCloud avatar Aug 01 '25 04:08 LukeShortCloud