2022-04-23 08:59:50 +00:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2020-02-09 20:53:22 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common/wall_clock.h"
|
|
|
|
|
2023-04-23 03:08:28 +00:00
|
|
|
namespace Common::X64 {
|
2020-02-09 20:53:22 +00:00
|
|
|
|
2020-09-29 19:19:37 +00:00
|
|
|
class NativeClock final : public WallClock {
|
2020-02-09 20:53:22 +00:00
|
|
|
public:
|
2023-04-23 03:08:28 +00:00
|
|
|
explicit NativeClock(u64 rdtsc_frequency_);
|
2020-02-09 20:53:22 +00:00
|
|
|
|
2023-04-23 03:08:28 +00:00
|
|
|
std::chrono::nanoseconds GetTimeNS() const override;
|
2020-02-09 20:53:22 +00:00
|
|
|
|
2023-04-23 03:08:28 +00:00
|
|
|
std::chrono::microseconds GetTimeUS() const override;
|
2020-02-09 20:53:22 +00:00
|
|
|
|
2023-04-23 03:08:28 +00:00
|
|
|
std::chrono::milliseconds GetTimeMS() const override;
|
2020-02-09 20:53:22 +00:00
|
|
|
|
2023-04-23 03:08:28 +00:00
|
|
|
u64 GetCNTPCT() const override;
|
2020-02-09 20:53:22 +00:00
|
|
|
|
2023-05-28 21:45:47 +00:00
|
|
|
u64 GetGPUTick() const override;
|
|
|
|
|
2023-04-23 03:08:28 +00:00
|
|
|
u64 GetHostTicksNow() const override;
|
2020-02-09 20:53:22 +00:00
|
|
|
|
2023-04-23 03:08:28 +00:00
|
|
|
u64 GetHostTicksElapsed() const override;
|
2020-02-25 16:28:55 +00:00
|
|
|
|
2023-04-23 03:08:28 +00:00
|
|
|
bool IsNative() const override;
|
2022-06-28 20:42:00 +00:00
|
|
|
|
2023-04-23 03:08:28 +00:00
|
|
|
private:
|
|
|
|
u64 start_ticks;
|
|
|
|
u64 rdtsc_frequency;
|
2023-03-05 02:44:31 +00:00
|
|
|
|
2023-04-23 03:08:28 +00:00
|
|
|
u64 ns_rdtsc_factor;
|
|
|
|
u64 us_rdtsc_factor;
|
|
|
|
u64 ms_rdtsc_factor;
|
|
|
|
u64 cntpct_rdtsc_factor;
|
2023-05-28 21:45:47 +00:00
|
|
|
u64 gputick_rdtsc_factor;
|
2020-02-09 20:53:22 +00:00
|
|
|
};
|
|
|
|
|
2023-04-23 03:08:28 +00:00
|
|
|
} // namespace Common::X64
|