From 9045b94d1ad7e945475d52bba152fdbdb36debbf Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 22 Jun 2020 16:25:16 +0200 Subject: Defer setting a QVulkanInstance on the window ...to createRhi(). There is no need for the VkInstance before that point. Change-Id: I87f4e8154e96409bccd7844f1bf80b957bb54d69 Reviewed-by: Andy Nichols --- src/quick/scenegraph/qsgrhisupport.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/quick/scenegraph/qsgrhisupport.cpp') diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index 5029103cff..e8855ab071 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -583,6 +583,15 @@ QRhi *QSGRhiSupport::createRhi(QQuickWindow *window, QOffscreenSurface *offscree #if QT_CONFIG(vulkan) if (backend == QRhi::Vulkan) { QRhiVulkanInitParams rhiParams; + // QQuickWindows must get a QVulkanInstance automatically (it is + // created when the first window is constructed and is destroyed only + // on exit), unless the application decided to set its own. With + // QQuickRenderControl, no QVulkanInstance is created, because it must + // always be under the application's control then (since the default + // instance we could create here would not be configurable by the + // application in any way, and that is often not acceptable). + if (!window->vulkanInstance() && !wd->renderControl) + window->setVulkanInstance(QSGRhiSupport::defaultVulkanInstance()); rhiParams.inst = window->vulkanInstance(); if (!rhiParams.inst) qWarning("No QVulkanInstance set for QQuickWindow, this is wrong."); -- cgit v1.2.3