From f700de56f8ae6c15c7fd7d18bdaf47bf1e21b219 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 31 May 2024 15:28:09 +0000 Subject: [PATCH] core: Disable Qt RHI pipeline cache The Qt pipeline cache causes a disk sync on every load and save of a QQuickWindow. This causes a stutter under high disk usage. The gains from this cache are minimal on our simple scenes on PC hardware. Especially given mesa has it's own cache, profiling on my personal laptop showed the pipeline as being 0ms. There is an upstream patch at https://codereview.qt-project.org/c/qt/qtdeclarative/+/564411 . QSaveFile still has a sync, but that should only be hit for the first non-cached run. I'm also adding a flag to QSaveFile to fix the QML cache and first run case. Tested via running kwin with `strace -e inject=fdatasync:delay_enter=10000000` to simulate a slow flush. BUG: 487043 --- src/main_wayland.cpp | 5 +++++ src/main_x11.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/main_wayland.cpp b/src/main_wayland.cpp index 000178c59e..66e4cd8369 100644 --- a/src/main_wayland.cpp +++ b/src/main_wayland.cpp @@ -285,6 +285,11 @@ int main(int argc, char *argv[]) // enforce our internal qpa plugin, unfortunately command line switch has precedence setenv("QT_QPA_PLATFORM", "wayland-org.kde.kwin.qpa", true); + // The shader (currently) causes a blocking disk flush on load and save of every QQuickWindow + // Because it's on load, it will happen every time not just occasionally + // The gains are minimal, disable until it's fixed + QCoreApplication::setAttribute(Qt::AA_DisableShaderDiskCache); + KWin::ApplicationWayland a(argc, argv); // reset QT_QPA_PLATFORM so we don't propagate it to our children (e.g. apps launched from the overview effect) diff --git a/src/main_x11.cpp b/src/main_x11.cpp index 3506eb07ed..b3729c8704 100644 --- a/src/main_x11.cpp +++ b/src/main_x11.cpp @@ -400,6 +400,11 @@ int main(int argc, char *argv[]) // For sharing thumbnails between our scene graph and qtquick. QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); + // The shader (currently) causes a blocking disk flush on load and save of every QQuickWindow + // Because it's on load, it will happen every time not just occasionally + // The gains are minimal, disable until it's fixed + QCoreApplication::setAttribute(Qt::AA_DisableShaderDiskCache); + QSurfaceFormat format = QSurfaceFormat::defaultFormat(); // shared opengl contexts must have the same reset notification policy format.setOptions(QSurfaceFormat::ResetNotification);