mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 21:38:01 +03: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()
|
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();
|
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
|
// Returns some relative time in microseconds, don't change this fact
|
||||||
u64 get_system_time()
|
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();
|
const u64 tsc = utils::get_tsc();
|
||||||
|
|
||||||
|
|
|
@ -524,7 +524,7 @@ std::string utils::get_system_info()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fmt::append(result, " | TSC: Bad");
|
fmt::append(result, " | TSC: Disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_avx())
|
if (has_avx())
|
||||||
|
@ -772,15 +772,26 @@ static const bool s_tsc_freq_evaluated = []() -> bool
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!utils::has_invariant_tsc())
|
if (!utils::has_invariant_tsc())
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (utils::get_cpu_brand().find("Ryzen") != umax)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
LARGE_INTEGER freq;
|
LARGE_INTEGER freq;
|
||||||
if (!QueryPerformanceFrequency(&freq))
|
if (!QueryPerformanceFrequency(&freq))
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (freq.QuadPart <= 9'999'999)
|
if (freq.QuadPart <= 9'999'999)
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const ullong timer_freq = freq.QuadPart;
|
const ullong timer_freq = freq.QuadPart;
|
||||||
#else
|
#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])));
|
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;
|
return true;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue