System: Move state display updates to call sites

Fixes black frames when changing settings with runahead/rewind enabled.
This commit is contained in:
Stenzek 2025-01-01 23:05:07 +10:00
parent f3b7686457
commit 37e5e64ddc
No known key found for this signature in database
3 changed files with 24 additions and 18 deletions

View File

@ -243,7 +243,7 @@ void GPU::SoftReset()
UpdateGPUIdle();
}
bool GPU::DoState(StateWrapper& sw, bool update_display)
bool GPU::DoState(StateWrapper& sw)
{
if (sw.IsWriting())
{
@ -378,10 +378,6 @@ bool GPU::DoState(StateWrapper& sw, bool update_display)
UpdateDMARequest();
UpdateCRTCConfig();
UpdateCommandTickEvent();
// If we're paused, need to update the display FB.
if (update_display)
UpdateDisplay(false);
}
else // if not memory state
{
@ -395,7 +391,7 @@ bool GPU::DoState(StateWrapper& sw, bool update_display)
return !sw.HasError();
}
void GPU::DoMemoryState(StateWrapper& sw, System::MemorySaveState& mss, bool update_display)
void GPU::DoMemoryState(StateWrapper& sw, System::MemorySaveState& mss)
{
sw.Do(&m_GPUSTAT.bits);
@ -438,12 +434,6 @@ void GPU::DoMemoryState(StateWrapper& sw, System::MemorySaveState& mss, bool upd
sizeof(GPUBackendDoMemoryStateCommand)));
cmd->memory_save_state = &mss;
GPUThread::PushCommandAndWakeThread(cmd);
if (update_display)
{
DebugAssert(sw.IsReading());
UpdateDisplay(false);
}
}
void GPU::UpdateDMARequest()

View File

@ -97,8 +97,8 @@ public:
void Initialize();
void Shutdown();
void Reset(bool clear_vram);
bool DoState(StateWrapper& sw, bool update_display);
void DoMemoryState(StateWrapper& sw, System::MemorySaveState& mss, bool update_display);
bool DoState(StateWrapper& sw);
void DoMemoryState(StateWrapper& sw, System::MemorySaveState& mss);
// Render statistics debug window.
void DrawDebugStateWindow(float scale);
@ -216,6 +216,9 @@ public:
// Dumps raw VRAM to a file.
bool DumpVRAMToFile(const char* filename);
// Kicks the current frame to the backend for display.
void UpdateDisplay(bool submit_frame);
// Queues the current frame for presentation. Should only be used with runahead.
void QueuePresentCurrentFrame();
@ -296,7 +299,6 @@ private:
void ReadVRAM(u16 x, u16 y, u16 width, u16 height);
void UpdateVRAM(u16 x, u16 y, u16 width, u16 height, const void* data, bool set_mask, bool check_mask);
void UpdateDisplay(bool submit_frame);
void PrepareForDraw();
void FinishPolyline();

View File

@ -1178,6 +1178,10 @@ void System::RecreateGPU(GPURenderer renderer)
}
ClearMemorySaveStates(true, false);
g_gpu.UpdateDisplay(false);
if (IsPaused())
GPUThread::PresentCurrentFrame();
}
void System::LoadSettings(bool display_osd_messages)
@ -2390,7 +2394,7 @@ bool System::DoState(StateWrapper& sw, bool update_display)
if (!sw.DoMarker("InterruptController") || !InterruptController::DoState(sw))
return false;
if (!sw.DoMarker("GPU") || !g_gpu.DoState(sw, update_display))
if (!sw.DoMarker("GPU") || !g_gpu.DoState(sw))
return false;
if (!sw.DoMarker("CDROM") || !CDROM::DoState(sw))
@ -2459,7 +2463,14 @@ bool System::DoState(StateWrapper& sw, bool update_display)
Achievements::ResetClient();
}
return !sw.HasError();
if (sw.HasError())
return false;
// If we're paused, need to update the display FB.
if (update_display)
g_gpu.UpdateDisplay(false);
return true;
}
System::MemorySaveState& System::AllocateMemoryState()
@ -2665,7 +2676,7 @@ void System::DoMemoryState(StateWrapper& sw, MemorySaveState& mss, bool update_d
SAVE_COMPONENT("DMA", DMA::DoState(sw));
SAVE_COMPONENT("InterruptController", InterruptController::DoState(sw));
g_gpu.DoMemoryState(sw, mss, update_display);
g_gpu.DoMemoryState(sw, mss);
SAVE_COMPONENT("CDROM", CDROM::DoState(sw));
SAVE_COMPONENT("Pad", Pad::DoState(sw, true));
@ -2677,6 +2688,9 @@ void System::DoMemoryState(StateWrapper& sw, MemorySaveState& mss, bool update_d
SAVE_COMPONENT("Achievements", Achievements::DoState(sw));
#undef SAVE_COMPONENT
if (update_display)
g_gpu.UpdateDisplay(false);
}
bool System::LoadBIOS(Error* error)