From af78ecb86ba7cc59a2c1acd90664a5d4ba56ebdc Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 21 Apr 2021 08:23:06 +0200 Subject: render: unconditionally read WLR_RENDERER Prior to this commit, WLR_RENDERER was only looked up when the backend returned a DRM FD. Make it so WLR_RENDERER is always looked up, so that running wlroots on a system without a GPU and with WLR_RENDERER=gles2 fails as expected instead of falling back to the Pixman renderer. --- render/wlr_renderer.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'render/wlr_renderer.c') diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c index d9397c40..34530e4d 100644 --- a/render/wlr_renderer.c +++ b/render/wlr_renderer.c @@ -231,6 +231,11 @@ struct wlr_renderer *wlr_renderer_autocreate_with_drm_fd(int drm_fd) { if (name) { #if WLR_HAS_GLES2_RENDERER if (strcmp(name, "gles2") == 0) { + if (drm_fd < 0) { + wlr_log(WLR_ERROR, "Cannot create GLES2 renderer: " + "no DRM FD available"); + return NULL; + } return wlr_gles2_renderer_create_with_drm_fd(drm_fd); } #endif @@ -244,10 +249,14 @@ struct wlr_renderer *wlr_renderer_autocreate_with_drm_fd(int drm_fd) { struct wlr_renderer *renderer = NULL; #if WLR_HAS_GLES2_RENDERER - if ((renderer = wlr_gles2_renderer_create_with_drm_fd(drm_fd)) != NULL) { - return renderer; + if (drm_fd >= 0) { + if ((renderer = wlr_gles2_renderer_create_with_drm_fd(drm_fd)) != NULL) { + return renderer; + } + wlr_log(WLR_DEBUG, "Failed to create GLES2 renderer"); + } else { + wlr_log(WLR_DEBUG, "Skipping GLES2 renderer: no DRM FD available"); } - wlr_log(WLR_DEBUG, "Failed to create gles2 renderer"); #endif if ((renderer = wlr_pixman_renderer_create()) != NULL) { @@ -260,13 +269,8 @@ struct wlr_renderer *wlr_renderer_autocreate_with_drm_fd(int drm_fd) { } 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); - if (drm_fd < 0) { - wlr_log(WLR_ERROR, "Failed to get DRM FD from backend"); - wlr_log(WLR_INFO, "Falling back on pixman renderer"); - return wlr_pixman_renderer_create(); - } - return wlr_renderer_autocreate_with_drm_fd(drm_fd); } -- cgit v1.2.3