[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt: fix Qt Quick's default format adjustments are not considered

François Cartegnie (@fcartegnie) gitlab at videolan.org
Thu Sep 24 06:48:45 UTC 2026



François Cartegnie pushed to branch master at VideoLAN / VLC


Commits:
82702dec by Fatih Uzunoglu at 2026-09-24T08:38:27+02:00
qt: fix Qt Quick's default format adjustments are not considered

- - - - -
8fee47c1 by Fatih Uzunoglu at 2026-09-24T08:38:27+02:00
qt: fix default surface format is not adjusted in asynchronous rhi probe case

- - - - -


1 changed file:

- modules/gui/qt/qt.cpp


Changes:

=====================================
modules/gui/qt/qt.cpp
=====================================
@@ -979,6 +979,39 @@ static void *Thread( void *obj )
     // It is guaranteed that the returned format is supported, if a format is returned.
     static const auto createCompatibleOpenGLFormat = []() -> std::optional<QSurfaceFormat> {
         QOpenGLContext defaultCtx;
+
+        QSurfaceFormat defaultFormat = defaultCtx.format();
+
+        /// <QSGDefaultContext::defaultSurfaceFormat()>
+        /// This is copied from `QSGDefaultContext::defaultSurfaceFormat()`, since
+        /// it is not public. The default `QSurfaceFormat::defaultFormat()` that is
+        /// provided by Qt Gui naturally does not consider the default format of
+        /// Qt Quick:
+        // These depend solely on the env.vars., not QQuickGraphicsConfiguration
+        // since that does not have a flag that maps 100% to QSG_NO_xx_BUFFER.
+        static bool useDepth = qEnvironmentVariableIsEmpty("QSG_NO_DEPTH_BUFFER");
+        static bool useStencil = qEnvironmentVariableIsEmpty("QSG_NO_STENCIL_BUFFER");
+        static bool enableDebug = qEnvironmentVariableIsSet("QSG_OPENGL_DEBUG");
+        static bool disableVSync = qEnvironmentVariableIsSet("QSG_NO_VSYNC");
+        if (useDepth && defaultFormat.depthBufferSize() == -1)
+            defaultFormat.setDepthBufferSize(24);
+        else if (!useDepth)
+            defaultFormat.setDepthBufferSize(0);
+        if (useStencil && defaultFormat.stencilBufferSize() == -1)
+            defaultFormat.setStencilBufferSize(8);
+        else if (!useStencil)
+            defaultFormat.setStencilBufferSize(0);
+        if (enableDebug)
+            defaultFormat.setOption(QSurfaceFormat::DebugContext);
+        if (QQuickWindow::hasDefaultAlphaBuffer())
+            defaultFormat.setAlphaBufferSize(8);
+        defaultFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
+        if (disableVSync) // swapInterval defaults to 1, it has no -1 special value
+            defaultFormat.setSwapInterval(0);
+        /// </QSGDefaultContext::defaultSurfaceFormat()>
+
+        defaultCtx.setFormat(defaultFormat);
+
         // This is really unnecessary to check, since Qt should not be using unavailable contexts, but nevertheless.
         if (Q_UNLIKELY(!defaultCtx.create()))
             return std::nullopt;
@@ -1182,6 +1215,19 @@ static void *Thread( void *obj )
             const auto globalThreadPool = QThreadPool::globalInstance();
             assert(globalThreadPool);
 
+            if (graphicsApiValue.toInt() == QSGRendererInterface::OpenGL)
+            {
+                // Due to asynchronous probing, we need to set the default
+                // format before the main interface window's (`::create()`)
+                // is called. Since previous probe result succeeded with
+                // OpenGL and required version, we can assume that the there
+                // will be again a compatible OpenGL format, rather than
+                // storing and re-using the version (considering that it
+                // takes negligible time to re-create the compatible format):
+                if (const auto format = createCompatibleOpenGLFormat()) /* [[likely]] */
+                    QSurfaceFormat::setDefaultFormat(*format);
+            }
+
             rhiProbeTask->start(*globalThreadPool, -1);
         }
         else



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1b92ac6ce09a94f69cac98bf0c5b9de5289a1e73...8fee47c1a1bfeba1a4d103c15966eab9e27cb910

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/1b92ac6ce09a94f69cac98bf0c5b9de5289a1e73...8fee47c1a1bfeba1a4d103c15966eab9e27cb910
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list