Convert CPU caps into a global instead of MT safe global

This commit is contained in:
lizzie 2026-05-23 21:08:24 +00:00
parent bb4e264fc4
commit f123ba00c5
9 changed files with 31 additions and 35 deletions

View file

@ -76,13 +76,12 @@ CPUCaps::Manufacturer CPUCaps::ParseManufacturer(std::string_view brand_string)
return Manufacturer::Unknown;
}
// Detects the various CPU features
static CPUCaps Detect() {
/// @brief Detects the various CPU features
const CPUCaps g_cpu_caps = [] {
CPUCaps caps = {};
// Assumes the CPU supports the CPUID instruction. Those that don't would likely not support
// yuzu at all anyway
int cpu_id[4];
// Detect CPU's CPUID capabilities and grab manufacturer string
@ -197,14 +196,8 @@ static CPUCaps Detect() {
caps.max_frequency = cpu_id[1];
caps.bus_frequency = cpu_id[2];
}
return caps;
}
const CPUCaps& GetCPUCaps() {
static CPUCaps caps = Detect();
return caps;
}
}();
std::optional<int> GetProcessorCount() {
#if defined(_WIN32)

View file

@ -70,11 +70,8 @@ struct CPUCaps {
bool waitpkg : 1;
};
/**
* Gets the supported capabilities of the host CPU
* @return Reference to a CPUCaps struct with the detected host CPU capabilities
*/
const CPUCaps& GetCPUCaps();
/// @brief Global cpu caps
extern const CPUCaps g_cpu_caps;
/// Detects CPU core count
std::optional<int> GetProcessorCount();