render/allocator: add udmabuf allocator
udmabuf can create a DMA-BUF backed by a memfd. This is useful when running with a software implementation of GL/Vulkan: the memfd can be passed to the parent compositor via wl_shm and the DMA-BUF can be imported via the usual APIs into GL/Vulkan.
The Wayland/X11 backends don't work yet: they try to import the DMA-BUF into the parent compositor and GPU drivers tend to not like DMA-BUFs backed by system memory. See hack patch below.
Still, this patch series works completely fine under the headless backend. This is a valuable feature because some compositors would like to test their GL/Vulkan codepath in CI.
To test:
- Set
WLR_RENDERER_FORCE_SOFTWARE=1
- Optionally, set
WLR_RENDERER=vulkan
to use that instead of GLES2 - Either set
WLR_BACKENDS=headless
, or apply the hack patch below and run nested in another Wayland compositor
Wayland backend hack to for shm
From 46b33f3b7c65c0ceb5958be7898dbde89133a5be Mon Sep 17 00:00:00 2001
From: Simon Ser <contact@emersion.fr>
Date: Thu, 3 Oct 2024 12:33:58 +0200
Subject: [PATCH] hack: disable DMA-BUFs in Wayland backend
---
backend/wayland/backend.c | 5 +++--
backend/wayland/output.c | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index 9a74e691993f..81175ca42d4d 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -550,8 +550,9 @@ static void backend_destroy(struct wlr_backend *backend) {
}
static int backend_get_drm_fd(struct wlr_backend *backend) {
- struct wlr_wl_backend *wl = get_wl_backend_from_backend(backend);
- return wl->drm_fd;
+ //struct wlr_wl_backend *wl = get_wl_backend_from_backend(backend);
+ //return wl->drm_fd;
+ return -1;
}
static uint32_t get_buffer_caps(struct wlr_backend *backend) {
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index e672028b7c6a..59c377d94977 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -164,7 +164,7 @@ static bool test_buffer(struct wlr_wl_backend *wl,
struct wlr_buffer *wlr_buffer) {
struct wlr_dmabuf_attributes dmabuf;
struct wlr_shm_attributes shm;
- if (wlr_buffer_get_dmabuf(wlr_buffer, &dmabuf)) {
+ if (false && wlr_buffer_get_dmabuf(wlr_buffer, &dmabuf)) {
return wlr_drm_format_set_has(&wl->linux_dmabuf_v1_formats,
dmabuf.format, dmabuf.modifier);
} else if (wlr_buffer_get_shm(wlr_buffer, &shm)) {
@@ -216,7 +216,7 @@ static struct wlr_wl_buffer *create_wl_buffer(struct wlr_wl_backend *wl,
struct wlr_dmabuf_attributes dmabuf;
struct wlr_shm_attributes shm;
struct wl_buffer *wl_buffer;
- if (wlr_buffer_get_dmabuf(wlr_buffer, &dmabuf)) {
+ if (false && wlr_buffer_get_dmabuf(wlr_buffer, &dmabuf)) {
wl_buffer = import_dmabuf(wl, &dmabuf);
} else if (wlr_buffer_get_shm(wlr_buffer, &shm)) {
wl_buffer = import_shm(wl, &shm);
--
2.46.2
Closes: #2871