From d368028bd5557810af954ef96bf0f4addd97f551 Mon Sep 17 00:00:00 2001 From: Austin Shafer Date: Wed, 31 Jan 2024 15:37:07 -0500 Subject: [PATCH] allocator: remove backend parameter in allocator_autocreate_with_drm_fd Since we only use the backend capabilities here we can simply pass them in directly. This allows other locations to create an allocator even if they don't have a backend. They can simply specify the caps they want instead. --- backend/drm/renderer.c | 4 +++- include/render/allocator/allocator.h | 2 +- render/allocator/allocator.c | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index 321d583c..e4aadc10 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -6,6 +6,7 @@ #include "backend/drm/drm.h" #include "backend/drm/fb.h" #include "backend/drm/renderer.h" +#include "backend/backend.h" #include "render/drm_format_set.h" #include "render/allocator/allocator.h" #include "render/pixel_format.h" @@ -19,7 +20,8 @@ bool init_drm_renderer(struct wlr_drm_backend *drm, return false; } - renderer->allocator = allocator_autocreate_with_drm_fd(&drm->backend, + uint32_t backend_caps = backend_get_buffer_caps(&drm->backend); + renderer->allocator = allocator_autocreate_with_drm_fd(backend_caps, renderer->wlr_rend, drm->fd); if (renderer->allocator == NULL) { wlr_log(WLR_ERROR, "Failed to create allocator"); diff --git a/include/render/allocator/allocator.h b/include/render/allocator/allocator.h index 2abdd43d..5f8bd2a1 100644 --- a/include/render/allocator/allocator.h +++ b/include/render/allocator/allocator.h @@ -4,6 +4,6 @@ #include struct wlr_allocator *allocator_autocreate_with_drm_fd( - struct wlr_backend *backend, struct wlr_renderer *renderer, int drm_fd); + uint32_t backend_caps, struct wlr_renderer *renderer, int drm_fd); #endif diff --git a/render/allocator/allocator.c b/render/allocator/allocator.c index f71902f2..e0620a1b 100644 --- a/render/allocator/allocator.c +++ b/render/allocator/allocator.c @@ -93,9 +93,8 @@ static int reopen_drm_node(int drm_fd, bool allow_render_node) { } struct wlr_allocator *allocator_autocreate_with_drm_fd( - struct wlr_backend *backend, struct wlr_renderer *renderer, + uint32_t backend_caps, struct wlr_renderer *renderer, int drm_fd) { - uint32_t backend_caps = backend_get_buffer_caps(backend); uint32_t renderer_caps = renderer_get_render_buffer_caps(renderer); struct wlr_allocator *alloc = NULL; @@ -149,12 +148,14 @@ struct wlr_allocator *allocator_autocreate_with_drm_fd( struct wlr_allocator *wlr_allocator_autocreate(struct wlr_backend *backend, struct wlr_renderer *renderer) { + uint32_t backend_caps = backend_get_buffer_caps(backend); // Note, drm_fd may be negative if unavailable int drm_fd = wlr_backend_get_drm_fd(backend); if (drm_fd < 0) { drm_fd = wlr_renderer_get_drm_fd(renderer); } - return allocator_autocreate_with_drm_fd(backend, renderer, drm_fd); + + return allocator_autocreate_with_drm_fd(backend_caps, renderer, drm_fd); } void wlr_allocator_destroy(struct wlr_allocator *alloc) {