all repos — mgba @ 787c99b949b93e7263c53f483ff556dbd9684869

mGBA Game Boy Advance Emulator

Qt: Improve GL syncing
Vicki Pfau vi@endrift.com
Tue, 21 May 2019 22:32:24 -0700
commit

787c99b949b93e7263c53f483ff556dbd9684869

parent

2781a2a9f951b39ff89e47d0d13106918e1316c3

3 files changed, 7 insertions(+), 3 deletions(-)

jump to
M src/platform/qt/CoreController.hsrc/platform/qt/CoreController.h

@@ -98,6 +98,9 @@

void setInputController(InputController*); void setLogger(LogController*); + bool audioSync() const { return m_audioSync; } + bool videoSync() const { return m_videoSync; } + public slots: void start(); void stop();
M src/platform/qt/Display.cppsrc/platform/qt/Display.cpp

@@ -20,7 +20,7 @@ Display* Display::create(QWidget* parent) {

#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY) QSurfaceFormat format; format.setSwapInterval(1); - format.setSwapBehavior(QSurfaceFormat::TripleBuffer); + format.setSwapBehavior(QSurfaceFormat::SingleBuffer); #endif switch (s_driver) {
M src/platform/qt/DisplayGL.cppsrc/platform/qt/DisplayGL.cpp

@@ -264,11 +264,12 @@ PainterGL* painter = static_cast<PainterGL*>(v->user);

if (!painter->m_gl->isValid()) { return; } + painter->m_gl->doneCurrent(); + painter->m_gl->swapBuffers(painter->m_surface); painter->m_gl->makeCurrent(painter->m_surface); #if defined(_WIN32) && defined(USE_EPOXY) epoxy_handle_external_wglMakeCurrent(); #endif - painter->m_gl->swapBuffers(painter->m_gl->surface()); }; m_backend->init(m_backend, 0);

@@ -383,7 +384,7 @@ m_painter.end();

m_backend->swap(m_backend); if (!m_delayTimer.isValid()) { m_delayTimer.start(); - } else if (m_gl->format().swapInterval()) { + } else if (m_gl->format().swapInterval() && m_context->videoSync()) { while (m_delayTimer.elapsed() < 15) { QThread::usleep(100); }