aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-04-21 08:23:06 +0200
committerSimon Ser <contact@emersion.fr>2021-04-26 15:05:34 +0200
commitaf78ecb86ba7cc59a2c1acd90664a5d4ba56ebdc (patch)
tree29e0cda5c1cb36b3de91486c92690acdede91a7c
parent8a27050b4e7dbe87769ef5e8d578dc0c959bc3e5 (diff)
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.
-rw-r--r--render/wlr_renderer.c22
1 files changed, 13 insertions, 9 deletions
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);
}