diff options
author | RSDuck <RSDuck@users.noreply.github.com> | 2021-02-16 15:00:23 +0100 |
---|---|---|
committer | RSDuck <RSDuck@users.noreply.github.com> | 2021-02-16 15:00:23 +0100 |
commit | 64c6654d949b86ff528d975ba700f8477c269557 (patch) | |
tree | 85b9d6ef115a039f8cabd3894f3f2a3a4bd8dece /src/frontend/qt_sdl/main.cpp | |
parent | 295d60e4cb217f73c28e514f1e05127d6892e0ac (diff) |
use syncs instead of glFinish
Diffstat (limited to 'src/frontend/qt_sdl/main.cpp')
-rw-r--r-- | src/frontend/qt_sdl/main.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index 3e26489..3cae0c5 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -487,20 +487,33 @@ void EmuThread::run() } } +#ifdef OGLRENDERER_ENABLED + if (videoRenderer == 1) + { + FrontBufferLock.lock(); + if (FrontBufferReverseSyncs[FrontBuffer ^ 1]) + glWaitSync(FrontBufferReverseSyncs[FrontBuffer ^ 1], 0, GL_TIMEOUT_IGNORED); + FrontBufferLock.unlock(); + } +#endif + // emulate u32 nlines = NDS::RunFrame(); FrontBufferLock.lock(); + FrontBuffer = GPU::FrontBuffer; #ifdef OGLRENDERER_ENABLED if (videoRenderer == 1) { + if (FrontBufferSyncs[FrontBuffer]) + glDeleteSync(FrontBufferSyncs[FrontBuffer]); + FrontBufferSyncs[FrontBuffer] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); // this is hacky but this is the easiest way to call // this function without dealling with a ton of // macro mess - epoxy_glFinish(); + epoxy_glFlush(); } #endif - FrontBuffer = GPU::FrontBuffer; FrontBufferLock.unlock(); #ifdef MELONCAP @@ -1012,6 +1025,8 @@ void ScreenPanelGL::paintGL() #ifdef OGLRENDERER_ENABLED if (GPU::Renderer != 0) { + if (emuThread->FrontBufferSyncs[emuThread->FrontBuffer]) + glWaitSync(emuThread->FrontBufferSyncs[emuThread->FrontBuffer], 0, GL_TIMEOUT_IGNORED); // hardware-accelerated render GPU::CurGLCompositor->BindOutputTexture(frontbuf); } @@ -1046,16 +1061,15 @@ void ScreenPanelGL::paintGL() } screenShader->release(); + + if (emuThread->FrontBufferReverseSyncs[emuThread->FrontBuffer]) + glDeleteSync(emuThread->FrontBufferReverseSyncs[emuThread->FrontBuffer]); + emuThread->FrontBufferReverseSyncs[emuThread->FrontBuffer] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + emuThread->FrontBufferLock.unlock(); } OSD::Update(this); OSD::DrawGL(this, w*factor, h*factor); - - if (emuThread) - { - glFinish(); - emuThread->FrontBufferLock.unlock(); - } } void ScreenPanelGL::resizeEvent(QResizeEvent* event) |