present_sync: only save as many entries as the swapchain depth

Saving more than the swapchain depth is just wasteful. We can just save
a copy of the vo_opts here and check the value whenever we're updating
values.
This commit is contained in:
Dudemanguy committed 2023-11-07 00:52:46 +00:00
1 parent cf69fa03ca
commit 2872e929bb
5 files changed
+10 -7

No files matched your search

+1 -1
View File
@@ -1030,7 +1030,7 @@ bool vo_drm_init(struct vo *vo)
drm->ev.version = DRM_EVENT_CONTEXT_VERSION;
drm->ev.page_flip_handler = &drm_pflip_cb;
drm->present = mp_present_initialize(drm, VO_MAX_SWAPCHAIN_DEPTH);
drm->present = mp_present_initialize(drm, drm->vo->opts, VO_MAX_SWAPCHAIN_DEPTH);
return true;
+5 -3
View File
@@ -57,13 +57,14 @@ void present_sync_get_info(struct mp_present *present, struct vo_vsync_info *inf
LL_APPEND(list_node, present, cur);
}
struct mp_present *mp_present_initialize(void *talloc_ctx, int entries)
struct mp_present *mp_present_initialize(void *talloc_ctx, struct mp_vo_opts *opts, int entries)
{
struct mp_present *present = talloc_zero(talloc_ctx, struct mp_present);
for (int i = 0; i < entries; i++) {
struct mp_present_entry *entry = talloc_zero(present, struct mp_present_entry);
LL_APPEND(list_node, present, entry);
}
present->opts = opts;
return present;
}
@@ -120,8 +121,9 @@ void present_sync_update_values(struct mp_present *present, int64_t ust,
int64_t msc)
{
struct mp_present_entry *cur = present->head;
while (cur) {
if (!cur->ust)
int index = 0;
while (cur && ++index) {
if (!cur->ust || index == present->opts->swapchain_depth)
break;
cur = cur->list_node.next;
}
+2 -1
View File
@@ -39,9 +39,10 @@ struct mp_present_entry {
struct mp_present {
struct mp_present_entry *head, *tail;
struct mp_vo_opts *opts;
};
struct mp_present *mp_present_initialize(void *talloc_ctx, int entries);
struct mp_present *mp_present_initialize(void *talloc_ctx, struct mp_vo_opts *opts, int entries);
// Used during the get_vsync call to deliver the presentation statistics to the VO.
void present_sync_get_info(struct mp_present *present, struct vo_vsync_info *info);
+1 -1
View File
@@ -2283,7 +2283,7 @@ bool vo_wayland_init(struct vo *vo)
wl->fback_pool->len = VO_MAX_SWAPCHAIN_DEPTH;
wl->fback_pool->fback = talloc_zero_array(wl->fback_pool, struct wp_presentation_feedback *,
wl->fback_pool->len);
wl->present = mp_present_initialize(wl, VO_MAX_SWAPCHAIN_DEPTH);
wl->present = mp_present_initialize(wl, wl->vo_opts, VO_MAX_SWAPCHAIN_DEPTH);
} else {
MP_VERBOSE(wl, "Compositor doesn't support the %s protocol!\n",
wp_presentation_interface.name);
+1 -1
View File
@@ -626,7 +626,7 @@ bool vo_x11_init(struct vo *vo)
x11_error_output = x11->log;
XSetErrorHandler(x11_errorhandler);
x11->present = mp_present_initialize(x11, VO_MAX_SWAPCHAIN_DEPTH);
x11->present = mp_present_initialize(x11, x11->opts, VO_MAX_SWAPCHAIN_DEPTH);
dispName = XDisplayName(NULL);