From dabd2e7207ca0cf53d2abce32b3b7531badfa0de Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 14 Dec 2020 19:57:05 +0100 Subject: backend/drm: grab DMA-BUF from wlr_buffer instead of gbm_bo Get the DMA-BUF directly out of the wlr_buffer instead of relying on the gbm_bo. This eliminates a roundtrip through GBM. --- backend/drm/drm.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'backend') diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 50256abd..9f3ff355 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -626,14 +626,21 @@ static bool drm_connector_export_dmabuf(struct wlr_output *output, } struct wlr_drm_fb *fb = &crtc->primary->queued_fb; - if (fb->bo == NULL) { + if (fb->wlr_buf == NULL) { fb = &crtc->primary->current_fb; } - if (fb->bo == NULL) { + if (fb->wlr_buf == NULL) { return false; } - return export_drm_bo(fb->bo, attribs); + // export_dmabuf gives ownership of the DMA-BUF to the caller, so we need + // to dup it + struct wlr_dmabuf_attributes buf_attribs = {0}; + if (!wlr_buffer_get_dmabuf(fb->wlr_buf, &buf_attribs)) { + return false; + } + + return wlr_dmabuf_attributes_copy(attribs, &buf_attribs); } struct wlr_drm_fb *plane_get_next_fb(struct wlr_drm_plane *plane) { -- cgit v1.2.3