diff options
author | Simon Ser <contact@emersion.fr> | 2021-07-09 13:07:22 +0200 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2021-07-26 11:44:16 -0400 |
commit | 3cf2535c23394439a16c6060bfa06b59261cebcb (patch) | |
tree | af82fd11829455215b5ea789f2667d2f9c23029b | |
parent | ace2eda073f838e1327abd7ffb8e5111e52f4b86 (diff) |
render/egl: add support for EGL_EXT_device_drm_render_node
This EGL extension has been added in [1]. The upsides are:
- We directly get a render node, instead of having to convert the
primary node name to a render node name.
- If EGL_DRM_RENDER_NODE_FILE_EXT returns NULL, that means there is
no render node being used by the driver.
[1]: https://github.com/KhronosGroup/EGL-Registry/pull/127
-rw-r--r-- | include/wlr/render/egl.h | 1 | ||||
-rw-r--r-- | render/egl.c | 40 |
2 files changed, 30 insertions, 11 deletions
diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h index 4a474062..3a09ba97 100644 --- a/include/wlr/render/egl.h +++ b/include/wlr/render/egl.h @@ -43,6 +43,7 @@ struct wlr_egl { // Device extensions bool EXT_device_drm; + bool EXT_device_drm_render_node; } exts; struct { diff --git a/render/egl.c b/render/egl.c index 9fa2add5..1fe30048 100644 --- a/render/egl.c +++ b/render/egl.c @@ -289,6 +289,8 @@ struct wlr_egl *wlr_egl_create_with_drm_fd(int drm_fd) { egl->exts.EXT_device_drm = check_egl_ext(device_exts_str, "EGL_EXT_device_drm"); + egl->exts.EXT_device_drm_render_node = + check_egl_ext(device_exts_str, "EGL_EXT_device_drm_render_node"); } if (!check_egl_ext(display_exts_str, "EGL_KHR_no_config_context") && @@ -712,23 +714,39 @@ static char *get_render_name(const char *name) { } int wlr_egl_dup_drm_fd(struct wlr_egl *egl) { - if (egl->device == EGL_NO_DEVICE_EXT || !egl->exts.EXT_device_drm) { + if (egl->device == EGL_NO_DEVICE_EXT || (!egl->exts.EXT_device_drm && + !egl->exts.EXT_device_drm_render_node)) { return -1; } - const char *primary_name = egl->procs.eglQueryDeviceStringEXT(egl->device, - EGL_DRM_DEVICE_FILE_EXT); - if (primary_name == NULL) { - wlr_log(WLR_ERROR, - "eglQueryDeviceStringEXT(EGL_DRM_DEVICE_FILE_EXT) failed"); - return -1; + char *render_name = NULL; +#ifdef EGL_EXT_device_drm_render_node + if (egl->exts.device_drm_render_node_ext) { + const char *name = egl->procs.eglQueryDeviceStringEXT(egl->device, + EGL_DRM_RENDER_NODE_FILE_EXT); + if (name == NULL) { + wlr_log(WLR_DEBUG, "EGL device has no render node"); + return -1; + } + render_name = strdup(name); } +#endif - char *render_name = get_render_name(primary_name); if (render_name == NULL) { - wlr_log(WLR_ERROR, "Can't find render node name for device %s", - primary_name); - return -1; + const char *primary_name = egl->procs.eglQueryDeviceStringEXT(egl->device, + EGL_DRM_DEVICE_FILE_EXT); + if (primary_name == NULL) { + wlr_log(WLR_ERROR, + "eglQueryDeviceStringEXT(EGL_DRM_DEVICE_FILE_EXT) failed"); + return -1; + } + + render_name = get_render_name(primary_name); + if (render_name == NULL) { + wlr_log(WLR_ERROR, "Can't find render node name for device %s", + primary_name); + return -1; + } } int render_fd = open(render_name, O_RDWR | O_NONBLOCK | O_CLOEXEC); |