mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-21 22:52:20 +00:00
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:
parent
5fac9b1beb
commit
1c24b1182b
@ -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;
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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");
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wayland-util.h>
|
||||
#include <wlr/backend/drm.h>
|
||||
@ -79,7 +78,6 @@ struct wlr_drm_backend {
|
||||
|
||||
struct wlr_drm_backend *parent;
|
||||
const struct wlr_drm_interface *iface;
|
||||
clockid_t clock;
|
||||
bool addfb2_modifiers;
|
||||
|
||||
int fd;
|
||||
|
@ -43,7 +43,6 @@ struct wlr_wl_backend {
|
||||
struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1;
|
||||
struct wl_list seats; // wlr_wl_seat.link
|
||||
struct zwp_tablet_manager_v2 *tablet_manager;
|
||||
clockid_t presentation_clock;
|
||||
struct wlr_drm_format_set shm_formats;
|
||||
struct wlr_drm_format_set linux_dmabuf_v1_formats;
|
||||
struct wl_drm *legacy_drm;
|
||||
|
@ -51,10 +51,6 @@ bool wlr_backend_start(struct wlr_backend *backend);
|
||||
* automatically when the struct wl_display is destroyed.
|
||||
*/
|
||||
void wlr_backend_destroy(struct wlr_backend *backend);
|
||||
/**
|
||||
* Returns the clock used by the backend for presentation feedback.
|
||||
*/
|
||||
clockid_t wlr_backend_get_presentation_clock(struct wlr_backend *backend);
|
||||
/**
|
||||
* Returns the DRM node file descriptor used by the backend's underlying
|
||||
* platform. Can be used by consumers for additional rendering operations.
|
||||
|
@ -10,13 +10,11 @@
|
||||
#define WLR_BACKEND_INTERFACE_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <time.h>
|
||||
#include <wlr/backend.h>
|
||||
|
||||
struct wlr_backend_impl {
|
||||
bool (*start)(struct wlr_backend *backend);
|
||||
void (*destroy)(struct wlr_backend *backend);
|
||||
clockid_t (*get_presentation_clock)(struct wlr_backend *backend);
|
||||
int (*get_drm_fd)(struct wlr_backend *backend);
|
||||
uint32_t (*get_buffer_caps)(struct wlr_backend *backend);
|
||||
};
|
||||
|
@ -21,7 +21,6 @@ struct wlr_output_event_present;
|
||||
|
||||
struct wlr_presentation {
|
||||
struct wl_global *global;
|
||||
clockid_t clock;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
|
@ -913,9 +913,7 @@ void wlr_output_send_present(struct wlr_output *output,
|
||||
|
||||
struct timespec now;
|
||||
if (event->presented && event->when == NULL) {
|
||||
clockid_t clock = wlr_backend_get_presentation_clock(output->backend);
|
||||
errno = 0;
|
||||
if (clock_gettime(clock, &now) != 0) {
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &now) != 0) {
|
||||
wlr_log_errno(WLR_ERROR, "failed to send output present event: "
|
||||
"failed to read clock");
|
||||
return;
|
||||
|
@ -168,7 +168,7 @@ static void presentation_bind(struct wl_client *client, void *data,
|
||||
wl_resource_set_implementation(resource, &presentation_impl, presentation,
|
||||
NULL);
|
||||
|
||||
wp_presentation_send_clock_id(resource, (uint32_t)presentation->clock);
|
||||
wp_presentation_send_clock_id(resource, CLOCK_MONOTONIC);
|
||||
}
|
||||
|
||||
static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
||||
@ -194,8 +194,6 @@ struct wlr_presentation *wlr_presentation_create(struct wl_display *display,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
presentation->clock = wlr_backend_get_presentation_clock(backend);
|
||||
|
||||
wl_signal_init(&presentation->events.destroy);
|
||||
|
||||
presentation->display_destroy.notify = handle_display_destroy;
|
||||
|
Loading…
Reference in New Issue
Block a user