From 5a2177a51c346223b3b7c1ed5c0c70bbcbd8a5f5 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Tue, 20 Apr 2021 12:13:58 +0200 Subject: [PATCH] platforms/drm: use surfaceless context On multi-gpu systems it could happen that the primary GPU has no working outputs attached, yet we still need the egl context. --- src/plugins/platforms/drm/egl_gbm_backend.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/plugins/platforms/drm/egl_gbm_backend.cpp b/src/plugins/platforms/drm/egl_gbm_backend.cpp index 534cbe2141..a02487b451 100644 --- a/src/plugins/platforms/drm/egl_gbm_backend.cpp +++ b/src/plugins/platforms/drm/egl_gbm_backend.cpp @@ -86,6 +86,10 @@ bool EglGbmBackend::initializeEgl() // Use eglGetPlatformDisplayEXT() to get the display pointer // if the implementation supports it. if (display == EGL_NO_DISPLAY) { + if (!supportsSurfacelessContext()) { + setFailed("EGL_KHR_surfaceless_context extension is unavailable!"); + return false; + } const bool hasMesaGBM = hasClientExtension(QByteArrayLiteral("EGL_MESA_platform_gbm")); const bool hasKHRGBM = hasClientExtension(QByteArrayLiteral("EGL_KHR_platform_gbm")); const GLenum platform = hasMesaGBM ? EGL_PLATFORM_GBM_MESA : EGL_PLATFORM_GBM_KHR; @@ -151,12 +155,8 @@ bool EglGbmBackend::initRenderingContext() qCCritical(KWIN_DRM) << "Create Window Surfaces failed"; return false; } - if (!m_outputs.isEmpty()) { - // Set our first surface as the one for the abstract backend, just to make it happy. - setSurface(m_outputs.first().eglSurface); - if (isPrimary()) { - return makeContextCurrent(m_outputs.first()); - } + if (isPrimary()) { + return makeCurrent(); } return true; } @@ -196,9 +196,6 @@ bool EglGbmBackend::resetOutput(Output &output, DrmOutput *drmOutput) return false; } - if (surface() == output.eglSurface || surface() == EGL_NO_SURFACE) { - setSurface(eglSurface); - } // destroy previous surface if (output.eglSurface != EGL_NO_SURFACE) { eglDestroySurface(eglDisplay(), output.eglSurface);