From 77a65255564c38221a000902bcb0fd3382deb972 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 26 Jan 2024 21:27:36 +1000 Subject: [PATCH] Counters: Move input poll to after throttle --- pcsx2-gsrunner/Main.cpp | 2 +- pcsx2-qt/QtHost.cpp | 2 +- pcsx2/Counters.cpp | 3 +++ pcsx2/VMManager.cpp | 6 ++++-- pcsx2/VMManager.h | 3 ++- tests/ctest/core/StubHost.cpp | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pcsx2-gsrunner/Main.cpp b/pcsx2-gsrunner/Main.cpp index cfb61e74cb..ffa89abc04 100644 --- a/pcsx2-gsrunner/Main.cpp +++ b/pcsx2-gsrunner/Main.cpp @@ -707,7 +707,7 @@ int main(int argc, char* argv[]) return EXIT_SUCCESS; } -void Host::VSyncOnCPUThread() +void Host::PumpMessagesOnCPUThread() { // update GS thread copy of frame number MTGS::RunOnGSThread([frame_number = GSDumpReplayer::GetFrameNumber()]() { s_dump_frame_number = frame_number; }); diff --git a/pcsx2-qt/QtHost.cpp b/pcsx2-qt/QtHost.cpp index ef3d00bd1f..8fc16565d1 100644 --- a/pcsx2-qt/QtHost.cpp +++ b/pcsx2-qt/QtHost.cpp @@ -1122,7 +1122,7 @@ void Host::OnCreateMemoryCardOpenRequested() emit g_emu_thread->onCreateMemoryCardOpenRequested(); } -void Host::VSyncOnCPUThread() +void Host::PumpMessagesOnCPUThread() { g_emu_thread->getEventLoop()->processEvents(QEventLoop::AllEvents); } diff --git a/pcsx2/Counters.cpp b/pcsx2/Counters.cpp index 47e8fbb401..062aa17466 100644 --- a/pcsx2/Counters.cpp +++ b/pcsx2/Counters.cpp @@ -498,6 +498,9 @@ static __fi void VSyncStart(u32 sCycle) gsPostVsyncStart(); // MUST be after framelimit; doing so before causes funk with frame times! + // Poll input after MTGS frame push, just in case it has to stall to catch up. + VMManager::Internal::PollInputOnCPUThread(); + if (EmuConfig.Trace.Enabled && EmuConfig.Trace.EE.m_EnableAll) SysTrace.EE.Counters.Write(" ================ EE COUNTER VSYNC START (frame: %d) ================", g_FrameCount); diff --git a/pcsx2/VMManager.cpp b/pcsx2/VMManager.cpp index c04dc86960..a7f6be821e 100644 --- a/pcsx2/VMManager.cpp +++ b/pcsx2/VMManager.cpp @@ -2484,11 +2484,13 @@ void VMManager::Internal::VSyncOnCPUThread() Achievements::FrameUpdate(); PollDiscordPresence(); +} +void VMManager::Internal::PollInputOnCPUThread() +{ + Host::PumpMessagesOnCPUThread(); InputManager::PollSources(); - Host::VSyncOnCPUThread(); - if (EmuConfig.EnableRecordingTools) { // This code is called _before_ Counter's vsync end, and _after_ vsync start diff --git a/pcsx2/VMManager.h b/pcsx2/VMManager.h index 5090a99298..9afa447093 100644 --- a/pcsx2/VMManager.h +++ b/pcsx2/VMManager.h @@ -272,6 +272,7 @@ namespace VMManager void ELFLoadingOnCPUThread(std::string elf_path); void EntryPointCompilingOnCPUThread(); void VSyncOnCPUThread(); + void PollInputOnCPUThread(); } // namespace Internal } // namespace VMManager @@ -317,5 +318,5 @@ namespace Host const std::string& disc_serial, u32 disc_crc, u32 current_crc); /// Provided by the host; called once per frame at guest vsync. - void VSyncOnCPUThread(); + void PumpMessagesOnCPUThread(); } // namespace Host diff --git a/tests/ctest/core/StubHost.cpp b/tests/ctest/core/StubHost.cpp index 23ea03336f..b6f66e5db1 100644 --- a/tests/ctest/core/StubHost.cpp +++ b/tests/ctest/core/StubHost.cpp @@ -169,7 +169,7 @@ void Host::RequestVMShutdown(bool allow_confirm, bool allow_save_state, bool def { } -void Host::VSyncOnCPUThread() +void Host::PumpMessagesOnCPUThread() { }