summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Subv2018-08-12 20:41:28 -0500
committerGravatar Subv2018-08-12 20:41:28 -0500
commitd9237660429adaa9f549d10e79252a713f1da874 (patch)
tree6573f68774fbb2e2e7019c1e6c2c5454bf60e899 /src
parentKernel/SVC: Don't reschedule the current core when creating a new thread. (diff)
downloadyuzu-d9237660429adaa9f549d10e79252a713f1da874.tar.gz
yuzu-d9237660429adaa9f549d10e79252a713f1da874.tar.xz
yuzu-d9237660429adaa9f549d10e79252a713f1da874.zip
CPU/Timing: Use an approximated amortized amount of ticks when advancing timing.
We divide the number of ticks to add by the number of cores (4) to obtain a more or less rough estimate of the actual number of ticks added. This assumes that all 4 cores are doing similar work. Previously we were adding ~4 times the number of ticks, thus making the games think that time was going way too fast. This lets us bypass certain hangs in some games like Breath of the Wild. We should modify our CoreTiming to support multiple cores (both running in a single thread, and in multiple host threads).
Diffstat (limited to 'src')
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic.cpp11
-rw-r--r--src/core/core_cpu.cpp1
2 files changed, 11 insertions, 1 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp
index ceb3f7683..0996f129c 100644
--- a/src/core/arm/dynarmic/arm_dynarmic.cpp
+++ b/src/core/arm/dynarmic/arm_dynarmic.cpp
@@ -86,7 +86,16 @@ public:
86 } 86 }
87 87
88 void AddTicks(u64 ticks) override { 88 void AddTicks(u64 ticks) override {
89 CoreTiming::AddTicks(ticks - num_interpreted_instructions); 89 // Divide the number of ticks by the amount of CPU cores. TODO(Subv): This yields only a
90 // rough approximation of the amount of executed ticks in the system, it may be thrown off
91 // if not all cores are doing a similar amount of work. Instead of doing this, we should
92 // device a way so that timing is consistent across all cores without increasing the ticks 4
93 // times.
94 u64 amortized_ticks = (ticks - num_interpreted_instructions) / Core::NUM_CPU_CORES;
95 // Always execute at least one tick.
96 amortized_ticks = std::max<u64>(amortized_ticks, 1);
97
98 CoreTiming::AddTicks(amortized_ticks);
90 num_interpreted_instructions = 0; 99 num_interpreted_instructions = 0;
91 } 100 }
92 u64 GetTicksRemaining() override { 101 u64 GetTicksRemaining() override {
diff --git a/src/core/core_cpu.cpp b/src/core/core_cpu.cpp
index 46a522fcd..3f1c70624 100644
--- a/src/core/core_cpu.cpp
+++ b/src/core/core_cpu.cpp
@@ -90,6 +90,7 @@ void Cpu::RunLoop(bool tight_loop) {
90 LOG_TRACE(Core, "Core-{} idling", core_index); 90 LOG_TRACE(Core, "Core-{} idling", core_index);
91 91
92 if (IsMainCore()) { 92 if (IsMainCore()) {
93 // TODO(Subv): Only let CoreTiming idle if all 4 cores are idling.
93 CoreTiming::Idle(); 94 CoreTiming::Idle();
94 CoreTiming::Advance(); 95 CoreTiming::Advance();
95 } 96 }