yuzu-emu
/
yuzu
Archived
1
0
Fork 0

native_clock: Use RealTimeClock instead of SteadyClock

We want to synchronize RDTSC to real time.
This commit is contained in:
Morph 2023-03-05 02:42:48 -05:00
parent 6f9918552c
commit c27a626b5b
1 changed files with 4 additions and 4 deletions

View File

@ -53,11 +53,11 @@ u64 EstimateRDTSCFrequency() {
FencedRDTSC(); FencedRDTSC();
// Get the current time. // Get the current time.
const auto start_time = Common::SteadyClock::Now(); const auto start_time = Common::RealTimeClock::Now();
const u64 tsc_start = FencedRDTSC(); const u64 tsc_start = FencedRDTSC();
// Wait for 250 milliseconds. // Wait for 250 milliseconds.
std::this_thread::sleep_for(std::chrono::milliseconds{250}); std::this_thread::sleep_for(std::chrono::milliseconds{250});
const auto end_time = Common::SteadyClock::Now(); const auto end_time = Common::RealTimeClock::Now();
const u64 tsc_end = FencedRDTSC(); const u64 tsc_end = FencedRDTSC();
// Calculate differences. // Calculate differences.
const u64 timer_diff = static_cast<u64>( const u64 timer_diff = static_cast<u64>(
@ -75,13 +75,13 @@ NativeClock::NativeClock(u64 emulated_cpu_frequency_, u64 emulated_clock_frequen
// Thread to re-adjust the RDTSC frequency after 30 seconds has elapsed. // Thread to re-adjust the RDTSC frequency after 30 seconds has elapsed.
time_sync_thread = std::jthread{[this](std::stop_token token) { time_sync_thread = std::jthread{[this](std::stop_token token) {
// Get the current time. // Get the current time.
const auto start_time = Common::SteadyClock::Now(); const auto start_time = Common::RealTimeClock::Now();
const u64 tsc_start = FencedRDTSC(); const u64 tsc_start = FencedRDTSC();
// Wait for 30 seconds. // Wait for 30 seconds.
if (!Common::StoppableTimedWait(token, std::chrono::seconds{30})) { if (!Common::StoppableTimedWait(token, std::chrono::seconds{30})) {
return; return;
} }
const auto end_time = Common::SteadyClock::Now(); const auto end_time = Common::RealTimeClock::Now();
const u64 tsc_end = FencedRDTSC(); const u64 tsc_end = FencedRDTSC();
// Calculate differences. // Calculate differences.
const u64 timer_diff = static_cast<u64>( const u64 timer_diff = static_cast<u64>(