diff options
-rw-r--r-- | backend/drm/backend.c | 2 | ||||
-rw-r--r-- | backend/drm/drm.c | 6 | ||||
-rw-r--r-- | backend/drm/renderer.c | 22 | ||||
-rw-r--r-- | include/backend/drm/renderer.h | 4 |
4 files changed, 25 insertions, 9 deletions
diff --git a/backend/drm/backend.c b/backend/drm/backend.c index e3148821..468fca6e 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -143,7 +143,7 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display, goto error_event; } - if (!wlr_drm_renderer_init(&drm->renderer, drm->fd)) { + if (!wlr_drm_renderer_init(drm, &drm->renderer)) { wlr_log(L_ERROR, "Failed to initialize renderer"); goto error_event; } diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 3effa9ff..ccdc92d9 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -856,9 +856,13 @@ void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn) { case WLR_DRM_CONN_CLEANUP:; struct wlr_drm_crtc *crtc = conn->crtc; for (int i = 0; i < 3; ++i) { + if (!crtc->planes[i]) { + continue; + } + wlr_drm_surface_finish(&crtc->planes[i]->surf); wlr_drm_surface_finish(&crtc->planes[i]->mgpu_surf); - if (crtc->planes[i] && crtc->planes[i]->id == 0) { + if (crtc->planes[i]->id == 0) { free(crtc->planes[i]); crtc->planes[i] = NULL; } diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index bcadf17e..c5840436 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -15,8 +15,9 @@ #include <wlr/render.h> #include "backend/drm/drm.h" -bool wlr_drm_renderer_init(struct wlr_drm_renderer *renderer, int fd) { - renderer->gbm = gbm_create_device(fd); +bool wlr_drm_renderer_init(struct wlr_drm_backend *drm, + struct wlr_drm_renderer *renderer) { + renderer->gbm = gbm_create_device(drm->fd); if (!renderer->gbm) { wlr_log(L_ERROR, "Failed to create GBM device"); return false; @@ -24,15 +25,23 @@ bool wlr_drm_renderer_init(struct wlr_drm_renderer *renderer, int fd) { if (!wlr_egl_init(&renderer->egl, EGL_PLATFORM_GBM_MESA, GBM_FORMAT_ARGB8888, renderer->gbm)) { - gbm_device_destroy(renderer->gbm); - return false; + goto error_gbm; } - struct wlr_drm_backend *drm = wl_container_of(renderer, drm, renderer); renderer->wlr_rend = wlr_gles2_renderer_create(&drm->backend); + if (!renderer->wlr_rend) { + wlr_log(L_ERROR, "Failed to create WLR renderer"); + goto error_egl; + } - renderer->fd = fd; + renderer->fd = drm->fd; return true; + +error_egl: + wlr_egl_free(&renderer->egl); +error_gbm: + gbm_device_destroy(renderer->gbm); + return false; } void wlr_drm_renderer_finish(struct wlr_drm_renderer *renderer) { @@ -40,6 +49,7 @@ void wlr_drm_renderer_finish(struct wlr_drm_renderer *renderer) { return; } + wlr_renderer_destroy(renderer->wlr_rend); wlr_egl_free(&renderer->egl); gbm_device_destroy(renderer->gbm); } diff --git a/include/backend/drm/renderer.h b/include/backend/drm/renderer.h index 8fcf566d..45127cd0 100644 --- a/include/backend/drm/renderer.h +++ b/include/backend/drm/renderer.h @@ -9,6 +9,7 @@ #include <wlr/render.h> +struct wlr_drm_backend; struct wlr_drm_plane; struct wlr_drm_renderer { @@ -32,7 +33,8 @@ struct wlr_drm_surface { struct gbm_bo *back; }; -bool wlr_drm_renderer_init(struct wlr_drm_renderer *renderer, int fd); +bool wlr_drm_renderer_init(struct wlr_drm_backend *drm, + struct wlr_drm_renderer *renderer); void wlr_drm_renderer_finish(struct wlr_drm_renderer *renderer); bool wlr_drm_surface_init(struct wlr_drm_surface *surf, |