Remove Platform::sceneEglConfig()

With per-screen rendering, every output may have different EGLConfig.
Having a single global EGLConfig doesn't work out well.

This change removes Platform::sceneEglConfig(). It's used primarily to
create the global share context. In hindsight, the global share context
can be created without EGLConfig as it's never made current.

EGL_NO_CONFIG_KHR is part of EGL_KHR_no_config_context extension, which
is supported by both Mesa and NVIDIA driver so it should be safe to make
it mandatory.
This commit is contained in:
Vlad Zahorodnii 2021-08-15 12:32:06 +03:00
parent bc7b28bb65
commit e315b0f9fe
2 changed files with 12 additions and 21 deletions

View file

@ -119,20 +119,6 @@ public:
*/
void setSceneEglGlobalShareContext(EGLContext context);
/**
* The EglConfig used by the compositing scene.
*/
EGLConfig sceneEglConfig() const {
return m_eglConfig;
}
/**
* Sets the @p config used by the compositing scene.
* @see sceneEglConfig
*/
void setSceneEglConfig(EGLConfig config) {
m_eglConfig = config;
}
/**
* Implementing subclasses should provide a size in case the backend represents
* a basic screen and uses the BasicScreens.
@ -547,7 +533,6 @@ private:
int m_initialOutputCount = 1;
qreal m_initialOutputScale = 1;
EGLDisplay m_eglDisplay;
EGLConfig m_eglConfig = nullptr;
EGLContext m_context = EGL_NO_CONTEXT;
EGLContext m_globalShareContext = EGL_NO_CONTEXT;
int m_hideCursorCounter = 0;

View file

@ -40,7 +40,6 @@ static bool isOpenGLES_helper()
static EGLContext ensureGlobalShareContext()
{
const EGLDisplay eglDisplay = kwinApp()->platform()->sceneEglDisplay();
const EGLConfig eglConfig = kwinApp()->platform()->sceneEglConfig();
if (kwinApp()->platform()->sceneEglGlobalShareContext() != EGL_NO_CONTEXT) {
return kwinApp()->platform()->sceneEglGlobalShareContext();
@ -56,7 +55,7 @@ static EGLContext ensureGlobalShareContext()
attribs = builder.build();
}
s_globalShareContext = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, attribs.data());
s_globalShareContext = eglCreateContext(eglDisplay, EGL_NO_CONFIG_KHR, EGL_NO_CONTEXT, attribs.data());
if (s_globalShareContext == EGL_NO_CONTEXT) {
qCWarning(KWIN_OPENGL, "Failed to create global share context: 0x%x", eglGetError());
}
@ -108,7 +107,6 @@ void AbstractEglBackend::cleanup()
eglDestroyContext(m_display, m_context);
eglReleaseThread();
kwinApp()->platform()->setSceneEglContext(EGL_NO_CONTEXT);
kwinApp()->platform()->setSceneEglConfig(nullptr);
}
}
@ -144,6 +142,17 @@ bool AbstractEglBackend::initEglAPI()
qCDebug(KWIN_OPENGL) << "EGL version: " << major << "." << minor;
const QByteArray eglExtensions = eglQueryString(m_display, EGL_EXTENSIONS);
setExtensions(eglExtensions.split(' '));
const QByteArray requiredExtensions[] = {
QByteArrayLiteral("EGL_KHR_no_config_context"),
};
for (const QByteArray &extensionName : requiredExtensions) {
if (!hasExtension(extensionName)) {
qCWarning(KWIN_OPENGL) << extensionName << "extension is unsupported";
return false;
}
}
setSupportsSurfacelessContext(hasExtension(QByteArrayLiteral("EGL_KHR_surfaceless_context")));
setSupportsNativeFence(hasExtension(QByteArrayLiteral("EGL_ANDROID_native_fence_sync")));
return true;
@ -355,9 +364,6 @@ void AbstractEglBackend::setEglDisplay(const EGLDisplay &display) {
void AbstractEglBackend::setConfig(const EGLConfig &config)
{
m_config = config;
if (isPrimary()) {
kwinApp()->platform()->setSceneEglConfig(config);
}
}
void AbstractEglBackend::setSurface(const EGLSurface &surface)