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.
This commit is contained in:
Vlad Zahorodnii 2020-10-16 16:11:23 +03:00
parent a195223a8d
commit 33fad70c9b
3 changed files with 16 additions and 2 deletions

View file

@ -13,6 +13,9 @@
#include <qobject.h>
#include <QVector>
#include <epoxy/egl.h>
#include <fixx11h.h>
#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<DrmPlane*> 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<DrmPlane*> m_planes;

View file

@ -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) {

View file

@ -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) {