aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/env_vars.md2
-rw-r--r--render/wlr_renderer.c29
2 files changed, 28 insertions, 3 deletions
diff --git a/docs/env_vars.md b/docs/env_vars.md
index 66c6dcc6..a07b2f19 100644
--- a/docs/env_vars.md
+++ b/docs/env_vars.md
@@ -10,6 +10,8 @@ wlroots reads these environment variables
of following shell search semantics for "Xwayland")
* *WLR_RENDERER*: forces the creation of a specified renderer (available
renderers: gles2, pixman, vulkan)
+* *WLR_RENDER_DRM_DEVICE*: specifies the DRM node to use for
+ hardware-accelerated renderers.
## DRM backend
diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c
index 6667a819..ff315913 100644
--- a/render/wlr_renderer.c
+++ b/render/wlr_renderer.c
@@ -348,18 +348,41 @@ out:
}
struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend) {
- // Note, drm_fd may be negative if unavailable
- int drm_fd = wlr_backend_get_drm_fd(backend);
+ int drm_fd = -1;
+ int render_drm_fd = -1;
+
+ // Allow the user to override the render node
+ const char *render_name = getenv("WLR_RENDER_DRM_DEVICE");
+ if (render_name != NULL) {
+ wlr_log(WLR_INFO,
+ "Opening DRM render node '%s' from WLR_RENDER_DRM_DEVICE",
+ render_name);
+ render_drm_fd = open(render_name, O_RDWR | O_CLOEXEC);
+ if (render_drm_fd < 0) {
+ wlr_log_errno(WLR_ERROR, "Failed to open '%s'", render_name);
+ return NULL;
+ }
+ if (drmGetNodeTypeFromFd(render_drm_fd) != DRM_NODE_RENDER) {
+ wlr_log(WLR_ERROR, "'%s' is not a DRM render node", render_name);
+ close(render_drm_fd);
+ return NULL;
+ }
+ drm_fd = render_drm_fd;
+ }
+
+ if (drm_fd < 0) {
+ drm_fd = wlr_backend_get_drm_fd(backend);
+ }
// If the backend hasn't picked a DRM FD, but accepts DMA-BUFs, pick an
// arbitrary render node
- int render_drm_fd = -1;
uint32_t backend_caps = backend_get_buffer_caps(backend);
if (drm_fd < 0 && (backend_caps & WLR_BUFFER_CAP_DMABUF) != 0) {
render_drm_fd = open_drm_render_node();
drm_fd = render_drm_fd;
}
+ // Note, drm_fd may be negative if unavailable
struct wlr_renderer *renderer = renderer_autocreate_with_drm_fd(drm_fd);
if (render_drm_fd >= 0) {