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@emersion.fr> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11797>
This commit is contained in:
@@ -45,6 +45,7 @@ struct _egl_device {
|
|||||||
|
|
||||||
EGLBoolean MESA_device_software;
|
EGLBoolean MESA_device_software;
|
||||||
EGLBoolean EXT_device_drm;
|
EGLBoolean EXT_device_drm;
|
||||||
|
EGLBoolean EXT_device_drm_render_node;
|
||||||
|
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LIBDRM
|
||||||
drmDevicePtr device;
|
drmDevicePtr device;
|
||||||
@@ -97,8 +98,10 @@ _eglCheckDeviceHandle(EGLDeviceEXT device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_EGLDevice _eglSoftwareDevice = {
|
_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,
|
.MESA_device_software = EGL_TRUE,
|
||||||
|
.EXT_device_drm_render_node = EGL_TRUE,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef HAVE_LIBDRM
|
#ifdef HAVE_LIBDRM
|
||||||
@@ -143,6 +146,12 @@ _eglAddDRMDevice(drmDevicePtr device, _EGLDevice **out_dev)
|
|||||||
dev->EXT_device_drm = EGL_TRUE;
|
dev->EXT_device_drm = EGL_TRUE;
|
||||||
dev->device = device;
|
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)
|
if (out_dev)
|
||||||
*out_dev = dev;
|
*out_dev = dev;
|
||||||
|
|
||||||
@@ -197,6 +206,8 @@ _eglDeviceSupports(_EGLDevice *dev, _EGLDeviceExtension ext)
|
|||||||
return dev->MESA_device_software;
|
return dev->MESA_device_software;
|
||||||
case _EGL_DEVICE_DRM:
|
case _EGL_DEVICE_DRM:
|
||||||
return dev->EXT_device_drm;
|
return dev->EXT_device_drm;
|
||||||
|
case _EGL_DEVICE_DRM_RENDER_NODE:
|
||||||
|
return dev->EXT_device_drm_render_node;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
return EGL_FALSE;
|
return EGL_FALSE;
|
||||||
@@ -236,16 +247,31 @@ _eglQueryDeviceStringEXT(_EGLDevice *dev, EGLint name)
|
|||||||
switch (name) {
|
switch (name) {
|
||||||
case EGL_EXTENSIONS:
|
case EGL_EXTENSIONS:
|
||||||
return dev->extensions;
|
return dev->extensions;
|
||||||
#ifdef HAVE_LIBDRM
|
|
||||||
case EGL_DRM_DEVICE_FILE_EXT:
|
case EGL_DRM_DEVICE_FILE_EXT:
|
||||||
if (_eglDeviceSupports(dev, _EGL_DEVICE_DRM))
|
if (!_eglDeviceSupports(dev, _EGL_DEVICE_DRM))
|
||||||
return dev->device->nodes[DRM_NODE_PRIMARY];
|
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
|
#endif
|
||||||
FALLTHROUGH;
|
case EGL_DRM_RENDER_NODE_FILE_EXT:
|
||||||
default:
|
if (!_eglDeviceSupports(dev, _EGL_DEVICE_DRM_RENDER_NODE))
|
||||||
_eglError(EGL_BAD_PARAMETER, "eglQueryDeviceStringEXT");
|
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;
|
return NULL;
|
||||||
};
|
#endif
|
||||||
|
}
|
||||||
|
_eglError(EGL_BAD_PARAMETER, "eglQueryDeviceStringEXT");
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do a fresh lookup for devices.
|
/* Do a fresh lookup for devices.
|
||||||
|
@@ -61,6 +61,7 @@ _eglAddDevice(int fd, bool software);
|
|||||||
enum _egl_device_extension {
|
enum _egl_device_extension {
|
||||||
_EGL_DEVICE_SOFTWARE,
|
_EGL_DEVICE_SOFTWARE,
|
||||||
_EGL_DEVICE_DRM,
|
_EGL_DEVICE_DRM,
|
||||||
|
_EGL_DEVICE_DRM_RENDER_NODE,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum _egl_device_extension _EGLDeviceExtension;
|
typedef enum _egl_device_extension _EGLDeviceExtension;
|
||||||
|
Reference in New Issue
Block a user