Runtime depend on GLES in all egl backends
As we don't have GLPLatform before the backend is fully created the AbstractEglBackend has a new method isOpenGLES() -> bool which determines based on QOpenGLContext::openGLModuleType().
This commit is contained in:
parent
2f065b9c6b
commit
14d943caea
6 changed files with 110 additions and 124 deletions
|
@ -88,14 +88,10 @@ bool AbstractEglBackend::initEglAPI()
|
||||||
}
|
}
|
||||||
qCDebug(KWIN_CORE) << "Egl Initialize succeeded";
|
qCDebug(KWIN_CORE) << "Egl Initialize succeeded";
|
||||||
|
|
||||||
#ifdef KWIN_HAVE_OPENGLES
|
if (eglBindAPI(isOpenGLES() ? EGL_OPENGL_ES_API : EGL_OPENGL_API) == EGL_FALSE) {
|
||||||
eglBindAPI(EGL_OPENGL_ES_API);
|
|
||||||
#else
|
|
||||||
if (eglBindAPI(EGL_OPENGL_API) == EGL_FALSE) {
|
|
||||||
qCCritical(KWIN_CORE) << "bind OpenGL API failed";
|
qCCritical(KWIN_CORE) << "bind OpenGL API failed";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
qCDebug(KWIN_CORE) << "EGL version: " << major << "." << minor;
|
qCDebug(KWIN_CORE) << "EGL version: " << major << "." << minor;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -178,6 +174,11 @@ void AbstractEglBackend::doneCurrent()
|
||||||
eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AbstractEglBackend::isOpenGLES() const
|
||||||
|
{
|
||||||
|
return QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES;
|
||||||
|
}
|
||||||
|
|
||||||
AbstractEglTexture::AbstractEglTexture(SceneOpenGL::Texture *texture, AbstractEglBackend *backend)
|
AbstractEglTexture::AbstractEglTexture(SceneOpenGL::Texture *texture, AbstractEglBackend *backend)
|
||||||
: SceneOpenGL::TexturePrivate()
|
: SceneOpenGL::TexturePrivate()
|
||||||
, q(texture)
|
, q(texture)
|
||||||
|
|
|
@ -68,6 +68,7 @@ protected:
|
||||||
void initClientExtensions();
|
void initClientExtensions();
|
||||||
void initWayland();
|
void initWayland();
|
||||||
bool hasClientExtension(const QByteArray &ext) const;
|
bool hasClientExtension(const QByteArray &ext) const;
|
||||||
|
bool isOpenGLES() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EGLDisplay m_display = EGL_NO_DISPLAY;
|
EGLDisplay m_display = EGL_NO_DISPLAY;
|
||||||
|
|
|
@ -132,39 +132,39 @@ bool EglGbmBackend::initRenderingContext()
|
||||||
initBufferConfigs();
|
initBufferConfigs();
|
||||||
|
|
||||||
EGLContext context = EGL_NO_CONTEXT;
|
EGLContext context = EGL_NO_CONTEXT;
|
||||||
#ifdef KWIN_HAVE_OPENGLES
|
if (isOpenGLES()) {
|
||||||
const EGLint context_attribs[] = {
|
const EGLint context_attribs[] = {
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs);
|
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs);
|
||||||
#else
|
} else {
|
||||||
const EGLint context_attribs_31_core[] = {
|
const EGLint context_attribs_31_core[] = {
|
||||||
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
||||||
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
||||||
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
const EGLint context_attribs_legacy[] = {
|
const EGLint context_attribs_legacy[] = {
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* eglExtensionsCString = eglQueryString(eglDisplay(), EGL_EXTENSIONS);
|
const char* eglExtensionsCString = eglQueryString(eglDisplay(), EGL_EXTENSIONS);
|
||||||
const QList<QByteArray> extensions = QByteArray::fromRawData(eglExtensionsCString, qstrlen(eglExtensionsCString)).split(' ');
|
const QList<QByteArray> extensions = QByteArray::fromRawData(eglExtensionsCString, qstrlen(eglExtensionsCString)).split(' ');
|
||||||
|
|
||||||
// Try to create a 3.1 core context
|
// Try to create a 3.1 core context
|
||||||
if (options->glCoreProfile() && extensions.contains(QByteArrayLiteral("EGL_KHR_create_context")))
|
if (options->glCoreProfile() && extensions.contains(QByteArrayLiteral("EGL_KHR_create_context")))
|
||||||
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs_31_core);
|
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs_31_core);
|
||||||
|
|
||||||
if (context == EGL_NO_CONTEXT)
|
if (context == EGL_NO_CONTEXT)
|
||||||
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs_legacy);
|
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs_legacy);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
if (context == EGL_NO_CONTEXT) {
|
if (context == EGL_NO_CONTEXT) {
|
||||||
qCCritical(KWIN_DRM) << "Create Context failed";
|
qCCritical(KWIN_DRM) << "Create Context failed";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
setContext(context);
|
setContext(context);
|
||||||
|
|
||||||
|
@ -233,11 +233,7 @@ bool EglGbmBackend::initBufferConfigs()
|
||||||
EGL_GREEN_SIZE, 1,
|
EGL_GREEN_SIZE, 1,
|
||||||
EGL_BLUE_SIZE, 1,
|
EGL_BLUE_SIZE, 1,
|
||||||
EGL_ALPHA_SIZE, 0,
|
EGL_ALPHA_SIZE, 0,
|
||||||
#ifdef KWIN_HAVE_OPENGLES
|
EGL_RENDERABLE_TYPE, isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT,
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
|
||||||
#else
|
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
|
||||||
#endif
|
|
||||||
EGL_CONFIG_CAVEAT, EGL_NONE,
|
EGL_CONFIG_CAVEAT, EGL_NONE,
|
||||||
EGL_NONE,
|
EGL_NONE,
|
||||||
};
|
};
|
||||||
|
|
|
@ -113,36 +113,36 @@ bool EglGbmBackend::initRenderingContext()
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLContext context = EGL_NO_CONTEXT;
|
EGLContext context = EGL_NO_CONTEXT;
|
||||||
#ifdef KWIN_HAVE_OPENGLES
|
if (isOpenGLES()) {
|
||||||
const EGLint context_attribs[] = {
|
const EGLint context_attribs[] = {
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs);
|
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs);
|
||||||
#else
|
} else {
|
||||||
const EGLint context_attribs_31_core[] = {
|
const EGLint context_attribs_31_core[] = {
|
||||||
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
||||||
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
||||||
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
const EGLint context_attribs_legacy[] = {
|
const EGLint context_attribs_legacy[] = {
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
// Try to create a 3.1 core context
|
// Try to create a 3.1 core context
|
||||||
if (options->glCoreProfile() && extensions.contains(QByteArrayLiteral("EGL_KHR_create_context")))
|
if (options->glCoreProfile() && extensions.contains(QByteArrayLiteral("EGL_KHR_create_context")))
|
||||||
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs_31_core);
|
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs_31_core);
|
||||||
|
|
||||||
if (context == EGL_NO_CONTEXT)
|
if (context == EGL_NO_CONTEXT)
|
||||||
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs_legacy);
|
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs_legacy);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
if (context == EGL_NO_CONTEXT) {
|
if (context == EGL_NO_CONTEXT) {
|
||||||
// qCCritical(KWIN_DRM) << "Create Context failed";
|
// qCCritical(KWIN_DRM) << "Create Context failed";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
setContext(context);
|
setContext(context);
|
||||||
setSurfaceLessContext(true);
|
setSurfaceLessContext(true);
|
||||||
|
@ -158,11 +158,7 @@ bool EglGbmBackend::initBufferConfigs()
|
||||||
EGL_GREEN_SIZE, 1,
|
EGL_GREEN_SIZE, 1,
|
||||||
EGL_BLUE_SIZE, 1,
|
EGL_BLUE_SIZE, 1,
|
||||||
EGL_ALPHA_SIZE, 0,
|
EGL_ALPHA_SIZE, 0,
|
||||||
#ifdef KWIN_HAVE_OPENGLES
|
EGL_RENDERABLE_TYPE, isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT,
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
|
||||||
#else
|
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
|
||||||
#endif
|
|
||||||
EGL_CONFIG_CAVEAT, EGL_NONE,
|
EGL_CONFIG_CAVEAT, EGL_NONE,
|
||||||
EGL_NONE,
|
EGL_NONE,
|
||||||
};
|
};
|
||||||
|
|
|
@ -114,35 +114,35 @@ bool EglWaylandBackend::initRenderingContext()
|
||||||
initBufferConfigs();
|
initBufferConfigs();
|
||||||
|
|
||||||
EGLContext context = EGL_NO_CONTEXT;
|
EGLContext context = EGL_NO_CONTEXT;
|
||||||
#ifdef KWIN_HAVE_OPENGLES
|
if (isOpenGLES()) {
|
||||||
const EGLint context_attribs[] = {
|
const EGLint context_attribs[] = {
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs);
|
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs);
|
||||||
#else
|
} else {
|
||||||
const EGLint context_attribs_31_core[] = {
|
const EGLint context_attribs_31_core[] = {
|
||||||
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
||||||
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
||||||
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
const EGLint context_attribs_legacy[] = {
|
const EGLint context_attribs_legacy[] = {
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* eglExtensionsCString = eglQueryString(eglDisplay(), EGL_EXTENSIONS);
|
const char* eglExtensionsCString = eglQueryString(eglDisplay(), EGL_EXTENSIONS);
|
||||||
const QList<QByteArray> extensions = QByteArray::fromRawData(eglExtensionsCString, qstrlen(eglExtensionsCString)).split(' ');
|
const QList<QByteArray> extensions = QByteArray::fromRawData(eglExtensionsCString, qstrlen(eglExtensionsCString)).split(' ');
|
||||||
|
|
||||||
// Try to create a 3.1 core context
|
// Try to create a 3.1 core context
|
||||||
if (options->glCoreProfile() && extensions.contains(QByteArrayLiteral("EGL_KHR_create_context")))
|
if (options->glCoreProfile() && extensions.contains(QByteArrayLiteral("EGL_KHR_create_context")))
|
||||||
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs_31_core);
|
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs_31_core);
|
||||||
|
|
||||||
if (context == EGL_NO_CONTEXT)
|
if (context == EGL_NO_CONTEXT)
|
||||||
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs_legacy);
|
context = eglCreateContext(eglDisplay(), config(), EGL_NO_CONTEXT, context_attribs_legacy);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
if (context == EGL_NO_CONTEXT) {
|
if (context == EGL_NO_CONTEXT) {
|
||||||
qCCritical(KWIN_WAYLAND_BACKEND) << "Create Context failed";
|
qCCritical(KWIN_WAYLAND_BACKEND) << "Create Context failed";
|
||||||
|
@ -201,11 +201,7 @@ bool EglWaylandBackend::initBufferConfigs()
|
||||||
EGL_GREEN_SIZE, 1,
|
EGL_GREEN_SIZE, 1,
|
||||||
EGL_BLUE_SIZE, 1,
|
EGL_BLUE_SIZE, 1,
|
||||||
EGL_ALPHA_SIZE, 0,
|
EGL_ALPHA_SIZE, 0,
|
||||||
#ifdef KWIN_HAVE_OPENGLES
|
EGL_RENDERABLE_TYPE, isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT,
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
|
||||||
#else
|
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
|
||||||
#endif
|
|
||||||
EGL_CONFIG_CAVEAT, EGL_NONE,
|
EGL_CONFIG_CAVEAT, EGL_NONE,
|
||||||
EGL_NONE,
|
EGL_NONE,
|
||||||
};
|
};
|
||||||
|
|
|
@ -227,34 +227,34 @@ bool EglOnXBackend::initRenderingContext()
|
||||||
setSurface(surface);
|
setSurface(surface);
|
||||||
|
|
||||||
EGLContext ctx = EGL_NO_CONTEXT;
|
EGLContext ctx = EGL_NO_CONTEXT;
|
||||||
#ifdef KWIN_HAVE_OPENGLES
|
if (isOpenGLES()) {
|
||||||
const EGLint context_attribs[] = {
|
const EGLint context_attribs[] = {
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx = eglCreateContext(dpy, config(), EGL_NO_CONTEXT, context_attribs);
|
ctx = eglCreateContext(dpy, config(), EGL_NO_CONTEXT, context_attribs);
|
||||||
#else
|
} else {
|
||||||
const EGLint context_attribs_31_core[] = {
|
const EGLint context_attribs_31_core[] = {
|
||||||
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
EGL_CONTEXT_MAJOR_VERSION_KHR, 3,
|
||||||
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
EGL_CONTEXT_MINOR_VERSION_KHR, 1,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
const EGLint context_attribs_legacy[] = {
|
const EGLint context_attribs_legacy[] = {
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
const QByteArray eglExtensions = eglQueryString(dpy, EGL_EXTENSIONS);
|
const QByteArray eglExtensions = eglQueryString(dpy, EGL_EXTENSIONS);
|
||||||
const QList<QByteArray> extensions = eglExtensions.split(' ');
|
const QList<QByteArray> extensions = eglExtensions.split(' ');
|
||||||
|
|
||||||
// Try to create a 3.1 core context
|
// Try to create a 3.1 core context
|
||||||
if (options->glCoreProfile() && extensions.contains("EGL_KHR_create_context"))
|
if (options->glCoreProfile() && extensions.contains("EGL_KHR_create_context"))
|
||||||
ctx = eglCreateContext(dpy, config(), EGL_NO_CONTEXT, context_attribs_31_core);
|
ctx = eglCreateContext(dpy, config(), EGL_NO_CONTEXT, context_attribs_31_core);
|
||||||
|
|
||||||
if (ctx == EGL_NO_CONTEXT)
|
if (ctx == EGL_NO_CONTEXT)
|
||||||
ctx = eglCreateContext(dpy, config(), EGL_NO_CONTEXT, context_attribs_legacy);
|
ctx = eglCreateContext(dpy, config(), EGL_NO_CONTEXT, context_attribs_legacy);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
if (ctx == EGL_NO_CONTEXT) {
|
if (ctx == EGL_NO_CONTEXT) {
|
||||||
qCCritical(KWIN_CORE) << "Create Context failed";
|
qCCritical(KWIN_CORE) << "Create Context failed";
|
||||||
|
@ -284,11 +284,7 @@ bool EglOnXBackend::initBufferConfigs()
|
||||||
EGL_GREEN_SIZE, 1,
|
EGL_GREEN_SIZE, 1,
|
||||||
EGL_BLUE_SIZE, 1,
|
EGL_BLUE_SIZE, 1,
|
||||||
EGL_ALPHA_SIZE, 0,
|
EGL_ALPHA_SIZE, 0,
|
||||||
#ifdef KWIN_HAVE_OPENGLES
|
EGL_RENDERABLE_TYPE, isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT,
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
|
||||||
#else
|
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
|
||||||
#endif
|
|
||||||
EGL_CONFIG_CAVEAT, EGL_NONE,
|
EGL_CONFIG_CAVEAT, EGL_NONE,
|
||||||
EGL_NONE,
|
EGL_NONE,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue