aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-03-02 13:26:53 +0100
committerDrew DeVault <sir@cmpwn.com>2020-03-04 03:22:19 +0100
commit348f52b5fc9be71bc22a6c0e00682667fb62374a (patch)
tree0b1d187177b5ce0fac0011d4e5d60ae5eee07465
parent613f9c6f8d1b50427430505c17275fd93f7afb18 (diff)
output: remove wlr_output_impl.schedule_frame
This function allowed backends to provide a custom function for frame scheduling. Before resuming the rendering loop, the DRM and Wayland backends would wait for vsync. There isn't a clear benefit of doing this. The only upside is that we get more stable timings: the delay between two repaints doesn't change too much and is close to a mutliple of the refresh rate. However this introduces latency, especially when a client misses a frame. For instance a fullscreen game missing vblank will need to wait more than a whole frame before being able to display new content. This worst case scenario happens as follows: - Client is still rendering its frame and cannot submit it in time - Deadline is reached - Compositor decides to stop the rendering loop since nothing changed on screen - Client finally manages to render its frame, submits it - Compositor calls wlr_output_schedule_frame - DRM backend waits for next vblank - The wlr_output frame event is fired, compositor draws new content on screen - On the second next vblank, the new content reaches the screen With this patch, the wlr_output frame event is fired immediately when the client submits its late frame. This change also makes it easier to support variable refresh rate, since VRR is all about being able to present too-late frames earlier. References: https://github.com/swaywm/wlroots/issues/1925
-rw-r--r--backend/drm/drm.c42
-rw-r--r--backend/wayland/output.c15
-rw-r--r--include/wlr/interfaces/wlr_output.h1
-rw-r--r--types/wlr_output.c7
4 files changed, 2 insertions, 63 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index a97915ec..ebea340e 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -960,47 +960,6 @@ static bool drm_connector_move_cursor(struct wlr_output *output,
return ok;
}
-static bool drm_connector_schedule_frame(struct wlr_output *output) {
- struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
- struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend);
- if (!drm->session->active) {
- return false;
- }
-
- // We need to figure out where we are in the vblank cycle
- // TODO: try using drmWaitVBlank and fallback to pageflipping
-
- struct wlr_drm_crtc *crtc = conn->crtc;
- if (!crtc) {
- return false;
- }
- struct wlr_drm_plane *plane = crtc->primary;
- struct gbm_bo *bo = plane->surf.back;
- if (!bo) {
- // We haven't swapped buffers yet -- can't do a pageflip
- wlr_output_send_frame(output);
- return true;
- }
- if (drm->parent) {
- bo = copy_drm_surface_mgpu(&plane->mgpu_surf, bo);
- }
-
- if (conn->pageflip_pending) {
- wlr_log(WLR_ERROR, "Skipping pageflip on output '%s'",
- conn->output.name);
- return true;
- }
-
- uint32_t fb_id = get_fb_for_bo(bo, plane->drm_format, drm->addfb2_modifiers);
- if (!drm->iface->crtc_pageflip(drm, conn, crtc, fb_id, NULL)) {
- return false;
- }
-
- conn->pageflip_pending = true;
- wlr_output_update_enabled(output, true);
- return true;
-}
-
static uint32_t strip_alpha_channel(uint32_t format) {
switch (format) {
case DRM_FORMAT_ARGB8888:
@@ -1070,7 +1029,6 @@ static const struct wlr_output_impl output_impl = {
.set_gamma = set_drm_connector_gamma,
.get_gamma_size = drm_connector_get_gamma_size,
.export_dmabuf = drm_connector_export_dmabuf,
- .schedule_frame = drm_connector_schedule_frame,
.attach_buffer = drm_connector_attach_buffer,
};
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index 7a3a08d0..2c80c77f 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -415,20 +415,6 @@ static bool output_move_cursor(struct wlr_output *_output, int x, int y) {
return true;
}
-static bool output_schedule_frame(struct wlr_output *wlr_output) {
- struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
-
- if (output->frame_callback != NULL) {
- wlr_log(WLR_ERROR, "Skipping frame scheduling");
- return true;
- }
-
- output->frame_callback = wl_surface_frame(output->surface);
- wl_callback_add_listener(output->frame_callback, &frame_listener, output);
- wl_surface_commit(output->surface);
- return true;
-}
-
static const struct wlr_output_impl output_impl = {
.destroy = output_destroy,
.attach_render = output_attach_render,
@@ -436,7 +422,6 @@ static const struct wlr_output_impl output_impl = {
.commit = output_commit,
.set_cursor = output_set_cursor,
.move_cursor = output_move_cursor,
- .schedule_frame = output_schedule_frame,
};
bool wlr_output_is_wl(struct wlr_output *wlr_output) {
diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h
index 8d4a3fd8..12980ee5 100644
--- a/include/wlr/interfaces/wlr_output.h
+++ b/include/wlr/interfaces/wlr_output.h
@@ -27,7 +27,6 @@ struct wlr_output_impl {
size_t (*get_gamma_size)(struct wlr_output *output);
bool (*export_dmabuf)(struct wlr_output *output,
struct wlr_dmabuf_attributes *attribs);
- bool (*schedule_frame)(struct wlr_output *output);
bool (*attach_buffer)(struct wlr_output *output, struct wlr_buffer *buffer);
};
diff --git a/types/wlr_output.c b/types/wlr_output.c
index 611309db..51b1fcae 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -599,11 +599,8 @@ void wlr_output_send_frame(struct wlr_output *output) {
static void schedule_frame_handle_idle_timer(void *data) {
struct wlr_output *output = data;
output->idle_frame = NULL;
- if (!output->frame_pending && output->impl->schedule_frame) {
- // Ask the backend to send a frame event when appropriate
- if (output->impl->schedule_frame(output)) {
- output->frame_pending = true;
- }
+ if (!output->frame_pending) {
+ wlr_output_send_frame(output);
}
}