summaryrefslogtreecommitdiff
path: root/src/core/core_timing.cpp
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-10-11 14:44:14 -0400
committerGravatar Fernando Sahmkow2019-10-11 14:44:14 -0400
commite0650a2034026d8292196128d2f9decb50eeb0f3 (patch)
tree59c51153a985e7fb66e62c812250c6dacd69a82c /src/core/core_timing.cpp
parentCore Timing: Correct Idle and remove lefting pragma (diff)
downloadyuzu-e0650a2034026d8292196128d2f9decb50eeb0f3.tar.gz
yuzu-e0650a2034026d8292196128d2f9decb50eeb0f3.tar.xz
yuzu-e0650a2034026d8292196128d2f9decb50eeb0f3.zip
Core_Timing: Address Feedback and suppress warnings.
Diffstat (limited to 'src/core/core_timing.cpp')
-rw-r--r--src/core/core_timing.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index 3ca265b4f..780c6843a 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -38,10 +38,8 @@ CoreTiming::CoreTiming() = default;
38CoreTiming::~CoreTiming() = default; 38CoreTiming::~CoreTiming() = default;
39 39
40void CoreTiming::Initialize() { 40void CoreTiming::Initialize() {
41 for (std::size_t core = 0; core < num_cpu_cores; core++) { 41 downcounts.fill(MAX_SLICE_LENGTH);
42 downcounts[core] = MAX_SLICE_LENGTH; 42 time_slice.fill(MAX_SLICE_LENGTH);
43 time_slice[core] = MAX_SLICE_LENGTH;
44 }
45 slice_length = MAX_SLICE_LENGTH; 43 slice_length = MAX_SLICE_LENGTH;
46 global_timer = 0; 44 global_timer = 0;
47 idled_cycles = 0; 45 idled_cycles = 0;
@@ -162,17 +160,17 @@ std::optional<u64> CoreTiming::NextAvailableCore(const s64 needed_ticks) const {
162 if (time_slice[next_context] >= needed_ticks) { 160 if (time_slice[next_context] >= needed_ticks) {
163 return {next_context}; 161 return {next_context};
164 } else if (time_slice[next_context] >= 0) { 162 } else if (time_slice[next_context] >= 0) {
165 return {}; 163 return std::nullopt;
166 } 164 }
167 next_context = (next_context + 1) % num_cpu_cores; 165 next_context = (next_context + 1) % num_cpu_cores;
168 } 166 }
169 return {}; 167 return std::nullopt;
170} 168}
171 169
172void CoreTiming::Advance() { 170void CoreTiming::Advance() {
173 std::unique_lock<std::mutex> guard(inner_mutex); 171 std::unique_lock<std::mutex> guard(inner_mutex);
174 172
175 const int cycles_executed = accumulated_ticks; 173 const u64 cycles_executed = accumulated_ticks;
176 time_slice[current_context] = std::max<s64>(0, time_slice[current_context] - accumulated_ticks); 174 time_slice[current_context] = std::max<s64>(0, time_slice[current_context] - accumulated_ticks);
177 global_timer += cycles_executed; 175 global_timer += cycles_executed;
178 176
@@ -191,7 +189,8 @@ void CoreTiming::Advance() {
191 189
192 // Still events left (scheduled in the future) 190 // Still events left (scheduled in the future)
193 if (!event_queue.empty()) { 191 if (!event_queue.empty()) {
194 s64 needed_ticks = std::min<s64>(event_queue.front().time - global_timer, MAX_SLICE_LENGTH); 192 const s64 needed_ticks =
193 std::min<s64>(event_queue.front().time - global_timer, MAX_SLICE_LENGTH);
195 const auto next_core = NextAvailableCore(needed_ticks); 194 const auto next_core = NextAvailableCore(needed_ticks);
196 if (next_core) { 195 if (next_core) {
197 downcounts[*next_core] = needed_ticks; 196 downcounts[*next_core] = needed_ticks;