-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Add frame delta smoothing option (4.x) #52314
Conversation
Remember that V-Sync status can be changed at run-time, so this should ideally be changed. It's not critical as toggling V-Sync remains possible, but people playing a game after toggling V-Sync (and without restarting the game) will get a subpar experience.
My guess is that delta smoothing improves the situation with adaptive V-Sync if you can keep up with the monitor refresh rate. In situations where this is not the case, it will likely worsen things as V-Sync is automatically disabled when the CPU/GPU can't keep up with the monitor refresh rate. |
Yes I'm sure we can get this working, I'm hoping to get some ideas from reviewers who are familiar with vsync in 4. EDIT: Actually having a look, as far as I can see, the
It is possible it could improve things as is particular in ADAPTIVE mode but I'd like to get this thoroughly tested before enabling it in those modes, just in case it doesn't work well. I don't think this is necessary anyway to start with, it's fairly easy to turn on for the other modes if we decide, and we don't want this PR to hold up further work on the mainloop. |
Setting the VSync-mode at runtime is currently possible. (via |
e94fecf
to
f0aa2f4
Compare
This is now updated with reading the vsync from |
Note: Approved in PR meeting today, just needs a rebase. Rebased. Should be fine now, just tested. |
f0aa2f4
to
8a4b92e
Compare
This needs a small rebase again, but we should try to merge this PR before RC. We should also enable the option by default, and consider doing so in new projects in 3.6. Also, now that there's |
Needs another rebase. |
@lawnjelly I don't know how we missed this in the final PR review for 4.0. But I agree with Maran23, this looks like a straight port of a well-loved feature in 3.x. We may need to do something with the other vsync modes eventually, but starting with a straight port seems pretty safe and desirable to me. Do you know of any reason why we should delay merging this? If not, go ahead and rebase and we can merge soon. |
Yes it should be fine, I'll rebase, and poke someone to merge. 👍 |
8a4b92e
to
4658cdb
Compare
@clayjohn @akien-mga Rebased and ready. |
Friendly ping from me as well, just so we don't forget this PR again. 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. It appears to work the same as in 3.x and I am not aware of any reason why the same approach wouldn't work here. That being said, I am not an expert on main loop/timing stuff, so take my review for what it is
Would be nice to have @RandomShaper's review as well in case he is aware of something that I am not.
Frame deltas are currently measured by querying the OS timer each frame. This is subject to random error. Frame delta smoothing instead filters the delta read from the OS by replacing it with the refresh rate delta wherever possible. This PR also contains code to estimate the refresh rate based on the input deltas, without reading the refresh rate from the host OS. The delta_smooth_enabled setting can also be modified at runtime through OS::, and there is also now a command line setting to override the project setting.
4658cdb
to
7925670
Compare
Thanks! |
Frame deltas are currently measured by querying the OS timer each frame. This is subject to random error. Frame delta smoothing instead filters the delta read from the OS by replacing it with the refresh rate delta wherever possible.
This PR also contains code to estimate the refresh rate based on the input deltas, without reading the refresh rate from the host OS.
The delta_smooth_enabled setting can also be modified at runtime through OS::, and there is also now a command line setting to override the project setting.
Notes
vsync_enabled
is read slightly differently, from DisplayServer on recommendation from @GeometrorExtra Info
As before the majority of the code is the refresh rate estimator, which may take a bit of time to get your head around, however the important part that does the business is quite simple:
Essentially the idea is that we are just incrementing the delta by whole frame intervals. This works great around the refresh rate, because it takes care of small fluctuations, and if the frame rate is deviating too much it simply turns smoothing off again until it re-stabilizes.