HansKristian-Work / vkd3d-proton

Fork of VKD3D. Development branches for Proton's Direct3D 12 implementation.
GNU Lesser General Public License v2.1
1.76k stars 184 forks source link

Halved refresh rate in some situations in Cyberpunk 2077 #1926

Closed shmerl closed 4 months ago

shmerl commented 4 months ago

When running Cyberpunk 2077, there is a transient issue when monitor's refresh rate drops to half of the game framerate instead of matching it as adaptive sync should do.

I measure game framerate with MangoHud and monitor's refresh rate with on-screen OSD. They match most of the time, but sometimes refresh rate is halved. So for example the game would have 176 fps and OSD will show 88 Hz and so on. This happens with Wine XWayland and Wine Wayland both, but somehow more often with the latter.

Not sure if the issue is with Kwin, vkd3d-proton or radv. Could be on any level so I'm opening a bug here just in case.

I opened Wine bug first (https://bugs.winehq.org/show_bug.cgi?id=56002) thinking it's Wine-Wayland issue, but now I see it's not really limited to it so opening lower level bugs. I can open a radv or amdgpu bug as well if you recommend it.

And just to exclude this detail - it happens without mangohud too, so it's not the HUD interference if anything.

See attached video for the example of this

halved_refresh_rate.webm

GrabbenD commented 4 months ago

Same issue can be observed in Dead Island 2 (with Sway 1.9 meaning it's not specific to WM/DE)

For reference: drm/amd/-/issues/3166

shmerl commented 4 months ago

Well, in my case I don't get flicker. In fact, refresh rate is exactly half of game's framerate when it dips, so I guess it's still aligned somewhat. But still it's an incorrect behavior.

mbriar commented 4 months ago

Was reported before, apparently using vsync/fifo fixes it: https://github.com/HansKristian-Work/vkd3d-proton/issues/1911 More likely something going wrong in kwin or the mesa wsi than vkd3d-proton.

GrabbenD commented 4 months ago

VSYNC (FIFO_KHR) is the only working sync method on my end, otherwise refresh rate is exactly half of game's framerate like @shmerl said

shmerl commented 4 months ago

Hm, yes, I can confirm that setting vsync in the game (to 180 for me) this problem goes away. But I assumed fifo in general is not optimal and mailbox is as a more advanced option. It's still weird that when vsync option in the game is not enabled it behaves incorrectly. Is it a bug with the game itself or with Kwin or Mesa? Kwin developers didn't think it's a Kwin issue btw.

GrabbenD commented 4 months ago

@shmerl It can't be KWIN issue since Wlroots (Sway) has the exact same issue

shmerl commented 4 months ago

Should I open a radv bug?

GrabbenD commented 4 months ago

Kwin developers didn't think it's a Kwin issue btw.

By the way, can you drop a link to the KWIN issue report here? I'm trying to keep track of similar issues drm/amd/-/issues/3166#note_2277191

Should I open a radv bug?

Sounds like a good idea!

shmerl commented 4 months ago

It wasn't reported, just a comment from one of the kwin developers. So I haven't opened the issue.

mbriar commented 4 months ago

fifo in general is not optimal and mailbox is as a more advanced option.

If you don't want framerates much higher than the monitor's refresh rate there is not much reason to use mailbox with vrr. Mailbox is probably rather less optimal because it requires a huge amount of swapchain images which require more memory and can maybe even increase latency.

shmerl commented 4 months ago

Radv bug: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10746

HansKristian-Work commented 4 months ago

This cannot be a vkd3d-proton bug. Looks more like a DE bug. Closing unless there is actual proof this is vkd3d-proton's issue.

shmerl commented 1 week ago

FYI, now it got bad even with fifo. Still waiting for Plasma 6 to be packaged for Debian to confirm it works better with it.

shmerl commented 1 week ago

So far the working combination for me was like this (still stuck with Plasma 5 but Plasma 6 is coming to Debian soon so I'll retest):

With XWayaland it's worse, no matter what setting this bug pops up.