summaryrefslogtreecommitdiffstats
path: root/src/render/renderers/opengl/renderer/renderer.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2019-07-05 09:06:35 +0200
committerPaul Lemire <paul.lemire@kdab.com>2019-08-07 12:08:32 +0200
commit6631bf0983250e1a86cb9d27628c44b6e607609b (patch)
tree5ea8ee81d2119df25b0f2a87532f7d7d2dcf03a8 /src/render/renderers/opengl/renderer/renderer.cpp
parentda2c94c13c163922467e6d88e19442fc12aea523 (diff)
Make Scene3D rendering use the Manual Qt3D drive mode
This now makes Scene3D rendering fully synchronous and blocking: - All Qt3D jobs have to be executed before we can render the GL commands This makes the blocking mode that could be activated with SCENE3D_BLOCKING_RENDERMODE the default behavior now and therefore we could remove references to it in the code. This now means that Qt3D and QtQuick will be rendering at the same refresh rate, which in most cases won't be noticeable and will ensure that content from Qt3D scenes matches content from QtQuick scenes. The only downside is if the Qt3D rendering takes longer than the time expected by QtQuick, the whole QtQuick rendering will be slowed down. Previously the QtQuick rendering might have still run at 60fps while the Qt3D rendering at a lower fps. Now the QtQuick fps would be the same as the Qt3D fps. That being said, the old behavior also meant that if Qt3D didn't catch up, the delay between QtQuick and Qt3D would only increase frame after frame. This change allow to simplify the internals by making Scene3D and regular Qt3D use the same code paths internally. Please note that Scene3D relies on QQuickWindow::afterAnimating being called each frame. When using a QQuickRenderControl this means you might have to call it manually as part of your rendering code. Task-number: QTBUG-72385 Change-Id: I887daf6df632e296a892b844e738a67e973fee7f Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/render/renderers/opengl/renderer/renderer.cpp')
-rw-r--r--src/render/renderers/opengl/renderer/renderer.cpp58
1 files changed, 19 insertions, 39 deletions
diff --git a/src/render/renderers/opengl/renderer/renderer.cpp b/src/render/renderers/opengl/renderer/renderer.cpp
index b60eea33d..88dd77f39 100644
--- a/src/render/renderers/opengl/renderer/renderer.cpp
+++ b/src/render/renderers/opengl/renderer/renderer.cpp
@@ -627,34 +627,20 @@ void Renderer::render()
}
}
-void Renderer::doRender(bool scene3dBlocking)
+void Renderer::doRender()
{
Renderer::ViewSubmissionResultData submissionData;
bool hasCleanedQueueAndProceeded = false;
bool preprocessingComplete = false;
bool beganDrawing = false;
+
+ // Blocking until RenderQueue is full
const bool canSubmit = isReadyToSubmit();
// Lock the mutex to protect access to the renderQueue while we look for its state
QMutexLocker locker(m_renderQueue->mutex());
- bool queueIsComplete = m_renderQueue->isFrameQueueComplete();
- bool queueIsEmpty = m_renderQueue->targetRenderViewCount() == 0;
-
- // Scene3D Blocking Mode
- if (scene3dBlocking && !queueIsComplete && !queueIsEmpty) {
- int i = 0;
- // We wait at most 10ms to avoid a case we could never recover from
- while (!queueIsComplete && !queueIsEmpty && i++ < 10) {
- qCDebug(Backend) << Q_FUNC_INFO << "Waiting for ready queue (try:" << i << "/ 10)";
- locker.unlock();
- // Give worker threads a chance to complete the queue
- QThread::msleep(1);
- locker.relock();
- queueIsComplete = m_renderQueue->isFrameQueueComplete();
- // This could become true if we've tried to shutdown
- queueIsEmpty = m_renderQueue->targetRenderViewCount() == 0;
- }
- }
+ const bool queueIsComplete = m_renderQueue->isFrameQueueComplete();
+ const bool queueIsEmpty = m_renderQueue->targetRenderViewCount() == 0;
// When using synchronous rendering (QtQuick)
// We are not sure that the frame queue is actually complete
@@ -751,16 +737,12 @@ void Renderer::doRender(bool scene3dBlocking)
#endif
}
- // Only reset renderQueue and proceed to next frame if the submission
- // succeeded or if we are using a render thread and that is wasn't performed
- // already
-
// If hasCleanedQueueAndProceeded isn't true this implies that something went wrong
// with the rendering and/or the renderqueue is incomplete from some reason
- // (in the case of scene3d the render jobs may be taking too long ....)
// or alternatively it could be complete but empty (RenderQueue of size 0)
- if (!hasCleanedQueueAndProceeded &&
- (m_renderThread || queueIsComplete || queueIsEmpty)) {
+
+
+ if (!hasCleanedQueueAndProceeded) {
// RenderQueue was full but something bad happened when
// trying to render it and therefore proceedToNextFrame was not called
// Note: in this case the renderQueue mutex is still locked
@@ -825,21 +807,19 @@ bool Renderer::canRender() const
bool Renderer::isReadyToSubmit()
{
- // If we are using a render thread, make sure that
- // we've been told to render before rendering
- if (m_renderThread) { // Prevent ouf of order execution
- m_submitRenderViewsSemaphore.acquire(1);
+ // Make sure that we've been told to render before rendering
+ // Prevent ouf of order execution
+ m_submitRenderViewsSemaphore.acquire(1);
- // Check if shutdown has been requested
- if (m_running.load() == 0)
- return false;
+ // Check if shutdown has been requested
+ if (m_running.load() == 0)
+ return false;
- // When using Thread rendering, the semaphore should only
- // be released when the frame queue is complete and there's
- // something to render
- // The case of shutdown should have been handled just before
- Q_ASSERT(m_renderQueue->isFrameQueueComplete());
- }
+ // The semaphore should only
+ // be released when the frame queue is complete and there's
+ // something to render
+ // The case of shutdown should have been handled just before
+ Q_ASSERT(m_renderQueue->isFrameQueueComplete());
return true;
}