all repos — mgba @ b4cd441ef46c878909431d141bf0bf5e82508178

mGBA Game Boy Advance Emulator

Qt: Defer texture updates until frame is drawn (fixes #1590)
Vicki Pfau vi@endrift.com
Sat, 22 Feb 2020 02:05:44 +0000
commit

b4cd441ef46c878909431d141bf0bf5e82508178

parent

addb7c61149350d78ac7e291bea1218ad3e4890f

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

jump to
M CHANGESCHANGES

@@ -24,6 +24,7 @@ - Qt: Renderer can be changed while a game is running

- Qt: Add hex index to palette view - Qt: Add transformation matrix info to sprite view - Qt: Disable Replace ROM option when no game loaded + - Qt: Defer texture updates until frame is drawn (fixes mgba.io/i/1590) 0.8.1: (2020-02-16) Emulation fixes:
M src/platform/qt/DisplayGL.cppsrc/platform/qt/DisplayGL.cpp

@@ -327,7 +327,7 @@ m_backend->filter = false;

m_backend->lockAspectRatio = false; m_backend->interframeBlending = false; - for (int i = 0; i < 2; ++i) { + for (int i = 0; i < 3; ++i) { m_free.append(new uint32_t[1024 * 2048]); } }

@@ -423,6 +423,7 @@ mGLES2ShaderAttach(reinterpret_cast<mGLES2Context*>(m_backend), static_cast<mGLES2Shader*>(m_shader.passes), m_shader.nPasses);

} #endif + m_buffer = nullptr; m_active = true; m_started = true; }

@@ -490,6 +491,11 @@ void PainterGL::performDraw() {

m_painter.beginNativePainting(); float r = m_surface->devicePixelRatio(); m_backend->resized(m_backend, m_size.width() * r, m_size.height() * r); + if (m_buffer) { + m_backend->postFrame(m_backend, m_buffer); + m_free.append(m_buffer); + m_buffer = nullptr; + } m_backend->drawFrame(m_backend); m_painter.endNativePainting(); if (m_showOSD && m_messagePainter) {

@@ -520,9 +526,12 @@ m_mutex.unlock();

return; } uint32_t* buffer = m_queue.dequeue(); + if (m_buffer) { + m_free.append(m_buffer); + m_buffer = nullptr; + } if (buffer) { - m_backend->postFrame(m_backend, buffer); - m_free.append(buffer); + m_buffer = buffer; } m_mutex.unlock(); }

@@ -538,6 +547,10 @@ }

} if (buffer) { m_backend->postFrame(m_backend, buffer); + } + if (m_buffer) { + m_free.append(m_buffer); + m_buffer = nullptr; } m_mutex.unlock(); }
M src/platform/qt/DisplayGL.hsrc/platform/qt/DisplayGL.h

@@ -121,6 +121,7 @@ void dequeueAll();

QList<uint32_t*> m_free; QQueue<uint32_t*> m_queue; + uint32_t* m_buffer; QPainter m_painter; QMutex m_mutex; QWindow* m_surface;