mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-19 19:15:26 +00:00
Enable Time-based TSC for non-Ryzen CPUs
This commit is contained in:
parent
57b6ced957
commit
394fc8eb79
2 changed files with 15 additions and 4 deletions
|
@ -147,7 +147,7 @@ u64 convert_to_timebased_time(u64 time)
|
|||
|
||||
u64 get_timebased_time()
|
||||
{
|
||||
if (0) if (u64 freq = utils::get_tsc_freq())
|
||||
if (u64 freq = utils::get_tsc_freq())
|
||||
{
|
||||
const u64 tsc = utils::get_tsc();
|
||||
|
||||
|
@ -207,7 +207,7 @@ void initialize_timebased_time(u64 timebased_init, bool reset)
|
|||
// Returns some relative time in microseconds, don't change this fact
|
||||
u64 get_system_time()
|
||||
{
|
||||
if (0) if (u64 freq = utils::get_tsc_freq())
|
||||
if (u64 freq = utils::get_tsc_freq())
|
||||
{
|
||||
const u64 tsc = utils::get_tsc();
|
||||
|
||||
|
|
|
@ -524,7 +524,7 @@ std::string utils::get_system_info()
|
|||
}
|
||||
else
|
||||
{
|
||||
fmt::append(result, " | TSC: Bad");
|
||||
fmt::append(result, " | TSC: Disabled");
|
||||
}
|
||||
|
||||
if (has_avx())
|
||||
|
@ -772,15 +772,26 @@ static const bool s_tsc_freq_evaluated = []() -> bool
|
|||
#endif
|
||||
|
||||
if (!utils::has_invariant_tsc())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (utils::get_cpu_brand().find("Ryzen") != umax)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER freq;
|
||||
if (!QueryPerformanceFrequency(&freq))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (freq.QuadPart <= 9'999'999)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const ullong timer_freq = freq.QuadPart;
|
||||
#else
|
||||
|
@ -880,7 +891,7 @@ static const bool s_tsc_freq_evaluated = []() -> bool
|
|||
return round_tsc(res, utils::mul_saturate<u64>(utils::add_saturate<u64>(rdtsc_diff[0], rdtsc_diff[1]), utils::aligned_div(timer_freq, timer_data[1] - timer_data[0])));
|
||||
}();
|
||||
|
||||
atomic_storage<u64>::release(utils::s_tsc_freq, cal_tsc);
|
||||
atomic_storage<u64>::store(utils::s_tsc_freq, cal_tsc);
|
||||
return true;
|
||||
}();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue