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.
This commit is contained in:
Kenny Levinsen 2024-10-29 11:18:48 +01:00
parent 1edd5e224f
commit c1ce983826
2 changed files with 5 additions and 6 deletions

View File

@ -557,7 +557,7 @@ static void drm_connector_apply_commit(const struct wlr_drm_connector_state *sta
struct wlr_drm_crtc *crtc = conn->crtc; struct wlr_drm_crtc *crtc = conn->crtc;
drm_fb_copy(&crtc->primary->queued_fb, state->primary_fb); 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) { if (crtc->cursor != NULL) {
drm_fb_copy(&crtc->cursor->queued_fb, state->cursor_fb); 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; struct wlr_drm_plane *primary = conn->crtc->primary;
if (primary->queued_fb != NULL) { if (primary->queued_fb != NULL) {
state->primary_fb = drm_fb_lock(primary->queued_fb); 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) { } else if (primary->current_fb != NULL) {
state->primary_fb = drm_fb_lock(primary->current_fb); state->primary_fb = drm_fb_lock(primary->current_fb);
state->primary_viewport = primary->current_viewport; state->primary_viewport = primary->viewport;
} }
if (conn->cursor_enabled) { 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; struct wlr_drm_plane *plane = conn->crtc->primary;
if (plane->queued_fb) { if (plane->queued_fb) {
drm_fb_move(&plane->current_fb, &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) { if (conn->crtc->cursor && conn->crtc->cursor->queued_fb) {
drm_fb_move(&conn->crtc->cursor->current_fb, drm_fb_move(&conn->crtc->cursor->current_fb,

View File

@ -29,10 +29,10 @@ struct wlr_drm_plane {
/* Buffer submitted to the kernel, will be presented on next vblank */ /* Buffer submitted to the kernel, will be presented on next vblank */
struct wlr_drm_fb *queued_fb; struct wlr_drm_fb *queued_fb;
struct wlr_drm_viewport queued_viewport;
/* Buffer currently displayed on screen */ /* Buffer currently displayed on screen */
struct wlr_drm_fb *current_fb; 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; struct wlr_drm_format_set formats;