diff options
author | Ameer <aj662@drexel.edu> | 2020-07-04 06:59:40 +0200 |
---|---|---|
committer | Ameer <aj662@drexel.edu> | 2020-07-04 06:59:40 +0200 |
commit | f829932ed191ad469df01342191bf2725e8a20bb (patch) | |
tree | 0ae185ce3ef43ef9b085aae7b9ad5abb04e3d239 /src/common/wall_clock.h | |
parent | Fix for always firing triggers on some controllers, trigger threshold more universal (diff) | |
parent | Merge pull request #4218 from ogniK5377/opus-external (diff) | |
download | yuzu-f829932ed191ad469df01342191bf2725e8a20bb.tar yuzu-f829932ed191ad469df01342191bf2725e8a20bb.tar.gz yuzu-f829932ed191ad469df01342191bf2725e8a20bb.tar.bz2 yuzu-f829932ed191ad469df01342191bf2725e8a20bb.tar.lz yuzu-f829932ed191ad469df01342191bf2725e8a20bb.tar.xz yuzu-f829932ed191ad469df01342191bf2725e8a20bb.tar.zst yuzu-f829932ed191ad469df01342191bf2725e8a20bb.zip |
Diffstat (limited to 'src/common/wall_clock.h')
-rw-r--r-- | src/common/wall_clock.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h new file mode 100644 index 000000000..367d72134 --- /dev/null +++ b/src/common/wall_clock.h @@ -0,0 +1,53 @@ +// Copyright 2020 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <chrono> +#include <memory> + +#include "common/common_types.h" + +namespace Common { + +class WallClock { +public: + /// Returns current wall time in nanoseconds + virtual std::chrono::nanoseconds GetTimeNS() = 0; + + /// Returns current wall time in microseconds + virtual std::chrono::microseconds GetTimeUS() = 0; + + /// Returns current wall time in milliseconds + virtual std::chrono::milliseconds GetTimeMS() = 0; + + /// Returns current wall time in emulated clock cycles + virtual u64 GetClockCycles() = 0; + + /// Returns current wall time in emulated cpu cycles + virtual u64 GetCPUCycles() = 0; + + virtual void Pause(bool is_paused) = 0; + + /// Tells if the wall clock, uses the host CPU's hardware clock + bool IsNative() const { + return is_native; + } + +protected: + WallClock(u64 emulated_cpu_frequency, u64 emulated_clock_frequency, bool is_native) + : emulated_cpu_frequency{emulated_cpu_frequency}, + emulated_clock_frequency{emulated_clock_frequency}, is_native{is_native} {} + + u64 emulated_cpu_frequency; + u64 emulated_clock_frequency; + +private: + bool is_native; +}; + +std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, + u32 emulated_clock_frequency); + +} // namespace Common |