summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core_timing.cpp9
-rw-r--r--src/core/core_timing.h8
2 files changed, 14 insertions, 3 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index 4f0a3f8ea..e6112a3c9 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -253,9 +253,6 @@ void CoreTiming::ThreadLoop() {
253 auto wait_time = *next_time - GetGlobalTimeNs().count(); 253 auto wait_time = *next_time - GetGlobalTimeNs().count();
254 if (wait_time > 0) { 254 if (wait_time > 0) {
255#ifdef _WIN32 255#ifdef _WIN32
256 const auto timer_resolution_ns =
257 Common::Windows::GetCurrentTimerResolution().count();
258
259 while (!paused && !event.IsSet() && wait_time > 0) { 256 while (!paused && !event.IsSet() && wait_time > 0) {
260 wait_time = *next_time - GetGlobalTimeNs().count(); 257 wait_time = *next_time - GetGlobalTimeNs().count();
261 258
@@ -316,4 +313,10 @@ std::chrono::microseconds CoreTiming::GetGlobalTimeUs() const {
316 return std::chrono::microseconds{Common::WallClock::CPUTickToUS(cpu_ticks)}; 313 return std::chrono::microseconds{Common::WallClock::CPUTickToUS(cpu_ticks)};
317} 314}
318 315
316#ifdef _WIN32
317void CoreTiming::SetTimerResolutionNs(std::chrono::nanoseconds ns) {
318 timer_resolution_ns = ns.count();
319}
320#endif
321
319} // namespace Core::Timing 322} // namespace Core::Timing
diff --git a/src/core/core_timing.h b/src/core/core_timing.h
index 10db1de55..5bca1c78d 100644
--- a/src/core/core_timing.h
+++ b/src/core/core_timing.h
@@ -131,6 +131,10 @@ public:
131 /// Checks for events manually and returns time in nanoseconds for next event, threadsafe. 131 /// Checks for events manually and returns time in nanoseconds for next event, threadsafe.
132 std::optional<s64> Advance(); 132 std::optional<s64> Advance();
133 133
134#ifdef _WIN32
135 void SetTimerResolutionNs(std::chrono::nanoseconds ns);
136#endif
137
134private: 138private:
135 struct Event; 139 struct Event;
136 140
@@ -143,6 +147,10 @@ private:
143 147
144 s64 global_timer = 0; 148 s64 global_timer = 0;
145 149
150#ifdef _WIN32
151 s64 timer_resolution_ns;
152#endif
153
146 // The queue is a min-heap using std::make_heap/push_heap/pop_heap. 154 // The queue is a min-heap using std::make_heap/push_heap/pop_heap.
147 // We don't use std::priority_queue because we need to be able to serialize, unserialize and 155 // We don't use std::priority_queue because we need to be able to serialize, unserialize and
148 // erase arbitrary events (RemoveEvent()) regardless of the queue order. These aren't 156 // erase arbitrary events (RemoveEvent()) regardless of the queue order. These aren't