aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Gräßlin <[email protected]>2016-11-17 07:51:04 +0100
committerMartin Gräßlin <[email protected]>2016-11-17 13:00:29 +0100
commitd1de6899fd5e0e313a9b9d3b4a92ea808f0e8427 (patch)
tree7ca8c3e3eabec4c89046bbdc8da21fb7f24d3b77
parentdcf7f40c18fb56ea592aa35cd5ca238d98d39fe6 (diff)
Move querying the egl extensions into the AbstractEglBackend
Summary: Instead of having the egl extensions in the global kwinglutils lib it becomes private to the AbstractEglBackend. Just like on glx the glxextensions are moved into the platform. The extensions are queried from initEglAPI, that is as early as possible after initializing the EGLDisplay. This ensures that any implementing subclass can access the extensions early enough. As a note: the EglOnXBackend had a potentially wrong sequence for initializing the buffer age extension. It is now moved to the correct place where the result is needed for the first time. From the global API eglExtensions are removed from hasGLExtension and the eglExtensions function is dropped. As by that initEGL did not do anything it is also dropped. Test Plan: Tested nested kwin on Wayland, still works, extensions shown in debug console Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D3396
-rw-r--r--abstract_egl_backend.cpp13
-rw-r--r--debug_console.cpp2
-rw-r--r--libkwineffects/kwinglutils.cpp17
-rw-r--r--libkwineffects/kwinglutils.h3
-rw-r--r--platform.cpp7
-rw-r--r--plugins/platforms/x11/common/eglonxbackend.cpp13
6 files changed, 19 insertions, 36 deletions
diff --git a/abstract_egl_backend.cpp b/abstract_egl_backend.cpp
index ec01840..7ddcb78 100644
--- a/abstract_egl_backend.cpp
+++ b/abstract_egl_backend.cpp
@@ -104,6 +104,8 @@ bool AbstractEglBackend::initEglAPI()
return false;
}
qCDebug(KWIN_CORE) << "EGL version: " << major << "." << minor;
+ const QByteArray eglExtensions = eglQueryString(m_display, EGL_EXTENSIONS);
+ setExtensions(eglExtensions.split(' '));
return true;
}
@@ -115,7 +117,6 @@ static eglFuncPtr getProcAddress(const char* name)
void AbstractEglBackend::initKWinGL()
{
- initEGL();
GLPlatform *glPlatform = GLPlatform::instance();
glPlatform->detect(EglPlatformInterface);
options->setGlPreferBufferSwap(options->glPreferBufferSwap()); // resolve autosetting
@@ -129,7 +130,7 @@ void AbstractEglBackend::initBufferAge()
{
setSupportsBufferAge(false);
- if (hasGLExtension(QByteArrayLiteral("EGL_EXT_buffer_age"))) {
+ if (hasExtension(QByteArrayLiteral("EGL_EXT_buffer_age"))) {
const QByteArray useBufferAge = qgetenv("KWIN_USE_BUFFER_AGE");
if (useBufferAge != "0")
@@ -142,7 +143,7 @@ void AbstractEglBackend::initWayland()
if (!WaylandServer::self()) {
return;
}
- if (hasGLExtension(QByteArrayLiteral("EGL_WL_bind_wayland_display"))) {
+ if (hasExtension(QByteArrayLiteral("EGL_WL_bind_wayland_display"))) {
eglBindWaylandDisplayWL = (eglBindWaylandDisplayWL_func)eglGetProcAddress("eglBindWaylandDisplayWL");
eglUnbindWaylandDisplayWL = (eglUnbindWaylandDisplayWL_func)eglGetProcAddress("eglUnbindWaylandDisplayWL");
eglQueryWaylandBufferWL = (eglQueryWaylandBufferWL_func)eglGetProcAddress("eglQueryWaylandBufferWL");
@@ -202,10 +203,8 @@ bool AbstractEglBackend::isOpenGLES() const
bool AbstractEglBackend::createContext()
{
- const QByteArray eglExtensions = eglQueryString(m_display, EGL_EXTENSIONS);
- const QList<QByteArray> extensions = eglExtensions.split(' ');
- const bool haveRobustness = extensions.contains(QByteArrayLiteral("EGL_EXT_create_context_robustness"));
- const bool haveCreateContext = extensions.contains(QByteArrayLiteral("EGL_KHR_create_context"));
+ const bool haveRobustness = hasExtension(QByteArrayLiteral("EGL_EXT_create_context_robustness"));
+ const bool haveCreateContext = hasExtension(QByteArrayLiteral("EGL_KHR_create_context"));
EGLContext ctx = EGL_NO_CONTEXT;
if (isOpenGLES()) {
diff --git a/debug_console.cpp b/debug_console.cpp
index 63c17f2..5308c17 100644
--- a/debug_console.cpp
+++ b/debug_console.cpp
@@ -554,7 +554,7 @@ void DebugConsole::initGLTab()
m_ui->eglExtensionsBox->setVisible(true);
m_ui->glxExtensionsBox->setVisible(false);
- m_ui->eglExtensionsLabel->setText(extensionsString(eglExtensions()));
+ m_ui->eglExtensionsLabel->setText(extensionsString(static_cast<SceneOpenGL*>(Compositor::self()->scene())->backend()->extensions()));
} else {
m_ui->eglExtensionsBox->setVisible(false);
m_ui->glxExtensionsBox->setVisible(true);
diff --git a/libkwineffects/kwinglutils.cpp b/libkwineffects/kwinglutils.cpp
index 0221038..1a5735a 100644
--- a/libkwineffects/kwinglutils.cpp
+++ b/libkwineffects/kwinglutils.cpp
@@ -69,15 +69,6 @@ int glTextureUnitsCount;
// Functions
-void initEGL()
-{
- EGLDisplay dpy = eglGetCurrentDisplay();
- if (dpy == EGL_NO_DISPLAY)
- dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
- const QByteArray string = eglQueryString(dpy, EGL_EXTENSIONS);
- s_eglExtensions = string.split(' ');
-}
-
void initGL(std::function<resolveFuncPtr(const char*)> resolveFunction)
{
// Get list of supported OpenGL extensions
@@ -109,7 +100,6 @@ void cleanupGL()
GLPlatform::cleanup();
glExtensions.clear();
- s_eglExtensions.clear();
glTextureUnitsCount = 0;
}
@@ -121,12 +111,7 @@ bool hasGLVersion(int major, int minor, int release)
bool hasGLExtension(const QByteArray &extension)
{
- return glExtensions.contains(extension) || s_eglExtensions.contains(extension);
-}
-
-QList<QByteArray> eglExtensions()
-{
- return s_eglExtensions;
+ return glExtensions.contains(extension);
}
QList<QByteArray> openGLExtensions()
diff --git a/libkwineffects/kwinglutils.h b/libkwineffects/kwinglutils.h
index 116ff3e..27b2afb 100644
--- a/libkwineffects/kwinglutils.h
+++ b/libkwineffects/kwinglutils.h
@@ -53,8 +53,6 @@ class GLVertexBufferPrivate;
// Note that GL context has to be created by the time this function is called
typedef void (*resolveFuncPtr)();
void KWINGLUTILS_EXPORT initGL(std::function<resolveFuncPtr(const char*)> resolveFunction);
-// Initializes EGL function pointers
-void KWINGLUTILS_EXPORT initEGL();
// Cleans up all resources hold by the GL Context
void KWINGLUTILS_EXPORT cleanupGL();
@@ -80,7 +78,6 @@ inline bool KWINGLUTILS_EXPORT isPowerOfTwo(int x)
// TODO: Drop for Plasma 6, no longer needed after OpenGL 2.0
int KWINGLUTILS_EXPORT nearestPowerOfTwo(int x);
-QList<QByteArray> KWINGLUTILS_EXPORT eglExtensions();
QList<QByteArray> KWINGLUTILS_EXPORT openGLExtensions();
class KWINGLUTILS_EXPORT GLShader
diff --git a/platform.cpp b/platform.cpp
index aaceda0..de43251 100644
--- a/platform.cpp
+++ b/platform.cpp
@@ -285,7 +285,12 @@ void Platform::warpPointer(const QPointF &globalPos)
bool Platform::supportsQpaContext() const
{
- return hasGLExtension(QByteArrayLiteral("EGL_KHR_surfaceless_context"));
+ if (Compositor *c = Compositor::self()) {
+ if (SceneOpenGL *s = dynamic_cast<SceneOpenGL*>(c->scene())) {
+ return s->backend()->hasExtension(QByteArrayLiteral("EGL_KHR_surfaceless_context"));
+ }
+ }
+ return false;
}
EGLDisplay KWin::Platform::sceneEglDisplay() const
diff --git a/plugins/platforms/x11/common/eglonxbackend.cpp b/plugins/platforms/x11/common/eglonxbackend.cpp
index 077d9b8..49e2357 100644
--- a/plugins/platforms/x11/common/eglonxbackend.cpp
+++ b/plugins/platforms/x11/common/eglonxbackend.cpp
@@ -93,17 +93,15 @@ EglOnXBackend::~EglOnXBackend()
void EglOnXBackend::init()
{
qputenv("EGL_PLATFORM", "x11");
- initEGL(); // required to toggle
- initBufferAge(); // EGL_SWAP_BEHAVIOR_PRESERVED_BIT
if (!initRenderingContext()) {
setFailed(QStringLiteral("Could not initialize rendering context"));
return;
}
initKWinGL();
- if (!hasGLExtension(QByteArrayLiteral("EGL_KHR_image")) &&
- (!hasGLExtension(QByteArrayLiteral("EGL_KHR_image_base")) ||
- !hasGLExtension(QByteArrayLiteral("EGL_KHR_image_pixmap")))) {
+ if (!hasExtension(QByteArrayLiteral("EGL_KHR_image")) &&
+ (!hasExtension(QByteArrayLiteral("EGL_KHR_image_base")) ||
+ !hasExtension(QByteArrayLiteral("EGL_KHR_image_pixmap")))) {
setFailed(QStringLiteral("Required support for binding pixmaps to EGLImages not found, disabling compositing"));
return;
}
@@ -113,7 +111,7 @@ void EglOnXBackend::init()
}
// check for EGL_NV_post_sub_buffer and whether it can be used on the surface
- if (hasGLExtension(QByteArrayLiteral("EGL_NV_post_sub_buffer"))) {
+ if (hasExtension(QByteArrayLiteral("EGL_NV_post_sub_buffer"))) {
if (eglQuerySurface(eglDisplay(), surface(), EGL_POST_SUB_BUFFER_SUPPORTED_NV, &surfaceHasSubPost) == EGL_FALSE) {
EGLint error = eglGetError();
if (error != EGL_SUCCESS && error != EGL_BAD_ATTRIBUTE) {
@@ -125,8 +123,6 @@ void EglOnXBackend::init()
}
}
- initBufferAge();
-
setSyncsToVBlank(false);
setBlocksForRetrace(false);
gs_tripleBufferNeedsDetection = false;
@@ -280,6 +276,7 @@ EGLSurface EglOnXBackend::createSurface(xcb_window_t window)
bool EglOnXBackend::initBufferConfigs()
{
+ initBufferAge();
const EGLint config_attribs[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT | (supportsBufferAge() ? 0 : EGL_SWAP_BEHAVIOR_PRESERVED_BIT),
EGL_RED_SIZE, 1,