Expose the config and display for EGL-based QOpenGLContexts

...in the native interface.

Using OpenXR is impossible on some platforms (for example, Android)
without knowing all three. The EGLContext alone is not enough, and
EGL offers no way to query the EGLConfig a context was created with.
https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XR_KHR_opengl_es_enable

Therefore, expose all three so libs/apps can use the new way to query
these native resource without resorting to the old-style
nativeResourceFor* queries.

Change-Id: I7efb0a26b858150da55e711752af99426e744322
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Laszlo Agocs 2021-09-10 21:03:34 +02:00
parent 7c1230d9a8
commit e346b9524c
3 changed files with 17 additions and 0 deletions

View File

@ -58,6 +58,7 @@ struct __GLXcontextRec; typedef struct __GLXcontextRec *GLXContext;
#if QT_CONFIG(egl)
typedef void *EGLContext;
typedef void *EGLDisplay;
typedef void *EGLConfig;
#endif
#if !defined(Q_OS_MACOS) && defined(Q_CLANG_QDOC)
@ -103,6 +104,8 @@ struct Q_GUI_EXPORT QEGLContext
QT_DECLARE_NATIVE_INTERFACE(QEGLContext, 1, QOpenGLContext)
static QOpenGLContext *fromNative(EGLContext context, EGLDisplay display, QOpenGLContext *shareContext = nullptr);
virtual EGLContext nativeContext() const = 0;
virtual EGLConfig config() const = 0;
virtual EGLDisplay display() const = 0;
};
#endif

View File

@ -108,6 +108,8 @@ public:
bool isValid() const override { return m_eglContext != EGL_NO_CONTEXT; }
EGLContext nativeContext() const override { return eglContext(); }
EGLConfig config() const override { return eglConfig(); }
EGLDisplay display() const override { return eglDisplay(); }
EGLContext eglContext() const;
EGLDisplay eglDisplay() const;

View File

@ -143,6 +143,18 @@ QOpenGLContext *QNativeInterface::QGLXContext::fromNative(GLXContext visualBased
\return the underlying EGLContext.
*/
/*!
\fn EGLConfig QNativeInterface::QEGLContext::config() const
\since 6.3
\return the EGLConfig associated with the underlying EGLContext.
*/
/*!
\fn EGLDisplay QNativeInterface::QEGLContext::display() const
\since 6.3
\return the EGLDisplay associated with the underlying EGLContext.
*/
QT_DEFINE_NATIVE_INTERFACE(QEGLContext);
QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QEGLIntegration);