mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix frames getting backlogged (fixes #2122)
This commit is contained in:
parent
ab7cfb9634
commit
0a7f8fa55d
1
CHANGES
1
CHANGES
|
@ -18,6 +18,7 @@ Other fixes:
|
||||||
- Qt: Fix OpenGL renderer lagging behind when fast-forwarding (fixes mgba.io/i/2094)
|
- Qt: Fix OpenGL renderer lagging behind when fast-forwarding (fixes mgba.io/i/2094)
|
||||||
- Qt: Fix smudged window icon on Windows
|
- Qt: Fix smudged window icon on Windows
|
||||||
- Qt: Fix saving settings enabling camera when camera name changes (fixes mgba.io/i/2125)
|
- Qt: Fix saving settings enabling camera when camera name changes (fixes mgba.io/i/2125)
|
||||||
|
- Qt: Fix frames getting backlogged (fixes mgba.io/i/2122)
|
||||||
Misc:
|
Misc:
|
||||||
- Core: Truncate preloading ROMs that slightly exceed max size (fixes mgba.io/i/2093)
|
- Core: Truncate preloading ROMs that slightly exceed max size (fixes mgba.io/i/2093)
|
||||||
- GBA: Default-enable VBA bug compat for Ruby and Emerald ROM hacks
|
- GBA: Default-enable VBA bug compat for Ruby and Emerald ROM hacks
|
||||||
|
|
|
@ -371,7 +371,7 @@ void PainterGL::resizeContext() {
|
||||||
if (m_dims == size) {
|
if (m_dims == size) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dequeueAll();
|
dequeueAll(false);
|
||||||
m_backend->setDimensions(m_backend, size.width(), size.height());
|
m_backend->setDimensions(m_backend, size.width(), size.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,7 +429,7 @@ void PainterGL::start() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PainterGL::draw() {
|
void PainterGL::draw() {
|
||||||
if (!m_active || m_queue.isEmpty()) {
|
if (!m_started || m_queue.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mCoreSync* sync = &m_context->thread()->impl->sync;
|
mCoreSync* sync = &m_context->thread()->impl->sync;
|
||||||
|
@ -461,6 +461,11 @@ void PainterGL::draw() {
|
||||||
performDraw();
|
performDraw();
|
||||||
m_backend->swap(m_backend);
|
m_backend->swap(m_backend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMutexLocker locker(&m_mutex);
|
||||||
|
if (!m_queue.isEmpty()) {
|
||||||
|
QTimer::singleShot(1, this, &PainterGL::draw);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PainterGL::forceDraw() {
|
void PainterGL::forceDraw() {
|
||||||
|
@ -477,7 +482,7 @@ void PainterGL::forceDraw() {
|
||||||
void PainterGL::stop() {
|
void PainterGL::stop() {
|
||||||
m_active = false;
|
m_active = false;
|
||||||
m_started = false;
|
m_started = false;
|
||||||
dequeueAll();
|
dequeueAll(false);
|
||||||
if (m_context) {
|
if (m_context) {
|
||||||
if (m_videoProxy) {
|
if (m_videoProxy) {
|
||||||
m_videoProxy->detach(m_context.get());
|
m_videoProxy->detach(m_context.get());
|
||||||
|
@ -499,6 +504,7 @@ void PainterGL::stop() {
|
||||||
|
|
||||||
void PainterGL::pause() {
|
void PainterGL::pause() {
|
||||||
m_active = false;
|
m_active = false;
|
||||||
|
dequeueAll(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PainterGL::unpause() {
|
void PainterGL::unpause() {
|
||||||
|
@ -551,20 +557,24 @@ void PainterGL::dequeue() {
|
||||||
m_buffer = buffer;
|
m_buffer = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PainterGL::dequeueAll() {
|
void PainterGL::dequeueAll(bool keep) {
|
||||||
|
QMutexLocker locker(&m_mutex);
|
||||||
uint32_t* buffer = 0;
|
uint32_t* buffer = 0;
|
||||||
m_mutex.lock();
|
|
||||||
while (!m_queue.isEmpty()) {
|
while (!m_queue.isEmpty()) {
|
||||||
buffer = m_queue.dequeue();
|
buffer = m_queue.dequeue();
|
||||||
if (buffer) {
|
if (keep) {
|
||||||
|
if (m_buffer && buffer) {
|
||||||
|
m_free.append(m_buffer);
|
||||||
|
m_buffer = buffer;
|
||||||
|
}
|
||||||
|
} else if (buffer) {
|
||||||
m_free.append(buffer);
|
m_free.append(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_buffer) {
|
if (m_buffer && !keep) {
|
||||||
m_free.append(m_buffer);
|
m_free.append(m_buffer);
|
||||||
m_buffer = nullptr;
|
m_buffer = nullptr;
|
||||||
}
|
}
|
||||||
m_mutex.unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PainterGL::setVideoProxy(std::shared_ptr<VideoProxy> proxy) {
|
void PainterGL::setVideoProxy(std::shared_ptr<VideoProxy> proxy) {
|
||||||
|
|
|
@ -136,7 +136,7 @@ private:
|
||||||
void makeCurrent();
|
void makeCurrent();
|
||||||
void performDraw();
|
void performDraw();
|
||||||
void dequeue();
|
void dequeue();
|
||||||
void dequeueAll();
|
void dequeueAll(bool keep = false);
|
||||||
|
|
||||||
std::array<std::array<uint32_t, 0x100000>, 3> m_buffers;
|
std::array<std::array<uint32_t, 0x100000>, 3> m_buffers;
|
||||||
QList<uint32_t*> m_free;
|
QList<uint32_t*> m_free;
|
||||||
|
|
Loading…
Reference in New Issue