aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-07-12 17:23:25 +0200
committerSimon Ser <contact@emersion.fr>2021-07-28 22:52:35 +0200
commitc74dc45bb68c43a14d638b4c2b71e84ea4f94951 (patch)
tree343238bacdbe26c0470add634fbcfb2f6db4ab8a
parent9b99570869e41158b2cd5681b6403a74312fcc69 (diff)
backend/drm: drop get_renderer implementation
We can now just rely on the common code for this.
-rw-r--r--backend/backend.c5
-rw-r--r--backend/drm/backend.c27
-rw-r--r--include/wlr/backend.h1
3 files changed, 18 insertions, 15 deletions
diff --git a/backend/backend.c b/backend/backend.c
index dbf38214..ef1d523c 100644
--- a/backend/backend.c
+++ b/backend/backend.c
@@ -45,7 +45,9 @@ void wlr_backend_init(struct wlr_backend *backend,
void wlr_backend_finish(struct wlr_backend *backend) {
wlr_signal_emit_safe(&backend->events.destroy, backend);
wlr_allocator_destroy(backend->allocator);
- wlr_renderer_destroy(backend->renderer);
+ if (backend->has_own_renderer) {
+ wlr_renderer_destroy(backend->renderer);
+ }
}
bool wlr_backend_start(struct wlr_backend *backend) {
@@ -77,6 +79,7 @@ static bool backend_create_renderer(struct wlr_backend *backend) {
return false;
}
+ backend->has_own_renderer = true;
return true;
}
diff --git a/backend/drm/backend.c b/backend/drm/backend.c
index 39b9d221..cee3cfa5 100644
--- a/backend/drm/backend.c
+++ b/backend/drm/backend.c
@@ -11,6 +11,7 @@
#include <wlr/interfaces/wlr_output.h>
#include <wlr/util/log.h>
#include <xf86drm.h>
+#include "backend/backend.h"
#include "backend/drm/drm.h"
#include "util/signal.h"
@@ -61,17 +62,6 @@ static void backend_destroy(struct wlr_backend *backend) {
free(drm);
}
-static struct wlr_renderer *backend_get_renderer(
- struct wlr_backend *backend) {
- struct wlr_drm_backend *drm = get_drm_backend_from_backend(backend);
-
- if (drm->parent) {
- return drm->parent->renderer.wlr_rend;
- } else {
- return drm->renderer.wlr_rend;
- }
-}
-
static clockid_t backend_get_presentation_clock(struct wlr_backend *backend) {
struct wlr_drm_backend *drm = get_drm_backend_from_backend(backend);
return drm->clock;
@@ -87,17 +77,16 @@ static int backend_get_drm_fd(struct wlr_backend *backend) {
}
}
-static uint32_t backend_get_buffer_caps(struct wlr_backend *backend) {
+static uint32_t drm_backend_get_buffer_caps(struct wlr_backend *backend) {
return WLR_BUFFER_CAP_DMABUF;
}
static const struct wlr_backend_impl backend_impl = {
.start = backend_start,
.destroy = backend_destroy,
- .get_renderer = backend_get_renderer,
.get_presentation_clock = backend_get_presentation_clock,
.get_drm_fd = backend_get_drm_fd,
- .get_buffer_caps = backend_get_buffer_caps,
+ .get_buffer_caps = drm_backend_get_buffer_caps,
};
bool wlr_backend_is_drm(struct wlr_backend *b) {
@@ -236,6 +225,10 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
}
if (drm->parent) {
+ // Ensure we use the same renderer as the parent backend
+ drm->backend.renderer = wlr_backend_get_renderer(&drm->parent->backend);
+ assert(drm->backend.renderer != NULL);
+
// We'll perform a multi-GPU copy for all submitted buffers, we need
// to be able to texture from them
struct wlr_renderer *renderer = drm->renderer.wlr_rend;
@@ -258,6 +251,12 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
}
}
+ struct wlr_renderer *renderer = wlr_backend_get_renderer(&drm->backend);
+ struct wlr_allocator *allocator = backend_get_allocator(&drm->backend);
+ if (renderer == NULL || allocator == NULL) {
+ goto error_event;
+ }
+
drm->session_destroy.notify = handle_session_destroy;
wl_signal_add(&session->events.destroy, &drm->session_destroy);
diff --git a/include/wlr/backend.h b/include/wlr/backend.h
index 025f74bd..d616fa1d 100644
--- a/include/wlr/backend.h
+++ b/include/wlr/backend.h
@@ -28,6 +28,7 @@ struct wlr_backend {
// Private state
+ bool has_own_renderer;
struct wlr_renderer *renderer;
struct wlr_allocator *allocator;
};