summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2020-02-15 18:56:50 +0100
committerFernando Sahmkow <fsahmkow27@gmail.com>2020-06-18 22:29:22 +0200
commit96b2d8419c94f9bcb5f2f970bbb453aa7383b510 (patch)
tree9ca96e9c9ad0f85f57d19f89120ae8c1d6cf11e2 /src
parentCore/HostTiming: Allow events to be advanced manually. (diff)
downloadyuzu-96b2d8419c94f9bcb5f2f970bbb453aa7383b510.tar
yuzu-96b2d8419c94f9bcb5f2f970bbb453aa7383b510.tar.gz
yuzu-96b2d8419c94f9bcb5f2f970bbb453aa7383b510.tar.bz2
yuzu-96b2d8419c94f9bcb5f2f970bbb453aa7383b510.tar.lz
yuzu-96b2d8419c94f9bcb5f2f970bbb453aa7383b510.tar.xz
yuzu-96b2d8419c94f9bcb5f2f970bbb453aa7383b510.tar.zst
yuzu-96b2d8419c94f9bcb5f2f970bbb453aa7383b510.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/host_timing.cpp11
-rw-r--r--src/core/host_timing.h9
2 files changed, 19 insertions, 1 deletions
diff --git a/src/core/host_timing.cpp b/src/core/host_timing.cpp
index 5d35a96b1..2f40de1a1 100644
--- a/src/core/host_timing.cpp
+++ b/src/core/host_timing.cpp
@@ -36,7 +36,8 @@ struct CoreTiming::Event {
};
CoreTiming::CoreTiming() {
- clock = Common::CreateBestMatchingClock(Core::Timing::BASE_CLOCK_RATE, Core::Timing::CNTFREQ);
+ clock =
+ Common::CreateBestMatchingClock(Core::Hardware::BASE_CLOCK_RATE, Core::Hardware::CNTFREQ);
}
CoreTiming::~CoreTiming() = default;
@@ -110,6 +111,14 @@ void CoreTiming::UnscheduleEvent(const std::shared_ptr<EventType>& event_type, u
basic_lock.unlock();
}
+void CoreTiming::AddTicks(std::size_t core_index, u64 ticks) {
+ ticks_count[core_index] += ticks;
+}
+
+void CoreTiming::ResetTicks(std::size_t core_index) {
+ ticks_count[core_index] = 0;
+}
+
u64 CoreTiming::GetCPUTicks() const {
return clock->GetCPUCycles();
}
diff --git a/src/core/host_timing.h b/src/core/host_timing.h
index cd44b308c..5ad8c5f35 100644
--- a/src/core/host_timing.h
+++ b/src/core/host_timing.h
@@ -4,6 +4,7 @@
#pragma once
+#include <atomic>
#include <chrono>
#include <functional>
#include <memory>
@@ -18,6 +19,7 @@
#include "common/thread.h"
#include "common/threadsafe_queue.h"
#include "common/wall_clock.h"
+#include "core/hardware_properties.h"
namespace Core::HostTiming {
@@ -91,6 +93,11 @@ public:
/// We only permit one event of each type in the queue at a time.
void RemoveEvent(const std::shared_ptr<EventType>& event_type);
+
+ void AddTicks(std::size_t core_index, u64 ticks);
+
+ void ResetTicks(std::size_t core_index);
+
/// Returns current time in emulated CPU cycles
u64 GetCPUTicks() const;
@@ -138,6 +145,8 @@ private:
std::atomic<bool> wait_set{};
std::atomic<bool> shutting_down{};
std::atomic<bool> has_started{};
+
+ std::array<std::atomic<u64>, Core::Hardware::NUM_CPU_CORES> ticks_count{};
};
/// Creates a core timing event with the given name and callback.