summaryrefslogtreecommitdiff
path: root/src/common/x64/native_clock.h
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-02-09 16:53:22 -0400
committerGravatar Fernando Sahmkow2020-06-18 16:29:17 -0400
commit234b5ff6a999d7d69cdcdf214e0c3984cdab11cf (patch)
tree4f0ef41d7738b53d1b81ac2f7072bec1ba5fe8f1 /src/common/x64/native_clock.h
parentTests: Add base tests to host timing (diff)
downloadyuzu-234b5ff6a999d7d69cdcdf214e0c3984cdab11cf.tar.gz
yuzu-234b5ff6a999d7d69cdcdf214e0c3984cdab11cf.tar.xz
yuzu-234b5ff6a999d7d69cdcdf214e0c3984cdab11cf.zip
Common: Implement WallClock Interface and implement a native clock for x64
Diffstat (limited to 'src/common/x64/native_clock.h')
-rw-r--r--src/common/x64/native_clock.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/common/x64/native_clock.h b/src/common/x64/native_clock.h
new file mode 100644
index 000000000..b58cf9f5a
--- /dev/null
+++ b/src/common/x64/native_clock.h
@@ -0,0 +1,41 @@
1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <optional>
8
9#include "common/spin_lock.h"
10#include "common/wall_clock.h"
11
12namespace Common {
13
14namespace X64 {
15class NativeClock : public WallClock {
16public:
17 NativeClock(u64 emulated_cpu_frequency, u64 emulated_clock_frequency, u64 rtsc_frequency);
18
19 std::chrono::nanoseconds GetTimeNS() override;
20
21 std::chrono::microseconds GetTimeUS() override;
22
23 std::chrono::milliseconds GetTimeMS() override;
24
25 u64 GetClockCycles() override;
26
27 u64 GetCPUCycles() override;
28
29private:
30 u64 GetRTSC();
31
32 SpinLock rtsc_serialize{};
33 u64 last_measure{};
34 u64 accumulated_ticks{};
35 u64 rtsc_frequency;
36};
37} // namespace X64
38
39u64 EstimateRDTSCFrequency();
40
41} // namespace Common