diff options
author | Antti Määttä <antti.maatta@qt.io> | 2020-01-17 07:57:05 +0200 |
---|---|---|
committer | Antti Määttä <antti.maatta@qt.io> | 2020-01-22 13:28:49 +0200 |
commit | 88849a83a6f9ca3524cf3ba32c3a4ed7e6fabdb9 (patch) | |
tree | cbe79006339b63245381cef7e2822cbbf01dcae9 /src/runtime | |
parent | 7a49e1bdc590f0d3f397dd04355fd165bbd1cb86 (diff) |
Don't render when scene is not changing
Reduce CPU and GPU load by checking if the scene has changed and render
only if it has.
Task-number: QT3DS-4042
Change-Id: I54e447760f04fdad8d64319f326245175b471331
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/runtime')
-rw-r--r-- | src/runtime/Qt3DSApplication.cpp | 13 | ||||
-rw-r--r-- | src/runtime/Qt3DSApplication.h | 2 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/runtime/Qt3DSApplication.cpp b/src/runtime/Qt3DSApplication.cpp index cb8f732..79866c5 100644 --- a/src/runtime/Qt3DSApplication.cpp +++ b/src/runtime/Qt3DSApplication.cpp @@ -1031,7 +1031,7 @@ struct SApp : public IApplication } // End QT3DS_PERF_SCOPED_TIMER scope } - void UpdateScenes() { m_RuntimeFactory->GetSceneManager().Update(); } + bool UpdateScenes() { return m_RuntimeFactory->GetSceneManager().Update(); } bool LazyLoadSubPresentations() { @@ -1113,7 +1113,7 @@ struct SApp : public IApplication void ResetDirtyCounter() { m_DirtyCountdown = 5; } // Update all the presentations and render them. - void UpdateAndRender() override + bool UpdateAndRender() override { QT3DS_ASSERT(m_AppLoadContext.mPtr == NULL); m_ThisFrameStartTime = qt3ds::foundation::Time::getCurrentCounterValue(); @@ -1147,15 +1147,17 @@ struct SApp : public IApplication } UpdatePresentations(); - UpdateScenes(); + bool dirty = UpdateScenes(); // If subpresentations changed we need to check if any of them needs to be loaded. if (LazyLoadSubPresentations()) { // Just redo all UpdatePresentations(); - UpdateScenes(); + dirty |= UpdateScenes(); } - + bool renderNextFrame = false; + if (m_LastRenderWasDirty || dirty || m_initialFrame) + renderNextFrame = true; Render(); m_InputEnginePtr->ClearInputFrame(); @@ -1185,6 +1187,7 @@ struct SApp : public IApplication ResetDirtyCounter(); else m_DirtyCountdown = NVMax(0, m_DirtyCountdown - 1); + return renderNextFrame; } // hook this up to -layer-caching. diff --git a/src/runtime/Qt3DSApplication.h b/src/runtime/Qt3DSApplication.h index 72d88a1..ad447f7 100644 --- a/src/runtime/Qt3DSApplication.h +++ b/src/runtime/Qt3DSApplication.h @@ -174,7 +174,7 @@ public: virtual QList<Q3DStudio::CPresentation *> GetPresentationList() = 0; // Update all the presentations and render them. Called exactly once per frame. - virtual void UpdateAndRender() = 0; + virtual bool UpdateAndRender() = 0; virtual bool IsApplicationDirty() = 0; |