2020-02-09 12:53:22 -08:00
|
|
|
// Copyright 2020 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <chrono>
|
2020-02-10 07:20:40 -08:00
|
|
|
#include <memory>
|
2020-02-09 12:53:22 -08:00
|
|
|
|
|
|
|
#include "common/common_types.h"
|
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
|
|
|
|
class WallClock {
|
|
|
|
public:
|
2020-02-10 07:20:40 -08:00
|
|
|
/// Returns current wall time in nanoseconds
|
2020-02-09 12:53:22 -08:00
|
|
|
virtual std::chrono::nanoseconds GetTimeNS() = 0;
|
2020-02-10 07:20:40 -08:00
|
|
|
|
|
|
|
/// Returns current wall time in microseconds
|
2020-02-09 12:53:22 -08:00
|
|
|
virtual std::chrono::microseconds GetTimeUS() = 0;
|
2020-02-10 07:20:40 -08:00
|
|
|
|
|
|
|
/// Returns current wall time in milliseconds
|
2020-02-09 12:53:22 -08:00
|
|
|
virtual std::chrono::milliseconds GetTimeMS() = 0;
|
2020-02-10 07:20:40 -08:00
|
|
|
|
|
|
|
/// Returns current wall time in emulated clock cycles
|
2020-02-09 12:53:22 -08:00
|
|
|
virtual u64 GetClockCycles() = 0;
|
2020-02-10 07:20:40 -08:00
|
|
|
|
|
|
|
/// Returns current wall time in emulated cpu cycles
|
2020-02-09 12:53:22 -08:00
|
|
|
virtual u64 GetCPUCycles() = 0;
|
|
|
|
|
2020-02-25 08:28:55 -08:00
|
|
|
virtual void Pause(bool is_paused) = 0;
|
|
|
|
|
2020-02-09 12:53:22 -08:00
|
|
|
/// 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;
|
|
|
|
};
|
|
|
|
|
2020-02-10 09:33:13 -08:00
|
|
|
std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
|
|
|
|
u32 emulated_clock_frequency);
|
2020-02-09 12:53:22 -08:00
|
|
|
|
|
|
|
} // namespace Common
|