summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2022-12-16 10:30:19 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-12-19 11:28:58 +0000
commita1ad9e2999e8d99f74e06c0843a70a1ec4c7d14c (patch)
treef3ef106ee98a5023c03408af6fdc7a95e94d07b3
parentb1fea9fb29b42ab30bc7a474d439827a4a97f7d6 (diff)
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. Change-Id: Icc34b62a0af2ff44232b39c694a4702488a890a2 Reviewed-by: Mike Krus <mike.krus@kdab.com> (cherry picked from commit e2aac33d04804c3c8f4f554c206a8cb9dd14611e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/quick3d/imports/scene3d/scene3ditem.cpp10
-rw-r--r--src/quick3d/imports/scene3d/scene3ditem_p.h2
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