backend: drop wlr_backend_get_presentation_clock()

We can just assume CLOCK_MONOTONIC everywhere.

Simplifies the backend API, and fixes clock mismatches when multiple
backends are used together with different clocks.
This commit is contained in:
Simon Ser 2023-10-30 18:37:13 +01:00
parent 5fac9b1beb
commit 1c24b1182b
12 changed files with 13 additions and 56 deletions

View file

@ -116,13 +116,6 @@ static struct wlr_session *session_create_and_wait(struct wl_display *disp) {
#endif
}
clockid_t wlr_backend_get_presentation_clock(struct wlr_backend *backend) {
if (backend->impl->get_presentation_clock) {
return backend->impl->get_presentation_clock(backend);
}
return CLOCK_MONOTONIC;
}
int wlr_backend_get_drm_fd(struct wlr_backend *backend) {
if (!backend->impl->get_drm_fd) {
return -1;

View file

@ -64,11 +64,6 @@ static void backend_destroy(struct wlr_backend *backend) {
free(drm);
}
static clockid_t backend_get_presentation_clock(struct wlr_backend *backend) {
struct wlr_drm_backend *drm = get_drm_backend_from_backend(backend);
return drm->clock;
}
static int backend_get_drm_fd(struct wlr_backend *backend) {
struct wlr_drm_backend *drm = get_drm_backend_from_backend(backend);
@ -86,7 +81,6 @@ static uint32_t drm_backend_get_buffer_caps(struct wlr_backend *backend) {
static const struct wlr_backend_impl backend_impl = {
.start = backend_start,
.destroy = backend_destroy,
.get_presentation_clock = backend_get_presentation_clock,
.get_drm_fd = backend_get_drm_fd,
.get_buffer_caps = drm_backend_get_buffer_caps,
};

View file

@ -80,6 +80,11 @@ bool check_drm_features(struct wlr_drm_backend *drm) {
return false;
}
if (drmGetCap(drm->fd, DRM_CAP_TIMESTAMP_MONOTONIC, &cap) || !cap) {
wlr_log(WLR_ERROR, "DRM_CAP_TIMESTAMP_MONOTONIC unsupported");
return false;
}
if (env_parse_bool("WLR_DRM_FORCE_LIBLIFTOFF")) {
#if HAVE_LIBLIFTOFF
wlr_log(WLR_INFO,
@ -110,13 +115,10 @@ bool check_drm_features(struct wlr_drm_backend *drm) {
drm->supports_tearing_page_flips = drmGetCap(drm->fd, DRM_CAP_ASYNC_PAGE_FLIP, &cap) == 0 && cap == 1;
}
int ret = drmGetCap(drm->fd, DRM_CAP_TIMESTAMP_MONOTONIC, &cap);
drm->clock = (ret == 0 && cap == 1) ? CLOCK_MONOTONIC : CLOCK_REALTIME;
if (env_parse_bool("WLR_DRM_NO_MODIFIERS")) {
wlr_log(WLR_DEBUG, "WLR_DRM_NO_MODIFIERS set, disabling modifiers");
} else {
ret = drmGetCap(drm->fd, DRM_CAP_ADDFB2_MODIFIERS, &cap);
int ret = drmGetCap(drm->fd, DRM_CAP_ADDFB2_MODIFIERS, &cap);
drm->addfb2_modifiers = ret == 0 && cap == 1;
wlr_log(WLR_DEBUG, "ADDFB2 modifiers %s",
drm->addfb2_modifiers ? "supported" : "unsupported");

View file

@ -63,20 +63,6 @@ static void multi_backend_destroy(struct wlr_backend *wlr_backend) {
free(backend);
}
static clockid_t multi_backend_get_presentation_clock(
struct wlr_backend *backend) {
struct wlr_multi_backend *multi = multi_backend_from_backend(backend);
struct subbackend_state *sub;
wl_list_for_each(sub, &multi->backends, link) {
if (sub->backend->impl->get_presentation_clock) {
return wlr_backend_get_presentation_clock(sub->backend);
}
}
return CLOCK_MONOTONIC;
}
static int multi_backend_get_drm_fd(struct wlr_backend *backend) {
struct wlr_multi_backend *multi = multi_backend_from_backend(backend);
@ -115,7 +101,6 @@ static uint32_t multi_backend_get_buffer_caps(struct wlr_backend *backend) {
static const struct wlr_backend_impl backend_impl = {
.start = multi_backend_start,
.destroy = multi_backend_destroy,
.get_presentation_clock = multi_backend_get_presentation_clock,
.get_drm_fd = multi_backend_get_drm_fd,
.get_buffer_caps = multi_backend_get_buffer_caps,
};

View file

@ -95,7 +95,11 @@ static const struct xdg_wm_base_listener xdg_wm_base_listener = {
static void presentation_handle_clock_id(void *data,
struct wp_presentation *presentation, uint32_t clock) {
struct wlr_wl_backend *wl = data;
wl->presentation_clock = clock;
if (clock != CLOCK_MONOTONIC) {
wp_presentation_destroy(wl->presentation);
wl->presentation = NULL;
}
}
static const struct wp_presentation_listener presentation_listener = {
@ -535,11 +539,6 @@ static void backend_destroy(struct wlr_backend *backend) {
free(wl);
}
static clockid_t backend_get_presentation_clock(struct wlr_backend *backend) {
struct wlr_wl_backend *wl = get_wl_backend_from_backend(backend);
return wl->presentation_clock;
}
static int backend_get_drm_fd(struct wlr_backend *backend) {
struct wlr_wl_backend *wl = get_wl_backend_from_backend(backend);
return wl->drm_fd;
@ -554,7 +553,6 @@ static uint32_t get_buffer_caps(struct wlr_backend *backend) {
static const struct wlr_backend_impl backend_impl = {
.start = backend_start,
.destroy = backend_destroy,
.get_presentation_clock = backend_get_presentation_clock,
.get_drm_fd = backend_get_drm_fd,
.get_buffer_caps = get_buffer_caps,
};
@ -585,7 +583,6 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
wl_list_init(&wl->outputs);
wl_list_init(&wl->seats);
wl_list_init(&wl->buffers);
wl->presentation_clock = CLOCK_MONOTONIC;
if (remote_display != NULL) {
wl->remote_display = remote_display;