From c1ce983826c86e9405d8896a0a2f15cf15c4e74a Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Tue, 29 Oct 2024 11:18:48 +0100 Subject: [PATCH] backend/drm: Store only a single plane viewport We store both queued and current buffers to be able to retain both the framebuffer currently on screen and the one queued to replace it. From a re-use perspective, we only care about the last committed framebuffer. The viewport is only stored in order to be re-used together with the last committed framebuffer, so do away with the queued/current distinction and store a single viewport updated every time a commit completes. --- backend/drm/drm.c | 7 +++---- include/backend/drm/drm.h | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index dcd9f3af1..f34c9a085 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -557,7 +557,7 @@ static void drm_connector_apply_commit(const struct wlr_drm_connector_state *sta struct wlr_drm_crtc *crtc = conn->crtc; drm_fb_copy(&crtc->primary->queued_fb, state->primary_fb); - crtc->primary->queued_viewport = state->primary_viewport; + crtc->primary->viewport = state->primary_viewport; if (crtc->cursor != NULL) { drm_fb_copy(&crtc->cursor->queued_fb, state->cursor_fb); } @@ -674,10 +674,10 @@ static void drm_connector_state_init(struct wlr_drm_connector_state *state, struct wlr_drm_plane *primary = conn->crtc->primary; if (primary->queued_fb != NULL) { state->primary_fb = drm_fb_lock(primary->queued_fb); - state->primary_viewport = primary->queued_viewport; + state->primary_viewport = primary->viewport; } else if (primary->current_fb != NULL) { state->primary_fb = drm_fb_lock(primary->current_fb); - state->primary_viewport = primary->current_viewport; + state->primary_viewport = primary->viewport; } if (conn->cursor_enabled) { @@ -1962,7 +1962,6 @@ static void handle_page_flip(int fd, unsigned seq, struct wlr_drm_plane *plane = conn->crtc->primary; if (plane->queued_fb) { drm_fb_move(&plane->current_fb, &plane->queued_fb); - plane->current_viewport = plane->queued_viewport; } if (conn->crtc->cursor && conn->crtc->cursor->queued_fb) { drm_fb_move(&conn->crtc->cursor->current_fb, diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h index 9d3d62272..9409b7b10 100644 --- a/include/backend/drm/drm.h +++ b/include/backend/drm/drm.h @@ -29,10 +29,10 @@ struct wlr_drm_plane { /* Buffer submitted to the kernel, will be presented on next vblank */ struct wlr_drm_fb *queued_fb; - struct wlr_drm_viewport queued_viewport; /* Buffer currently displayed on screen */ struct wlr_drm_fb *current_fb; - struct wlr_drm_viewport current_viewport; + /* Viewport belonging to the last committed fb */ + struct wlr_drm_viewport viewport; struct wlr_drm_format_set formats;