Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion video/out/vulkan/context_wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ static bool wayland_vk_init(struct ra_ctx *ctx)
* thread which is just not good. Use MAILBOX for those compositors to
* avoid indefinite blocking. */
struct vo_wayland_state *wl = ctx->vo->wl;
p->use_fifo = wl->has_fifo && wl->present_v2 && wl->opts->wl_internal_vsync != 2;
p->use_fifo = wl->has_fifo && wl->presentation && wl->opts->wl_internal_vsync != 2 &&
vo_wayland_proxy_get_version((struct wl_proxy *)wl->presentation) >= 2;
if (!ra_vk_ctx_init(ctx, vk, params, p->use_fifo ? VK_PRESENT_MODE_FIFO_KHR : VK_PRESENT_MODE_MAILBOX_KHR))
goto error;

Expand Down
28 changes: 27 additions & 1 deletion video/out/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ struct vo_wayland_feedback_pool {
struct wp_presentation_feedback **fback;
struct vo_wayland_state *wl;
int last_zero_copy;
int last_refresh_type;
int len;
};

Expand Down Expand Up @@ -2591,6 +2592,21 @@ static void feedback_presented(void *data, struct wp_presentation_feedback *fbac
current_zero_copy ? "direct scanout" : "a copy");
fback_pool->last_zero_copy = current_zero_copy;
}
#ifdef WP_PRESENTATION_FEEDBACK_KIND_VARIABLE_RATE_SINCE_VERSION
if (wp_presentation_feedback_get_version(fback) >= 3) {
int refresh_type = flags & WP_PRESENTATION_FEEDBACK_KIND_FIXED_RATE ? 1 :
flags & WP_PRESENTATION_FEEDBACK_KIND_VARIABLE_RATE ? 0 :
-1;

if (fback_pool->last_refresh_type != refresh_type) {
MP_DBG(wl, "Presentation was done with %s refresh rate.\n",
refresh_type == 1 ? "fixed" :
refresh_type == 0 ? "variable" :
"unknown");
fback_pool->last_refresh_type = refresh_type;
}
}
#endif

if (fback)
remove_feedback(fback_pool, fback);
Expand All @@ -2616,6 +2632,7 @@ static void feedback_discarded(void *data, struct wp_presentation_feedback *fbac
{
struct vo_wayland_feedback_pool *fback_pool = data;
fback_pool->last_zero_copy = -1;
fback_pool->last_refresh_type = -1;
if (fback)
remove_feedback(fback_pool, fback);
}
Expand Down Expand Up @@ -2930,8 +2947,11 @@ static void registry_handle_add(void *data, struct wl_registry *reg, uint32_t id
}

if (!strcmp(interface, wp_presentation_interface.name) && found++) {
#ifdef WP_PRESENTATION_FEEDBACK_KIND_VARIABLE_RATE_SINCE_VERSION
ver = MPMIN(ver, 3);
#else
ver = MPMIN(ver, 2);
wl->present_v2 = ver == 2;
#endif
wl->presentation = wl_registry_bind(reg, id, &wp_presentation_interface, ver);
wp_presentation_add_listener(wl->presentation, &presentation_listener, wl);
}
Expand Down Expand Up @@ -4684,6 +4704,7 @@ bool vo_wayland_init(struct vo *vo)
wl->fback_pool->wl = wl;
wl->fback_pool->len = VO_MAX_SWAPCHAIN_DEPTH;
wl->fback_pool->last_zero_copy = -1,
wl->fback_pool->last_refresh_type = -1,
wl->fback_pool->fback = talloc_zero_array(wl->fback_pool, struct wp_presentation_feedback *,
wl->fback_pool->len);
wl->present = mp_present_initialize(wl, wl->opts, VO_MAX_SWAPCHAIN_DEPTH);
Expand Down Expand Up @@ -5078,6 +5099,11 @@ void vo_wayland_wakeup(struct vo *vo)
(void)write(wl->wakeup_pipe[1], &(char){0}, 1);
}

int vo_wayland_proxy_get_version(struct wl_proxy *proxy)
{
return wl_proxy_get_version(proxy);
}

#if HAVE_WAYLAND_PROTOCOLS_1_48
static char *session_file(void *talloc_ctx, const char *session, struct vo *vo)
{
Expand Down
2 changes: 1 addition & 1 deletion video/out/wayland_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ struct vo_wayland_state {
struct mp_present *present;
int64_t refresh_interval;
bool present_clock;
bool present_v2;
bool use_present;

/* single-pixel-buffer */
Expand Down Expand Up @@ -243,5 +242,6 @@ void vo_wayland_uninit(struct vo *vo);
void vo_wayland_wait_events(struct vo *vo, int64_t until_time_ns);
void vo_wayland_wait_frame(struct vo_wayland_state *wl);
void vo_wayland_wakeup(struct vo *vo);
int vo_wayland_proxy_get_version(struct wl_proxy *proxy);

#endif /* MPLAYER_WAYLAND_COMMON_H */
Loading