summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2020-02-25 17:28:55 +0100
committerFernando Sahmkow <fsahmkow27@gmail.com>2020-06-27 17:35:10 +0200
commit18dcb0934217628711c5b1d22fd6d7635e683e3f (patch)
tree426f78eb11aa79e0d1c7470b966fbae8ea8e3e6d /src
parentAudioCore: Use nanoseconds instead of cycles for buffer time. (diff)
downloadyuzu-18dcb0934217628711c5b1d22fd6d7635e683e3f.tar
yuzu-18dcb0934217628711c5b1d22fd6d7635e683e3f.tar.gz
yuzu-18dcb0934217628711c5b1d22fd6d7635e683e3f.tar.bz2
yuzu-18dcb0934217628711c5b1d22fd6d7635e683e3f.tar.lz
yuzu-18dcb0934217628711c5b1d22fd6d7635e683e3f.tar.xz
yuzu-18dcb0934217628711c5b1d22fd6d7635e683e3f.tar.zst
yuzu-18dcb0934217628711c5b1d22fd6d7635e683e3f.zip
Diffstat (limited to 'src')
-rw-r--r--src/common/wall_clock.cpp4
-rw-r--r--src/common/wall_clock.h2
-rw-r--r--src/common/x64/native_clock.cpp7
-rw-r--r--src/common/x64/native_clock.h2
-rw-r--r--src/core/core.cpp2
-rw-r--r--src/core/core_timing.cpp6
-rw-r--r--src/core/core_timing.h1
7 files changed, 23 insertions, 1 deletions
diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp
index d4d35f4e7..a46db6bbf 100644
--- a/src/common/wall_clock.cpp
+++ b/src/common/wall_clock.cpp
@@ -53,6 +53,10 @@ public:
return Common::Divide128On32(temporary, 1000000000).first;
}
+ void Pause(bool is_paused) override {
+ // Do nothing in this clock type.
+ }
+
private:
base_time_point start_time;
};
diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h
index ed284cf50..367d72134 100644
--- a/src/common/wall_clock.h
+++ b/src/common/wall_clock.h
@@ -28,6 +28,8 @@ public:
/// Returns current wall time in emulated cpu cycles
virtual u64 GetCPUCycles() = 0;
+ virtual void Pause(bool is_paused) = 0;
+
/// Tells if the wall clock, uses the host CPU's hardware clock
bool IsNative() const {
return is_native;
diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp
index 26d4d0ba6..926f92ff8 100644
--- a/src/common/x64/native_clock.cpp
+++ b/src/common/x64/native_clock.cpp
@@ -65,6 +65,13 @@ u64 NativeClock::GetRTSC() {
return accumulated_ticks;
}
+void NativeClock::Pause(bool is_paused) {
+ if (!is_paused) {
+ _mm_mfence();
+ last_measure = __rdtsc();
+ }
+}
+
std::chrono::nanoseconds NativeClock::GetTimeNS() {
const u64 rtsc_value = GetRTSC();
return std::chrono::nanoseconds{MultiplyAndDivide64(rtsc_value, 1000000000, rtsc_frequency)};
diff --git a/src/common/x64/native_clock.h b/src/common/x64/native_clock.h
index b58cf9f5a..3851f8fc2 100644
--- a/src/common/x64/native_clock.h
+++ b/src/common/x64/native_clock.h
@@ -26,6 +26,8 @@ public:
u64 GetCPUCycles() override;
+ void Pause(bool is_paused) override;
+
private:
u64 GetRTSC();
diff --git a/src/core/core.cpp b/src/core/core.cpp
index e8936b09d..1d6179a80 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -137,8 +137,8 @@ struct System::Impl {
ResultStatus Pause() {
status = ResultStatus::Success;
- kernel.Suspend(true);
core_timing.SyncPause(true);
+ kernel.Suspend(true);
cpu_manager.Pause(true);
return status;
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index cc32a853b..5a7abcfca 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -77,6 +77,9 @@ void CoreTiming::SyncPause(bool is_paused) {
return;
}
Pause(is_paused);
+ if (!is_paused) {
+ pause_event.Set();
+ }
event.Set();
while (paused_set != is_paused)
;
@@ -197,6 +200,9 @@ void CoreTiming::ThreadLoop() {
wait_set = false;
}
paused_set = true;
+ clock->Pause(true);
+ pause_event.Wait();
+ clock->Pause(false);
}
}
diff --git a/src/core/core_timing.h b/src/core/core_timing.h
index 707c8ef0c..c70b605c8 100644
--- a/src/core/core_timing.h
+++ b/src/core/core_timing.h
@@ -136,6 +136,7 @@ private:
std::shared_ptr<EventType> ev_lost;
Common::Event event{};
+ Common::Event pause_event{};
Common::SpinLock basic_lock{};
Common::SpinLock advance_lock{};
std::unique_ptr<std::thread> timer_thread;