diff options
| author | 2020-02-15 13:56:50 -0400 | |
|---|---|---|
| committer | 2020-06-18 16:29:22 -0400 | |
| commit | 96b2d8419c94f9bcb5f2f970bbb453aa7383b510 (patch) | |
| tree | 9ca96e9c9ad0f85f57d19f89120ae8c1d6cf11e2 /src | |
| parent | Core/HostTiming: Allow events to be advanced manually. (diff) | |
| download | yuzu-96b2d8419c94f9bcb5f2f970bbb453aa7383b510.tar.gz yuzu-96b2d8419c94f9bcb5f2f970bbb453aa7383b510.tar.xz yuzu-96b2d8419c94f9bcb5f2f970bbb453aa7383b510.zip | |
HostTiming: Correct rebase and implement AddTicks.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/host_timing.cpp | 11 | ||||
| -rw-r--r-- | src/core/host_timing.h | 9 |
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 { | |||
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | CoreTiming::CoreTiming() { | 38 | CoreTiming::CoreTiming() { |
| 39 | clock = Common::CreateBestMatchingClock(Core::Timing::BASE_CLOCK_RATE, Core::Timing::CNTFREQ); | 39 | clock = |
| 40 | Common::CreateBestMatchingClock(Core::Hardware::BASE_CLOCK_RATE, Core::Hardware::CNTFREQ); | ||
| 40 | } | 41 | } |
| 41 | 42 | ||
| 42 | CoreTiming::~CoreTiming() = default; | 43 | CoreTiming::~CoreTiming() = default; |
| @@ -110,6 +111,14 @@ void CoreTiming::UnscheduleEvent(const std::shared_ptr<EventType>& event_type, u | |||
| 110 | basic_lock.unlock(); | 111 | basic_lock.unlock(); |
| 111 | } | 112 | } |
| 112 | 113 | ||
| 114 | void CoreTiming::AddTicks(std::size_t core_index, u64 ticks) { | ||
| 115 | ticks_count[core_index] += ticks; | ||
| 116 | } | ||
| 117 | |||
| 118 | void CoreTiming::ResetTicks(std::size_t core_index) { | ||
| 119 | ticks_count[core_index] = 0; | ||
| 120 | } | ||
| 121 | |||
| 113 | u64 CoreTiming::GetCPUTicks() const { | 122 | u64 CoreTiming::GetCPUTicks() const { |
| 114 | return clock->GetCPUCycles(); | 123 | return clock->GetCPUCycles(); |
| 115 | } | 124 | } |
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 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <atomic> | ||
| 7 | #include <chrono> | 8 | #include <chrono> |
| 8 | #include <functional> | 9 | #include <functional> |
| 9 | #include <memory> | 10 | #include <memory> |
| @@ -18,6 +19,7 @@ | |||
| 18 | #include "common/thread.h" | 19 | #include "common/thread.h" |
| 19 | #include "common/threadsafe_queue.h" | 20 | #include "common/threadsafe_queue.h" |
| 20 | #include "common/wall_clock.h" | 21 | #include "common/wall_clock.h" |
| 22 | #include "core/hardware_properties.h" | ||
| 21 | 23 | ||
| 22 | namespace Core::HostTiming { | 24 | namespace Core::HostTiming { |
| 23 | 25 | ||
| @@ -91,6 +93,11 @@ public: | |||
| 91 | /// We only permit one event of each type in the queue at a time. | 93 | /// We only permit one event of each type in the queue at a time. |
| 92 | void RemoveEvent(const std::shared_ptr<EventType>& event_type); | 94 | void RemoveEvent(const std::shared_ptr<EventType>& event_type); |
| 93 | 95 | ||
| 96 | |||
| 97 | void AddTicks(std::size_t core_index, u64 ticks); | ||
| 98 | |||
| 99 | void ResetTicks(std::size_t core_index); | ||
| 100 | |||
| 94 | /// Returns current time in emulated CPU cycles | 101 | /// Returns current time in emulated CPU cycles |
| 95 | u64 GetCPUTicks() const; | 102 | u64 GetCPUTicks() const; |
| 96 | 103 | ||
| @@ -138,6 +145,8 @@ private: | |||
| 138 | std::atomic<bool> wait_set{}; | 145 | std::atomic<bool> wait_set{}; |
| 139 | std::atomic<bool> shutting_down{}; | 146 | std::atomic<bool> shutting_down{}; |
| 140 | std::atomic<bool> has_started{}; | 147 | std::atomic<bool> has_started{}; |
| 148 | |||
| 149 | std::array<std::atomic<u64>, Core::Hardware::NUM_CPU_CORES> ticks_count{}; | ||
| 141 | }; | 150 | }; |
| 142 | 151 | ||
| 143 | /// Creates a core timing event with the given name and callback. | 152 | /// Creates a core timing event with the given name and callback. |