ValveSoftware / csgo-osx-linux

Counter-Strike: Global Offensive
http://counter-strike.net
787 stars 69 forks source link

CS2: Severe stutter with Wayland (vkWaitForFences VK_TIMEOUT) #3271

Closed an0nfunc closed 4 months ago

an0nfunc commented 1 year ago

Your system information

Please describe your issue in as much detail as possible:

Stutter under Wayland (sway) + AMDGPU. This does not happen with X11 (i3).

As soon as the game runs a few seconds, there are severe stutters down to 1 fps every few seconds. Seems to be getting more frequent if the game runs for a while.

Log messages that seem to relate to this issue:

CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.255553 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.252701 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.252569 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.252716 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.255026 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.257787 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.256348 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.251057 seconds, error = VK_TIMEOUT

Steps for reproducing this issue:

  1. Run CS2 under Wayland + AMD GPU
alou-S commented 1 year ago

Try the -nojoy launch parameter

ErikReider commented 1 year ago

In CSGO, adding LD_PRELOAD="/usr/lib64/libSDL2-2.0.so.0" SDL_VIDEODRIVER=wayland as a launch option to force it to run as a wayland window fixed all stutters/jitters on my end (In the past for CSGO, not CS2). Could be a XWayland issue?

an0nfunc commented 1 year ago

Try the -nojoy launch parameter

I have that one already.

In CSGO, adding LD_PRELOAD="/usr/lib64/libSDL2-2.0.so.0" SDL_VIDEODRIVER=wayland as a launch option to force it to run as a wayland window fixed all stutters/jitters on my end. Could be a XWayland issue?

I'll try this, give me a second.

EDIT: As noted by @alou-S, this does not work.

alou-S commented 1 year ago

In CSGO, adding LD_PRELOAD="/usr/lib64/libSDL2-2.0.so.0" SDL_VIDEODRIVER=wayland as a launch option to force it to run as a wayland window fixed all stutters/jitters on my end. Could be a XWayland issue?

CS2 and Source 2 uses SDL3 this won't work.

@an0nfunc Could you give the replies for glxinfo -B

an0nfunc commented 1 year ago

@alou-S glxinfo -B: https://gist.github.com/an0nfunc/5d77bbb5b37d929b52855e45619282e0

alou-S commented 1 year ago

@an0nfunc Do you have a separate dedicated GPU or CS2 run on the iGPU?

ErikReider commented 1 year ago

In CSGO, adding LD_PRELOAD="/usr/lib64/libSDL2-2.0.so.0" SDL_VIDEODRIVER=wayland as a launch option to force it to run as a wayland window fixed all stutters/jitters on my end. Could be a XWayland issue?

CS2 and Source 2 uses SDL3 this won't work.

@an0nfunc Could you give the replies for glxinfo -B

I wrote "in CSGO"... Anyways, maybe there's something similar for sdl3?

an0nfunc commented 1 year ago

@an0nfunc Do you have a separate dedicated GPU or CS2 run on the iGPU?

As you can see in my sys info, the 3800X does not posses an igp.

alou-S commented 1 year ago

Erm my bad so you use a Vega 10 GPU ehehe. Pardon my ignorance. I'll try debugging directly on sway, I don't seem to have any issues on Kwin Wayland (KDE) with the latest mesa-git drivers.

an0nfunc commented 1 year ago

Erm my bad so you use a Vega 10 GPU ehehe. Pardon my ignorance. I'll try debugging directly on sway, I don't seem to have any issues on Kwin Wayland (KDE) with the latest mesa-git drivers.

Should I try mesa-git?

edit: Give me a sec, compiling...

alou-S commented 1 year ago

You could attempt, If you are using Arch derivative distros you can get mesa-tkg-git straight from Chaotic AUR. Its pre-compiled.

an0nfunc commented 1 year ago

Mesa is compiled quickly enough, just takes a few minutes. I'll report back.

EDIT: Still happens on mesa 23.3.0_devel.178293.65afc8bebf4.d41d8cd-1.

alou-S commented 1 year ago

Try disable Steam Overlay. Used to fix a similar issue when using dxvk on CS:GO

an0nfunc commented 1 year ago

Also happens with Steam Overlay disabled. I noticed it's much more intense after visiting advanced video options once. (unrelated to the overlay, just an observation)

Cruleo commented 1 year ago

Try FSR Ultra Quality, it fixed stuttering for me and others.

bunkbail commented 1 year ago

I'm on Debian SId + mesa experimental + KDE + Wayland, game is running smooth as butter. All stock settings. 5600X + 6900 XT.

an0nfunc commented 1 year ago

Just noticed that these stutters correspond with log messages in the ingame-console. Must have been tired yesterday to not notice.

CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.255553 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.252701 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.252569 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.252716 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.255026 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.257787 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 1 ) after 0.256348 seconds, error = VK_TIMEOUT
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
[RenderSystem] FrameSync() - bailing out of vkWaitForFences( fenceCount = 2 ) after 0.251057 seconds, error = VK_TIMEOUT
sand-r commented 1 year ago

I cannot reproduce this under sway with a 5700xt. no stutter or vulkan related error messages.

leotada commented 1 year ago

As I commented here: https://github.com/ValveSoftware/csgo-osx-linux/issues/3307#issuecomment-1739680927

For me lowering the graphics and disabling MSAA and FSR worked. Especially MSAA. I'm using Fedora Linux with AMD Mesa drivers.

Reduced stutter so much.

an0nfunc commented 1 year ago

Downgrading to mesa 23.0.3 seems to fix this. Not sure if the problem is on mesa or CS2's side.

EDIT: I'm currently bisecting mesa to find out what commit we are dealing with.

an0nfunc commented 1 year ago

Upstream mesa issue: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9902

EysseW commented 1 year ago

I am consistently having 60 fps in cs2, but not on Xorg. Is it related?

melvyn2 commented 1 year ago

For a simpler solution than switching to Xorg, running steam and CS2 in fullscreen gamescope gives a much higher consistent framerate (on KDE Wayland).

HurricanePootis commented 1 year ago

For a simpler solution than switching to Xorg, running steam and CS2 in fullscreen gamescope gives a much higher consistent framerate (on KDE Wayland).

Swag thanks for sharing

ico277 commented 1 year ago

This seems to be gone for me on linux lts (6.1.61).

sparkie3 commented 1 year ago

This seems to be gone for me on linux lts (6.1.61).

I just tried this on 6.1 because Xorg was crashing and the stutter is still there and my GPU is maxed out. No clue what's going on there.


CS2 Choppy on Wayland / Stutters

Issue transferred from https://github.com/ValveSoftware/csgo-osx-linux/issues/3542. @sparkie3 posted on 2023-11-07T15:51:58:

Your system information

Please describe your issue in as much detail as possible:

CS2 is very choppy on Wayland. It is similar to have the GPU on low power settings when playing, however I have manually set the power profile to the highest and verified via nvtop that the GPU power settings are at the highest level while playing. The game will smooth out if vsync is disabled, but the filtering also makes the game unplayable. I've tried multiple kernels, and tried 6.1 as another bug report suggested. The game is unplayable as it sits due to the choppy rendering.

Here is the console output: https://gist.github.com/sparkie3/99d49fb4ec49d4cfe53d10dd3b42f914

Root-Core commented 1 year ago

Gamescope helps a bit, until it enters a state that is even worse and unplayable. X11 is perfectly smooth.

For me it correlates with package loss / choke. It starts smoothish and stutters once there are network imperfections. After some time it recovers a little, but it keeps being stuttery. I don't know if it's caused by it, or vice verse.. or at all connected.

sparkie3 commented 11 months ago

Using a higher refresh rate monitor and freesync helps with this. There are still stutters but not quite as bad. I'm using the 6.7 dev kernels.

Janhouse commented 10 months ago

For me personally it worked fine during October/November and then at some point in December it started stuttering and was unable to keep up stable FPS. GPU usage was ~70% and CPU usage much lower than that.

Today Steam downloaded shader cache and then did some shader compilation, and now again it works fine without any stuttering and having stable FPS.

FPS on Linux seems lower than on Windows 10 but then again I have to play with variable refresh rate to not have forced v-sync, so I am limiting to 140fps anyway, which also allows to set everything on recommended high settings (1440p, 4x MSAA, high, high, 4x anisotropic filtering, FSR off). Without limiting FPS I get 200+ FPS on de_dust2. I also tried it on xorg and I get similar FPS there.

So having tried out different mesa and xwayland versions I concluded that it probably had something to do with shader cache and not mesa/xwayland itself.

Running CS2 on: Arch Linux, currently kernel v6.6.9, Ryzen 7 5800X, Radeon RX 6800 XT, Gnome Wayland with mutter VRR patches.

Playing with VRR at 140FPS feels good on Linux, was able to rank up and play at purple ranks without issues. I hope the performance doesn't degrade again any time soon. And looking forward to getting native wayland support for CS2 without xwayland.

an0nfunc commented 6 months ago

The upstream mesa issue was resolved, so I think this can be closed?

kisak-valve commented 4 months ago

Closing per the last comment.

Mauriciopizarro commented 2 months ago

What is the solution for this problem?

eclairevoyant commented 2 months ago

Use a recent kernel essentially