From f41f73f6c3230428ed0fb761e39054c63371c8f6 Mon Sep 17 00:00:00 2001 From: Silent Date: Thu, 30 Dec 2021 21:33:36 +0100 Subject: [PATCH] Fixup Win10 CPU Sets to check the EfficiencyClass Instead of picking the first physical core for Xbox threads, Cxbx-R now picks the first highest performance physical core. While at least Alder Lake lists performance cores first, this is not guaranteed to always be the case in the future. --- src/common/win32/Threads.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/common/win32/Threads.cpp b/src/common/win32/Threads.cpp index b9d07cf3f..d14e7b076 100644 --- a/src/common/win32/Threads.cpp +++ b/src/common/win32/Threads.cpp @@ -151,12 +151,16 @@ public: cpuSets.erase(cpuSets.begin()); } // Otherwise: Multiple physical cores - // Assign the first logical and physical core to Xbox, leave the rest of that - // physical core unassigned (if hyperthreading is active), the remaining - // physical cores to other threads + // Assign the first highest performance logical and physical core to Xbox, + // leave the rest of that physical core unassigned (if hyperthreading is active), + // give the remaining physical cores to other threads else { - const BYTE physicalCore = cpuSets[0]->CoreIndex; - m_xboxCPUSet = cpuSets[0]->Id; + auto highPerfCore = std::max_element(cpuSets.begin(), cpuSets.end(), [](const auto* left, const auto* right) + { + return left->EfficiencyClass < right->EfficiencyClass; + }); + const BYTE physicalCore = (*highPerfCore)->CoreIndex; + m_xboxCPUSet = (*highPerfCore)->Id; for (auto it = cpuSets.begin(); it != cpuSets.end(); ) { if ((*it)->CoreIndex == physicalCore) { it = cpuSets.erase(it);