Add EGL xcb platform

This enables GL applications to be written without any involvement of
Xlib.

EGL X11 platform is actually already xcb-only underneath, so this commit
just add the necessary interface changes so eglDisplay can be created
from a xcb_connection_t.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6474>
This commit is contained in:
Yuxuan Shui
2020-08-26 19:01:53 +01:00
committed by Marge Bot
parent 8bb1a75b4f
commit 53660e4c4e
10 changed files with 67 additions and 4 deletions

View File

@@ -388,6 +388,11 @@ _eglGetPlatformDisplayCommon(EGLenum platform, void *native_display,
disp = _eglGetX11Display((Display*) native_display, attrib_list);
break;
#endif
#ifdef HAVE_XCB_PLATFORM
case EGL_PLATFORM_XCB_EXT:
disp = _eglGetXcbDisplay((xcb_connection_t*) native_display, attrib_list);
break;
#endif
#ifdef HAVE_DRM_PLATFORM
case EGL_PLATFORM_GBM_MESA:
disp = _eglGetGbmDisplay((struct gbm_device*) native_display,

View File

@@ -70,6 +70,7 @@ static const struct {
const char *name;
} egl_platforms[] = {
{ _EGL_PLATFORM_X11, "x11" },
{ _EGL_PLATFORM_XCB, "xcb" },
{ _EGL_PLATFORM_WAYLAND, "wayland" },
{ _EGL_PLATFORM_DRM, "drm" },
{ _EGL_PLATFORM_ANDROID, "android" },
@@ -506,6 +507,27 @@ _eglGetX11Display(Display *native_display,
}
#endif /* HAVE_X11_PLATFORM */
#ifdef HAVE_XCB_PLATFORM
_EGLDisplay*
_eglGetXcbDisplay(xcb_connection_t *native_display,
const EGLAttrib *attrib_list)
{
/* EGL_EXT_platform_xcb recognizes exactly one attribute,
* EGL_PLATFORM_XCB_SCREEN_EXT, which is optional.
*/
if (attrib_list != NULL) {
for (int i = 0; attrib_list[i] != EGL_NONE; i += 2) {
if (attrib_list[i] != EGL_PLATFORM_XCB_SCREEN_EXT) {
_eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay");
return NULL;
}
}
}
return _eglFindDisplay(_EGL_PLATFORM_XCB, native_display, attrib_list);
}
#endif /* HAVE_XCB_PLATFORM */
#ifdef HAVE_DRM_PLATFORM
_EGLDisplay*
_eglGetGbmDisplay(struct gbm_device *native_display,

View File

@@ -45,6 +45,7 @@ extern "C" {
enum _egl_platform_type {
_EGL_PLATFORM_X11,
_EGL_PLATFORM_XCB,
_EGL_PLATFORM_WAYLAND,
_EGL_PLATFORM_DRM,
_EGL_PLATFORM_ANDROID,
@@ -294,6 +295,12 @@ _EGLDisplay*
_eglGetX11Display(Display *native_display, const EGLAttrib *attrib_list);
#endif
#ifdef HAVE_XCB_PLATFORM
typedef struct xcb_connection_t xcb_connection_t;
_EGLDisplay*
_eglGetXcbDisplay(xcb_connection_t *native_display, const EGLAttrib *attrib_list);
#endif
#ifdef HAVE_DRM_PLATFORM
struct gbm_device;

View File

@@ -89,6 +89,9 @@ struct _egl_global _eglGlobal =
" EGL_EXT_platform_x11"
" EGL_KHR_platform_x11"
#endif
#ifdef HAVE_XCB_PLATFORM
" EGL_MESA_platform_xcb"
#endif
#ifdef HAVE_DRM_PLATFORM
" EGL_MESA_platform_gbm"
" EGL_KHR_platform_gbm"