summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2022-01-30 18:57:23 +0100
committerMorph <39850852+Morph1984@users.noreply.github.com>2022-01-30 18:57:23 +0100
commit6267110b694d3b3f8a8561c61ad6b4a4548873b5 (patch)
tree5255d1ef13ff15fd65c4dfa535b366856cbd8c85
parentcommon: wall_clock: Utilize constants for ms, us, and ns ratios (diff)
downloadyuzu-6267110b694d3b3f8a8561c61ad6b4a4548873b5.tar
yuzu-6267110b694d3b3f8a8561c61ad6b4a4548873b5.tar.gz
yuzu-6267110b694d3b3f8a8561c61ad6b4a4548873b5.tar.bz2
yuzu-6267110b694d3b3f8a8561c61ad6b4a4548873b5.tar.lz
yuzu-6267110b694d3b3f8a8561c61ad6b4a4548873b5.tar.xz
yuzu-6267110b694d3b3f8a8561c61ad6b4a4548873b5.tar.zst
yuzu-6267110b694d3b3f8a8561c61ad6b4a4548873b5.zip
-rw-r--r--src/common/wall_clock.cpp16
-rw-r--r--src/common/wall_clock.h4
2 files changed, 12 insertions, 8 deletions
diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp
index 081e0562f..9acf7551e 100644
--- a/src/common/wall_clock.cpp
+++ b/src/common/wall_clock.cpp
@@ -65,16 +65,20 @@ private:
#ifdef ARCHITECTURE_x86_64
-std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
- u32 emulated_clock_frequency) {
+std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency,
+ u64 emulated_clock_frequency) {
const auto& caps = GetCPUCaps();
u64 rtsc_frequency = 0;
if (caps.invariant_tsc) {
rtsc_frequency = EstimateRDTSCFrequency();
}
- // Fallback to StandardWallClock if the hardware TSC does not have nanosecond precision.
- if (rtsc_frequency <= WallClock::NS_RATIO) {
+ // Fallback to StandardWallClock if the hardware TSC does not have the precision greater than:
+ // - A nanosecond
+ // - The emulated CPU frequency
+ // - The emulated clock counter frequency (CNTFRQ)
+ if (rtsc_frequency <= WallClock::NS_RATIO || rtsc_frequency <= emulated_cpu_frequency ||
+ rtsc_frequency <= emulated_clock_frequency) {
return std::make_unique<StandardWallClock>(emulated_cpu_frequency,
emulated_clock_frequency);
} else {
@@ -85,8 +89,8 @@ std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
#else
-std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
- u32 emulated_clock_frequency) {
+std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency,
+ u64 emulated_clock_frequency) {
return std::make_unique<StandardWallClock>(emulated_cpu_frequency, emulated_clock_frequency);
}
diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h
index 4d132c531..874448c27 100644
--- a/src/common/wall_clock.h
+++ b/src/common/wall_clock.h
@@ -53,7 +53,7 @@ private:
bool is_native;
};
-[[nodiscard]] std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
- u32 emulated_clock_frequency);
+[[nodiscard]] std::unique_ptr<WallClock> CreateBestMatchingClock(u64 emulated_cpu_frequency,
+ u64 emulated_clock_frequency);
} // namespace Common