Make EGL use Qt X connection without xcb_xlib with EGL_EXT_platform_xcb
This allows to create EGL context without involving Xlib. This extension was created a year ago and is present in Mesa since 21.0 Change-Id: I7cb0aece1e67b4db59d453cbcfbd317bb5d9c777 Reviewed-by: Liang Qi <liang.qi@qt.io>
This commit is contained in:
parent
3ca167a30e
commit
49d2944045
@ -924,7 +924,7 @@ qt_feature("xcb-glx" PRIVATE
|
||||
)
|
||||
qt_feature("xcb-egl-plugin" PRIVATE
|
||||
LABEL "EGL-X11 Plugin"
|
||||
CONDITION QT_FEATURE_egl_x11 AND QT_FEATURE_opengl
|
||||
CONDITION QT_FEATURE_opengl
|
||||
EMIT_IF QT_FEATURE_xcb
|
||||
)
|
||||
qt_feature("xcb-native-painting" PRIVATE
|
||||
|
@ -113,6 +113,10 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMEROUTPUTEXTPROC) (EGLDisplay
|
||||
#define EGL_PLATFORM_X11_KHR 0x31D5
|
||||
#endif
|
||||
|
||||
#ifndef EGL_PLATFORM_XCB_KHR
|
||||
#define EGL_PLATFORM_XCB_KHR 0x31DC
|
||||
#endif
|
||||
|
||||
#ifndef EGL_NV_stream_attrib
|
||||
typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMATTRIBNVPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSTREAMATTRIBNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib value);
|
||||
|
@ -74,15 +74,26 @@ bool QXcbEglIntegration::initialize(QXcbConnection *connection)
|
||||
|
||||
const char *extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
|
||||
|
||||
#if QT_CONFIG(xcb_xlib)
|
||||
if (extensions && strstr(extensions, "EGL_EXT_platform_x11")) {
|
||||
QEGLStreamConvenience streamFuncs;
|
||||
m_egl_display = streamFuncs.get_platform_display(EGL_PLATFORM_X11_KHR,
|
||||
xlib_display(),
|
||||
m_connection->xlib_display(),
|
||||
nullptr);
|
||||
}
|
||||
|
||||
#if QT_CONFIG(egl_x11)
|
||||
if (!m_egl_display)
|
||||
m_egl_display = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(xlib_display()));
|
||||
m_egl_display = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(m_connection->xlib_display()));
|
||||
#endif
|
||||
#else
|
||||
if (extensions && (strstr(extensions, "EGL_EXT_platform_xcb") || strstr(extensions, "EGL_MESA_platform_xcb"))) {
|
||||
QEGLStreamConvenience streamFuncs;
|
||||
m_egl_display = streamFuncs.get_platform_display(EGL_PLATFORM_XCB_KHR,
|
||||
reinterpret_cast<void *>(connection->xcb_connection()),
|
||||
nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
EGLint major, minor;
|
||||
bool success = eglInitialize(m_egl_display, &major, &minor);
|
||||
@ -127,15 +138,6 @@ QPlatformOffscreenSurface *QXcbEglIntegration::createPlatformOffscreenSurface(QO
|
||||
return new QEGLPbuffer(eglDisplay(), screen->surfaceFormatFor(surface->requestedFormat()), surface);
|
||||
}
|
||||
|
||||
void *QXcbEglIntegration::xlib_display() const
|
||||
{
|
||||
#if QT_CONFIG(xcb_xlib)
|
||||
return m_connection->xlib_display();
|
||||
#else
|
||||
return EGL_DEFAULT_DISPLAY;
|
||||
#endif
|
||||
}
|
||||
|
||||
xcb_visualid_t QXcbEglIntegration::getCompatibleVisualId(xcb_screen_t *screen, EGLConfig config) const
|
||||
{
|
||||
xcb_visualid_t visualId = 0;
|
||||
|
@ -38,7 +38,6 @@ public:
|
||||
bool supportsThreadedOpenGL() const override { return true; }
|
||||
|
||||
EGLDisplay eglDisplay() const { return m_egl_display; }
|
||||
void *xlib_display() const;
|
||||
|
||||
xcb_visualid_t getCompatibleVisualId(xcb_screen_t *screen, EGLConfig config) const;
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user