mirror of
https://gitee.com/openharmony/third_party_mesa3d
synced 2025-02-14 06:49:37 +00:00
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:
parent
8bb1a75b4f
commit
53660e4c4e
@ -0,0 +1 @@
|
||||
EGL_MESA_platform_xcb
|
@ -883,6 +883,12 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy,
|
||||
#define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6
|
||||
#endif /* EGL_EXT_platform_x11 */
|
||||
|
||||
#ifndef EGL_MESA_platform_xcb
|
||||
#define EGL_MESA_platform_xcb 1
|
||||
#define EGL_PLATFORM_XCB_EXT 0x31DC
|
||||
#define EGL_PLATFORM_XCB_SCREEN_EXT 0x31DE
|
||||
#endif /* EGL_MESA_platform_xcb */
|
||||
|
||||
#ifndef EGL_EXT_protected_content
|
||||
#define EGL_EXT_protected_content 1
|
||||
#define EGL_PROTECTED_CONTENT_EXT 0x32C0
|
||||
|
@ -827,6 +827,7 @@ gl_pkgconfig_c_flags = []
|
||||
if with_platform_x11
|
||||
if with_any_vk or with_egl or (with_glx == 'dri' and with_dri_platform == 'drm')
|
||||
pre_args += '-DHAVE_X11_PLATFORM'
|
||||
pre_args += '-DHAVE_XCB_PLATFORM'
|
||||
endif
|
||||
if with_glx == 'xlib' or with_glx == 'gallium-xlib'
|
||||
pre_args += '-DUSE_XSHM'
|
||||
|
@ -183,6 +183,11 @@ dri_is_thread_safe(void *loaderPrivate)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XCB_PLATFORM
|
||||
if (display->Platform == _EGL_PLATFORM_XCB)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WAYLAND_PLATFORM
|
||||
if (display->Platform == _EGL_PLATFORM_WAYLAND)
|
||||
return true;
|
||||
@ -1178,6 +1183,7 @@ dri2_initialize(_EGLDisplay *disp)
|
||||
ret = dri2_initialize_device(disp);
|
||||
break;
|
||||
case _EGL_PLATFORM_X11:
|
||||
case _EGL_PLATFORM_XCB:
|
||||
ret = dri2_initialize_x11(disp);
|
||||
break;
|
||||
case _EGL_PLATFORM_DRM:
|
||||
|
@ -1212,7 +1212,8 @@ dri2_find_screen_for_display(const _EGLDisplay *disp, int fallback_screen)
|
||||
const EGLAttrib *attr;
|
||||
|
||||
for (attr = disp->Options.Attribs; attr; attr += 2) {
|
||||
if (attr[0] == EGL_PLATFORM_X11_SCREEN_EXT)
|
||||
if (attr[0] == EGL_PLATFORM_X11_SCREEN_EXT ||
|
||||
attr[0] == EGL_PLATFORM_XCB_SCREEN_EXT)
|
||||
return attr[1];
|
||||
}
|
||||
|
||||
@ -1232,10 +1233,14 @@ dri2_get_xcb_connection(_EGLDisplay *disp,
|
||||
dri2_dpy->conn = xcb_connect(NULL, &screen);
|
||||
dri2_dpy->own_device = true;
|
||||
screen = dri2_find_screen_for_display(disp, screen);
|
||||
} else {
|
||||
} else if (disp->Platform == _EGL_PLATFORM_X11) {
|
||||
Display *dpy = disp->PlatformDisplay;
|
||||
dri2_dpy->conn = XGetXCBConnection(dpy);
|
||||
screen = DefaultScreen(dpy);
|
||||
} else {
|
||||
/* _EGL_PLATFORM_XCB */
|
||||
dri2_dpy->conn = disp->PlatformDisplay;
|
||||
screen = dri2_find_screen_for_display(disp, 0);
|
||||
}
|
||||
|
||||
if (!dri2_dpy->conn || xcb_connection_has_error(dri2_dpy->conn)) {
|
||||
|
@ -590,9 +590,10 @@
|
||||
<enum value="0x31D7" name="EGL_PLATFORM_GBM_MESA" alias="EGL_PLATFORM_GBM_KHR"/>
|
||||
<enum value="0x31D8" name="EGL_PLATFORM_WAYLAND_KHR"/>
|
||||
<enum value="0x31D8" name="EGL_PLATFORM_WAYLAND_EXT" alias="EGL_PLATFORM_WAYLAND_KHR"/>
|
||||
<unused start="0x31DC" end="0x31DC"/>
|
||||
<enum value="0x31DC" name="EGL_PLATFORM_XCB_EXT"/>
|
||||
<enum value="0x31DD" name="EGL_PLATFORM_SURFACELESS_MESA"/>
|
||||
<unused start="0x31DE" end="0x31DF"/>
|
||||
<enum value="0x31DE" name="EGL_PLATFORM_XCB_SCREEN_EXT"/>
|
||||
<unused start="0x31DF" end="0x31DF"/>
|
||||
</enums>
|
||||
|
||||
<!-- Due to an oversight in development, these enums alias the above MESA
|
||||
@ -2546,6 +2547,12 @@
|
||||
<enum name="EGL_PLATFORM_X11_SCREEN_EXT"/>
|
||||
</require>
|
||||
</extension>
|
||||
<extension name="EGL_EXT_platform_xcb" supported="egl">
|
||||
<require>
|
||||
<enum name="EGL_PLATFORM_XCB_EXT"/>
|
||||
<enum name="EGL_PLATFORM_XCB_SCREEN_EXT"/>
|
||||
</require>
|
||||
</extension>
|
||||
<extension name="EGL_EXT_protected_content" supported="egl">
|
||||
<require>
|
||||
<enum name="EGL_PROTECTED_CONTENT_EXT"/>
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user