-
Notifications
You must be signed in to change notification settings - Fork 566
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
X11 shell uses sleep to sync rendering. #932
Comments
This is a bit outside my current comfort zone, but if y'all don't mind answer lots of questions then I'd like to look into it. |
Yeah this is going to be rather tricky, because we want to sync the rendering to V-Sync as well. Some improvement may be possible as a side-effect of the timers work I want to do in #934, which may give a wake-up system of sorts. But the real question is going to be figuring out how to detect V-Sync timings and how to guarantee syncing to them. Some sort of V-Sync testing example/tool would be beneficial for druid in general. Something like vsynctester.com which could be used to test correctness on all platforms. |
I did some basic googling over the last day or two, and it seems like there are two common choices for syncing: glx and present. Metacity, mutter and xfwm seem to support both methods; I'm not sure if one is preferable (or more likely to be available) than the other. However, there is something more basic about request_anim that's bothering me -- I'll start a topic on zulip... |
So I've been playing around with Present, and it seems as though it has what we need. It works like this (apologies if this is known to everyone already, but it's new to me...):
|
Always good to have info written down, because even if the current participants know it - future ones might not. Also in this specific case I didn't know the X pixmap specifics. Regarding low latency, it's tricky. Yeah we could wait with rendering and do it at the last moment and that would allow the frame to contain the latest info. On the flip side if the frame render time varies then if we wait too long we can start missing vsync timings because of spikes in render time. |
Well, I did not know any of this 😂 If we want to get low latency it would probably require that we can reliably predict how long paint takes, which would have to happen at runtime and it would demand that the time needed for rendering does not vary to much. I don't know much about this but I would expect it to be rather difficult to get right, especially with partial invalidation it could vary quite a lot. For now I think it would be enough to get basic vsync working, we can always get fancy afterwards. |
This switches to using the X11 Present extension as the primary means of presenting frames in the x11 backend. In case the Present extension is unavailable, it falls back to a double-buffering strategy: it renders to a pixmap and then copies that pixmap to the screen. This improves #932, although the sleep path is still present in the fallback. Co-authored-by: Leopold Luley <[email protected]>
Looks like my comment in #989 auto-closed this. Re-opening because the sleeping still exists in the fallback method. |
Just for reference, this is the code in question: druid/druid-shell/src/platform/x11/window.rs Lines 588 to 598 in 3b3d401
|
From #475:
The code referred to is here
The text was updated successfully, but these errors were encountered: