summaryrefslogtreecommitdiffstats
path: root/video/out/wayland_common.c
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-11-02 13:41:32 -0500
committerDudemanguy <random342@airmail.cc>2023-11-06 15:44:45 +0000
commit261f51b475e17459274b24ae8a0515d7ac969cd0 (patch)
tree849355df70d6d216d1fdfd7a0515831ac0f7f977 /video/out/wayland_common.c
parentbcbd821fa9ff6b1128801b240f22541e1cd76555 (diff)
downloadmpv-261f51b475e17459274b24ae8a0515d7ac969cd0.tar.bz2
mpv-261f51b475e17459274b24ae8a0515d7ac969cd0.tar.xz
present_sync: rewrite around linked list
When this was originally written, the queuing/list approach was deliberately removed since it adds more complication and xorg/wayland don't really use it anyway. In practice, you only really have one frame in flight with presentation timestamps. However, one slight annoyance is that the drm code has its own thing which is almost exactly the same and does its own calculations. Ideally, we'd port drm to this instead, but the implementation there takes into account N-frames in flight which probably does actually work. So we need to make present_sync smarter and be able to handle this. mpv does actually have its own linked list implementation already which is a good fit for this. mp_present becomes the list and each mp_present_entry has its own set of timestamps. During initialization, we create all the entries we need and then simply treat it like a queue during the lifecycle of the VO. When an entry is fully used (present_sync_get_info), then we remove it from the list, zero it out, and append it to the end for future use. This avoids needing to allocate memory on every frame (which is what drm currently does) and allows for a reasonable number of in flight frames at the same time as this should never grow to some obscene number. The nice thing is that current users of present_sync don't need to change anything besides the initialization step.
Diffstat (limited to 'video/out/wayland_common.c')
-rw-r--r--video/out/wayland_common.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 144ff78284..e0f8cde208 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -2282,7 +2282,7 @@ bool vo_wayland_init(struct vo *vo)
wl->fback_pool->len = 8; // max swapchain depth allowed
wl->fback_pool->fback = talloc_zero_array(wl->fback_pool, struct wp_presentation_feedback *,
wl->fback_pool->len);
- wl->present = talloc_zero(wl, struct mp_present);
+ wl->present = mp_present_initialize(wl, 8); // max swapchain depth allowed
} else {
MP_VERBOSE(wl, "Compositor doesn't support the %s protocol!\n",
wp_presentation_interface.name);
@@ -2560,8 +2560,8 @@ void vo_wayland_wait_frame(struct vo_wayland_state *wl)
* 3. refresh rate of the output reported by the compositor
* 4. make up crap if vblank_time is still <= 0 (better than nothing) */
- if (wl->use_present)
- vblank_time = wl->present->vsync_duration;
+ if (wl->use_present && wl->present->head)
+ vblank_time = wl->present->head->vsync_duration;
if (vblank_time <= 0 && wl->refresh_interval > 0)
vblank_time = wl->refresh_interval;