diff options
author | liamwhite <liamwhite@users.noreply.github.com> | 2024-01-25 20:19:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-25 20:19:01 +0100 |
commit | d45561ace069024f47ed710d1165b607644d1ec3 (patch) | |
tree | a316f59c5a722dc15fe5c49b3641d9801c264970 /src/common/wall_clock.cpp | |
parent | Merge pull request #12781 from goldenx86/dozen (diff) | |
parent | Rework time service to fix time passing offline. (diff) | |
download | yuzu-d45561ace069024f47ed710d1165b607644d1ec3.tar yuzu-d45561ace069024f47ed710d1165b607644d1ec3.tar.gz yuzu-d45561ace069024f47ed710d1165b607644d1ec3.tar.bz2 yuzu-d45561ace069024f47ed710d1165b607644d1ec3.tar.lz yuzu-d45561ace069024f47ed710d1165b607644d1ec3.tar.xz yuzu-d45561ace069024f47ed710d1165b607644d1ec3.tar.zst yuzu-d45561ace069024f47ed710d1165b607644d1ec3.zip |
Diffstat (limited to 'src/common/wall_clock.cpp')
-rw-r--r-- | src/common/wall_clock.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp index 012fdc1e0..e14bf3e65 100644 --- a/src/common/wall_clock.cpp +++ b/src/common/wall_clock.cpp @@ -18,42 +18,40 @@ namespace Common { class StandardWallClock final : public WallClock { public: - explicit StandardWallClock() : start_time{SteadyClock::Now()} {} + explicit StandardWallClock() {} std::chrono::nanoseconds GetTimeNS() const override { - return SteadyClock::Now() - start_time; + return std::chrono::duration_cast<std::chrono::nanoseconds>( + std::chrono::system_clock::now().time_since_epoch()); } std::chrono::microseconds GetTimeUS() const override { - return static_cast<std::chrono::microseconds>(GetHostTicksElapsed() / NsToUsRatio::den); + return std::chrono::duration_cast<std::chrono::microseconds>( + std::chrono::system_clock::now().time_since_epoch()); } std::chrono::milliseconds GetTimeMS() const override { - return static_cast<std::chrono::milliseconds>(GetHostTicksElapsed() / NsToMsRatio::den); + return std::chrono::duration_cast<std::chrono::milliseconds>( + std::chrono::system_clock::now().time_since_epoch()); } - u64 GetCNTPCT() const override { - return GetHostTicksElapsed() * NsToCNTPCTRatio::num / NsToCNTPCTRatio::den; + s64 GetCNTPCT() const override { + return GetUptime() * NsToCNTPCTRatio::num / NsToCNTPCTRatio::den; } - u64 GetGPUTick() const override { - return GetHostTicksElapsed() * NsToGPUTickRatio::num / NsToGPUTickRatio::den; + s64 GetGPUTick() const override { + return GetUptime() * NsToGPUTickRatio::num / NsToGPUTickRatio::den; } - u64 GetHostTicksNow() const override { - return static_cast<u64>(SteadyClock::Now().time_since_epoch().count()); - } - - u64 GetHostTicksElapsed() const override { - return static_cast<u64>(GetTimeNS().count()); + s64 GetUptime() const override { + return std::chrono::duration_cast<std::chrono::nanoseconds>( + std::chrono::steady_clock::now().time_since_epoch()) + .count(); } bool IsNative() const override { return false; } - -private: - SteadyClock::time_point start_time; }; std::unique_ptr<WallClock> CreateOptimalClock() { |