From 63c3faa006dd477faba635eb5c9962077058ffb3 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Fri, 9 Jun 2017 17:15:55 +1200 Subject: [PATCH] Fixed rendering bug: Delay calling gbm_surface_release_buffer until it has been scanned out. --- backend/drm/drm.c | 12 ++++++++++-- include/backend/drm/drm.h | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 90695175f..066edd67e 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -111,8 +111,10 @@ static void wlr_drm_output_end(struct wlr_output_state *output) { } uint32_t fb_id = get_fb_for_bo(renderer->fd, bo); drmModePageFlip(renderer->fd, output->crtc, fb_id, DRM_MODE_PAGE_FLIP_EVENT, output); - gbm_surface_release_buffer(output->gbm, bo); output->pageflip_pending = true; + + output->bo_last = output->bo_current; + output->bo_current = bo; } void wlr_drm_output_start_renderer(struct wlr_output_state *output) { @@ -140,7 +142,8 @@ void wlr_drm_output_start_renderer(struct wlr_output_state *output) { drmModePageFlip(renderer->fd, output->crtc, fb_id, DRM_MODE_PAGE_FLIP_EVENT, output); - gbm_surface_release_buffer(output->gbm, bo); + output->bo_last = NULL; + output->bo_current = bo; } static bool display_init_renderer(struct wlr_drm_renderer *renderer, @@ -517,6 +520,11 @@ static void page_flip_handler(int fd, unsigned seq, struct wlr_backend_state *state = wl_container_of(output->renderer, state, renderer); + if (output->bo_last) { + gbm_surface_release_buffer(output->gbm, output->bo_last); + output->bo_last = NULL; + } + output->pageflip_pending = false; if (output->state == DRM_OUTPUT_CONNECTED) { wlr_drm_output_begin(output); diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h index 2d063adb1..443873fd4 100644 --- a/include/backend/drm/drm.h +++ b/include/backend/drm/drm.h @@ -47,6 +47,8 @@ struct wlr_output_state { struct wlr_drm_renderer *renderer; struct gbm_surface *gbm; + struct gbm_bo *bo_last; + struct gbm_bo *bo_current; EGLSurface *egl; bool pageflip_pending;