summaryrefslogtreecommitdiffstats
path: root/src/core/core_timing.cpp
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-10-08 23:18:06 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2019-10-09 18:30:33 +0200
commit65aff6930bdfe1ecbf7e3c7eec967c2c6149aaef (patch)
treed111578abe39248c638283a7f735f5dbc140e21d /src/core/core_timing.cpp
parentTests: Eliminate old Core Timing Tests (diff)
downloadyuzu-65aff6930bdfe1ecbf7e3c7eec967c2c6149aaef.tar
yuzu-65aff6930bdfe1ecbf7e3c7eec967c2c6149aaef.tar.gz
yuzu-65aff6930bdfe1ecbf7e3c7eec967c2c6149aaef.tar.bz2
yuzu-65aff6930bdfe1ecbf7e3c7eec967c2c6149aaef.tar.lz
yuzu-65aff6930bdfe1ecbf7e3c7eec967c2c6149aaef.tar.xz
yuzu-65aff6930bdfe1ecbf7e3c7eec967c2c6149aaef.tar.zst
yuzu-65aff6930bdfe1ecbf7e3c7eec967c2c6149aaef.zip
Diffstat (limited to 'src/core/core_timing.cpp')
-rw-r--r--src/core/core_timing.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index 6da2dcfb4..0ed6f9b19 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -13,6 +13,8 @@
#include "common/thread.h"
#include "core/core_timing_util.h"
+#pragma optoimize("", off)
+
namespace Core::Timing {
constexpr int MAX_SLICE_LENGTH = 10000;
@@ -114,7 +116,7 @@ void CoreTiming::UnscheduleEvent(const EventType* event_type, u64 userdata) {
u64 CoreTiming::GetTicks() const {
u64 ticks = static_cast<u64>(global_timer);
if (!is_global_timer_sane) {
- ticks += time_slice[current_context] - downcounts[current_context];
+ ticks += accumulated_ticks;
}
return ticks;
}
@@ -124,6 +126,7 @@ u64 CoreTiming::GetIdleTicks() const {
}
void CoreTiming::AddTicks(u64 ticks) {
+ accumulated_ticks += ticks;
downcounts[current_context] -= static_cast<s64>(ticks);
}
@@ -151,7 +154,6 @@ void CoreTiming::ForceExceptionCheck(s64 cycles) {
// downcount is always (much) smaller than MAX_INT so we can safely cast cycles to an int
// here. Account for cycles already executed by adjusting the g.slice_length
- slice_length -= downcounts[current_context] - static_cast<int>(cycles);
downcounts[current_context] = static_cast<int>(cycles);
}
@@ -172,8 +174,8 @@ std::optional<u64> CoreTiming::NextAvailableCore(const s64 needed_ticks) const {
void CoreTiming::Advance() {
std::unique_lock<std::mutex> guard(inner_mutex);
- const int cycles_executed = time_slice[current_context] - downcounts[current_context];
- time_slice[current_context] = std::max<s64>(0, downcounts[current_context]);
+ const int cycles_executed = accumulated_ticks;
+ time_slice[current_context] = std::max<s64>(0, time_slice[current_context] - accumulated_ticks);
global_timer += cycles_executed;
is_global_timer_sane = true;
@@ -198,6 +200,8 @@ void CoreTiming::Advance() {
}
}
+ accumulated_ticks = 0;
+
downcounts[current_context] = time_slice[current_context];
}
@@ -212,6 +216,9 @@ void CoreTiming::ResetRun() {
s64 needed_ticks = std::min<s64>(event_queue.front().time - global_timer, MAX_SLICE_LENGTH);
downcounts[current_context] = needed_ticks;
}
+
+ is_global_timer_sane = false;
+ accumulated_ticks = 0;
}
void CoreTiming::Idle() {