diff --git a/backend/drm/drm.c b/backend/drm/drm.c index bd482be3..95f8c3d0 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -377,7 +377,7 @@ static bool drm_crtc_page_flip(struct wlr_drm_connector *conn) { } assert(crtc->pending.active); - assert(plane_get_next_fb(crtc->primary)->type != WLR_DRM_FB_TYPE_NONE); + assert(plane_get_next_fb(crtc->primary)->bo); if (!drm_crtc_commit(conn, DRM_MODE_PAGE_FLIP_EVENT)) { return false; } @@ -650,10 +650,10 @@ static bool drm_connector_export_dmabuf(struct wlr_output *output, } struct wlr_drm_fb *fb = &crtc->primary->queued_fb; - if (fb->type == WLR_DRM_FB_TYPE_NONE) { + if (fb->bo == NULL) { fb = &crtc->primary->current_fb; } - if (fb->type == WLR_DRM_FB_TYPE_NONE) { + if (fb->bo == NULL) { return false; } @@ -661,10 +661,10 @@ static bool drm_connector_export_dmabuf(struct wlr_output *output, } struct wlr_drm_fb *plane_get_next_fb(struct wlr_drm_plane *plane) { - if (plane->pending_fb.type != WLR_DRM_FB_TYPE_NONE) { + if (plane->pending_fb.bo) { return &plane->pending_fb; } - if (plane->queued_fb.type != WLR_DRM_FB_TYPE_NONE) { + if (plane->queued_fb.bo) { return &plane->queued_fb; } return &plane->current_fb; @@ -680,7 +680,7 @@ static bool drm_connector_pageflip_renderer(struct wlr_drm_connector *conn) { // drm_crtc_page_flip expects a FB to be available struct wlr_drm_plane *plane = crtc->primary; - if (plane_get_next_fb(plane)->type == WLR_DRM_FB_TYPE_NONE) { + if (!plane_get_next_fb(plane)->bo) { drm_surface_render_black_frame(&plane->surf); if (!drm_fb_lock_surface(&plane->pending_fb, &plane->surf)) { return false; @@ -1507,11 +1507,10 @@ static void page_flip_handler(int fd, unsigned seq, } struct wlr_drm_plane *plane = conn->crtc->primary; - if (plane->queued_fb.type != WLR_DRM_FB_TYPE_NONE) { + if (plane->queued_fb.bo) { drm_fb_move(&plane->current_fb, &plane->queued_fb); } - if (conn->crtc->cursor && - conn->crtc->cursor->queued_fb.type != WLR_DRM_FB_TYPE_NONE) { + if (conn->crtc->cursor && conn->crtc->cursor->queued_fb.bo) { drm_fb_move(&conn->crtc->cursor->current_fb, &conn->crtc->cursor->queued_fb); } @@ -1522,7 +1521,8 @@ static void page_flip_handler(int fd, unsigned seq, * data between the GPUs, even if we were using the direct scanout * interface. */ - if (!drm->parent && plane->current_fb.type == WLR_DRM_FB_TYPE_WLR_BUFFER) { + if (!drm->parent && plane->current_fb.wlr_buf && + wlr_client_buffer_get(plane->current_fb.wlr_buf)) { present_flags |= WLR_OUTPUT_PRESENT_ZERO_COPY; } diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index 1d6a3277..a841aecf 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -280,21 +280,15 @@ bool drm_plane_init_surface(struct wlr_drm_plane *plane, } void drm_fb_clear(struct wlr_drm_fb *fb) { - switch (fb->type) { - case WLR_DRM_FB_TYPE_NONE: - assert(!fb->bo); - break; - case WLR_DRM_FB_TYPE_SURFACE: - abort(); // TODO: remove this case entirely - break; - case WLR_DRM_FB_TYPE_WLR_BUFFER: - gbm_bo_destroy(fb->bo); - wlr_buffer_unlock(fb->wlr_buf); - fb->wlr_buf = NULL; - break; + if (!fb->bo) { + assert(!fb->wlr_buf); + return; } - fb->type = WLR_DRM_FB_TYPE_NONE; + gbm_bo_destroy(fb->bo); + wlr_buffer_unlock(fb->wlr_buf); + + fb->wlr_buf = NULL; fb->bo = NULL; if (fb->mgpu_bo) { @@ -376,7 +370,6 @@ bool drm_fb_import_wlr(struct wlr_drm_fb *fb, struct wlr_drm_renderer *renderer, return false; } - fb->type = WLR_DRM_FB_TYPE_WLR_BUFFER; fb->wlr_buf = wlr_buffer_lock(buf); return true; diff --git a/include/backend/drm/renderer.h b/include/backend/drm/renderer.h index 8cc4b0de..e3fb6c9e 100644 --- a/include/backend/drm/renderer.h +++ b/include/backend/drm/renderer.h @@ -33,20 +33,12 @@ struct wlr_drm_surface { struct wlr_buffer *back_buffer; }; -enum wlr_drm_fb_type { - WLR_DRM_FB_TYPE_NONE, - WLR_DRM_FB_TYPE_SURFACE, - WLR_DRM_FB_TYPE_WLR_BUFFER -}; - struct wlr_drm_fb { - enum wlr_drm_fb_type type; struct gbm_bo *bo; + struct wlr_buffer *wlr_buf; struct wlr_drm_surface *mgpu_surf; struct gbm_bo *mgpu_bo; - - struct wlr_buffer *wlr_buf; }; bool init_drm_renderer(struct wlr_drm_backend *drm,