aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick/items/qquickwindow.cpp14
-rw-r--r--src/quick/scenegraph/qsgrhisupport.cpp9
2 files changed, 13 insertions, 10 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 5c7c39edf6..ddb39c3864 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -808,16 +808,10 @@ void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control)
q->setSurfaceType(windowManager ? windowManager->windowSurfaceType() : QSurface::OpenGLSurface);
q->setFormat(sg->defaultSurfaceFormat());
-#if QT_CONFIG(vulkan)
- // Normal QQuickWindows must get a QVulkanInstance automatically (it is
- // created when the first window is constructed and is destroyed only on
- // exit). With QQuickRenderControl however, no QVulkanInstance is created,
- // because it must 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 not acceptable in advanced use cases).
- if (!renderControl && q->surfaceType() == QSurface::VulkanSurface)
- q->setVulkanInstance(QSGRhiSupport::defaultVulkanInstance());
-#endif
+ // When using Vulkan, associating a scenegraph-managed QVulkanInstance with
+ // the window (but only when not using renderControl) is deferred to
+ // QSGRhiSupport::createRhi(). This allows applications to set up their own
+ // QVulkanInstance and set that on the window, if they wish to.
animationController.reset(new QQuickAnimatorController(q));
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.");