Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
an0nfunc opened this issue Sep 27, 2023 · 29 comments
Open

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

an0nfunc opened this issue Sep 27, 2023 · 29 comments

Comments

@an0nfunc
Copy link

an0nfunc commented Sep 27, 2023

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
Copy link

alou-S commented Sep 27, 2023

Try the -nojoy launch parameter

@ErikReider
Copy link

ErikReider commented Sep 27, 2023

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
Copy link
Author

an0nfunc commented Sep 27, 2023

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
Copy link

alou-S commented Sep 27, 2023

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
Copy link
Author

@alou-S
Copy link

alou-S commented Sep 27, 2023

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

@ErikReider
Copy link

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
Copy link
Author

@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
Copy link

alou-S commented Sep 27, 2023

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
Copy link
Author

an0nfunc commented Sep 27, 2023

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
Copy link

alou-S commented Sep 27, 2023

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

@an0nfunc
Copy link
Author

an0nfunc commented Sep 27, 2023

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
Copy link

alou-S commented Sep 28, 2023

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

@an0nfunc
Copy link
Author

an0nfunc commented Sep 28, 2023

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
Copy link

Cruleo commented Sep 28, 2023

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

@bunkbail
Copy link

bunkbail commented Sep 28, 2023

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

@an0nfunc
Copy link
Author

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

@an0nfunc an0nfunc changed the title CS2: Severe stutter with Wayland CS2: Severe stutter with Wayland (vkWaitForFences VK_TIMEOUT) Sep 28, 2023
@sannagy90
Copy link

sannagy90 commented Sep 28, 2023

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

@leotada
Copy link

leotada commented Sep 28, 2023

As I commented here:
#3307 (comment)

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
Copy link
Author

an0nfunc commented Sep 28, 2023

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
Copy link
Author

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

@EysseW
Copy link

EysseW commented Oct 11, 2023

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

@melvyn2
Copy link

melvyn2 commented Oct 17, 2023

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
Copy link

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
Copy link

ico277 commented Nov 6, 2023

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

@sparkie3
Copy link

sparkie3 commented Nov 7, 2023

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 #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
Copy link

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
Copy link

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
Copy link

Janhouse commented Jan 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests