diff --git a/GPU/Software/BinManager.cpp b/GPU/Software/BinManager.cpp index 89263806e2..81c1405c74 100644 --- a/GPU/Software/BinManager.cpp +++ b/GPU/Software/BinManager.cpp @@ -791,6 +791,8 @@ void BinManager::MakeRoom() { // It looks at the tiles again only when distributed_ says there's new work: reading their heads and tails over // and over took cache lines from the emulation thread, which writes the tails. void BinManager::LingerForWork(int start) { + if (!THREADS_LINGER) + return; double until = time_now_d() + LINGER_SECONDS; while (!waitingForIdle_.load(std::memory_order_relaxed)) { // Read before the look at the tiles, so work distributed during it isn't missed. diff --git a/GPU/Software/BinManager.h b/GPU/Software/BinManager.h index 0749026489..4757835ecb 100644 --- a/GPU/Software/BinManager.h +++ b/GPU/Software/BinManager.h @@ -17,6 +17,8 @@ #pragma once +#include "ppsspp_config.h" + #include #include #include "GPU/Software/Rasterizer.h" @@ -212,10 +214,22 @@ public: ~BinManager(); // More threads drawing slow the emulation thread down more than they help it, by taking from its core's - // share of power and clock speed (and with SMT, the core): in God of War and Wipeout on a 16 core Ryzen, - // six beat four, eight and all 31 the thread manager has. Under WSL2, where waking threads costs more than on - // bare metal: measure again there. + // share of power and clock speed (and with SMT, the core): in God of War and Wipeout on a 16 core Ryzen under + // WSL2, six beat four, eight and all 31 the thread manager has. An M1 does best with seven or eight. +#if PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(IOS) + static constexpr int MAX_DRAW_THREADS = 8; +#else static constexpr int MAX_DRAW_THREADS = 6; +#endif + // Whether drawing and transform threads out of work wait a moment for more, spinning, rather than end their + // tasks. Under WSL2, where waking a thread costs the waker about 15 us, it saved 4-8% of wall time; on macOS, + // where it's cheap, it cost wall time at every length tried. Not on Android either, where spinning costs + // battery. Unmeasured on native Windows and Linux. +#if (PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(LINUX)) && !PPSSPP_PLATFORM(ANDROID) + static constexpr bool THREADS_LINGER = true; +#else + static constexpr bool THREADS_LINGER = false; +#endif void UpdateState(); void UpdateClut(const void *src); diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index b6e7b08bdc..c7db7bd840 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -89,6 +89,8 @@ struct TransformUnit::RunJob { } // A run after lastGen with chunks left to take, within the time a helper waits for one. bool WaitForRun(uint32_t lastGen, uint32_t *newGen) { + if (!BinManager::THREADS_LINGER) + return false; const double until = time_now_d() + LINGER_SECONDS; do { const uint64_t v = claim.load(std::memory_order_acquire);