diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2019-12-04 08:14:29 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2019-12-04 13:39:06 +0100 |
commit | 96b1b9e3e198e751bb96eeb279106862ca38e7d7 (patch) | |
tree | 6021824238f649aaec3e95c148f94d9ed7e3ff8f /src/quick3d/imports/scene3d/scene3drenderer.cpp | |
parent | c2c4338185722e02cb55a886c14c04295713609a (diff) |
Fix OnDemand rendering with Scene3Dv5.14.0-rc2v5.14.0
When using OnDemand rendering, Scene3D would lock if nothing in
the scene were to change. By being blocked, it would also not
process jobs for other aspects (input, logics). That would prevent
things like a CameraController from running, which in turn would
make it impossible to move the camera and trigger a change in the
scene to request rendering.
Additionally, Scene3D would ignore whether the Qt3D renderer actually
needed rendering or not as it was watching on its own the changeArbiter
for changes to decide whether rendering was required or not. This would
ignore the case where Qt3D needs multiple frames to render a correct frame
(e.g loading buffers, shaders at frame n, rebuilding commands at frame n+1)
Scene3D now asks the Qt3D renderer by calling the shouldRender() function
to decide whether rendering is needed or not, in addition to watching the
changeArbiter.
Regardless of whether rendering is needed, it now let each aspect process
jobs. This ensures things like FrameAction/Input are processed.
Then, Scene3D decides whether full rendering is required or whether
it only has to be called to allow the Qt3D simulation loop to proceed for the
next frame. If the latter, it does it so as not to have QtQuick trigger a
redraw.
Change-Id: I870f773c224286d6b7ec0f6045319e51e09cbf8e
Task-number: QTBUG-80521
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/quick3d/imports/scene3d/scene3drenderer.cpp')
-rw-r--r-- | src/quick3d/imports/scene3d/scene3drenderer.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/quick3d/imports/scene3d/scene3drenderer.cpp b/src/quick3d/imports/scene3d/scene3drenderer.cpp index 1e322a615..fafeeedf4 100644 --- a/src/quick3d/imports/scene3d/scene3drenderer.cpp +++ b/src/quick3d/imports/scene3d/scene3drenderer.cpp @@ -161,6 +161,7 @@ Scene3DRenderer::Scene3DRenderer(Scene3DItem *item, Qt3DCore::QAspectEngine *asp , m_forceRecreate(false) , m_shouldRender(false) , m_dirtyViews(false) + , m_skipFrame(false) , m_allowRendering(0) , m_compositingMode(Scene3DItem::FBO) { @@ -278,6 +279,19 @@ void Scene3DRenderer::beforeSynchronize() // We could otherwise enter a deadlock state if (!m_allowRendering.tryAcquire(std::max(m_allowRendering.available(), 1))) return; + + // In the case of OnDemand rendering, we still need to get to this + // point to ensure we have processed jobs for all aspects. + // We also still need to call render() to allow proceeding with the + // next frame. However it won't be performing any 3d rendering at all + // so we do it here and return early. This prevents a costly QtQuick + // SceneGraph update for nothing + if (m_skipFrame) { + m_skipFrame = false; + static_cast<QRenderAspectPrivate*>(QRenderAspectPrivate::get(m_renderAspect))->renderSynchronous(false); + return; + } + m_shouldRender = true; // Check size / multisampling @@ -360,6 +374,11 @@ void Scene3DRenderer::setCompositingMode(Scene3DItem::CompositingMode mode) m_compositingMode = mode; } +void Scene3DRenderer::setSkipFrame(bool skip) +{ + m_skipFrame = skip; +} + // Main Thread, Render Thread locked void Scene3DRenderer::setScene3DViews(const QVector<Scene3DView *> views) { |