mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-02 11:55:59 +01:00
backend/wayland: fallback to wl_shm on missing render node
This commit is contained in:
parent
80865351bd
commit
9de93a866f
1 changed files with 47 additions and 32 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include "render/drm_format_set.h"
|
#include "render/drm_format_set.h"
|
||||||
#include "render/gbm_allocator.h"
|
#include "render/gbm_allocator.h"
|
||||||
#include "render/pixel_format.h"
|
#include "render/pixel_format.h"
|
||||||
|
#include "render/shm_allocator.h"
|
||||||
#include "render/wlr_renderer.h"
|
#include "render/wlr_renderer.h"
|
||||||
#include "util/signal.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");
|
"Remote Wayland compositor does not support xdg-shell");
|
||||||
goto error_registry;
|
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);
|
struct wl_event_loop *loop = wl_display_get_event_loop(wl->local_display);
|
||||||
int fd = wl_display_get_fd(wl->remote_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_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);
|
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);
|
wl->drm_fd = open(wl->drm_render_name, O_RDWR | O_NONBLOCK | O_CLOEXEC);
|
||||||
if (wl->drm_fd < 0) {
|
if (wl->drm_fd < 0) {
|
||||||
|
@ -461,6 +459,15 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
||||||
goto error_drm_fd;
|
goto error_drm_fd;
|
||||||
}
|
}
|
||||||
wl->allocator = &gbm_alloc->base;
|
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);
|
wl->renderer = wlr_renderer_autocreate(&wl->backend);
|
||||||
if (wl->renderer == NULL) {
|
if (wl->renderer == NULL) {
|
||||||
|
@ -468,21 +475,29 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
||||||
goto error_allocator;
|
goto error_allocator;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t fmt = DRM_FORMAT_ARGB8888;
|
const struct wlr_drm_format_set *remote_formats;
|
||||||
const struct wlr_drm_format *remote_format =
|
if (wl->drm_fd >= 0) {
|
||||||
wlr_drm_format_set_get(&wl->linux_dmabuf_v1_formats, fmt);
|
remote_formats = &wl->linux_dmabuf_v1_formats;
|
||||||
if (remote_format == NULL) {
|
} else {
|
||||||
wlr_log(WLR_ERROR, "Remote compositor doesn't support format "
|
remote_formats = &wl->shm_formats;
|
||||||
"0x%"PRIX32" via linux-dmabuf-unstable-v1", fmt);
|
|
||||||
goto error_renderer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct wlr_drm_format_set *render_formats =
|
const struct wlr_drm_format_set *render_formats =
|
||||||
wlr_renderer_get_render_formats(wl->renderer);
|
wlr_renderer_get_render_formats(wl->renderer);
|
||||||
if (render_formats == NULL) {
|
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;
|
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 =
|
const struct wlr_drm_format *render_format =
|
||||||
wlr_drm_format_set_get(render_formats, fmt);
|
wlr_drm_format_set_get(render_formats, fmt);
|
||||||
if (render_format == NULL) {
|
if (render_format == NULL) {
|
||||||
|
|
Loading…
Reference in a new issue