-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
vo: change vsync base to nanoseconds #12371
Conversation
ab222d2
to
ed59795
Compare
UST is actually "Unadjusted System Time". It has nothing to do with microseconds (i.e. please don't change that). |
3ae460b
to
7f49c80
Compare
Ok, fixed. My bad about the name change. For drm I reverted all changes, because apparently it works with microsecond timestamps. wayland and x11 goes through mpv's EDIT: Changed |
What issue is that actually meant to solve? I don't see anything concrete mentioned anywhere. |
Same as bda8439 fixed truncation of Also this is a base for further improving sync code, but first I want to have at least native timer resolution and not dealing with truncated values. Again same fix as bda8439 but with broader scope. I'm traveling this week, so will not have much time to improve/test it. But if someone wants to try feel free. I'm mostly thinking that we should have timer sync logic, to infer clock base of UST instead of assuming it's base, because it doesn't seem to be in fact defined. But baby steps, I want to incrementally work on this. |
The presentation stuff does seem a bit messed up (wayland and x11). Honestly just looking at it I'm not sure exactly why. I guess maybe a missed conversion somewhere. |
Alright, for some reason I thought that was different. Indeed the same 16666(.66666) truncation applies when you use microseconds over a smaller unit or floating-point. |
@Dudemanguy: So the main issue, was the assumption, same as the code currently assumes, that You can reproduce this on master adding following code to the
I reviewed sync code in general and made few notes of things that I'd like to change. I have vague plan in head, but this PR is not it at this moment. |
I actually noticed that happening on wayland as well the other day. I'm not sure how we should interpret such a value; it reeks of nonsense honestly. |
I need to read docs how exactly it is defined for wayland. But on Windows |
On another look, the changes LGTM. Works fine too. The only thing is the mac stuff which I'm not sure about. The README claims we support macOS 10.8 (no idea if this is even true), but clock_gettime apparently requires 10.12. I doubt we really care about ancient mac versions though. |
Nevermind. I still doubt that nanosec accuracy is required because the measuring itself is noisy to begin with, nano or u sec, so accounting for that noise is needed either way, and I doubt that accounting for usec noise would yield worse results than accounting for nanosec noise, but whatever. |
The original change was initiated by people complaining that
We are accounting for the noise, by averaging 200 past samples. Averaging truncated values introduces more error/bias. And adding more precision is free.
Yes, whatever. Thanks. I really don't understand this mentality, of not touching/improving things at all cost. Note that you did not make the changes, I did, so whatever... Wayland gives UST in nanoseconds, Windows uses QPC for their feedback. There is literally no gain in truncating those values, just because. Same in other places where we have higher precision timebase. Nowadays all platforms provides high resolution clocks we can utilize them. It is free. It doesn't harm anything to store more digits in int64_t, but whatever. |
There's several improvements to the vsync code that could be made. I have a few ideas in mind. But step one would be using higher precision clocks so I'm all for this. Actually I plan to follow up with some more unit changes after this PR (unless kasper beats me to it hah). |
@Dudemanguy: Go ahead, I don't have anything in the pipeline right now. I've seen some places that would benefit form higher precision timestamps though. I want to refactor how win32 presentation feedback works, but I think we are not in conflict there :) |
8ceb312
to
dfd5b62
Compare
This is not a proper way to do unit tests or whatever that was.
Those changes will alow to change vsync base to more precise time base. In general there is no reason to truncate values returned by system.
Just keep it directly as mp_time for internal implementation.
There is no reason to use microseconds precision. We have precise timers all all relevant platforms.
High refresh rate displays exists...
This causes only problems, because we convert mp_time to realtime, which is not atomic, so we introduce error. And even though on sane platforms it should work fine, after all the sleep time is in the past. winpthreads like to sleep for like over 10ms when the time is less than current time, but not more than 1s.
Download the artifacts for this pull request: |
Let's see if someone catches something. |
No description provided.