diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2022-12-16 10:30:19 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2022-12-19 11:01:51 +0100 |
commit | e2aac33d04804c3c8f4f554c206a8cb9dd14611e (patch) | |
tree | 1e247da4adb8fc70d5c02ed654cf1adafe6b0f67 /src | |
parent | 6b6465032f103a084e416cbddf03f8e83191aea2 (diff) | |
download | qt3d-e2aac33d04804c3c8f4f554c206a8cb9dd14611e.tar.gz |
Scene3DItem: fix screen flickering when using OnDemand
When using OnDemand, we detect whether Qt3D actually needs to render or
not. Based on that we set a flag on the Scene3DRenderer to tell it whether
it should render or not.
The subtlety lies in the fact that depending on that flag value, we will
still call Qt3D render but not at the same moment. We need to call render
to unlock the Qt3D render loop for next frame.
Therefore when we should skip a frame, we call render in
Scene3DRender::beforeSynchronize (updatePaintNode) and return early
while in the other case beforeSynchronize doesn't call render and it gets
called later in beforeRenderPassRecording. We know that the render call
in the skip frame case won't render anything.
To work correctly, we must obviously set the skip frame flag before
beforeSynchronize / beforeRenderPassRecording is called which
wasn't the case. This therefore resulted in random screen flashing as we
would end up having beforeSynchronize rely on the skip frame value for the
previous frame. This means we would end up issuing a render call in
beforeSynchronize using assuming it wouldn't render anything when it actually
did (no FBO would be bound and Qt3D would render straight to the window
...)
Also update the number of frames to render before skipping to 3 to match
Qt 5.15 and ensure we have something visible for the first time
Scene3D is launched.
Pick-to: 6.4 6.5
Change-Id: Icc34b62a0af2ff44232b39c694a4702488a890a2
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick3d/imports/scene3d/scene3ditem.cpp | 10 | ||||
-rw-r--r-- | src/quick3d/imports/scene3d/scene3ditem_p.h | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/quick3d/imports/scene3d/scene3ditem.cpp b/src/quick3d/imports/scene3d/scene3ditem.cpp index d1f1cea72..a65fb8baa 100644 --- a/src/quick3d/imports/scene3d/scene3ditem.cpp +++ b/src/quick3d/imports/scene3d/scene3ditem.cpp @@ -850,6 +850,11 @@ QSGNode *Scene3DItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNode } } + // Set whether we want the Renderer to be allowed to render or not + const bool skipFrame = !needsRender(renderAspect); + renderer->setSkipFrame(skipFrame); + renderer->allowRender(); + // Let the renderer prepare anything it needs to prior to the rendering if (m_wasFrameProcessed) renderer->beforeSynchronize(); @@ -857,11 +862,6 @@ QSGNode *Scene3DItem::updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNode // Force window->beforeRendering to be triggered managerNode->markDirty(QSGNode::DirtyForceUpdate); - // Set whether we want the Renderer to be allowed to render or not - const bool skipFrame = !needsRender(renderAspect); - renderer->setSkipFrame(skipFrame); - renderer->allowRender(); - m_wasSGUpdated = true; return managerNode; diff --git a/src/quick3d/imports/scene3d/scene3ditem_p.h b/src/quick3d/imports/scene3d/scene3ditem_p.h index 9b7c4f639..323e93d65 100644 --- a/src/quick3d/imports/scene3d/scene3ditem_p.h +++ b/src/quick3d/imports/scene3d/scene3ditem_p.h @@ -126,7 +126,7 @@ private: QMetaObject::Connection m_windowConnection; qint8 m_framesToRender; - static const qint8 ms_framesNeededToFlushPipeline = 2; + static const qint8 ms_framesNeededToFlushPipeline = 3; }; } // Qt3DRender |