From da0de12cced1574d70bc3ac7df4a1d9012833df7 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Tue, 3 Jul 2018 03:33:53 +0200 Subject: [PATCH] dqt2: lazy-initialize GraphicsWindow Initializing GraphicsWindow layout & children requires cooperation from the graphics stack: on my system, for example, it causes a Vulkan context to get created in order to get driver info. This is a slow operation, and right now it is taking about 60-70% of the Dolphin startup time on my system. Move instead to a lazy-initialization model where the constructor does nothing, instead offloading work to a separate Initialize() method called before the window is shown. I would expect this should be done for other larger parts of the UI, especially the ones where creating widgets ends up triggering large IO subsystems (I suspect controller configuration might be doing that). (I'm not super happy with how this is implemented, but right now it's a one-off, and it's a major complaint users have with the new UI. I prioritized getting something working quickly...) --- .../DolphinQt2/Config/Graphics/GraphicsWindow.cpp | 11 +++++++++++ .../Core/DolphinQt2/Config/Graphics/GraphicsWindow.h | 4 ++++ Source/Core/DolphinQt2/MainWindow.cpp | 1 + 3 files changed, 16 insertions(+) diff --git a/Source/Core/DolphinQt2/Config/Graphics/GraphicsWindow.cpp b/Source/Core/DolphinQt2/Config/Graphics/GraphicsWindow.cpp index bccac209de..0aaa900588 100644 --- a/Source/Core/DolphinQt2/Config/Graphics/GraphicsWindow.cpp +++ b/Source/Core/DolphinQt2/Config/Graphics/GraphicsWindow.cpp @@ -27,6 +27,17 @@ GraphicsWindow::GraphicsWindow(X11Utils::XRRConfiguration* xrr_config, MainWindow* parent) : QDialog(parent), m_xrr_config(xrr_config) { + // GraphicsWindow initialization is heavy due to dependencies on the graphics subsystem. + // To prevent blocking startup, we create the layout and children at first show time. +} + +void GraphicsWindow::Initialize() +{ + if (m_lazy_initialized) + return; + + m_lazy_initialized = true; + g_Config.Refresh(); g_video_backend->InitBackendInfo(); diff --git a/Source/Core/DolphinQt2/Config/Graphics/GraphicsWindow.h b/Source/Core/DolphinQt2/Config/Graphics/GraphicsWindow.h index 1850180dcd..bebcaa43d2 100644 --- a/Source/Core/DolphinQt2/Config/Graphics/GraphicsWindow.h +++ b/Source/Core/DolphinQt2/Config/Graphics/GraphicsWindow.h @@ -29,6 +29,8 @@ class GraphicsWindow final : public QDialog public: explicit GraphicsWindow(X11Utils::XRRConfiguration* xrr_config, MainWindow* parent); + void Initialize(); + void RegisterWidget(GraphicsWidget* widget); bool eventFilter(QObject* object, QEvent* event) override; signals: @@ -39,6 +41,8 @@ private: void OnBackendChanged(const QString& backend); void OnDescriptionAdded(QWidget* widget, const char* description); + bool m_lazy_initialized = false; + QTabWidget* m_tab_widget; QLabel* m_description; QDialogButtonBox* m_button_box; diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index b81b60b83a..25326547db 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -935,6 +935,7 @@ void MainWindow::ShowHotkeyDialog() void MainWindow::ShowGraphicsWindow() { + m_graphics_window->Initialize(); m_graphics_window->show(); m_graphics_window->raise(); m_graphics_window->activateWindow();