[packages/qt6] apply fix for QTBUG-136257

atler atler at pld-linux.org
Wed Jun 4 03:52:28 CEST 2025


commit fd96958d255ce1b25d66cc477178e0c19bb52782
Author: Jan Palus <atler at pld-linux.org>
Date:   Tue Jun 3 10:56:57 2025 +0200

    apply fix for QTBUG-136257

 QTBUG-136257.patch | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 qt6.spec           |   2 +
 2 files changed, 179 insertions(+)
---
diff --git a/qt6.spec b/qt6.spec
index e3ae914..6b37e4b 100644
--- a/qt6.spec
+++ b/qt6.spec
@@ -164,6 +164,7 @@ Patch5:		qtwebengine-cmake-build-type.patch
 Patch6:		qtquick3d-6.6.2-gcc14.patch
 Patch7:		webengine-seccomp-glibc2.41.patch
 Patch8:		qtwebengine-missing-dep.patch
+Patch9:		QTBUG-136257.patch
 URL:		https://www.qt.io/
 %{?with_directfb:BuildRequires:	DirectFB-devel}
 BuildRequires:	EGL-devel
@@ -3799,6 +3800,7 @@ narzędzia.
 %patch -P6 -p1 -d qtquick3d
 %patch -P7 -p1 -d qtwebengine/src/3rdparty/chromium
 %patch -P8 -p1 -d qtwebengine
+%patch -P9 -p1 -d qtwebengine
 
 %{__sed} -i -e 's,usr/X11R6/,usr/,g' qtbase/mkspecs/linux-g++-64/qmake.conf
 
