protonscr

Implement frame limiter like on DXVK

vkd3dclosed
HansKristian-Work/vkd3d-proton#1356 · opened 2022-12-28 by coajaxial · updated 2023-01-05 · 10 comments · github
Ccoajaxial 2022-12-28 github

Hello,

first off, you are doing great work here for a lot of people, so thank you!

I was wondering if you guys could implement a frame limiter like on DXVK with the DXVK_FRAME_RATE environment variable in VK3D? Something like VK3D_FRAME_RATE maybe? I'm a Steam Deck owner and I found that using the DXVK_FRAME_RATE limiter has way less input lag than using the integrated one of SteamOS. It would be nice to have that option for DX12 games, too!

Happy holidays!

KK0bin 2022-12-28 github

I found that using the DXVK_FRAME_RATE limiter has way less input lag than using the integrated one of SteamOS

That honestly sounds like placebo.

Ccoajaxial 2022-12-28 github

I found that using the DXVK_FRAME_RATE limiter has way less input lag than using the integrated one of SteamOS

That honestly sounds like placebo.

It's not:
https://www.youtube.com/watch?v=86A3gMJaxLQ

Top is Steam deck overlay fps limiter, bottom DXVK_FRAME_RATE. The difference is subtle in this game, but if you try this on Skyrim, the difference is MASSIVE.

KK0bin 2022-12-28 github

In the video it simply looks like you hit the bottom one earlier.

Ccoajaxial 2022-12-28 github

It's hard to convince someone on the internet, I know that myself, but I only have limited tools right now to prove my theory. So without any better prove, I won't argue about the input latency anymore. Still, this is a feature request, and one point is that DXVK had the option to limit FPS, whereas VKD3D does not. It could be still useful for people who like to tinker and who may have better tools than me to prove my theory.

Fflightlessmango 2022-12-28 github

I've seen multiple people say the same thing for using the mangohud fps limiter compared to gamescopes.
Assuming the input benefits are about the same, then this might be a better approach since it will work on native games as well and doesn't require changes in vkd3d

Ccoajaxial 2022-12-28 github

I didn't compare DXVK_FRAME_RATE vs. mangohud fps limiter yet, I'll give it a shot

Ccoajaxial 2022-12-28 github

So, I tested it, and yes, it seems like the mangohud fps limiter is on the same level as DXVK_FRAME_RATE. But again, I don't have the tools to measure the input lag exactly. Nonetheless, this issue was not primarily opened because of steam deck's poor fps limiter, it was more of a general feature request and a place for discussion (maybe there is actually an env variable not documented to limit fps or something like that). I fully understand that it is time consuming or maybe even harming the code base to implement a fps limiter right in the translation layer, and I can totally call it a day if that is enough to close the issue :)

Ccoajaxial 2022-12-30 github

So now here is some real prove I made, measuring the exact input latency: https://www.youtube.com/watch?v=kRH6_tN8g38

HHansKristian-Work maintainer 2023-01-05 github

A CPU side frame limiter tends to have lower latency than a frame limited based on GPU back-pressure, so this is not surprising at all. In the CPU frame limiter case, the presentation queue is always kept drained, so there is little to no latency to present. However, frame pacing will suffer since the system timer is not locked to VBlank. VRR mitigates that of course. Especially when using a timer to lock to 30 fps, frame pacing is unusable due to constant 16ms - 50ms jitter.

The ideal solution is when one that blocks the presentation thread based on presentation timing with headroom estimation or similar. When present_wait trickles through the ecosystem I have some ideas for a low-latency mode.

Ccoajaxial 2023-01-05 github

Thanks for the clarification of the differences between the to limiter types! And yes, I can confirm that jitteriness, but it seems to heavily depend on the game/load. There are heavy differences in games like Elden Ring, Skyrim and Witcher when using the CPU side frame limiter (so mangohud) for example; Elden Ring has the jitteriness you explained and has frame time differences from 5-10ms, But Skyrim and Witcher on the other hand have very consistent frame times, and so they just play better with mangohud overall.
But I guess we are well beyond the point of off-topic in this issue, and as my tests have proven, DXVK_FRAME_RATE has the same effect as using mangohud. I guess both are CPU side frame limiters as you call them, and as @flightlessmango said, using mangohud as an alternative that works on both DX11 and DX12 games is enough to not implement a frame limiter in VKD3D. So I will close the issue and thank you for all the conversation :)

Launch options