From 27d674e9ec226559bb6a18085f570928e277fa1e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sun, 6 Sep 2020 16:06:30 +0200 Subject: threaded renderloop: Do not abort with sleep when no changes after sync Task-number: QTBUG-86089 Change-Id: If1b3369d49b5088b78f683d7512b156af3765bce Reviewed-by: Andy Nichols --- src/quick/scenegraph/qsgthreadedrenderloop.cpp | 27 ++++++++++---------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'src/quick/scenegraph') diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index a47aa4f359..ff3bacf0e4 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -735,23 +735,16 @@ void QSGRenderThread::syncAndRender(QImage *grabImage) Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame, QQuickProfiler::SceneGraphRenderLoopSync); - if (!syncResultedInChanges - && !repaintRequested - && !(pendingUpdate & RepaintRequest) // may have been set in sync() - && sgrc->isValid() - && !grabRequested - && rhi) - { - qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- no changes, render aborted"); - if (rhi && rhi->isRecordingFrame()) - rhi->endFrame(cd->swapchain, QRhi::SkipPresent); - - int waitTime = vsyncDelta - (int) waitTimer.elapsed(); - if (waitTime > 0) - msleep(waitTime); - - return; - } + // Qt 6 no longer aborts when !syncResultedInChanges && !RepaintRequest, + // meaning this function always completes and presents a frame. This is + // more compatible with what the basic render loop (or a custom loop with + // QQuickRenderControl) would do, is more accurate due to not having to do + // an msleep() with an inaccurate interval, and avoids misunderstandings + // for signals like frameSwapped(). (in Qt 5 a continuously "updating" + // window is continuously presenting frames with the basic loop, but not + // with threaded due to aborting when sync() finds there are no relevant + // visual changes in the scene graph; this system proved to be simply too + // confusing in practice) qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- rendering started"); -- cgit v1.2.3