Mesa (main): egl: add support for EGL_EXT_device_drm_render_node
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jul 22 17:29:40 UTC 2021
Module: Mesa
Branch: main
Commit: 2a860bb8c35191e7505a71e17250d4ff060f17cb
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2a860bb8c35191e7505a71e17250d4ff060f17cb
Author: Simon Ser <contact at emersion.fr>
Date: Fri Jul 9 13:10:24 2021 +0200
egl: add support for EGL_EXT_device_drm_render_node
This new EGL extension has been introduced in [1].
When we have a DRM device and a render node, we can advertise the
extension and return the render node name for the
EGL_DRM_RENDER_NODE_FILE_EXT query.
For the special software EGL device, we can advertise the extension
and return NULL for the EGL_DRM_RENDER_NODE_FILE_EXT query, because
we can guarantee that llvmpipe will never use a render node for
rendering operations.
However, llvmpipe might be using a primary node when used with the
GBM platform. So we can't advertise EXT_device_drm in this case.
When we have a DRM device but no render node, that means we're on a
split render/display SoC. We _should_ return the render node used
by the renderonly driver, however Mesa needs more plumbing to allow
this, so let's just disable the extension for now.
[1]: https://github.com/KhronosGroup/EGL-Registry/pull/127
Signed-off-by: Simon Ser <contact at emersion.fr>
Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11797>
---
src/egl/main/egldevice.c | 42 ++++++++++++++++++++++++++++++++++--------
src/egl/main/egldevice.h | 1 +
2 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/src/egl/main/egldevice.c b/src/egl/main/egldevice.c
index 4e88897e2fa..a8ae1288f3d 100644
--- a/src/egl/main/egldevice.c
+++ b/src/egl/main/egldevice.c
@@ -45,6 +45,7 @@ struct _egl_device {
EGLBoolean MESA_device_software;
EGLBoolean EXT_device_drm;
+ EGLBoolean EXT_device_drm_render_node;
#ifdef HAVE_LIBDRM
drmDevicePtr device;
@@ -97,8 +98,10 @@ _eglCheckDeviceHandle(EGLDeviceEXT device)
}
_EGLDevice _eglSoftwareDevice = {
- .extensions = "EGL_MESA_device_software",
+ /* TODO: EGL_EXT_device_drm support for KMS + llvmpipe */
+ .extensions = "EGL_MESA_device_software EGL_EXT_device_drm_render_node",
.MESA_device_software = EGL_TRUE,
+ .EXT_device_drm_render_node = EGL_TRUE,
};
#ifdef HAVE_LIBDRM
@@ -143,6 +146,12 @@ _eglAddDRMDevice(drmDevicePtr device, _EGLDevice **out_dev)
dev->EXT_device_drm = EGL_TRUE;
dev->device = device;
+ /* TODO: EGL_EXT_device_drm_render_node support for kmsro + renderonly */
+ if (device->available_nodes & (1 << DRM_NODE_RENDER)) {
+ dev->extensions = "EGL_EXT_device_drm EGL_EXT_device_drm_render_node";
+ dev->EXT_device_drm_render_node = EGL_TRUE;
+ }
+
if (out_dev)
*out_dev = dev;
@@ -197,6 +206,8 @@ _eglDeviceSupports(_EGLDevice *dev, _EGLDeviceExtension ext)
return dev->MESA_device_software;
case _EGL_DEVICE_DRM:
return dev->EXT_device_drm;
+ case _EGL_DEVICE_DRM_RENDER_NODE:
+ return dev->EXT_device_drm_render_node;
default:
assert(0);
return EGL_FALSE;
@@ -236,16 +247,31 @@ _eglQueryDeviceStringEXT(_EGLDevice *dev, EGLint name)
switch (name) {
case EGL_EXTENSIONS:
return dev->extensions;
-#ifdef HAVE_LIBDRM
case EGL_DRM_DEVICE_FILE_EXT:
- if (_eglDeviceSupports(dev, _EGL_DEVICE_DRM))
- return dev->device->nodes[DRM_NODE_PRIMARY];
+ if (!_eglDeviceSupports(dev, _EGL_DEVICE_DRM))
+ break;
+#ifdef HAVE_LIBDRM
+ return dev->device->nodes[DRM_NODE_PRIMARY];
+#else
+ /* This should never happen: we don't yet support EGL_DEVICE_DRM for the
+ * software device, and physical devices are only exposed when libdrm is
+ * available. */
+ assert(0);
+ break;
#endif
- FALLTHROUGH;
- default:
- _eglError(EGL_BAD_PARAMETER, "eglQueryDeviceStringEXT");
+ case EGL_DRM_RENDER_NODE_FILE_EXT:
+ if (!_eglDeviceSupports(dev, _EGL_DEVICE_DRM_RENDER_NODE))
+ break;
+#ifdef HAVE_LIBDRM
+ return dev->device ? dev->device->nodes[DRM_NODE_RENDER] : NULL;
+#else
+ /* Physical devices are only exposed when libdrm is available. */
+ assert(_eglDeviceSupports(dev, _EGL_DEVICE_SOFTWARE));
return NULL;
- };
+#endif
+ }
+ _eglError(EGL_BAD_PARAMETER, "eglQueryDeviceStringEXT");
+ return NULL;
}
/* Do a fresh lookup for devices.
diff --git a/src/egl/main/egldevice.h b/src/egl/main/egldevice.h
index 83a47d5eacc..bf2337d4fd4 100644
--- a/src/egl/main/egldevice.h
+++ b/src/egl/main/egldevice.h
@@ -61,6 +61,7 @@ _eglAddDevice(int fd, bool software);
enum _egl_device_extension {
_EGL_DEVICE_SOFTWARE,
_EGL_DEVICE_DRM,
+ _EGL_DEVICE_DRM_RENDER_NODE,
};
typedef enum _egl_device_extension _EGLDeviceExtension;
More information about the mesa-commit
mailing list