summaryrefslogtreecommitdiffstats
path: root/src/libs/dxvk-native-1.9.2a/src/util/util_time.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/dxvk-native-1.9.2a/src/util/util_time.h')
-rw-r--r--src/libs/dxvk-native-1.9.2a/src/util/util_time.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/libs/dxvk-native-1.9.2a/src/util/util_time.h b/src/libs/dxvk-native-1.9.2a/src/util/util_time.h
new file mode 100644
index 00000000..cbadfa5d
--- /dev/null
+++ b/src/libs/dxvk-native-1.9.2a/src/util/util_time.h
@@ -0,0 +1,50 @@
+#pragma once
+
+#include <chrono>
+#include <cstdint>
+
+#if defined(_WIN32) && !defined(__WINE__)
+#include <windows.h>
+#endif
+
+namespace dxvk {
+
+#if defined(_WIN32) && !defined(__WINE__)
+ struct high_resolution_clock {
+ static constexpr bool is_steady = true;
+
+ using rep = int64_t;
+ using period = std::nano;
+ using duration = std::chrono::nanoseconds;
+ using time_point = std::chrono::time_point<high_resolution_clock>;
+
+ static inline time_point now() noexcept {
+ // Keep the frequency static, this doesn't change at all.
+ static const int64_t freq = getFrequency();
+ const int64_t counter = getCounter();
+
+ const int64_t whole = (counter / freq) * period::den;
+ const int64_t part = (counter % freq) * period::den / freq;
+
+ return time_point(duration(whole + part));
+ }
+
+ static inline int64_t getFrequency() {
+ LARGE_INTEGER freq;
+ QueryPerformanceFrequency(&freq);
+
+ return freq.QuadPart;
+ }
+
+ static inline int64_t getCounter() {
+ LARGE_INTEGER count;
+ QueryPerformanceCounter(&count);
+
+ return count.QuadPart;
+ }
+ };
+#else
+ using high_resolution_clock = std::chrono::high_resolution_clock;
+#endif
+
+} \ No newline at end of file