mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 06:10:03 -06:00
use syncs instead of glFinish
This commit is contained in:
@ -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
|
// emulate
|
||||||
u32 nlines = NDS::RunFrame();
|
u32 nlines = NDS::RunFrame();
|
||||||
|
|
||||||
FrontBufferLock.lock();
|
FrontBufferLock.lock();
|
||||||
|
FrontBuffer = GPU::FrontBuffer;
|
||||||
#ifdef OGLRENDERER_ENABLED
|
#ifdef OGLRENDERER_ENABLED
|
||||||
if (videoRenderer == 1)
|
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 is hacky but this is the easiest way to call
|
||||||
// this function without dealling with a ton of
|
// this function without dealling with a ton of
|
||||||
// macro mess
|
// macro mess
|
||||||
epoxy_glFinish();
|
epoxy_glFlush();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
FrontBuffer = GPU::FrontBuffer;
|
|
||||||
FrontBufferLock.unlock();
|
FrontBufferLock.unlock();
|
||||||
|
|
||||||
#ifdef MELONCAP
|
#ifdef MELONCAP
|
||||||
@ -1012,6 +1025,8 @@ void ScreenPanelGL::paintGL()
|
|||||||
#ifdef OGLRENDERER_ENABLED
|
#ifdef OGLRENDERER_ENABLED
|
||||||
if (GPU::Renderer != 0)
|
if (GPU::Renderer != 0)
|
||||||
{
|
{
|
||||||
|
if (emuThread->FrontBufferSyncs[emuThread->FrontBuffer])
|
||||||
|
glWaitSync(emuThread->FrontBufferSyncs[emuThread->FrontBuffer], 0, GL_TIMEOUT_IGNORED);
|
||||||
// hardware-accelerated render
|
// hardware-accelerated render
|
||||||
GPU::CurGLCompositor->BindOutputTexture(frontbuf);
|
GPU::CurGLCompositor->BindOutputTexture(frontbuf);
|
||||||
}
|
}
|
||||||
@ -1046,16 +1061,15 @@ void ScreenPanelGL::paintGL()
|
|||||||
}
|
}
|
||||||
|
|
||||||
screenShader->release();
|
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::Update(this);
|
||||||
OSD::DrawGL(this, w*factor, h*factor);
|
OSD::DrawGL(this, w*factor, h*factor);
|
||||||
|
|
||||||
if (emuThread)
|
|
||||||
{
|
|
||||||
glFinish();
|
|
||||||
emuThread->FrontBufferLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenPanelGL::resizeEvent(QResizeEvent* event)
|
void ScreenPanelGL::resizeEvent(QResizeEvent* event)
|
||||||
|
@ -63,6 +63,9 @@ public:
|
|||||||
int FrontBuffer = 0;
|
int FrontBuffer = 0;
|
||||||
QMutex FrontBufferLock;
|
QMutex FrontBufferLock;
|
||||||
|
|
||||||
|
GLsync FrontBufferReverseSyncs[2] = {nullptr, nullptr};
|
||||||
|
GLsync FrontBufferSyncs[2] = {nullptr, nullptr};
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void windowUpdate();
|
void windowUpdate();
|
||||||
void windowTitleChange(QString title);
|
void windowTitleChange(QString title);
|
||||||
|
Reference in New Issue
Block a user