summaryrefslogtreecommitdiff
path: root/src/core/core_timing.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/core_timing.h')
-rw-r--r--src/core/core_timing.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/core/core_timing.h b/src/core/core_timing.h
index 161c7007d..3bb88c810 100644
--- a/src/core/core_timing.h
+++ b/src/core/core_timing.h
@@ -7,6 +7,7 @@
7#include <chrono> 7#include <chrono>
8#include <functional> 8#include <functional>
9#include <mutex> 9#include <mutex>
10#include <optional>
10#include <string> 11#include <string>
11#include <unordered_map> 12#include <unordered_map>
12#include <vector> 13#include <vector>
@@ -104,7 +105,19 @@ public:
104 105
105 std::chrono::microseconds GetGlobalTimeUs() const; 106 std::chrono::microseconds GetGlobalTimeUs() const;
106 107
107 int GetDowncount() const; 108 void ResetRun();
109
110 s64 GetDowncount() const;
111
112 void SwitchContext(u64 new_context) {
113 current_context = new_context;
114 }
115
116 bool CanCurrentContextRun() const {
117 return time_slice[current_context] > 0;
118 }
119
120 std::optional<u64> NextAvailableCore(const s64 needed_ticks) const;
108 121
109private: 122private:
110 struct Event; 123 struct Event;
@@ -112,10 +125,16 @@ private:
112 /// Clear all pending events. This should ONLY be done on exit. 125 /// Clear all pending events. This should ONLY be done on exit.
113 void ClearPendingEvents(); 126 void ClearPendingEvents();
114 127
128 static constexpr u64 num_cpu_cores = 4;
129
115 s64 global_timer = 0; 130 s64 global_timer = 0;
116 s64 idled_cycles = 0; 131 s64 idled_cycles = 0;
117 int slice_length = 0; 132 s64 slice_length = 0;
118 int downcount = 0; 133 u64 accumulated_ticks = 0;
134 std::array<s64, num_cpu_cores> downcounts{};
135 // Slice of time assigned to each core per run.
136 std::array<s64, num_cpu_cores> time_slice{};
137 u64 current_context = 0;
119 138
120 // Are we in a function that has been called from Advance() 139 // Are we in a function that has been called from Advance()
121 // If events are scheduled from a function that gets called from Advance(), 140 // If events are scheduled from a function that gets called from Advance(),