diff options
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgtexture.cpp | 8 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgcontext.cpp | 3 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgcontext_p.h | 2 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgdefaultrendercontext.cpp | 9 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgdefaultrendercontext_p.h | 2 |
6 files changed, 18 insertions, 8 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 50777ef03d..0b12b13978 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -430,7 +430,7 @@ void QQuickWindowPrivate::syncSceneGraph() if (renderTargetId && !QQuickRenderControl::renderWindowFor(q)) devicePixelRatio = 1; - context->prepareSync(devicePixelRatio); + context->prepareSync(devicePixelRatio, rhi ? swapchain->currentFrameCommandBuffer() : nullptr); animationController->beforeNodeSync(); diff --git a/src/quick/scenegraph/coreapi/qsgtexture.cpp b/src/quick/scenegraph/coreapi/qsgtexture.cpp index 715633fdba..418aaca605 100644 --- a/src/quick/scenegraph/coreapi/qsgtexture.cpp +++ b/src/quick/scenegraph/coreapi/qsgtexture.cpp @@ -842,11 +842,15 @@ void QSGTexturePrivate::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *res /*! \fn bool QSGDynamicTexture::updateTexture() - Call this function to explicitly update the dynamic texture. Calling bind() will bind - the content that was previously updated. + Call this function to explicitly update the dynamic texture. The function returns true if the texture was changed as a resul of the update; otherwise returns false. + + \note This function is typically called from QQuickItem::updatePaintNode() + or QSGNode::preprocess(), meaning during the \c{synchronization} or the + \c{node preprocessing} phases of the scenegraph. Calling it at other times + is discouraged and can lead to unexpected behavior. */ /*! diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index 17eb1e312c..e3c951e5ed 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -341,9 +341,10 @@ void QSGRenderContext::invalidate() { } -void QSGRenderContext::prepareSync(qreal devicePixelRatio) +void QSGRenderContext::prepareSync(qreal devicePixelRatio, QRhiCommandBuffer *cb) { Q_UNUSED(devicePixelRatio); + Q_UNUSED(cb); } void QSGRenderContext::beginNextFrame(QSGRenderer *renderer, diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h index 244bcfabd1..d389420907 100644 --- a/src/quick/scenegraph/qsgcontext_p.h +++ b/src/quick/scenegraph/qsgcontext_p.h @@ -174,7 +174,7 @@ public: using RenderPassCallback = void (*)(void *); - virtual void prepareSync(qreal devicePixelRatio); + virtual void prepareSync(qreal devicePixelRatio, QRhiCommandBuffer *cb); virtual void beginNextFrame(QSGRenderer *renderer, RenderPassCallback mainPassRecordingStart, RenderPassCallback mainPassRecordingEnd, diff --git a/src/quick/scenegraph/qsgdefaultrendercontext.cpp b/src/quick/scenegraph/qsgdefaultrendercontext.cpp index e8c3ac4abb..b5bf56649b 100644 --- a/src/quick/scenegraph/qsgdefaultrendercontext.cpp +++ b/src/quick/scenegraph/qsgdefaultrendercontext.cpp @@ -200,9 +200,14 @@ void QSGDefaultRenderContext::invalidate() emit invalidated(); } -void QSGDefaultRenderContext::prepareSync(qreal devicePixelRatio) +void QSGDefaultRenderContext::prepareSync(qreal devicePixelRatio, QRhiCommandBuffer *cb) { m_currentDevicePixelRatio = devicePixelRatio; + + // we store the command buffer already here, in case there is something in + // an updatePaintNode() implementation that leads to needing it (for + // example, an updateTexture() call on a QSGRhiLayer) + m_currentFrameCommandBuffer = cb; } static QBasicMutex qsg_framerender_mutex; @@ -244,7 +249,7 @@ void QSGDefaultRenderContext::beginNextRhiFrame(QSGRenderer *renderer, QRhiRende renderer->setCommandBuffer(cb); renderer->setRenderPassRecordingCallbacks(mainPassRecordingStart, mainPassRecordingEnd, callbackUserData); - m_currentFrameCommandBuffer = cb; + m_currentFrameCommandBuffer = cb; // usually the same as what was passed to prepareSync() but cannot count on that having been called m_currentFrameRenderPass = rp; } diff --git a/src/quick/scenegraph/qsgdefaultrendercontext_p.h b/src/quick/scenegraph/qsgdefaultrendercontext_p.h index 2fdb3a48dd..97ed681f9a 100644 --- a/src/quick/scenegraph/qsgdefaultrendercontext_p.h +++ b/src/quick/scenegraph/qsgdefaultrendercontext_p.h @@ -104,7 +104,7 @@ public: void initialize(const QSGRenderContext::InitParams *params) override; void invalidate() override; - void prepareSync(qreal devicePixelRatio) override; + void prepareSync(qreal devicePixelRatio, QRhiCommandBuffer *cb) override; void beginNextFrame(QSGRenderer *renderer, RenderPassCallback mainPassRecordingStart, RenderPassCallback mainPassRecordingEnd, |