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:
parent
1b96c4e24f
commit
2a860bb8c3
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue