summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2020-02-10 19:45:08 +0100
committerFernando Sahmkow <fsahmkow27@gmail.com>2020-06-18 22:29:21 +0200
commit1f7dd36499786d373b143a4437d4c32e077a32aa (patch)
tree26d21b113d85c6630f3ff67f7affc7c1b6f508a5 /src/core
parentCommon: Make MinGW build use Windows Fibers instead of fcontext_t (diff)
downloadyuzu-1f7dd36499786d373b143a4437d4c32e077a32aa.tar
yuzu-1f7dd36499786d373b143a4437d4c32e077a32aa.tar.gz
yuzu-1f7dd36499786d373b143a4437d4c32e077a32aa.tar.bz2
yuzu-1f7dd36499786d373b143a4437d4c32e077a32aa.tar.lz
yuzu-1f7dd36499786d373b143a4437d4c32e077a32aa.tar.xz
yuzu-1f7dd36499786d373b143a4437d4c32e077a32aa.tar.zst
yuzu-1f7dd36499786d373b143a4437d4c32e077a32aa.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core_timing_util.cpp14
-rw-r--r--src/core/core_timing_util.h2
-rw-r--r--src/core/host_timing.cpp4
-rw-r--r--src/core/host_timing.h6
4 files changed, 19 insertions, 7 deletions
diff --git a/src/core/core_timing_util.cpp b/src/core/core_timing_util.cpp
index f42666b4d..be34b26fe 100644
--- a/src/core/core_timing_util.cpp
+++ b/src/core/core_timing_util.cpp
@@ -49,9 +49,19 @@ s64 nsToCycles(std::chrono::nanoseconds ns) {
return (Hardware::BASE_CLOCK_RATE * ns.count()) / 1000000000;
}
+u64 msToClockCycles(std::chrono::milliseconds ns) {
+ const u128 temp = Common::Multiply64Into128(ns.count(), Hardware::CNTFREQ);
+ return Common::Divide128On32(temp, 1000).first;
+}
+
+u64 usToClockCycles(std::chrono::microseconds ns) {
+ const u128 temp = Common::Multiply64Into128(ns.count(), Hardware::CNTFREQ);
+ return Common::Divide128On32(temp, 1000000).first;
+}
+
u64 nsToClockCycles(std::chrono::nanoseconds ns) {
- const u128 temporal = Common::Multiply64Into128(ns.count(), CNTFREQ);
- return Common::Divide128On32(temporal, 1000000000).first;
+ const u128 temp = Common::Multiply64Into128(ns.count(), Hardware::CNTFREQ);
+ return Common::Divide128On32(temp, 1000000000).first;
}
u64 CpuCyclesToClockCycles(u64 ticks) {
diff --git a/src/core/core_timing_util.h b/src/core/core_timing_util.h
index 65fb7368b..b3c58447d 100644
--- a/src/core/core_timing_util.h
+++ b/src/core/core_timing_util.h
@@ -13,6 +13,8 @@ namespace Core::Timing {
s64 msToCycles(std::chrono::milliseconds ms);
s64 usToCycles(std::chrono::microseconds us);
s64 nsToCycles(std::chrono::nanoseconds ns);
+u64 msToClockCycles(std::chrono::milliseconds ns);
+u64 usToClockCycles(std::chrono::microseconds ns);
u64 nsToClockCycles(std::chrono::nanoseconds ns);
inline std::chrono::milliseconds CyclesToMs(s64 cycles) {
diff --git a/src/core/host_timing.cpp b/src/core/host_timing.cpp
index c734a118e..be80d9f8e 100644
--- a/src/core/host_timing.cpp
+++ b/src/core/host_timing.cpp
@@ -76,11 +76,11 @@ void CoreTiming::SyncPause(bool is_paused) {
;
}
-bool CoreTiming::IsRunning() {
+bool CoreTiming::IsRunning() const {
return !paused_set;
}
-bool CoreTiming::HasPendingEvents() {
+bool CoreTiming::HasPendingEvents() const {
return !(wait_set && event_queue.empty());
}
diff --git a/src/core/host_timing.h b/src/core/host_timing.h
index 15a150904..679fcf491 100644
--- a/src/core/host_timing.h
+++ b/src/core/host_timing.h
@@ -72,15 +72,15 @@ public:
void SyncPause(bool is_paused);
/// Checks if core timing is running.
- bool IsRunning();
+ bool IsRunning() const;
/// Checks if the timer thread has started.
- bool HasStarted() {
+ bool HasStarted() const {
return has_started;
}
/// Checks if there are any pending time events.
- bool HasPendingEvents();
+ bool HasPendingEvents() const;
/// Schedules an event in core timing
void ScheduleEvent(s64 ns_into_future, const std::shared_ptr<EventType>& event_type,