Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
backend/drm: add support for wlr_swapchain buffer age
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion committed Jul 27, 2020
1 parent a5a7c4f commit fa22f19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 11 additions & 2 deletions backend/drm/drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,25 @@ static bool drm_connector_attach_render(struct wlr_output *output,
return drm_surface_make_current(&conn->crtc->primary->surf, buffer_age);
}

static void drm_plane_set_committed(struct wlr_drm_plane *plane) {
drm_fb_move(&plane->queued_fb, &plane->pending_fb);

struct wlr_buffer *queued = plane->queued_fb.wlr_buf;
if (queued != NULL) {
wlr_swapchain_set_buffer_submitted(plane->surf.swapchain, queued);
}
}

static bool drm_crtc_commit(struct wlr_drm_connector *conn, uint32_t flags) {
struct wlr_drm_backend *drm =
get_drm_backend_from_backend(conn->output.backend);
struct wlr_drm_crtc *crtc = conn->crtc;
bool ok = drm->iface->crtc_commit(drm, conn, flags);
if (ok && !(flags & DRM_MODE_ATOMIC_TEST_ONLY)) {
memcpy(&crtc->current, &crtc->pending, sizeof(struct wlr_drm_crtc_state));
drm_fb_move(&crtc->primary->queued_fb, &crtc->primary->pending_fb);
drm_plane_set_committed(crtc->primary);
if (crtc->cursor != NULL) {
drm_fb_move(&crtc->cursor->queued_fb, &crtc->cursor->pending_fb);
drm_plane_set_committed(crtc->cursor);
}
} else {
memcpy(&crtc->pending, &crtc->current, sizeof(struct wlr_drm_crtc_state));
Expand Down
6 changes: 1 addition & 5 deletions backend/drm/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static void finish_drm_surface(struct wlr_drm_surface *surf) {
bool drm_surface_make_current(struct wlr_drm_surface *surf,
int *buffer_age) {
assert(surf->back_buffer == NULL);
surf->back_buffer = wlr_swapchain_acquire(surf->swapchain);
surf->back_buffer = wlr_swapchain_acquire(surf->swapchain, buffer_age);
if (surf->back_buffer == NULL) {
wlr_log(WLR_ERROR, "Failed to acquire swapchain buffer");
return false;
Expand All @@ -150,10 +150,6 @@ bool drm_surface_make_current(struct wlr_drm_surface *surf,
return false;
}

// TODO: damage tracking
if (buffer_age != NULL) {
*buffer_age = -1;
}
return true;
}

Expand Down

0 comments on commit fa22f19

Please sign in to comment.