diff --git a/QTBUG-136257.patch b/QTBUG-136257.patch
new file mode 100644
index 0000000..8b3e24d
--- /dev/null
+++ b/QTBUG-136257.patch
@@ -0,0 +1,177 @@
+From 92f8382ac822175cc5546164b86dba9f226d2e5e Mon Sep 17 00:00:00 2001
+From: Peter Varga <pvarga at inf.u-szeged.hu>
+Date: Thu, 08 May 2025 14:08:48 +0200
+Subject: [PATCH] Create EGLImage with eglCreateDRMImageMESA() for exporting dma_buf
+
+This simplifies the code because it is not needed to create OpenGL
+texture to allocate buffer. This way we can get rid of creating a
+temporary OpenGL context and swapping EGLSurface.
+
+Moreover, eglCreateImage() does not guarantee that the buffer is
+shareable thus certain GPU drivers may fail to export.
+
+Fixes: QTBUG-136257
+Done-with: Jan Palus
+Change-Id: Ie72d052a2a8b1a41bebf0eab8a4928d38c8fc864
+Reviewed-by: Allan Sandfeld Jensen <allan.jensen at qt.io>
+Reviewed-by: Jan Palus <jpalus at fastmail.com>
+(cherry picked from commit 2ed5f9632292c6e531f353dae800cb12274af91a)
+Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot at qt-project.org>
+(cherry picked from commit ddcd30454aa6338d898c9d20c8feb48f36632e16)
+---
+
+diff --git a/src/core/ozone/egl_helper.cpp b/src/core/ozone/egl_helper.cpp
+index d12280f..1ed679d 100644
+--- a/src/core/ozone/egl_helper.cpp
++++ b/src/core/ozone/egl_helper.cpp
+@@ -58,90 +58,14 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-class ScopedGLContext
+-{
+-public:
+-    ScopedGLContext(QOffscreenSurface *surface, EGLHelper::EGLFunctions *eglFun)
+-        : m_context(new QOpenGLContext()), m_eglFun(eglFun)
+-    {
+-        if ((m_previousEGLContext = m_eglFun->eglGetCurrentContext())) {
+-            m_previousEGLDrawSurface = m_eglFun->eglGetCurrentSurface(EGL_DRAW);
+-            m_previousEGLReadSurface = m_eglFun->eglGetCurrentSurface(EGL_READ);
+-            m_previousEGLDisplay = m_eglFun->eglGetCurrentDisplay();
+-        }
+-
+-        if (!m_context->create()) {
+-            qWarning("Failed to create OpenGL context.");
+-            return;
+-        }
+-
+-        Q_ASSERT(surface->isValid());
+-        if (!m_context->makeCurrent(surface)) {
+-            qWarning("Failed to make OpenGL context current.");
+-            return;
+-        }
+-    }
+-
+-    ~ScopedGLContext()
+-    {
+-        if (!m_textures.empty()) {
+-            auto *glFun = m_context->functions();
+-            glFun->glDeleteTextures(m_textures.size(), m_textures.data());
+-        }
+-
+-        if (m_previousEGLContext) {
+-            // Make sure the scoped context is not current when restoring the previous
+-            // EGL context otherwise the QOpenGLContext destructor resets the restored
+-            // current context.
+-            m_context->doneCurrent();
+-
+-            m_eglFun->eglMakeCurrent(m_previousEGLDisplay, m_previousEGLDrawSurface,
+-                                     m_previousEGLReadSurface, m_previousEGLContext);
+-            if (m_eglFun->eglGetError() != EGL_SUCCESS)
+-                qWarning("Failed to restore EGL context.");
+-        }
+-    }
+-
+-    bool isValid() const { return m_context->isValid() && (m_context->surface() != nullptr); }
+-
+-    EGLContext eglContext() const
+-    {
+-        QNativeInterface::QEGLContext *nativeInterface =
+-                m_context->nativeInterface<QNativeInterface::QEGLContext>();
+-        return nativeInterface->nativeContext();
+-    }
+-
+-    uint createTexture(int width, int height)
+-    {
+-        auto *glFun = m_context->functions();
+-
+-        uint glTexture;
+-        glFun->glGenTextures(1, &glTexture);
+-        glFun->glBindTexture(GL_TEXTURE_2D, glTexture);
+-        glFun->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+-                            NULL);
+-        glFun->glBindTexture(GL_TEXTURE_2D, 0);
+-
+-        m_textures.push_back(glTexture);
+-        return glTexture;
+-    }
+-
+-private:
+-    QScopedPointer<QOpenGLContext> m_context;
+-    EGLHelper::EGLFunctions *m_eglFun;
+-    EGLContext m_previousEGLContext = nullptr;
+-    EGLSurface m_previousEGLDrawSurface = nullptr;
+-    EGLSurface m_previousEGLReadSurface = nullptr;
+-    EGLDisplay m_previousEGLDisplay = nullptr;
+-    std::vector<uint> m_textures;
+-};
+-
+ EGLHelper::EGLFunctions::EGLFunctions()
+ {
+     QOpenGLContext *context = OzoneUtilQt::getQOpenGLContext();
+ 
+     eglCreateImage =
+             reinterpret_cast<PFNEGLCREATEIMAGEPROC>(context->getProcAddress("eglCreateImage"));
++    eglCreateDRMImageMESA = reinterpret_cast<PFNEGLCREATEDRMIMAGEMESAPROC>(
++            context->getProcAddress("eglCreateDRMImageMESA"));
+     eglDestroyImage =
+             reinterpret_cast<PFNEGLDESTROYIMAGEPROC>(context->getProcAddress("eglDestroyImage"));
+     eglExportDMABUFImageMESA = reinterpret_cast<PFNEGLEXPORTDMABUFIMAGEMESAPROC>(
+@@ -198,6 +122,7 @@
+         const char *displayExtensions = m_functions->eglQueryString(m_eglDisplay, EGL_EXTENSIONS);
+         m_isDmaBufSupported = strstr(displayExtensions, "EGL_EXT_image_dma_buf_import")
+                 && strstr(displayExtensions, "EGL_EXT_image_dma_buf_import_modifiers")
++                && strstr(displayExtensions, "EGL_MESA_drm_image")
+                 && strstr(displayExtensions, "EGL_MESA_image_dma_buf_export");
+     }
+ 
+@@ -218,19 +143,17 @@
+     if (!m_isDmaBufSupported)
+         return;
+ 
+-    ScopedGLContext context(m_offscreenSurface.get(), m_functions.get());
+-    if (!context.isValid())
+-        return;
++    // clang-format off
++    EGLint attribs[] = {
++        EGL_WIDTH, width,
++        EGL_HEIGHT, height,
++        EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
++        EGL_DRM_BUFFER_USE_MESA, EGL_DRM_BUFFER_USE_SHARE_MESA,
++        EGL_NONE
++    };
++    // clang-format on
+ 
+-    EGLContext eglContext = context.eglContext();
+-    if (!eglContext) {
+-        qWarning("EGL: No EGLContext.");
+-        return;
+-    }
+-
+-    uint64_t textureId = context.createTexture(width, height);
+-    EGLImage eglImage = m_functions->eglCreateImage(m_eglDisplay, eglContext, EGL_GL_TEXTURE_2D,
+-                                                    (EGLClientBuffer)textureId, NULL);
++    EGLImage eglImage = m_functions->eglCreateDRMImageMESA(m_eglDisplay, attribs);
+     if (eglImage == EGL_NO_IMAGE) {
+         qWarning() << "EGL: Failed to create EGLImage:" << getLastEGLErrorString();
+         return;
+diff --git a/src/core/ozone/egl_helper.h b/src/core/ozone/egl_helper.h
+index a1a1aa0..7594e1f 100644
+--- a/src/core/ozone/egl_helper.h
++++ b/src/core/ozone/egl_helper.h
+@@ -11,6 +11,7 @@
+ #include <EGL/eglext.h>
+ 
+ #undef eglCreateImage
++#undef eglCreateDRMImageMESA
+ #undef eglDestroyImage
+ #undef eglExportDMABUFImageMESA
+ #undef eglExportDMABUFImageQueryMESA
+@@ -33,6 +34,7 @@
+         EGLFunctions();
+ 
+         PFNEGLCREATEIMAGEPROC eglCreateImage;
++        PFNEGLCREATEDRMIMAGEMESAPROC eglCreateDRMImageMESA;
+         PFNEGLDESTROYIMAGEPROC eglDestroyImage;
+         PFNEGLEXPORTDMABUFIMAGEMESAPROC eglExportDMABUFImageMESA;
+         PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC eglExportDMABUFImageQueryMESA;
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/qt6.git/commitdiff/272e7884fbf6834d8a5560f0ed56705d62353a50



More information about the pld-cvs-commit mailing list