From 95797b05f1fcc53ad4c932ec171a46bdde4b08de Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 7 Mar 2025 15:49:05 +1000 Subject: [PATCH] GPU: Force early run on GP0 FIFO overflow And don't crash if a game spams GP0 writes and it overflows. --- src/core/gpu.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index 097cabae3..d8f84fa3d 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -531,6 +531,19 @@ void GPU::WriteRegister(u32 offset, u32 value) if (m_gpu_dump) [[unlikely]] m_gpu_dump->WriteGP0Packet(value); + // FIFO can be overflowed through direct GP0 writes if the command tick event hasn't run, because + // there's no backpressure applied to the CPU. Instead force the GPU to run and catch up. + if (m_fifo.GetSize() >= m_fifo_size) [[unlikely]] + { + s_command_tick_event.InvokeEarly(); + + if (m_fifo.GetSize() >= m_fifo.GetCapacity()) [[unlikely]] + { + WARNING_LOG("GPU FIFO overflow via GP0 write, size={}", m_fifo.GetSize()); + return; + } + } + m_fifo.Push(value); ExecuteCommands(); return;