Open brndd opened 10 months ago
is there any difference if you run either of these four commands: (note that you might get tearing with these)
MESA_VK_WSI_PRESENT_MODE=immediate gamescope -e -w 2560 -h 1440 -W 2560 -H 1440 -f -r 144 -- mangohud %command%
MESA_VK_WSI_PRESENT_MODE=immediate vk_xwayland_wait_ready=false gamescope -e -w 2560 -h 1440 -W 2560 -H 1440 -f -r 144 -- mangohud %command%
MESA_VK_WSI_PRESENT_MODE=immediate gamescope -e -w 2560 -h 1440 -W 2560 -H 1440 -f -r 144 -- env MESA_VK_WSI_PRESENT_MODE=relaxed mangohud %command%
MESA_VK_WSI_PRESENT_MODE=immediate vk_xwayland_wait_ready=false gamescope -e -w 2560 -h 1440 -W 2560 -H 1440 -f -r 144 -- env MESA_VK_WSI_PRESENT_MODE=relaxed mangohud %command%
if you don't want tearing, you could also try this command:
MESA_VK_WSI_PRESENT_MODE=mailbox vk_xwayland_wait_ready=false gamescope -e -w 2560 -h 1440 -W 2560 -H 1440 -f -r 144 -- mangohud %command%
None of those seemed to have any effect on the issue.
edit: actually, the last one (mailbox) does have an effect. It makes Mangohud show that the game is running at 60fps while the Steam Overlay and my eyes show that it's running at 36fps.
@brndd hmmmm pretty weird... Now I'm down to grasping at thin straws, but I guess it's still worth trying to:
which would be this command:
MESA_VK_WSI_PRESENT_MODE=immediate vk_xwayland_wait_ready=false gamescope -e -w 2560 -h 1440 -W 2560 -H 1440 -f -r 144 -o 144 -- env DXVK_CONFIG="dxgi.syncInterval=0; d3d9.presentInterval=0; dxgi.maxFrameLatency=7; d3d9.maxFrameLatency=7" DXVK_HUD=full %command%
the one other thought would be to set gamescope's nested refresh rate to the approximate fps (94 fps) that the game was able to reach when running without gamescope. now, if you weren't using a VRR monitor, then doing this could increase stutter, but since you do, then it should be fine:
MESA_VK_WSI_PRESENT_MODE=immediate vk_xwayland_wait_ready=false gamescope -e -w 2560 -h 1440 -W 2560 -H 1440 -f -r 94 -o 94 -- env DXVK_CONFIG="dxgi.syncInterval=0; d3d9.presentInterval=0; dxgi.maxFrameLatency=7; d3d9.maxFrameLatency=7" DXVK_HUD=full %command%
That command has the same issue as the mailbox one in Dark Souls 3 (dxvk overlay reports stable 60fps, Steam overlay shows the real FPS being a stuttery mess), and in Baldur's Gate 3 it just results in very poor performance (i.e. no different from the command I pasted in the report with vsync disabled).
It seems that Gamescope just has inherently awful performance on my system for some reason. It must be a regression somewhere, because things used to work perfectly fine some time ago. I installed an older version of Gamescope that I'm pretty sure used to work in the past, 3.11.49, and the issue happens there too.
So it's probably a regression somewhere else that's causing Gamescope to have terrible performance.
So it's probably a regression somewhere else that's causing Gamescope to have terrible performance.
hmmmm I wonder if it's an issue with wayland (which would cause you to experience a similar performance degradation for both new and old gamescope versions, due to all the system wayland libraries being shared libraries) itself??? This is just a hunch, but I feel like wayland may be the one place where there could be an issue that isn't noticable when playing a game without gamescope, but becomes noticable when running it under gamescope...
I'm not sure if trying to switch your kde session to use x11 (not sure if your version of kde supports it anymore) would make any difference, since I know that gamescope uses certain wayland functions even when running on an x11 desktop...
EDIT: another possibility I've just thought of: could it be an issue with mesa/amd driver? https://gitlab.freedesktop.org/mesa/mesa/-/issues/10518 https://gitlab.freedesktop.org/mesa/mesa/-/issues/10309 https://gitlab.freedesktop.org/mesa/mesa/-/issues/8307
I thought it could be the powersaving settings being an issue, but setting the card's power profile to high with echo high > /sys/class/drm/card2/device/power_dpm_force_performance_level
does not seem to make any difference, so probably not.
The older Gamescope versions I tried do use older versions of wlroots, and Fedora packages older versions of wlroots separately (wlroots0.15 and wlroots0.16). I dunno if there are other Wayland dependencies for Gamescope.
I thought it could be the powersaving settings being an issue, but setting the card's power profile to high with
echo high > /sys/class/drm/card2/device/power_dpm_force_performance_level
does not seem to make any difference, so probably not.The older Gamescope versions I tried do use older versions of wlroots, and Fedora packages older versions of wlroots separately (wlroots0.15 and wlroots0.16). I dunno if there are other Wayland dependencies for Gamescope.
I don't think the wlroots version matters much, since gamescope is built with a statically linked version of wlroots The two wayland-parts that could have an impact on gamescope's behavior would be:
I tried running Steam in a tty without KWin using Gamescope's embedded session, and at least for Dark Souls 3 the stuttering issue didn't seem to be present there, but the environment was very inconvenient and I don't have the patience to set it up properly right now, so I didn't test very rigorously -- just loaded into the game and tried opening menus, which normally would immediately trigger the issue.
I also tried KDE's X11 session, and the issue was present there.
I thought it might have something to do with the cursor, since KWin apparently handles VRR cursors by forcing a refresh every time the cursor moves and the menu being brought up displays the cursor in Dark Souls 3, but none of the cursor-related settings in Gamescope seemed to have an effect, and neither did turning of VRR so it probably isn't that particular quirk of KWin causing it. I guess it could still be cursor-related, but I don't know how I would go about turning it off entirely.
Uhhh at this point…. @Joshua-Ashton do you have any thoughts on this? I feel like we’ve got some info on this issue now, but not sure where to go from here…
Replying to https://github.com/ValveSoftware/gamescope/issues/1115#issuecomment-1921271549
hmmm maybe also check which gpu gamescope is using:
just launch steam from the command line, and then after launching the game, look for the text in the terminal that says:
vulkan: selecting physical device <gpu description>
It uses the 6700XT -- I think it would show in Mangohud too if it were using my iGPU... and the performance would be much worse, I've been there :^).
However, and this is very strange: when I run Steam through the console (by typing steam
into Konsole), the performance issue with Gamescope doesn't happen; both Baldur's Gate 3 and Dark Souls 3 run perfectly fine. As soon as I close Steam and start it the normal way (through KDE's applications menu or KRunner), the problem comes back. WTF!?
It uses the 6700XT -- I think it would show in Mangohud too if it were using my iGPU... and the performance would be much worse, I've been there :^).
However, and this is very strange: when I run Steam through the console (by typing
steam
into Konsole), the performance issue with Gamescope doesn't happen; both Baldur's Gate 3 and Dark Souls 3 run perfectly fine. As soon as I close Steam and start it the normal way (through KDE's applications menu or KRunner), the problem comes back. WTF!?
HUH... well at least that means you have a sort-of work-around for now... you might want to also file a bug on KDE's site/gitlab since I feel like that must indicate that there's a weird interaction between the KDE desktop environment (or some component of it) and gamescope...
https://bugs.kde.org/ https://invent.kde.org/groups/plasma/-/issues
I compared the environment between running Steam from the command line and via KRunner, and it looks like KRunner is setting DRI_PRIME=pci-0000_00_02_0
, which is... yup, guessed it, my iGPU. Something about Steam is smart enough to ignore this nonsense and use my dedicated GPU for the actual game itself (going by the game running normally without Gamescope), but this env var seems to cause issues for Gamescope.
Amending the startup parameters to DRI_PRIME="" gamescope -e -w 2560 -h 1440 -W 2560 -H 1440 -f -r 144 -- mangohud %command%
is a workaround for the issue until I figure out a way to stop KDE from having my iGPU in DRI_PRIME.
System specs:
Launching Dark Souls 3 or Elden Ring with the below command from Steam causes the game to get locked to a low FPS, which is always Gamescope's refresh rate divided by some integer (i.e. likely vsync shenanigans). Without Gamescope the games run at a locked 60fps. Also affects Baldur's Gate 3, which allows disabling vsync -- doing so shows that the game is running with far worse framerates and frame pacing under Gamescope than without it. Likely affects other games, but I only tested these.
gamescope -e -w 2560 -h 1440 -W 2560 -H 1440 -f -r 144 -- mangohud %command%
A curious behaviour in Dark Souls 3 is that sometimes, randomly, the game runs at 60fps under Gamescope, but as soon as I open a menu it drops to 30fps and never recovers.
I am using a VRR monitor, but disabling VRR or changing the refresh rate did not seem to affect this. Disabling my secondary 60Hz monitor also did not seem to affect this. Mangohud does not seem to affect the issue either, but I'm leaving it in the command above because it makes it easier to see what the frames are doing.
This was not an issue when I played Elden Ring with Gamescope last summer, so the cause is likely something that changed since then. Whether that something is Gamescope, Mesa, the kernel or what, I don't know, but I am filing this here first because the issue only happens when the games run under Gamescope.
Baldur's Gate 3 screenshots
Gamescope enabled, triple-buffered vsync
![2024-01-28T17:41:19](https://github.com/ValveSoftware/gamescope/assets/5822375/d85bd0fa-a852-4118-bacf-016ce7af53c6)Gamescope enabled, vsync off
![2024-01-28T17:41:33](https://github.com/ValveSoftware/gamescope/assets/5822375/e94b5ebd-c5d8-445d-9192-43ea97689785)No Gamescope, triple-buffered vsync (framerate is same as without vsync due to VRR monitor)
![2024-01-28T17:43:19](https://github.com/ValveSoftware/gamescope/assets/5822375/9ee6c563-2f31-4958-8d70-6e8a1df26f78)