summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2020-01-17 07:57:05 +0200
committerAntti Määttä <antti.maatta@qt.io>2020-01-22 13:28:49 +0200
commit88849a83a6f9ca3524cf3ba32c3a4ed7e6fabdb9 (patch)
treecbe79006339b63245381cef7e2822cbbf01dcae9 /src/engine
parent7a49e1bdc590f0d3f397dd04355fd165bbd1cb86 (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/engine')
-rw-r--r--src/engine/Qt3DSRenderRuntimeBinding.cpp4
-rw-r--r--src/engine/Qt3DSRuntimeView.cpp8
-rw-r--r--src/engine/Qt3DSRuntimeView.h2
3 files changed, 9 insertions, 5 deletions
diff --git a/src/engine/Qt3DSRenderRuntimeBinding.cpp b/src/engine/Qt3DSRenderRuntimeBinding.cpp
index 28c5403..e830e0f 100644
--- a/src/engine/Qt3DSRenderRuntimeBinding.cpp
+++ b/src/engine/Qt3DSRenderRuntimeBinding.cpp
@@ -1505,9 +1505,11 @@ struct Qt3DSRenderSceneManager : public Q3DStudio::ISceneManager,
bool firstFrame) override
{
Qt3DSRenderScene *theFirstScene = nullptr;
- for (QT3DSU32 idx = 0, end = m_Scenes.size(); idx < end && theFirstScene == nullptr; ++idx)
+ for (QT3DSU32 idx = 0, end = m_Scenes.size(); idx < end; ++idx) {
if (m_Scenes[idx].second->m_RuntimePresentation == inPresentation)
theFirstScene = m_Scenes[idx].second;
+ m_Scenes[idx].second->TransferDirtyProperties();
+ }
if (theFirstScene && theFirstScene->m_Presentation) {
m_LastRenderedScene = theFirstScene;
diff --git a/src/engine/Qt3DSRuntimeView.cpp b/src/engine/Qt3DSRuntimeView.cpp
index fd3be65..2335cf1 100644
--- a/src/engine/Qt3DSRuntimeView.cpp
+++ b/src/engine/Qt3DSRuntimeView.cpp
@@ -179,7 +179,7 @@ public:
void Cleanup() override;
bool CanRender() override;
- void Render() override;
+ bool Render() override;
bool WasLastFrameDirty() override;
bool HandleMessage(const QEvent *inEvent) override;
@@ -394,8 +394,9 @@ bool CRuntimeView::CanRender()
* returns KD_TRUE to call egl_render and swap properly, KD_FALSE if there has been no scene update
*or redraw.
*/
-void CRuntimeView::Render()
+bool CRuntimeView::Render()
{
+ bool ret = true;
if (m_Application.mPtr == nullptr) {
// InitializeGraphics has not been called
QT3DS_ASSERT(false);
@@ -403,7 +404,7 @@ void CRuntimeView::Render()
PerfLogGeneralEvent1(DATALOGGER_FRAME);
- m_Application->UpdateAndRender();
+ ret = m_Application->UpdateAndRender();
if (m_startupTime < 0 && m_startupTimer && m_startupTimer->isValid()) {
@@ -457,6 +458,7 @@ void CRuntimeView::Render()
manager.PopState();
}
+ return ret;
}
bool CRuntimeView::WasLastFrameDirty()
diff --git a/src/engine/Qt3DSRuntimeView.h b/src/engine/Qt3DSRuntimeView.h
index e3f57d1..e0061b0 100644
--- a/src/engine/Qt3DSRuntimeView.h
+++ b/src/engine/Qt3DSRuntimeView.h
@@ -185,7 +185,7 @@ public: // loading
virtual bool CanRender() = 0;
- virtual void Render() = 0;
+ virtual bool Render() = 0;
virtual bool WasLastFrameDirty() = 0;