all repos — mgba @ 60ec3e0e9926da9a10771f164f5040359f077872

mGBA Game Boy Advance Emulator

Qt: Fix up GL changes causing timing issues
Vicki Pfau vi@endrift.com
Sun, 29 Nov 2020 22:03:03 -0800
commit

60ec3e0e9926da9a10771f164f5040359f077872

parent

2d6087aa985fc401b1753f4482f07a512828f170

1 files changed, 7 insertions(+), 6 deletions(-)

jump to
M src/platform/qt/DisplayGL.cppsrc/platform/qt/DisplayGL.cpp

@@ -441,7 +441,7 @@ mCoreSync* sync = &m_context->thread()->impl->sync;

if (!mCoreSyncWaitFrameStart(sync)) { mCoreSyncWaitFrameEnd(sync); ++m_lagging; - if (m_delayTimer.elapsed() < 1000 / m_surface->screen()->refreshRate()) { + if ((sync->audioWait || sync->videoFrameWait) && m_delayTimer.elapsed() < 1000 / m_surface->screen()->refreshRate()) { QTimer::singleShot(1, this, &PainterGL::draw); } return;

@@ -453,16 +453,18 @@ m_videoProxy->setBlocking(sync->audioWait && std::abs(60.f - sync->fpsTarget) < 0.1f);

} if (!m_delayTimer.isValid()) { m_delayTimer.start(); - } else if (sync->audioWait || sync->videoFrameWait) { - while (m_delayTimer.nsecsElapsed() + 2000000 < 1000000000 / sync->fpsTarget) { - QThread::usleep(500); + } else { + if (sync->audioWait || sync->videoFrameWait) { + while (m_delayTimer.nsecsElapsed() + 2000000 < 1000000000 / sync->fpsTarget) { + QThread::usleep(500); + } } + m_delayTimer.restart(); } mCoreSyncWaitFrameEnd(sync); performDraw(); m_backend->swap(m_backend); - m_delayTimer.restart(); } void PainterGL::forceDraw() {

@@ -546,7 +548,6 @@ m_free.append(m_buffer);

m_buffer = nullptr; } m_buffer = buffer; - return; } void PainterGL::dequeueAll() {