[vlc-commits] [Git][videolan/vlc][master] qt: workaround for nvidia on xwayland
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu Oct 12 16:46:17 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
70d1d262 by Fatih Uzunoglu at 2023-10-12T15:40:03+00:00
qt: workaround for nvidia on xwayland
- - - - -
2 changed files:
- modules/gui/qt/maininterface/compositor_x11_uisurface.cpp
- modules/gui/qt/maininterface/compositor_x11_uisurface.hpp
Changes:
=====================================
modules/gui/qt/maininterface/compositor_x11_uisurface.cpp
=====================================
@@ -21,7 +21,8 @@
#include <QQuickWindow>
#include <QQuickItem>
#include <QOffscreenSurface>
-#include <QGuiApplication>
+#include <QApplication>
+#include <QThread>
#include "compositor_x11_uisurface.hpp"
#include "compositor_common.hpp"
@@ -48,6 +49,13 @@ CompositorX11UISurface::CompositorX11UISurface(QWindow* window, QScreen* screen)
// UI is renderred on offscreen, no need for double bufferring
format.setSwapBehavior(QSurfaceFormat::SingleBuffer);
+ // Check if this is XWayland:
+ if (Q_UNLIKELY(QApplication::platformName() == QLatin1String("xcb") &&
+ qEnvironmentVariable("XDG_SESSION_TYPE") == QLatin1String("wayland")))
+ {
+ applyNvidiaWorkaround(format);
+ }
+
setFormat(format);
m_context = new QOpenGLContext();
@@ -322,6 +330,33 @@ void CompositorX11UISurface::resizeFbo()
}
}
+void CompositorX11UISurface::applyNvidiaWorkaround(QSurfaceFormat &format)
+{
+ assert(QThread::currentThread() == qApp->thread());
+
+ QOffscreenSurface surface;
+ surface.setFormat(format);
+ surface.create();
+
+ QOpenGLContext ctx;
+ ctx.setFormat(format);
+ if (ctx.create() && ctx.makeCurrent(&surface))
+ {
+ // Context needs to be created to access the functions
+ if (QOpenGLFunctions * const func = ctx.functions())
+ {
+ if (const GLubyte* str = func->glGetString(GL_VENDOR))
+ {
+ if (!strcmp(reinterpret_cast<const char *>(str), "NVIDIA Corporation"))
+ {
+ // for some reason SingleBuffer is not supported:
+ format.setSwapBehavior(QSurfaceFormat::DefaultSwapBehavior);
+ }
+ }
+ }
+ }
+}
+
void CompositorX11UISurface::resizeEvent(QResizeEvent *)
{
if (m_onscreenSize != size() * devicePixelRatio())
=====================================
modules/gui/qt/maininterface/compositor_x11_uisurface.hpp
=====================================
@@ -90,6 +90,8 @@ protected:
void resizeFbo();
private:
+ static void applyNvidiaWorkaround(QSurfaceFormat& format);
+
QQuickItem* m_rootItem = nullptr;
QOpenGLContext *m_context = nullptr;
CompositorOffscreenWindow* m_uiWindow = nullptr;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/70d1d26280a212cfcb86a831ed8b2dcb02f4ca99
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/70d1d26280a212cfcb86a831ed8b2dcb02f4ca99
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list