summaryrefslogtreecommitdiffstats
path: root/src/core/core_timing.cpp
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2023-04-23 06:01:08 +0200
committerMorph <39850852+Morph1984@users.noreply.github.com>2023-06-08 03:44:42 +0200
commit8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf (patch)
tree2bb7be86aafe9986811758b508a7581d2efe8ac4 /src/core/core_timing.cpp
parentnvnflinger: Acquire lock prior to signaling the vsync variable (diff)
downloadyuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.tar
yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.tar.gz
yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.tar.bz2
yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.tar.lz
yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.tar.xz
yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.tar.zst
yuzu-8e56a84566036cfff0aa5c3d80ae1b051d2bd0bf.zip
Diffstat (limited to '')
-rw-r--r--src/core/core_timing.cpp35
1 files changed, 8 insertions, 27 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index 4f2692b05..9a1d5a69a 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -16,7 +16,6 @@
#include "common/microprofile.h"
#include "core/core_timing.h"
-#include "core/core_timing_util.h"
#include "core/hardware_properties.h"
namespace Core::Timing {
@@ -45,9 +44,7 @@ struct CoreTiming::Event {
}
};
-CoreTiming::CoreTiming()
- : cpu_clock{Common::CreateBestMatchingClock(Hardware::BASE_CLOCK_RATE, Hardware::CNTFREQ)},
- event_clock{Common::CreateStandardWallClock(Hardware::BASE_CLOCK_RATE, Hardware::CNTFREQ)} {}
+CoreTiming::CoreTiming() : clock{Common::CreateOptimalClock()} {}
CoreTiming::~CoreTiming() {
Reset();
@@ -180,7 +177,7 @@ void CoreTiming::AddTicks(u64 ticks_to_add) {
void CoreTiming::Idle() {
if (!event_queue.empty()) {
const u64 next_event_time = event_queue.front().time;
- const u64 next_ticks = nsToCycles(std::chrono::nanoseconds(next_event_time)) + 10U;
+ const u64 next_ticks = Common::WallClock::NSToCNTPCT(next_event_time) + 10U;
if (next_ticks > ticks) {
ticks = next_ticks;
}
@@ -193,18 +190,11 @@ void CoreTiming::ResetTicks() {
downcount = MAX_SLICE_LENGTH;
}
-u64 CoreTiming::GetCPUTicks() const {
- if (is_multicore) [[likely]] {
- return cpu_clock->GetCPUCycles();
- }
- return ticks;
-}
-
u64 CoreTiming::GetClockTicks() const {
if (is_multicore) [[likely]] {
- return cpu_clock->GetClockCycles();
+ return clock->GetCNTPCT();
}
- return CpuCyclesToClockCycles(ticks);
+ return ticks;
}
std::optional<s64> CoreTiming::Advance() {
@@ -297,9 +287,7 @@ void CoreTiming::ThreadLoop() {
}
paused_set = true;
- event_clock->Pause(true);
pause_event.Wait();
- event_clock->Pause(false);
}
}
@@ -315,25 +303,18 @@ void CoreTiming::Reset() {
has_started = false;
}
-std::chrono::nanoseconds CoreTiming::GetCPUTimeNs() const {
- if (is_multicore) [[likely]] {
- return cpu_clock->GetTimeNS();
- }
- return CyclesToNs(ticks);
-}
-
std::chrono::nanoseconds CoreTiming::GetGlobalTimeNs() const {
if (is_multicore) [[likely]] {
- return event_clock->GetTimeNS();
+ return clock->GetTimeNS();
}
- return CyclesToNs(ticks);
+ return std::chrono::nanoseconds{Common::WallClock::CNTPCTToNS(ticks)};
}
std::chrono::microseconds CoreTiming::GetGlobalTimeUs() const {
if (is_multicore) [[likely]] {
- return event_clock->GetTimeUS();
+ return clock->GetTimeUS();
}
- return CyclesToUs(ticks);
+ return std::chrono::microseconds{Common::WallClock::CNTPCTToUS(ticks)};
}
} // namespace Core::Timing