From d9bbc416a62c2d280e6921da6b25128a1b3a9e22 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 22 Dec 2020 18:42:59 +0100 Subject: backend/drm: re-use FBs Instead of importing buffers to GBM and KMS at each frame, cache them and re-use them while the wlr_buffer is alive. This is the same as [1] and [2] but for the DRM backend. [1]: https://github.com/swaywm/wlroots/pull/2538 [2]: https://github.com/swaywm/wlroots/pull/2539 --- include/backend/drm/drm.h | 1 + include/backend/drm/renderer.h | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'include/backend') diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h index 23b06847..52aacf39 100644 --- a/include/backend/drm/drm.h +++ b/include/backend/drm/drm.h @@ -86,6 +86,7 @@ struct wlr_drm_backend { struct wl_listener session_active; struct wl_listener dev_change; + struct wl_list fbs; // wlr_drm_fb.link struct wl_list outputs; struct wlr_drm_renderer renderer; diff --git a/include/backend/drm/renderer.h b/include/backend/drm/renderer.h index 8316a070..fdc8a75d 100644 --- a/include/backend/drm/renderer.h +++ b/include/backend/drm/renderer.h @@ -31,8 +31,12 @@ struct wlr_drm_surface { struct wlr_drm_fb { struct wlr_buffer *wlr_buf; + struct wl_list link; // wlr_drm_backend.fbs + struct gbm_bo *bo; uint32_t id; + + struct wl_listener wlr_buf_destroy; }; bool init_drm_renderer(struct wlr_drm_backend *drm, @@ -47,6 +51,7 @@ bool drm_fb_lock_surface(struct wlr_drm_fb **fb, struct wlr_drm_backend *drm, bool drm_fb_import(struct wlr_drm_fb **fb, struct wlr_drm_backend *drm, struct wlr_buffer *buf, struct wlr_drm_surface *mgpu, const struct wlr_drm_format_set *formats); +void drm_fb_destroy(struct wlr_drm_fb *fb); void drm_fb_clear(struct wlr_drm_fb **fb); void drm_fb_move(struct wlr_drm_fb **new, struct wlr_drm_fb **old); -- cgit v1.2.3