From b4447c39a95bc03d7874a323e179d0f8cda83255 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 19 Jun 2020 14:45:41 +0200 Subject: Fix up exposing the swapchain to Quick3D Quick3D is broken in combination with QQuickRenderControl. This is because just exposing the swapchain is not enough - there is no swapchain with QQuickRenderControl. Rather, one needs access to the command buffer and render target then. Change-Id: I6c06ad3d83ab0018b9f985073757a3378dbce24b Reviewed-by: Andy Nichols --- src/quick/scenegraph/qsgrhisupport.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/quick/scenegraph/qsgrhisupport.cpp') diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index 007739d2d7..618e1f1411 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -441,10 +441,23 @@ const void *QSGRhiSupport::rifResource(QSGRendererInterface::Resource res, const QQuickWindow *w) { QRhi *rhi = rc->rhi(); - if (res == QSGRendererInterface::RhiResource || !rhi) + if (!rhi) + return nullptr; + + // Accessing the underlying QRhi* objects are essential both for Qt Quick + // 3D and advanced solutions, such as VR engine integrations. + switch (res) { + case QSGRendererInterface::RhiResource: return rhi; - if (res == QSGRendererInterface::RhiSwapchainResource) + case QSGRendererInterface::RhiSwapchainResource: return QQuickWindowPrivate::get(w)->swapchain; + case QSGRendererInterface::RhiRedirectCommandBuffer: + return QQuickWindowPrivate::get(w)->redirect.commandBuffer; + case QSGRendererInterface::RhiRedirectRenderTarget: + return QQuickWindowPrivate::get(w)->redirect.rt.renderTarget; + default: + break; + } const QRhiNativeHandles *nat = rhi->nativeHandles(); if (!nat) -- cgit v1.2.3