CoreTiming: An event due before the slice ends shortens it

Each slice is sized to end at the next queued event, but scheduling a
sooner one didn't touch it, so the new event waited for the old slice to
run out. An alarm set by a thread that kept running went off 175-440us
late. GE enqueues worked around this with hleCoreTimingForceCheck(); now
every caller gets it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-09-30 09:06:30 -06:00
1 parent 3118490ecf
commit 93a0d50384
1 file changed
+10
+10
View File
@@ -15,6 +15,7 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <algorithm>
#include <atomic>
#include <climits>
#include <cstdio>
@@ -289,6 +290,15 @@ void ScheduleEvent(s64 cyclesIntoFuture, int event_type, u64 userdata)
ne->type = event_type;
ne->time = GetTicks(currentMIPS) + cyclesIntoFuture;
AddEventToQueue(ne);
// The slice was sized to end at the next event. If this one is due sooner, end it there, or it
// fires late: an alarm set by a thread that keeps running went off hundreds of us late
// (pspautotests threads/scheduling/alarmcosts).
if (cyclesIntoFuture < currentMIPS->downcount) {
const int diff = (int)std::max<s64>(cyclesIntoFuture, 0) - currentMIPS->downcount;
slicelength += diff;
currentMIPS->downcount += diff;
}
}
// Returns cycles left in timer.