Qt: Defer texture updates until frame is drawn (fixes #1590)

This commit is contained in:
Vicki Pfau 2020-02-22 02:05:44 +00:00
parent addb7c6114
commit b4cd441ef4
3 changed files with 18 additions and 3 deletions

View File

@ -24,6 +24,7 @@ Misc:
- 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:

View File

@ -327,7 +327,7 @@ PainterGL::PainterGL(QWindow* surface, QOpenGLContext* parent, int forceVersion)
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 @@ void PainterGL::start() {
}
#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 @@ void PainterGL::dequeue() {
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();
}
@ -539,6 +548,10 @@ void PainterGL::dequeueAll() {
if (buffer) {
m_backend->postFrame(m_backend, buffer);
}
if (m_buffer) {
m_free.append(m_buffer);
m_buffer = nullptr;
}
m_mutex.unlock();
}

View File

@ -121,6 +121,7 @@ private:
QList<uint32_t*> m_free;
QQueue<uint32_t*> m_queue;
uint32_t* m_buffer;
QPainter m_painter;
QMutex m_mutex;
QWindow* m_surface;