From 2cdb646531d949e08b8a0538b05bd38af3157408 Mon Sep 17 00:00:00 2001 From: Markus Ongyerth Date: Mon, 29 Jan 2018 11:29:54 +0100 Subject: [PATCH 1/2] relases gbm buffers on init The wlr_drm_surface_init function is called (upon others) when the drm mode is changed. When the surface was used previously this replaced the gbm_surface, but did not replace the gbm buffers (front/back). With this, wlr_drm_surface_get_from never set up the new buffers with the new glViewport because surf->front existed. This frees the buffers to get new buffers on the new surface with the new viewport. --- backend/drm/renderer.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index 00182c59..d28164aa 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -66,6 +66,17 @@ bool wlr_drm_surface_init(struct wlr_drm_surface *surf, surf->width = width; surf->height = height; + if (surf->gbm) { + if (surf->front) { + gbm_surface_release_buffer(surf->gbm, surf->front); + surf->front = NULL; + } + if (surf->back) { + gbm_surface_release_buffer(surf->gbm, surf->back); + surf->back = NULL; + } + } + surf->gbm = gbm_surface_create(renderer->gbm, width, height, format, GBM_BO_USE_RENDERING | flags); if (!surf->gbm) { From cde0f454b376703e68662f9552b38fc10e97b74a Mon Sep 17 00:00:00 2001 From: Markus Ongyerth Date: Mon, 29 Jan 2018 11:49:31 +0100 Subject: [PATCH 2/2] Clean up the gbm/egl as well --- backend/drm/renderer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index d28164aa..350bfce4 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -75,6 +75,10 @@ bool wlr_drm_surface_init(struct wlr_drm_surface *surf, gbm_surface_release_buffer(surf->gbm, surf->back); surf->back = NULL; } + gbm_surface_destroy(surf->gbm); + } + if (surf->egl) { + eglDestroySurface(surf->renderer->egl.display, surf->egl); } surf->gbm = gbm_surface_create(renderer->gbm, width, height,