summaryrefslogtreecommitdiffstats
path: root/src/core/core_timing.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2019-10-15 17:48:30 +0200
committerGitHub <noreply@github.com>2019-10-15 17:48:30 +0200
commitcab2619aeb111bd6c5dbcc5adc0d2e8154a1e8fc (patch)
tree1664df6e9abff74f37adee0c90ae3c9eaff6babf /src/core/core_timing.h
parentMerge pull request #2897 from DarkLordZach/oss-ext-fonts-1 (diff)
parentCore_Timing: Address Remaining feedback. (diff)
downloadyuzu-cab2619aeb111bd6c5dbcc5adc0d2e8154a1e8fc.tar
yuzu-cab2619aeb111bd6c5dbcc5adc0d2e8154a1e8fc.tar.gz
yuzu-cab2619aeb111bd6c5dbcc5adc0d2e8154a1e8fc.tar.bz2
yuzu-cab2619aeb111bd6c5dbcc5adc0d2e8154a1e8fc.tar.lz
yuzu-cab2619aeb111bd6c5dbcc5adc0d2e8154a1e8fc.tar.xz
yuzu-cab2619aeb111bd6c5dbcc5adc0d2e8154a1e8fc.tar.zst
yuzu-cab2619aeb111bd6c5dbcc5adc0d2e8154a1e8fc.zip
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 @@
#include <chrono>
#include <functional>
#include <mutex>
+#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
@@ -104,7 +105,19 @@ public:
std::chrono::microseconds GetGlobalTimeUs() const;
- int GetDowncount() const;
+ void ResetRun();
+
+ s64 GetDowncount() const;
+
+ void SwitchContext(u64 new_context) {
+ current_context = new_context;
+ }
+
+ bool CanCurrentContextRun() const {
+ return time_slice[current_context] > 0;
+ }
+
+ std::optional<u64> NextAvailableCore(const s64 needed_ticks) const;
private:
struct Event;
@@ -112,10 +125,16 @@ private:
/// Clear all pending events. This should ONLY be done on exit.
void ClearPendingEvents();
+ static constexpr u64 num_cpu_cores = 4;
+
s64 global_timer = 0;
s64 idled_cycles = 0;
- int slice_length = 0;
- int downcount = 0;
+ s64 slice_length = 0;
+ u64 accumulated_ticks = 0;
+ std::array<s64, num_cpu_cores> downcounts{};
+ // Slice of time assigned to each core per run.
+ std::array<s64, num_cpu_cores> time_slice{};
+ u64 current_context = 0;
// Are we in a function that has been called from Advance()
// If events are scheduled from a function that gets called from Advance(),