backend/wayland: fallback to wl_shm on missing render node

master
Simon Ser 4 years ago
parent 80865351bd
commit 9de93a866f

@ -21,6 +21,7 @@
#include "render/drm_format_set.h"
#include "render/gbm_allocator.h"
#include "render/pixel_format.h"
#include "render/shm_allocator.h"
#include "render/wlr_renderer.h"
#include "util/signal.h"
@ -424,11 +425,6 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
"Remote Wayland compositor does not support xdg-shell");
goto error_registry;
}
if (!wl->drm_render_name) {
wlr_log(WLR_ERROR, "Failed to get DRM render node from remote Wayland "
"compositor wl_drm interface");
goto error_registry;
}
struct wl_event_loop *loop = wl_display_get_event_loop(wl->local_display);
int fd = wl_display_get_fd(wl->remote_display);
@ -440,6 +436,8 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
}
wl_event_source_check(wl->remote_display_src);
wl->drm_fd = -1;
if (wl->drm_render_name != NULL) {
wlr_log(WLR_DEBUG, "Opening DRM render node %s", wl->drm_render_name);
wl->drm_fd = open(wl->drm_render_name, O_RDWR | O_NONBLOCK | O_CLOEXEC);
if (wl->drm_fd < 0) {
@ -461,6 +459,15 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
goto error_drm_fd;
}
wl->allocator = &gbm_alloc->base;
} else {
wlr_log(WLR_DEBUG, "No render node found, falling back to shared memory");
struct wlr_shm_allocator *shm_alloc = wlr_shm_allocator_create();
if (shm_alloc == NULL) {
wlr_log(WLR_ERROR, "Failed to create shared memory allocator");
goto error_remote_display_src;
}
wl->allocator = &shm_alloc->base;
}
wl->renderer = wlr_renderer_autocreate(&wl->backend);
if (wl->renderer == NULL) {
@ -468,21 +475,29 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
goto error_allocator;
}
uint32_t fmt = DRM_FORMAT_ARGB8888;
const struct wlr_drm_format *remote_format =
wlr_drm_format_set_get(&wl->linux_dmabuf_v1_formats, fmt);
if (remote_format == NULL) {
wlr_log(WLR_ERROR, "Remote compositor doesn't support format "
"0x%"PRIX32" via linux-dmabuf-unstable-v1", fmt);
goto error_renderer;
const struct wlr_drm_format_set *remote_formats;
if (wl->drm_fd >= 0) {
remote_formats = &wl->linux_dmabuf_v1_formats;
} else {
remote_formats = &wl->shm_formats;
}
const struct wlr_drm_format_set *render_formats =
wlr_renderer_get_render_formats(wl->renderer);
if (render_formats == NULL) {
wlr_log(WLR_ERROR, "Failed to get available DMA-BUF formats from renderer");
wlr_log(WLR_ERROR, "Failed to get available render-capable formats");
goto error_renderer;
}
uint32_t fmt = DRM_FORMAT_ARGB8888;
const struct wlr_drm_format *remote_format =
wlr_drm_format_set_get(remote_formats, fmt);
if (remote_format == NULL) {
wlr_log(WLR_ERROR, "Remote compositor doesn't support DRM format "
"0x%"PRIX32, fmt);
goto error_renderer;
}
const struct wlr_drm_format *render_format =
wlr_drm_format_set_get(render_formats, fmt);
if (render_format == NULL) {

Loading…
Cancel
Save