Commit 23b669b6 authored by Laszlo Agocs's avatar Laszlo Agocs
Browse files

examplefw: stop using requestUpdate for now

So e.g. NoVSync can give the maximal performance.
parent 4980179d
...@@ -153,8 +153,7 @@ protected: ...@@ -153,8 +153,7 @@ protected:
QMatrix4x4 m_proj; QMatrix4x4 m_proj;
QElapsedTimer m_timer; QElapsedTimer m_timer;
qint64 m_elapsedMs; int m_frameCount;
int m_elapsedCount;
#ifndef QT_NO_OPENGL #ifndef QT_NO_OPENGL
QOpenGLContext *m_context = nullptr; QOpenGLContext *m_context = nullptr;
...@@ -334,8 +333,8 @@ void Window::resizeSwapChain() ...@@ -334,8 +333,8 @@ void Window::resizeSwapChain()
m_hasSwapChain = m_sc->buildOrResize(); m_hasSwapChain = m_sc->buildOrResize();
m_elapsedMs = 0; m_frameCount = 0;
m_elapsedCount = 0; m_timer.restart();
m_proj = m_r->clipSpaceCorrMatrix(); m_proj = m_r->clipSpaceCorrMatrix();
m_proj.perspective(45.0f, outputSize.width() / (float) outputSize.height(), 0.01f, 1000.0f); m_proj.perspective(45.0f, outputSize.width() / (float) outputSize.height(), 0.01f, 1000.0f);
...@@ -381,21 +380,28 @@ void Window::render() ...@@ -381,21 +380,28 @@ void Window::render()
return; return;
} }
if (m_elapsedCount) m_frameCount += 1;
m_elapsedMs += m_timer.elapsed(); if (m_timer.elapsed() > 1000) {
m_timer.restart(); qDebug("%d", m_frameCount);
m_elapsedCount += 1; m_timer.restart();
if (m_elapsedMs >= 4000) { m_frameCount = 0;
qDebug("%f", m_elapsedCount / 4.0f);
m_elapsedMs = 0;
m_elapsedCount = 0;
} }
customRender(); customRender();
m_r->endFrame(m_sc); m_r->endFrame(m_sc);
requestUpdate(); // There should be no need to rely on requestUpdate().
// Outside Apple that's a 5 ms timer, otherwise backed by CVDisplayLink but
// for Metal we do not need that either.
bool sillyPlatform = false;
#ifdef Q_OS_DARWIN
sillyPlatform = graphicsApi == OpenGL;
#endif
if (sillyPlatform)
requestUpdate();
else
QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
} }
int main(int argc, char **argv) int main(int argc, char **argv)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment