Skip to content

Commit

Permalink
Counters: Move input poll to after throttle
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Jan 27, 2024
1 parent 5eacab3 commit 77a6525
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pcsx2-gsrunner/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; });
Expand Down
2 changes: 1 addition & 1 deletion pcsx2-qt/QtHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions pcsx2/Counters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 4 additions & 2 deletions pcsx2/VMManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pcsx2/VMManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ namespace VMManager
void ELFLoadingOnCPUThread(std::string elf_path);
void EntryPointCompilingOnCPUThread();
void VSyncOnCPUThread();
void PollInputOnCPUThread();
} // namespace Internal
} // namespace VMManager

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/ctest/core/StubHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void Host::RequestVMShutdown(bool allow_confirm, bool allow_save_state, bool def
{
}

void Host::VSyncOnCPUThread()
void Host::PumpMessagesOnCPUThread()
{
}

Expand Down

0 comments on commit 77a6525

Please sign in to comment.