PowerPC: Set host CPU rounding mode on init and savestate

Not doing this can cause desyncs when TASing. (I don't know
how common such desyncs would be, though. For games that
don't change rounding modes, they shouldn't be a problem.)
This commit is contained in:
JosJuice
2021-06-10 19:54:07 +02:00
parent 8f9bb5612a
commit 9db0ebd4b6
9 changed files with 26 additions and 31 deletions

View File

@@ -20,6 +20,7 @@
#include "Common/Logging/Log.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
#include "Core/HW/CPU.h"
#include "Core/HW/SystemTimers.h"
@@ -129,6 +130,7 @@ void DoState(PointerWrap& p)
if (p.GetMode() == PointerWrap::MODE_READ)
{
RoundingModeUpdated();
IBATUpdated();
DBATUpdated();
}
@@ -180,6 +182,7 @@ static void ResetRegisters()
}
SetXER({});
RoundingModeUpdated();
DBATUpdated();
IBATUpdated();
@@ -246,10 +249,6 @@ CPUCore DefaultCPUCore()
void Init(CPUCore cpu_core)
{
// NOTE: This function runs on EmuThread, not the CPU Thread.
// Changing the rounding mode has a limited effect.
FPURoundMode::SetPrecisionMode(FPURoundMode::PREC_53);
s_invalidate_cache_thread_safe =
CoreTiming::RegisterEvent("invalidateEmulatedCache", InvalidateCacheThreadSafe);
@@ -632,4 +631,13 @@ void UpdateFPRF(double dvalue)
FPSCR.FPRF = Common::ClassifyDouble(dvalue);
}
void RoundingModeUpdated()
{
// The rounding mode is separate for each thread, so this must run on the CPU thread
ASSERT(Core::IsCPUThread());
FPURoundMode::SetRoundMode(FPSCR.RN);
FPURoundMode::SetSIMDMode(FPSCR.RN, FPSCR.NI);
}
} // namespace PowerPC