diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-06-19 14:45:41 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-06-19 18:30:03 +0200 |
commit | b4447c39a95bc03d7874a323e179d0f8cda83255 (patch) | |
tree | ac47563b96d35a06561762531b1bbd52e760aab6 /src/quick/scenegraph | |
parent | aef24b3a945fe15828e3bc304c5b0333125f05fb (diff) |
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 <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/scenegraph')
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgrendererinterface.cpp | 15 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgrendererinterface.h | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgrhisupport.cpp | 17 |
3 files changed, 30 insertions, 4 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp index 6970aa0afb..efbab4086c 100644 --- a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp +++ b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp @@ -113,8 +113,19 @@ QT_BEGIN_NAMESPACE the scenegraph, when applicable. This value was introduced in Qt 5.14. \value RhiSwapchainResource The resource is a pointer to a QRhiSwapchain - instance that is associated with the window. This value was introduced in - Qt 6.0. + instance that is associated with the window. The value is null when the + window is used in combination with QQuickRenderControl. This value was + introduced in Qt 6.0. + + \value RhiRedirectCommandBuffer The resource is a pointer to a + QRhiCommandBuffer instance that is associated with the window and its + QQuickRenderControl. The value is null when the window is not associated + with a QQuickRenderControl. This value was introduced in Qt 6.0. + + \value RhiRedirectRenderTarget The resource is a pointer to a + QRhiTextureRenderTarget instance that is associated with the window and its + QQuickRenderControl. The value is null when the window is not associated + with a QQuickRenderControl. This value was introduced in Qt 6.0. \value PhysicalDeviceResource The resource is a pointer to the pysical device object used by the scenegraph, when applicable. For example, a diff --git a/src/quick/scenegraph/coreapi/qsgrendererinterface.h b/src/quick/scenegraph/coreapi/qsgrendererinterface.h index 9d7b9a5738..c001ecc2db 100644 --- a/src/quick/scenegraph/coreapi/qsgrendererinterface.h +++ b/src/quick/scenegraph/coreapi/qsgrendererinterface.h @@ -68,6 +68,8 @@ public: PainterResource, RhiResource, RhiSwapchainResource, + RhiRedirectCommandBuffer, + RhiRedirectRenderTarget, PhysicalDeviceResource, OpenGLContextResource, DeviceContextResource, 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) |