From f91b895c9a3546150b25af1adc1b3148664b9a6c Mon Sep 17 00:00:00 2001 From: Triang3l Date: Mon, 13 Sep 2021 23:13:02 +0300 Subject: [PATCH] [Base] Don't use raw clock where unsupported --- src/xenia/base/clock.cc | 10 ++++++---- src/xenia/base/clock.h | 9 +++++++++ src/xenia/base/clock_x64.cc | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/xenia/base/clock.cc b/src/xenia/base/clock.cc index e5c237101..058eae43a 100644 --- a/src/xenia/base/clock.cc +++ b/src/xenia/base/clock.cc @@ -109,18 +109,20 @@ inline uint64_t QueryGuestSystemTimeOffset() { } uint64_t Clock::QueryHostTickFrequency() { +#if XE_CLOCK_RAW_AVAILABLE if (cvars::clock_source_raw) { return host_tick_frequency_raw(); - } else { - return host_tick_frequency_platform(); } +#endif + return host_tick_frequency_platform(); } uint64_t Clock::QueryHostTickCount() { +#if XE_CLOCK_RAW_AVAILABLE if (cvars::clock_source_raw) { return host_tick_count_raw(); - } else { - return host_tick_count_platform(); } +#endif + return host_tick_count_platform(); } double Clock::guest_time_scalar() { return guest_time_scalar_; } diff --git a/src/xenia/base/clock.h b/src/xenia/base/clock.h index 9ab3728c4..eeee36fb8 100644 --- a/src/xenia/base/clock.h +++ b/src/xenia/base/clock.h @@ -13,6 +13,11 @@ #include #include "xenia/base/cvar.h" +#include "xenia/base/platform.h" + +#if XE_ARCH_AMD64 +#define XE_CLOCK_RAW_AVAILABLE 1 +#endif DECLARE_bool(clock_no_scaling); DECLARE_bool(clock_source_raw); @@ -24,10 +29,14 @@ class Clock { // Host ticks-per-second. Generally QueryHostTickFrequency should be used. // Either from platform suplied time source or from hardware directly. static uint64_t host_tick_frequency_platform(); +#if XE_CLOCK_RAW_AVAILABLE static uint64_t host_tick_frequency_raw(); +#endif // Host tick count. Generally QueryHostTickCount() should be used. static uint64_t host_tick_count_platform(); +#if XE_CLOCK_RAW_AVAILABLE static uint64_t host_tick_count_raw(); +#endif // Queries the host tick frequency. static uint64_t QueryHostTickFrequency(); diff --git a/src/xenia/base/clock_x64.cc b/src/xenia/base/clock_x64.cc index 3a573f489..e84d5baf2 100644 --- a/src/xenia/base/clock_x64.cc +++ b/src/xenia/base/clock_x64.cc @@ -7,11 +7,11 @@ ****************************************************************************** */ +#include "xenia/base/clock.h" #include "xenia/base/platform.h" -#if XE_ARCH_AMD64 +#if XE_ARCH_AMD64 && XE_CLOCK_RAW_AVAILABLE -#include "xenia/base/clock.h" #include "xenia/base/logging.h" // Wrap all these different cpu compiler intrinsics.