aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-05-31 16:39:34 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-06-03 10:51:25 +0200
commitff6369767321afc49b37645bb6b85d3556921645 (patch)
treea6a45cd6c6450d5bee220f44412118c5646e229e /src
parente2c5ee11bcdc2f093004716f5e65e81cdce9ff85 (diff)
Expose the QRhiSwapchain via QSGRendererInterface
...similarly to how we already do it for the QRhi itself. Just follow the same pattern. This allows Qt Quick 3D to stop peeking directly into QQuickWindowPrivate and accessing member variables in there. Code like the following QQuickWindowPrivate *wd = QQuickWindowPrivate::get(window); QRhiCommandBuffer *cb = wd->swapchain->currentFrameCommandBuffer(); QRhiRenderPassDescriptor *rp = wd->rpDescForSwapchain; can now be written ca. like this, without pulling in quick-private: QRhiSwapChain *swapchain = window->rendererInterface->getResource(window, RhiSwapchain) QRhiCommandBuffer *cb = swapchain->currentFrameCommandBuffer(); QRhiRenderPassDescriptor *rp = swapchain->renderPassDescriptor(); This provides a more stable interface between the scenegraph and Quick 3D. In addition, this is also handy for manual tests, external test applications, etc. in case they do QRhi-based rendering in a QQuickWindow. Now these are also fine with just gui-private, no need to access QQuickWindowPrivate anymore. Change-Id: I921fb1c33c2fc77081272b1f180fdc2c87ed3ab5 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquickwindow_p.h1
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendererinterface.cpp4
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendererinterface.h1
-rw-r--r--src/quick/scenegraph/qsgdefaultcontext.cpp4
-rw-r--r--src/quick/scenegraph/qsgrhisupport.cpp5
-rw-r--r--src/quick/scenegraph/qsgrhisupport_p.h4
6 files changed, 15 insertions, 4 deletions
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h
index afc47ce848..a65b87f8b6 100644
--- a/src/quick/items/qquickwindow_p.h
+++ b/src/quick/items/qquickwindow_p.h
@@ -131,6 +131,7 @@ public:
};
static inline QQuickWindowPrivate *get(QQuickWindow *c) { return c->d_func(); }
+ static inline const QQuickWindowPrivate *get(const QQuickWindow *c) { return c->d_func(); }
QQuickWindowPrivate();
~QQuickWindowPrivate() override;
diff --git a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
index 9b5701df5a..febd155c40 100644
--- a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
@@ -112,6 +112,10 @@ QT_BEGIN_NAMESPACE
\value RhiResource The resource is a pointer to the QRhi instance used by
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.
+
\value PhysicalDeviceResource The resource is a pointer to the pysical
device object used by the scenegraph, when applicable. For example, a
\c{VkPhysicalDevice *}. Note that with Vulkan the returned value is a
diff --git a/src/quick/scenegraph/coreapi/qsgrendererinterface.h b/src/quick/scenegraph/coreapi/qsgrendererinterface.h
index 6224e08e84..0c009de77b 100644
--- a/src/quick/scenegraph/coreapi/qsgrendererinterface.h
+++ b/src/quick/scenegraph/coreapi/qsgrendererinterface.h
@@ -67,6 +67,7 @@ public:
CommandListResource,
PainterResource,
RhiResource,
+ RhiSwapchainResource,
PhysicalDeviceResource,
OpenGLContextResource,
DeviceContextResource,
diff --git a/src/quick/scenegraph/qsgdefaultcontext.cpp b/src/quick/scenegraph/qsgdefaultcontext.cpp
index fee1a8449e..8318d96eac 100644
--- a/src/quick/scenegraph/qsgdefaultcontext.cpp
+++ b/src/quick/scenegraph/qsgdefaultcontext.cpp
@@ -324,13 +324,13 @@ void *QSGDefaultContext::getResource(QQuickWindow *window, Resource resource) co
if (rhiSupport->graphicsApi() == OpenGL)
return rc->openglContext();
else
- return const_cast<void *>(rhiSupport->rifResource(resource, rc));
+ return const_cast<void *>(rhiSupport->rifResource(resource, rc, window));
#if QT_CONFIG(vulkan)
case VulkanInstanceResource:
return window->vulkanInstance();
#endif
default:
- return const_cast<void *>(rhiSupport->rifResource(resource, rc));
+ return const_cast<void *>(rhiSupport->rifResource(resource, rc, window));
}
}
diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp
index 510f98ed6b..07730a5d2b 100644
--- a/src/quick/scenegraph/qsgrhisupport.cpp
+++ b/src/quick/scenegraph/qsgrhisupport.cpp
@@ -436,7 +436,8 @@ static const void *qsgrhi_mtl_rifResource(QSGRendererInterface::Resource res, co
#endif
const void *QSGRhiSupport::rifResource(QSGRendererInterface::Resource res,
- const QSGDefaultRenderContext *rc)
+ const QSGDefaultRenderContext *rc,
+ const QQuickWindow *w)
{
// ### This condition is a temporary workaround to allow compilation
// with -no-opengl, but Vulkan or Metal enabled, to succeed. Full
@@ -447,6 +448,8 @@ const void *QSGRhiSupport::rifResource(QSGRendererInterface::Resource res,
QRhi *rhi = rc->rhi();
if (res == QSGRendererInterface::RhiResource || !rhi)
return rhi;
+ if (res == QSGRendererInterface::RhiSwapchainResource)
+ return QQuickWindowPrivate::get(w)->swapchain;
const QRhiNativeHandles *nat = rhi->nativeHandles();
if (!nat)
diff --git a/src/quick/scenegraph/qsgrhisupport_p.h b/src/quick/scenegraph/qsgrhisupport_p.h
index 9e9b6f88bc..587ecb2df3 100644
--- a/src/quick/scenegraph/qsgrhisupport_p.h
+++ b/src/quick/scenegraph/qsgrhisupport_p.h
@@ -119,7 +119,9 @@ public:
QSurface::SurfaceType windowSurfaceType() const;
- const void *rifResource(QSGRendererInterface::Resource res, const QSGDefaultRenderContext *rc);
+ const void *rifResource(QSGRendererInterface::Resource res,
+ const QSGDefaultRenderContext *rc,
+ const QQuickWindow *w);
int chooseSampleCountForWindowWithRhi(QWindow *window, QRhi *rhi);