From 33fad70c9bf496ef25947cb216d233c57b5a181e Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 16 Oct 2020 16:11:23 +0300 Subject: [PATCH] platforms/drm: Fix initialization of EGL displays Currently, every time compositing is restarted, both the gbm and the egl streams backend will re-obtain the EGLDisplay object. This is wrong because the core assumption is that the EGL display doesn't change once it has been obtained. --- plugins/platforms/drm/drm_gpu.h | 12 ++++++++++++ plugins/platforms/drm/egl_gbm_backend.cpp | 3 ++- plugins/platforms/drm/egl_stream_backend.cpp | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/platforms/drm/drm_gpu.h b/plugins/platforms/drm/drm_gpu.h index 21dec50644..29cad2b1d9 100644 --- a/plugins/platforms/drm/drm_gpu.h +++ b/plugins/platforms/drm/drm_gpu.h @@ -13,6 +13,9 @@ #include #include +#include +#include + #include "drm_buffer.h" struct gbm_device; @@ -58,6 +61,10 @@ public: gbm_device *gbmDevice() const { return m_gbmDevice; } + + EGLDisplay eglDisplay() const { + return m_eglDisplay; + } QVector planes() const { return m_planes; @@ -66,6 +73,10 @@ public: void setGbmDevice(gbm_device *d) { m_gbmDevice = d; } + + void setEglDisplay(EGLDisplay display) { + m_eglDisplay = display; + } DrmDumbBuffer *createBuffer(const QSize &size) const { return new DrmDumbBuffer(m_fd, size); @@ -95,6 +106,7 @@ private: bool m_atomicModeSetting; bool m_useEglStreams; gbm_device* m_gbmDevice; + EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; // all available planes: primarys, cursors and overlays QVector m_planes; diff --git a/plugins/platforms/drm/egl_gbm_backend.cpp b/plugins/platforms/drm/egl_gbm_backend.cpp index 6188f5f3f6..8074e4431c 100644 --- a/plugins/platforms/drm/egl_gbm_backend.cpp +++ b/plugins/platforms/drm/egl_gbm_backend.cpp @@ -74,7 +74,7 @@ void EglGbmBackend::cleanupOutput(Output &output) bool EglGbmBackend::initializeEgl() { initClientExtensions(); - EGLDisplay display = eglDisplay(); + EGLDisplay display = m_gpu->eglDisplay(); // Use eglGetPlatformDisplayEXT() to get the display pointer // if the implementation supports it. @@ -98,6 +98,7 @@ bool EglGbmBackend::initializeEgl() m_gpu->setGbmDevice(device); display = eglGetPlatformDisplayEXT(platform, device, nullptr); + m_gpu->setEglDisplay(display); } if (display == EGL_NO_DISPLAY) { diff --git a/plugins/platforms/drm/egl_stream_backend.cpp b/plugins/platforms/drm/egl_stream_backend.cpp index a166fb962b..ab6d25c21f 100644 --- a/plugins/platforms/drm/egl_stream_backend.cpp +++ b/plugins/platforms/drm/egl_stream_backend.cpp @@ -121,7 +121,7 @@ void EglStreamBackend::cleanupOutput(const Output &o) bool EglStreamBackend::initializeEgl() { initClientExtensions(); - EGLDisplay display = eglDisplay(); + EGLDisplay display = m_gpu->eglDisplay(); if (display == EGL_NO_DISPLAY) { if (!hasClientExtension(QByteArrayLiteral("EGL_EXT_device_base")) && !(hasClientExtension(QByteArrayLiteral("EGL_EXT_device_query")) && @@ -157,6 +157,7 @@ bool EglStreamBackend::initializeEgl() display = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, device, platformAttribs); break; } + m_gpu->setEglDisplay(display); } if (display == EGL_NO_DISPLAY) {