From 118736ff754b2de6f362e298fa028f4720d6d328 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 23 Jun 2014 23:02:46 -0700 Subject: [PATCH] Don't eat extra cycles when idling. Rescheduling between threads takes about 3000 cycles, but that's not true for both sides of e.g. a delay. Fixes #6409 (assuming 60fps is what a PSP gets.) --- Core/HLE/sceKernelThread.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index f4897e3091..051b8940f8 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -3216,9 +3216,9 @@ void __KernelSwitchContext(Thread *target, const char *reason) else __SetCurrentThread(NULL, 0, NULL); + const bool fromIdle = oldUID == threadIdleID[0] || oldUID == threadIdleID[1]; + const bool toIdle = currentThread == threadIdleID[0] || currentThread == threadIdleID[1]; #if DEBUG_LEVEL <= MAX_LOGLEVEL || DEBUG_LOG == NOTICE_LOG - bool fromIdle = oldUID == threadIdleID[0] || oldUID == threadIdleID[1]; - bool toIdle = currentThread == threadIdleID[0] || currentThread == threadIdleID[1]; if (!(fromIdle && toIdle)) { u64 nowCycles = CoreTiming::GetTicks(); @@ -3235,7 +3235,13 @@ void __KernelSwitchContext(Thread *target, const char *reason) #endif // Switching threads eats some cycles. This is a low approximation. - currentMIPS->downcount -= 3000; + if (fromIdle && toIdle) { + // Don't eat any cycles going between idle. + } else if (fromIdle || toIdle) { + currentMIPS->downcount -= 1500; + } else { + currentMIPS->downcount -= 3000; + } if (target) {