aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/quick/scenegraph/customrendernode/CMakeLists.txt2
-rw-r--r--examples/quick/scenegraph/customrendernode/customrender.cpp22
-rw-r--r--examples/quick/scenegraph/customrendernode/doc/src/customrendernode.qdoc26
-rw-r--r--src/particles/qquickimageparticle.cpp2
-rw-r--r--src/quick/items/qquickframebufferobject.cpp2
-rw-r--r--src/quick/items/qquickgraphicsconfiguration.cpp5
-rw-r--r--src/quick/items/qquickgraphicsdevice.cpp4
-rw-r--r--src/quick/items/qquickpainteditem.cpp2
-rw-r--r--src/quick/items/qquickrendercontrol.cpp35
-rw-r--r--src/quick/items/qquickrendercontrol.h5
-rw-r--r--src/quick/items/qquickrendertarget.cpp21
-rw-r--r--src/quick/items/qquickwindow.cpp44
-rw-r--r--src/quick/items/qquickwindow.h5
-rw-r--r--src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp2
-rw-r--r--src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h2
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterialshader_p.h4
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendernode.cpp53
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendernode.h4
-rw-r--r--src/quick/scenegraph/coreapi/qsgtexture.cpp2
-rw-r--r--src/quick/scenegraph/coreapi/qsgtexture_mac.mm2
-rw-r--r--src/quick/scenegraph/qsgadaptationlayer_p.h2
-rw-r--r--src/quick/scenegraph/qsgdefaultcontext.cpp5
-rw-r--r--src/quick/scenegraph/qsgdefaultinternalimagenode.cpp2
-rw-r--r--src/quick/scenegraph/qsgdefaultrendercontext_p.h2
-rw-r--r--src/quick/scenegraph/qsgrhidistancefieldglyphcache_p.h2
-rw-r--r--src/quick/scenegraph/qsgrhilayer_p.h2
-rw-r--r--src/quick/scenegraph/qsgrhishadereffectnode.cpp2
-rw-r--r--src/quick/scenegraph/qsgrhisupport_p.h21
-rw-r--r--src/quick/scenegraph/qsgrhitextureglyphcache_p.h2
-rw-r--r--src/quick/scenegraph/util/qsgplaintexture.cpp2
-rw-r--r--src/quick/scenegraph/util/qsgrhiatlastexture_p.h2
-rw-r--r--src/quick/scenegraph/util/qsgtexturematerial.cpp2
-rw-r--r--src/quickshapes/qquickshape.cpp2
-rw-r--r--src/quickshapes/qquickshapegenericrenderer.cpp2
-rw-r--r--src/quickwidgets/qquickwidget_p.h2
-rw-r--r--tests/auto/quick/nodes/tst_nodestest.cpp7
-rw-r--r--tests/auto/quick/qquickitemrhiintegration/rhiitem.cpp3
-rw-r--r--tests/auto/quick/qquickitemrhiintegration/rhiitem.h2
-rw-r--r--tests/auto/quick/qquickitemrhiintegration/tst_qquickitemrhiintegration.cpp2
-rw-r--r--tests/auto/quick/qquickrendercontrol/tst_qquickrendercontrol.cpp13
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp3
-rw-r--r--tests/auto/quick/rendernode/tst_rendernode.cpp2
43 files changed, 224 insertions, 106 deletions
diff --git a/examples/quick/scenegraph/customrendernode/CMakeLists.txt b/examples/quick/scenegraph/customrendernode/CMakeLists.txt
index ada750d56a..58e22ad1b8 100644
--- a/examples/quick/scenegraph/customrendernode/CMakeLists.txt
+++ b/examples/quick/scenegraph/customrendernode/CMakeLists.txt
@@ -23,7 +23,7 @@ target_link_libraries(customrendernode PRIVATE
Qt6::Core
Qt6::GuiPrivate
Qt6::Qml
- Qt6::QuickPrivate
+ Qt6::Quick
)
qt_add_qml_module(customrendernode
diff --git a/examples/quick/scenegraph/customrendernode/customrender.cpp b/examples/quick/scenegraph/customrendernode/customrender.cpp
index e95341438e..86ec664d9d 100644
--- a/examples/quick/scenegraph/customrendernode/customrender.cpp
+++ b/examples/quick/scenegraph/customrendernode/customrender.cpp
@@ -5,11 +5,10 @@
#include <QSGTextureProvider>
#include <QSGRenderNode>
#include <QSGTransformNode>
-#include <QSGRendererInterface>
#include <QQuickWindow>
#include <QFile>
-#include <private/qrhi_p.h>
-#include <private/qsgrendernode_p.h>
+
+#include <rhi/qrhi.h>
class CustomRenderNode : public QSGRenderNode
{
@@ -114,11 +113,8 @@ QSGRenderNode::StateFlags CustomRenderNode::changedStates() const
void CustomRenderNode::prepare()
{
- QSGRendererInterface *renderInterface = m_window->rendererInterface();
- QRhiSwapChain *swapChain = static_cast<QRhiSwapChain *>(
- renderInterface->getResource(m_window, QSGRendererInterface::RhiSwapchainResource));
- QRhi *rhi = static_cast<QRhi *>(
- renderInterface->getResource(m_window, QSGRendererInterface::RhiResource));
+ QRhiSwapChain *swapChain = m_window->swapChain();
+ QRhi *rhi = m_window->rhi();
Q_ASSERT(swapChain);
Q_ASSERT(rhi);
@@ -163,7 +159,7 @@ void CustomRenderNode::prepare()
// RHI backends with isYUpInFrameBuffer == false. We swap the triangle winding
// order to work around this.
//
- m_pipeLine->setFrontFace(QSGRenderNodePrivate::get(this)->m_rt.rt->resourceType() == QRhiResource::TextureRenderTarget
+ m_pipeLine->setFrontFace(renderTarget()->resourceType() == QRhiResource::TextureRenderTarget
&& rhi->isYUpInFramebuffer()
? QRhiGraphicsPipeline::CW
: QRhiGraphicsPipeline::CCW);
@@ -179,7 +175,7 @@ void CustomRenderNode::prepare()
inputLayout.setBindings({ { 2 * sizeof(float) } });
inputLayout.setAttributes({ { 0, 0, QRhiVertexInputAttribute::Float2, 0 } });
m_pipeLine->setVertexInputLayout(inputLayout);
- m_pipeLine->setRenderPassDescriptor(QSGRenderNodePrivate::get(this)->m_rt.rpDesc);
+ m_pipeLine->setRenderPassDescriptor(renderTarget()->renderPassDescriptor());
m_pipeLine->create();
}
@@ -195,16 +191,14 @@ void CustomRenderNode::prepare()
void CustomRenderNode::render(const RenderState *state)
{
- QSGRendererInterface *renderInterface = m_window->rendererInterface();
- QRhiSwapChain *swapChain = static_cast<QRhiSwapChain *>(
- renderInterface->getResource(m_window, QSGRendererInterface::RhiSwapchainResource));
+ QRhiSwapChain *swapChain = m_window->swapChain();
Q_ASSERT(swapChain);
QRhiCommandBuffer *cb = swapChain->currentFrameCommandBuffer();
Q_ASSERT(cb);
cb->setGraphicsPipeline(m_pipeLine);
- QSize renderTargetSize = QSGRenderNodePrivate::get(this)->m_rt.rt->pixelSize();
+ QSize renderTargetSize = renderTarget()->pixelSize();
cb->setViewport(QRhiViewport(0, 0, renderTargetSize.width(), renderTargetSize.height()));
cb->setShaderResources();
QRhiCommandBuffer::VertexInput vertexBindings[] = { { m_vertexBuffer, 0 } };
diff --git a/examples/quick/scenegraph/customrendernode/doc/src/customrendernode.qdoc b/examples/quick/scenegraph/customrendernode/doc/src/customrendernode.qdoc
index 1972d99c4d..4240e30558 100644
--- a/examples/quick/scenegraph/customrendernode/doc/src/customrendernode.qdoc
+++ b/examples/quick/scenegraph/customrendernode/doc/src/customrendernode.qdoc
@@ -12,15 +12,21 @@
\image customrendernode-example.gif
- QSGRenderNode allows direct access to the Render Hardware Interface (RHI) within the
- scenegraph. This example demonstrates how to create QSGRenderNode based render node
- and manage it with a custom item. The render node creates an RHI pipeline, updates
- vertex and uniform buffers, and renders into the RHI command buffer.
+ QSGRenderNode allows direct access to the Render Hardware Interface (RHI)
+ within the scenegraph. This example demonstrates how to create QSGRenderNode
+ based render node and manage it with a custom item. The render node creates
+ an RHI pipeline, updates vertex and uniform buffers, and renders into the
+ RHI command buffer.
- \warning This example demonstrates advanced, low-level functionality
- performing portable, cross-platform 3D rendering, while relying on private
- APIs from the Qt Gui and Qt Quick modules. Developers are encouraged to
- carefully evaluate the potential lack of source and binary compatibility
- guarantees before using these APIs in their applications.
+ In practice this is a portable, cross-platform approach to perform custom
+ rendering inline with the scenegraph's own rendering, without resorting to a
+ native 3D API such as OpenGL, Metal, or Vulkan. Rather, the application uses
+ Qt's graphics and shader abstraction layer.
- */
+ \note This example demonstrates advanced, low-level functionality performing
+ portable, cross-platform 3D rendering, while relying on APIs with limited
+ compatibility guarantee from the Qt Gui module. To be able to use the QRhi
+ APIs, the application links to \c{Qt::GuiPrivate} and includes
+ \c{<rhi/qrhi.h>}.
+
+*/
diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp
index 6dd504210e..727bd371cf 100644
--- a/src/particles/qquickimageparticle.cpp
+++ b/src/particles/qquickimageparticle.cpp
@@ -17,7 +17,7 @@
#include <private/qqmlglobal_p.h>
#include <QtQml/qqmlinfo.h>
#include <QtCore/QtMath>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <cmath>
diff --git a/src/quick/items/qquickframebufferobject.cpp b/src/quick/items/qquickframebufferobject.cpp
index 0633d01ce4..832ce55187 100644
--- a/src/quick/items/qquickframebufferobject.cpp
+++ b/src/quick/items/qquickframebufferobject.cpp
@@ -8,7 +8,7 @@
#include <private/qquickitem_p.h>
#include <private/qsgadaptationlayer_p.h>
#include <qsgtextureprovider.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <QSGSimpleTextureNode>
#include <QSGRendererInterface>
diff --git a/src/quick/items/qquickgraphicsconfiguration.cpp b/src/quick/items/qquickgraphicsconfiguration.cpp
index 750a2b427a..a7eaf3c0f8 100644
--- a/src/quick/items/qquickgraphicsconfiguration.cpp
+++ b/src/quick/items/qquickgraphicsconfiguration.cpp
@@ -3,10 +3,7 @@
#include "qquickgraphicsconfiguration_p.h"
#include <QCoreApplication>
-
-#if QT_CONFIG(vulkan)
-#include <QtGui/private/qrhivulkan_p.h>
-#endif
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/items/qquickgraphicsdevice.cpp b/src/quick/items/qquickgraphicsdevice.cpp
index a10052bae5..f973a13e96 100644
--- a/src/quick/items/qquickgraphicsdevice.cpp
+++ b/src/quick/items/qquickgraphicsdevice.cpp
@@ -212,12 +212,14 @@ QQuickGraphicsDevice QQuickGraphicsDevice::fromDeviceObjects(VkPhysicalDevice ph
#endif
/*!
- \internal
+ \return a new QQuickGraphicsDevice referencing an existing \a rhi object.
\note Similarly to fromOpenGLContext(), the caller must be careful to only
share a QRhi (and so the underlying graphics context or device) between
QQuickWindows that are known to be compatible, not breaking the underlying
graphics API's rules when it comes to threading, pixel formats, etc.
+
+ \since 6.6
*/
QQuickGraphicsDevice QQuickGraphicsDevice::fromRhi(QRhi *rhi)
{
diff --git a/src/quick/items/qquickpainteditem.cpp b/src/quick/items/qquickpainteditem.cpp
index 80b092e3fe..c0b591b2bb 100644
--- a/src/quick/items/qquickpainteditem.cpp
+++ b/src/quick/items/qquickpainteditem.cpp
@@ -8,7 +8,7 @@
#include <QtQuick/private/qsgcontext_p.h>
#include <private/qsgadaptationlayer_p.h>
#include <qsgtextureprovider.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <qmath.h>
diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp
index 5956babaf0..49438c92db 100644
--- a/src/quick/items/qquickrendercontrol.cpp
+++ b/src/quick/items/qquickrendercontrol.cpp
@@ -26,7 +26,7 @@
#include <QtCore/private/qobject_p.h>
#include <QtQuick/private/qquickwindow_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
@@ -565,6 +565,39 @@ QQuickWindow *QQuickRenderControl::window() const
}
/*!
+ \return the QRhi this QQuickRenderControl is associated with.
+
+ \note The QRhi exists only when initialize() has successfully completed.
+ Before that the return value is null.
+
+ \since 6.6
+ */
+QRhi *QQuickRenderControl::rhi() const
+{
+ Q_D(const QQuickRenderControl);
+ return d->rhi;
+}
+
+/*!
+ \return the current command buffer.
+
+ Once beginFrame() is called, a QRhiCommandBuffer is set up automatically.
+ That is the command buffer Qt Quick scenegraph uses, but in some cases
+ applications may also want to query it, for example to issue resource
+ updates (for example, a texture readback).
+
+ The command buffer is only valid for use between beginFrame() and
+ endFrame().
+
+ \since 6.6
+ */
+QRhiCommandBuffer *QQuickRenderControl::commandBuffer() const
+{
+ Q_D(const QQuickRenderControl);
+ return d->cb;
+}
+
+/*!
Specifies the start of a graphics frame. Calls to sync() or render() must
be enclosed by calls to beginFrame() and endFrame().
diff --git a/src/quick/items/qquickrendercontrol.h b/src/quick/items/qquickrendercontrol.h
index 195b518dcc..1d8da84e57 100644
--- a/src/quick/items/qquickrendercontrol.h
+++ b/src/quick/items/qquickrendercontrol.h
@@ -14,6 +14,8 @@ class QQuickWindow;
class QOpenGLContext;
class QQuickRenderControlPrivate;
class QThread;
+class QRhi;
+class QRhiCommandBuffer;
class Q_QUICK_EXPORT QQuickRenderControl : public QObject
{
@@ -44,6 +46,9 @@ public:
QQuickWindow *window() const;
+ QRhi *rhi() const;
+ QRhiCommandBuffer *commandBuffer() const;
+
protected:
explicit QQuickRenderControl(QQuickRenderControlPrivate &dd, QObject *parent = nullptr);
diff --git a/src/quick/items/qquickrendertarget.cpp b/src/quick/items/qquickrendertarget.cpp
index 6c1d89b64a..16acf2dcb8 100644
--- a/src/quick/items/qquickrendertarget.cpp
+++ b/src/quick/items/qquickrendertarget.cpp
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qquickrendertarget_p.h"
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <QtQuick/private/qquickitem_p.h>
#include <QtQuick/private/qquickwindow_p.h>
#include <QtQuick/private/qsgrhisupport_p.h>
@@ -592,7 +592,7 @@ QQuickRenderTarget QQuickRenderTarget::fromVulkanImage(VkImage image, VkImageLay
/*!
\overload
- \return a new QQuickRenderTarget referencing n Vulkan image object specified
+ \return a new QQuickRenderTarget referencing a Vulkan image object specified
by \a image. The image is assumed to have a format of
VK_FORMAT_R8G8B8A8_UNORM.
@@ -621,8 +621,21 @@ QQuickRenderTarget QQuickRenderTarget::fromVulkanImage(VkImage image, VkImageLay
#endif
/*!
- \internal
- */
+ \return a new QQuickRenderTarget referencing an existing \a renderTarget.
+
+ \a renderTarget will in most cases be a QRhiTextureRenderTarget, which
+ allows directing the Qt Quick scene's rendering into a QRhiTexture.
+
+ \note the resulting QQuickRenderTarget does not own \a renderTarget and any
+ underlying native resources, it merely contains references and the
+ associated metadata of the size and sample count. It is the caller's
+ responsibility to ensure that the referenced resources exists as long as
+ necessary.
+
+ \since 6.6
+
+ \sa QQuickWindow::setRenderTarget(), QQuickRenderControl
+*/
QQuickRenderTarget QQuickRenderTarget::fromRhiRenderTarget(QRhiRenderTarget *renderTarget)
{
QQuickRenderTarget rt;
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index f4697864a1..0f82ba08a7 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -49,7 +49,7 @@
#include <private/qdebug_p.h>
#endif
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
@@ -3828,6 +3828,48 @@ QSGRendererInterface *QQuickWindow::rendererInterface() const
}
/*!
+ \return the QRhi object used by this window for rendering.
+
+ Available only when the window is using Qt's 3D API and shading language
+ abstractions, meaning the result is always null when using the \c software
+ adaptation.
+
+ The result is valid only when rendering has been initialized, which is
+ indicated by the emission of the sceneGraphInitialized() signal. Before
+ that point, the returned value is null. With a regular, on-screen
+ QQuickWindow scenegraph initialization typically happens when the native
+ window gets exposed (shown) the first time. When using QQuickRenderControl,
+ initialization is done in the explicit
+ \l{QQuickRenderControl::initialize()}{initialize()} call.
+
+ In practice this function is a shortcut to querying the QRhi via the
+ QSGRendererInterface.
+
+ \since 6.6
+ */
+QRhi *QQuickWindow::rhi() const
+{
+ Q_D(const QQuickWindow);
+ return d->rhi;
+}
+
+/*!
+ \return the QRhiSwapChain used by this window, if there is one.
+
+ \note Only on-screen windows backed by one of the standard render loops
+ (such as, \c basic or \c threaded) will have a swapchain. Otherwise the
+ returned value is null. For example, the result is always null when the
+ window is used with QQuickRenderControl.
+
+ \since 6.6
+ */
+QRhiSwapChain *QQuickWindow::swapChain() const
+{
+ Q_D(const QQuickWindow);
+ return d->swapchain;
+}
+
+/*!
Requests the specified graphics \a api.
When the built-in, default graphics adaptation is used, \a api specifies
diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h
index 3f3c82a4b8..acd5344446 100644
--- a/src/quick/items/qquickwindow.h
+++ b/src/quick/items/qquickwindow.h
@@ -33,6 +33,8 @@ class QQuickPalette;
class QQuickRenderTarget;
class QQuickGraphicsDevice;
class QQuickGraphicsConfiguration;
+class QRhi;
+class QRhiSwapChain;
class Q_QUICK_EXPORT QQuickWindow : public QWindow
{
@@ -155,6 +157,9 @@ public:
static TextRenderType textRenderType();
static void setTextRenderType(TextRenderType renderType);
+ QRhi *rhi() const;
+ QRhiSwapChain *swapChain() const;
+
Q_SIGNALS:
void frameSwapped();
void sceneGraphInitialized();
diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp
index 0e33312a9e..629c6427b8 100644
--- a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp
+++ b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture.cpp
@@ -6,7 +6,7 @@
#include <QDebug>
#include <QtQuick/private/qquickwindow_p.h>
#include <QtQuick/private/qquickitem_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h
index a9ff902e6e..ea1056419e 100644
--- a/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h
+++ b/src/quick/scenegraph/compressedtexture/qsgcompressedtexture_p.h
@@ -18,7 +18,7 @@
#include <private/qtexturefiledata_p.h>
#include <private/qsgcontext_p.h>
#include <private/qsgtexture_p.h>
-#include <private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <QQuickTextureFactory>
#include <QOpenGLFunctions>
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
index 9a024804a7..91a64eaa42 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
@@ -27,7 +27,7 @@
#include <QtCore/QBitArray>
#include <QtCore/QStack>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h b/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h
index de0161e431..1eebb9a6ed 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h
+++ b/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h
@@ -18,8 +18,8 @@
#include <private/qtquickglobal_p.h>
#include "qsgmaterialshader.h"
#include "qsgmaterial.h"
-#include <QtGui/private/qrhi_p.h>
-#include <QtGui/private/qshader_p.h>
+#include <rhi/qrhi.h>
+#include <rhi/qshader.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/coreapi/qsgrendernode.cpp b/src/quick/scenegraph/coreapi/qsgrendernode.cpp
index eee8316d05..c176b470cc 100644
--- a/src/quick/scenegraph/coreapi/qsgrendernode.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrendernode.cpp
@@ -366,6 +366,59 @@ qreal QSGRenderNode::inheritedOpacity() const
return d->m_opacity;
}
+/*!
+ \return the current render target.
+
+ This is provided mainly to enable prepare() and render() implementations
+ that use QRhi accessing the QRhiRenderTarget's
+ \l{QRhiRenderPassDescriptor}{renderPassDescriptor} or
+ \l{QRhiRenderTarget::pixelSize()}{pixel size}.
+
+ To build a QRhiGraphicsPipeline, which implies having to provide a
+ QRhiRenderPassDescriptor, query the renderPassDescriptor from the render
+ target. Be aware however that the render target may change over the
+ lifetime of the custom QQuickItem and the QSGRenderNode. For example,
+ consider what happens when dynamically setting \c{layer.enabled: true} on
+ the item or an ancestor of it: this triggers rendering into a texture, not
+ directly to the window, which means the QSGRenderNode is going to work with
+ a different render target from then on. The new render target may then have
+ a different pixel format, which can make already built graphics pipelines
+ incompatible. This can be handled with logic such as the following:
+
+ \code
+ if (m_pipeline && renderTarget()->renderPassDescriptor()->serializedFormat() != m_renderPassFormat) {
+ delete m_pipeline;
+ m_pipeline = nullptr;
+ }
+ if (!m_pipeline) {
+ // Build a new QRhiGraphicsPipeline.
+ // ...
+ // Store the serialized format for fast and simple comparisons later on.
+ m_renderPassFormat = renderTarget()->renderPassDescriptor()->serializedFormat();
+ }
+ \endcode
+
+ \since 6.6
+
+ \sa commandBuffer()
+ */
+QRhiRenderTarget *QSGRenderNode::renderTarget() const
+{
+ return d->m_rt.rt;
+}
+
+/*!
+ \return the current command buffer.
+
+ \since 6.6
+
+ \sa renderTarget()
+ */
+QRhiCommandBuffer *QSGRenderNode::commandBuffer() const
+{
+ return d->m_rt.cb;
+}
+
QSGRenderNode::RenderState::~RenderState()
{
}
diff --git a/src/quick/scenegraph/coreapi/qsgrendernode.h b/src/quick/scenegraph/coreapi/qsgrendernode.h
index fcf2b0e559..bc40c75e57 100644
--- a/src/quick/scenegraph/coreapi/qsgrendernode.h
+++ b/src/quick/scenegraph/coreapi/qsgrendernode.h
@@ -9,6 +9,8 @@
QT_BEGIN_NAMESPACE
class QSGRenderNodePrivate;
+class QRhiRenderTarget;
+class QRhiCommandBuffer;
class Q_QUICK_EXPORT QSGRenderNode : public QSGNode
{
@@ -58,6 +60,8 @@ public:
const QMatrix4x4 *matrix() const;
const QSGClipNode *clipList() const;
qreal inheritedOpacity() const;
+ QRhiRenderTarget *renderTarget() const;
+ QRhiCommandBuffer *commandBuffer() const;
private:
QSGRenderNodePrivate *d;
diff --git a/src/quick/scenegraph/coreapi/qsgtexture.cpp b/src/quick/scenegraph/coreapi/qsgtexture.cpp
index 29c0f74033..1492d045e7 100644
--- a/src/quick/scenegraph/coreapi/qsgtexture.cpp
+++ b/src/quick/scenegraph/coreapi/qsgtexture.cpp
@@ -9,7 +9,7 @@
#include <private/qquickitem_p.h> // qquickwindow_p.h cannot be included on its own due to template nonsense
#include <private/qquickwindow_p.h>
#include <QtCore/private/qnativeinterface_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) && defined(__GLIBC__)
#define CAN_BACKTRACE_EXECINFO
diff --git a/src/quick/scenegraph/coreapi/qsgtexture_mac.mm b/src/quick/scenegraph/coreapi/qsgtexture_mac.mm
index fb3c9fcf04..c68a1b732f 100644
--- a/src/quick/scenegraph/coreapi/qsgtexture_mac.mm
+++ b/src/quick/scenegraph/coreapi/qsgtexture_mac.mm
@@ -6,7 +6,7 @@
#include <private/qquickitem_p.h>
#include <private/qquickwindow_p.h>
#include <QtCore/private/qnativeinterface_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h
index 0e3d32528e..57f104de41 100644
--- a/src/quick/scenegraph/qsgadaptationlayer_p.h
+++ b/src/quick/scenegraph/qsgadaptationlayer_p.h
@@ -31,7 +31,7 @@
#include <QtGui/private/qdatabuffer_p.h>
#include <private/qdistancefield_p.h>
#include <private/qintrusivelist_p.h>
-#include <QtGui/private/qshader_p.h>
+#include <rhi/qshader.h>
// ### remove
#include <QtQuick/private/qquicktext_p.h>
diff --git a/src/quick/scenegraph/qsgdefaultcontext.cpp b/src/quick/scenegraph/qsgdefaultcontext.cpp
index f3f85445e5..b66a7bd3ca 100644
--- a/src/quick/scenegraph/qsgdefaultcontext.cpp
+++ b/src/quick/scenegraph/qsgdefaultcontext.cpp
@@ -29,10 +29,7 @@
#include <algorithm>
-#include <QtGui/private/qrhi_p.h>
-#if QT_CONFIG(opengl)
-# include <QtGui/private/qrhigles2_p.h>
-#endif
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp b/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp
index 9179382f89..258db309b6 100644
--- a/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp
@@ -7,7 +7,7 @@
#include <private/qsgtexturematerial_p.h>
#include <qopenglfunctions.h>
#include <QtCore/qmath.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/qsgdefaultrendercontext_p.h b/src/quick/scenegraph/qsgdefaultrendercontext_p.h
index 580a973e85..06c6adfc64 100644
--- a/src/quick/scenegraph/qsgdefaultrendercontext_p.h
+++ b/src/quick/scenegraph/qsgdefaultrendercontext_p.h
@@ -16,7 +16,7 @@
//
#include <QtQuick/private/qsgcontext_p.h>
-#include <QtGui/private/qshader_p.h>
+#include <rhi/qshader.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/qsgrhidistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgrhidistancefieldglyphcache_p.h
index b7653881f5..dc593e323b 100644
--- a/src/quick/scenegraph/qsgrhidistancefieldglyphcache_p.h
+++ b/src/quick/scenegraph/qsgrhidistancefieldglyphcache_p.h
@@ -17,7 +17,7 @@
#include "qsgadaptationlayer_p.h"
#include <private/qsgareaallocator_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/qsgrhilayer_p.h b/src/quick/scenegraph/qsgrhilayer_p.h
index 502672b725..38e1dd4d5c 100644
--- a/src/quick/scenegraph/qsgrhilayer_p.h
+++ b/src/quick/scenegraph/qsgrhilayer_p.h
@@ -17,7 +17,7 @@
#include <private/qsgadaptationlayer_p.h>
#include <private/qsgcontext_p.h>
#include <private/qsgtexture_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/qsgrhishadereffectnode.cpp b/src/quick/scenegraph/qsgrhishadereffectnode.cpp
index 9f634067d5..8e57236671 100644
--- a/src/quick/scenegraph/qsgrhishadereffectnode.cpp
+++ b/src/quick/scenegraph/qsgrhishadereffectnode.cpp
@@ -7,7 +7,7 @@
#include <qsgmaterialshader.h>
#include <qsgtextureprovider.h>
#include <private/qsgplaintexture_p.h>
-#include <QtGui/private/qshaderdescription_p.h>
+#include <rhi/qshaderdescription.h>
#include <QQmlFile>
#include <QFile>
#include <QFileSelector>
diff --git a/src/quick/scenegraph/qsgrhisupport_p.h b/src/quick/scenegraph/qsgrhisupport_p.h
index cc79e8fd1a..a3a36420d6 100644
--- a/src/quick/scenegraph/qsgrhisupport_p.h
+++ b/src/quick/scenegraph/qsgrhisupport_p.h
@@ -18,26 +18,7 @@
#include "qsgrenderloop_p.h"
#include "qsgrendererinterface.h"
-#include <QtGui/private/qrhi_p.h>
-
-#include <QtGui/private/qrhinull_p.h>
-
-#if QT_CONFIG(opengl)
-#include <QtGui/private/qrhigles2_p.h>
-#endif
-
-#if QT_CONFIG(vulkan)
-#include <QtGui/private/qrhivulkan_p.h>
-#endif
-
-#ifdef Q_OS_WIN
-#include <QtGui/private/qrhid3d11_p.h>
-#include <QtGui/private/qrhid3d12_p.h>
-#endif
-
-#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
-#include <QtGui/private/qrhimetal_p.h>
-#endif
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/qsgrhitextureglyphcache_p.h b/src/quick/scenegraph/qsgrhitextureglyphcache_p.h
index 3c6b99bc9f..fbe020c3a2 100644
--- a/src/quick/scenegraph/qsgrhitextureglyphcache_p.h
+++ b/src/quick/scenegraph/qsgrhitextureglyphcache_p.h
@@ -16,7 +16,7 @@
//
#include <QtGui/private/qtextureglyphcache_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgplaintexture.cpp b/src/quick/scenegraph/util/qsgplaintexture.cpp
index e87300efec..e3ea9ffc17 100644
--- a/src/quick/scenegraph/util/qsgplaintexture.cpp
+++ b/src/quick/scenegraph/util/qsgplaintexture.cpp
@@ -8,7 +8,7 @@
#include <private/qqmlglobal_p.h>
#include <QtGui/qguiapplication.h>
#include <QtGui/qpa/qplatformnativeinterface.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <QtQuick/private/qsgrhisupport_p.h>
#include <qtquick_tracepoints_p.h>
diff --git a/src/quick/scenegraph/util/qsgrhiatlastexture_p.h b/src/quick/scenegraph/util/qsgrhiatlastexture_p.h
index b766a8f400..5eb9c68495 100644
--- a/src/quick/scenegraph/util/qsgrhiatlastexture_p.h
+++ b/src/quick/scenegraph/util/qsgrhiatlastexture_p.h
@@ -19,7 +19,7 @@
#include <QtQuick/private/qsgplaintexture_p.h>
#include <QtQuick/private/qsgareaallocator_p.h>
#include <QtGui/QSurface>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp
index 6a02aef992..ff59508e63 100644
--- a/src/quick/scenegraph/util/qsgtexturematerial.cpp
+++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp
@@ -3,7 +3,7 @@
#include "qsgtexturematerial_p.h"
#include <private/qsgtexture_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
QT_BEGIN_NAMESPACE
diff --git a/src/quickshapes/qquickshape.cpp b/src/quickshapes/qquickshape.cpp
index 0aa9696068..551376778a 100644
--- a/src/quickshapes/qquickshape.cpp
+++ b/src/quickshapes/qquickshape.cpp
@@ -10,7 +10,7 @@
#include <QtGui/private/qdrawhelper_p.h>
#include <QOpenGLFunctions>
#include <QLoggingCategory>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
static void initResources()
{
diff --git a/src/quickshapes/qquickshapegenericrenderer.cpp b/src/quickshapes/qquickshapegenericrenderer.cpp
index b2b6af041f..a7f830ad01 100644
--- a/src/quickshapes/qquickshapegenericrenderer.cpp
+++ b/src/quickshapes/qquickshapegenericrenderer.cpp
@@ -4,7 +4,7 @@
#include "qquickshapegenericrenderer_p.h"
#include <QtGui/private/qtriangulator_p.h>
#include <QtGui/private/qtriangulatingstroker_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <QSGVertexColorMaterial>
#if QT_CONFIG(thread)
diff --git a/src/quickwidgets/qquickwidget_p.h b/src/quickwidgets/qquickwidget_p.h
index 7167f4fdea..b5eb7b4ba5 100644
--- a/src/quickwidgets/qquickwidget_p.h
+++ b/src/quickwidgets/qquickwidget_p.h
@@ -17,7 +17,7 @@
#include "qquickwidget.h"
#include <private/qwidget_p.h>
-#include <private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <private/qbackingstorerhisupport_p.h>
#include <QtCore/qurl.h>
diff --git a/tests/auto/quick/nodes/tst_nodestest.cpp b/tests/auto/quick/nodes/tst_nodestest.cpp
index 5cec3034d8..decf235c69 100644
--- a/tests/auto/quick/nodes/tst_nodestest.cpp
+++ b/tests/auto/quick/nodes/tst_nodestest.cpp
@@ -18,28 +18,23 @@
#include <QtGui/qpa/qplatformintegration.h>
#include <QtGui/qoffscreensurface.h>
-#include <QtGui/private/qrhi_p.h>
-#include <QtGui/private/qrhinull_p.h>
+#include <rhi/qrhi.h>
#if QT_CONFIG(opengl)
# include <QOpenGLContext>
-# include <QtGui/private/qrhigles2_p.h>
# define TST_GL
#endif
#if QT_CONFIG(vulkan)
# include <QVulkanInstance>
-# include <QtGui/private/qrhivulkan_p.h>
# define TST_VK
#endif
#ifdef Q_OS_WIN
-#include <QtGui/private/qrhid3d11_p.h>
# define TST_D3D11
#endif
#if defined(Q_OS_MACOS) || defined(Q_OS_IOS)
-# include <QtGui/private/qrhimetal_p.h>
# define TST_MTL
#endif
diff --git a/tests/auto/quick/qquickitemrhiintegration/rhiitem.cpp b/tests/auto/quick/qquickitemrhiintegration/rhiitem.cpp
index bcc1f2f6a3..a79731e628 100644
--- a/tests/auto/quick/qquickitemrhiintegration/rhiitem.cpp
+++ b/tests/auto/quick/qquickitemrhiintegration/rhiitem.cpp
@@ -51,8 +51,7 @@ void RhiItemNode::releaseNativeTexture()
void RhiItemNode::sync()
{
if (!m_rhi) {
- QSGRendererInterface *rif = m_window->rendererInterface();
- m_rhi = static_cast<QRhi *>(rif->getResource(m_window, QSGRendererInterface::RhiResource));
+ m_rhi = m_window->rhi();
if (!m_rhi) {
qWarning("No QRhi found for window %p, RhiItem will not be functional", m_window);
return;
diff --git a/tests/auto/quick/qquickitemrhiintegration/rhiitem.h b/tests/auto/quick/qquickitemrhiintegration/rhiitem.h
index 6439bfba4a..ba36247039 100644
--- a/tests/auto/quick/qquickitemrhiintegration/rhiitem.h
+++ b/tests/auto/quick/qquickitemrhiintegration/rhiitem.h
@@ -5,7 +5,7 @@
#define RHIITEM_H
#include <QQuickItem>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
class RhiItem;
class RhiItemPrivate;
diff --git a/tests/auto/quick/qquickitemrhiintegration/tst_qquickitemrhiintegration.cpp b/tests/auto/quick/qquickitemrhiintegration/tst_qquickitemrhiintegration.cpp
index 9915c81fc1..811bb8e4d4 100644
--- a/tests/auto/quick/qquickitemrhiintegration/tst_qquickitemrhiintegration.cpp
+++ b/tests/auto/quick/qquickitemrhiintegration/tst_qquickitemrhiintegration.cpp
@@ -4,7 +4,7 @@
#include <qtest.h>
#include <QtQuickTestUtils/private/qmlutils_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <QQuickView>
#include <QSGRendererInterface>
diff --git a/tests/auto/quick/qquickrendercontrol/tst_qquickrendercontrol.cpp b/tests/auto/quick/qquickrendercontrol/tst_qquickrendercontrol.cpp
index 2d56312f9d..883f7e7a07 100644
--- a/tests/auto/quick/qquickrendercontrol/tst_qquickrendercontrol.cpp
+++ b/tests/auto/quick/qquickrendercontrol/tst_qquickrendercontrol.cpp
@@ -19,8 +19,7 @@
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qpa/qplatformintegration.h>
-#include <QtGui/private/qrhi_p.h>
-#include <QtQuick/private/qquickrendercontrol_p.h>
+#include <rhi/qrhi.h>
#if QT_CONFIG(vulkan)
#include <QVulkanInstance>
@@ -193,13 +192,7 @@ void tst_RenderControl::renderAndReadBackWithRhi()
QCOMPARE(quickWindow->rendererInterface()->graphicsApi(), api);
- // What comes now is technically cheating - as long as QRhi is not a public
- // API this is not something applications can follow doing. However, it
- // allows us to test out the pipeline without having to write 4 different
- // native (Vulkan, Metal, D3D11, OpenGL) implementations of all what's below.
-
- QQuickRenderControlPrivate *rd = QQuickRenderControlPrivate::get(renderControl.data());
- QRhi *rhi = rd->rhi;
+ QRhi *rhi = renderControl->rhi();
Q_ASSERT(rhi);
const QSize size = rootItem->size().toSize();
@@ -302,7 +295,7 @@ void tst_RenderControl::renderAndReadBackWithRhi()
};
QRhiResourceUpdateBatch *readbackBatch = rhi->nextResourceUpdateBatch();
readbackBatch->readBackTexture(tex.data(), &readResult);
- rd->cb->resourceUpdate(readbackBatch);
+ renderControl->commandBuffer()->resourceUpdate(readbackBatch);
// our frame is done, submit
renderControl->endFrame();
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index 1aa3a46dd1..f79c3bd23c 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -27,13 +27,12 @@
#include <QOperatingSystemVersion>
#include <functional>
#include <QtGui/private/qeventpoint_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
#if QT_CONFIG(opengl)
#include <QOpenGLContext>
#endif
#if QT_CONFIG(vulkan)
#include <QVulkanInstance>
-#include <QtGui/private/qrhivulkan_p.h>
#endif
Q_LOGGING_CATEGORY(lcTests, "qt.quick.tests")
diff --git a/tests/auto/quick/rendernode/tst_rendernode.cpp b/tests/auto/quick/rendernode/tst_rendernode.cpp
index 44e1123cd7..5bb2b8dadb 100644
--- a/tests/auto/quick/rendernode/tst_rendernode.cpp
+++ b/tests/auto/quick/rendernode/tst_rendernode.cpp
@@ -6,7 +6,7 @@
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
#include <private/qsgrendernode_p.h>
-#include <QtGui/private/qrhi_p.h>
+#include <rhi/qrhi.h>
#include <QtQuickTestUtils/private/qmlutils_p.h>