Merge pull request #5201 from lioncash/determinism

Core: Hide determinism global
This commit is contained in:
Anthony 2017-04-04 06:21:07 +00:00 committed by GitHub
commit 90acceaf41
19 changed files with 39 additions and 38 deletions

View File

@ -209,7 +209,7 @@ bool CBoot::SetupWiiMemory(u64 ios_title_id)
if (serno.empty() || serno == "000000000") if (serno.empty() || serno == "000000000")
{ {
if (Core::g_want_determinism) if (Core::WantsDeterminism())
serno = "123456789"; serno = "123456789";
else else
serno = SettingsHandler::GenerateSerialNumber(); serno = SettingsHandler::GenerateSerialNumber();

View File

@ -84,19 +84,13 @@ namespace Core
// TODO: ugly, remove // TODO: ugly, remove
bool g_aspect_wide; bool g_aspect_wide;
bool g_want_determinism; static bool s_wants_determinism;
// Declarations and definitions // Declarations and definitions
static Common::Timer s_timer; static Common::Timer s_timer;
static std::atomic<u32> s_drawn_frame; static std::atomic<u32> s_drawn_frame;
static std::atomic<u32> s_drawn_video; static std::atomic<u32> s_drawn_video;
// Function forwarding
void Callback_WiimoteInterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
// Function declarations
void EmuThread();
static bool s_is_stopping = false; static bool s_is_stopping = false;
static bool s_hardware_initialized = false; static bool s_hardware_initialized = false;
static bool s_is_started = false; static bool s_is_started = false;
@ -130,6 +124,8 @@ static void InitIsCPUKey()
} }
#endif #endif
static void EmuThread();
bool GetIsThrottlerTempDisabled() bool GetIsThrottlerTempDisabled()
{ {
return s_is_throttler_temp_disabled; return s_is_throttler_temp_disabled;
@ -220,6 +216,11 @@ bool IsGPUThread()
} }
} }
bool WantsDeterminism()
{
return s_wants_determinism;
}
// This is called from the GUI thread. See the booting call schedule in // This is called from the GUI thread. See the booting call schedule in
// BootManager.cpp // BootManager.cpp
bool Init() bool Init()
@ -451,7 +452,7 @@ static void FifoPlayerThread()
// Initialize and create emulation thread // Initialize and create emulation thread
// Call browser: Init():s_emu_thread(). // Call browser: Init():s_emu_thread().
// See the BootManager.cpp file description for a complete call schedule. // See the BootManager.cpp file description for a complete call schedule.
void EmuThread() static void EmuThread()
{ {
const SConfig& core_parameter = SConfig::GetInstance(); const SConfig& core_parameter = SConfig::GetInstance();
s_is_booting.Set(); s_is_booting.Set();
@ -947,19 +948,19 @@ void UpdateWantDeterminism(bool initial)
// settings that depend on it, such as GPU determinism mode. should have // settings that depend on it, such as GPU determinism mode. should have
// override options for testing, // override options for testing,
bool new_want_determinism = Movie::IsMovieActive() || NetPlay::IsNetPlayRunning(); bool new_want_determinism = Movie::IsMovieActive() || NetPlay::IsNetPlayRunning();
if (new_want_determinism != g_want_determinism || initial) if (new_want_determinism != s_wants_determinism || initial)
{ {
NOTICE_LOG(COMMON, "Want determinism <- %s", new_want_determinism ? "true" : "false"); NOTICE_LOG(COMMON, "Want determinism <- %s", new_want_determinism ? "true" : "false");
bool was_unpaused = Core::PauseAndLock(true); bool was_unpaused = Core::PauseAndLock(true);
g_want_determinism = new_want_determinism; s_wants_determinism = new_want_determinism;
IOS::HLE::UpdateWantDeterminism(new_want_determinism); IOS::HLE::UpdateWantDeterminism(new_want_determinism);
Fifo::UpdateWantDeterminism(new_want_determinism); Fifo::UpdateWantDeterminism(new_want_determinism);
// We need to clear the cache because some parts of the JIT depend on want_determinism, e.g. use // We need to clear the cache because some parts of the JIT depend on want_determinism, e.g. use
// of FMA. // of FMA.
JitInterface::ClearCache(); JitInterface::ClearCache();
Core::InitializeWiiRoot(g_want_determinism); Core::InitializeWiiRoot(s_wants_determinism);
Core::PauseAndLock(false, was_unpaused); Core::PauseAndLock(false, was_unpaused);
} }

View File

@ -21,8 +21,6 @@ namespace Core
// TODO: ugly, remove // TODO: ugly, remove
extern bool g_aspect_wide; extern bool g_aspect_wide;
extern bool g_want_determinism;
bool GetIsThrottlerTempDisabled(); bool GetIsThrottlerTempDisabled();
void SetIsThrottlerTempDisabled(bool disable); void SetIsThrottlerTempDisabled(bool disable);
@ -51,6 +49,8 @@ bool IsRunningInCurrentThread(); // this tells us whether we are running in the
bool IsCPUThread(); // this tells us whether we are the CPU thread. bool IsCPUThread(); // this tells us whether we are the CPU thread.
bool IsGPUThread(); bool IsGPUThread();
bool WantsDeterminism();
// [NOT THREADSAFE] For use by Host only // [NOT THREADSAFE] For use by Host only
void SetState(State state); void SetState(State state);
State GetState(); State GetState();

View File

@ -260,7 +260,7 @@ void ScheduleEvent(s64 cycles_into_future, EventType* event_type, u64 userdata,
} }
else else
{ {
if (Core::g_want_determinism) if (Core::WantsDeterminism())
{ {
ERROR_LOG(POWERPC, "Someone scheduled an off-thread \"%s\" event while netplay or " ERROR_LOG(POWERPC, "Someone scheduled an off-thread \"%s\" event while netplay or "
"movie play/record was active. This is likely to cause a desync.", "movie play/record was active. This is likely to cause a desync.",

View File

@ -176,7 +176,7 @@ bool DSPLLE::Initialize(bool wii, bool dsp_thread)
return false; return false;
// needs to be after DSPCore_Init for the dspjit ptr // needs to be after DSPCore_Init for the dspjit ptr
if (Core::g_want_determinism || !g_dsp_jit) if (Core::WantsDeterminism() || !g_dsp_jit)
dsp_thread = false; dsp_thread = false;
m_wii = wii; m_wii = wii;
@ -300,7 +300,7 @@ void DSPLLE::DSP_Update(int cycles)
if (m_is_dsp_on_thread) if (m_is_dsp_on_thread)
{ {
if (s_request_disable_thread || Core::g_want_determinism) if (s_request_disable_thread || Core::WantsDeterminism())
{ {
DSP_StopSoundStream(); DSP_StopSoundStream();
m_is_dsp_on_thread = false; m_is_dsp_on_thread = false;

View File

@ -429,7 +429,7 @@ u32 CEXIIPL::GetEmulatedTime(u32 epoch)
} }
else else
{ {
_assert_(!Core::g_want_determinism); _assert_(!Core::WantsDeterminism());
ltime = Common::Timer::GetLocalTimeSinceJan1970() - SystemTimers::GetLocalTimeRTCOffset(); ltime = Common::Timer::GetLocalTimeSinceJan1970() - SystemTimers::GetLocalTimeRTCOffset();
} }

View File

@ -50,7 +50,7 @@ void Init()
if (SConfig::GetInstance().bWii) if (SConfig::GetInstance().bWii)
{ {
Core::InitializeWiiRoot(Core::g_want_determinism); Core::InitializeWiiRoot(Core::WantsDeterminism());
IOS::Init(); IOS::Init();
IOS::HLE::Init(); // Depends on Memory IOS::HLE::Init(); // Depends on Memory
} }

View File

@ -44,7 +44,7 @@ GCPadStatus CSIDevice_GCAdapter::GetPadStatus()
int CSIDevice_GCAdapter::RunBuffer(u8* buffer, int length) int CSIDevice_GCAdapter::RunBuffer(u8* buffer, int length)
{ {
if (!Core::g_want_determinism) if (!Core::WantsDeterminism())
{ {
// The previous check is a hack to prevent a desync due to SI devices // The previous check is a hack to prevent a desync due to SI devices
// being different and returning different values on RunBuffer(); // being different and returning different values on RunBuffer();

View File

@ -394,7 +394,7 @@ bool Wiimote::Step()
// when a movie is active, this button status update is disabled (moved), because movies only // when a movie is active, this button status update is disabled (moved), because movies only
// record data reports. // record data reports.
if (!Core::g_want_determinism) if (!Core::WantsDeterminism())
{ {
UpdateButtonsStatus(); UpdateButtonsStatus();
} }
@ -453,7 +453,7 @@ void Wiimote::GetButtonData(u8* const data)
{ {
// when a movie is active, the button update happens here instead of Wiimote::Step, to avoid // when a movie is active, the button update happens here instead of Wiimote::Step, to avoid
// potential desync issues. // potential desync issues.
if (Core::g_want_determinism) if (Core::WantsDeterminism())
{ {
UpdateButtonsStatus(); UpdateButtonsStatus();
} }

View File

@ -150,7 +150,7 @@ static s32 MapWiiSockOptNameToNative(u32 optname)
IPCCommandResult NetIPTop::IOCtl(const IOCtlRequest& request) IPCCommandResult NetIPTop::IOCtl(const IOCtlRequest& request)
{ {
if (Core::g_want_determinism) if (Core::WantsDeterminism())
{ {
return GetDefaultReply(IPC_EACCES); return GetDefaultReply(IPC_EACCES);
} }
@ -722,7 +722,7 @@ IPCCommandResult NetIPTop::HandleGetInterfaceOptRequest(const IOCtlVRequest& req
{ {
u32 address = 0; u32 address = 0;
#ifdef _WIN32 #ifdef _WIN32
if (!Core::g_want_determinism) if (!Core::WantsDeterminism())
{ {
PIP_ADAPTER_ADDRESSES AdapterAddresses = nullptr; PIP_ADAPTER_ADDRESSES AdapterAddresses = nullptr;
ULONG OutBufferLength = 0; ULONG OutBufferLength = 0;

View File

@ -29,7 +29,7 @@ void GetMACAddress(u8* mac)
// exist or can't be parsed. // exist or can't be parsed.
std::string wireless_mac = SConfig::GetInstance().m_WirelessMac; std::string wireless_mac = SConfig::GetInstance().m_WirelessMac;
if (Core::g_want_determinism) if (Core::WantsDeterminism())
wireless_mac = "12:34:56:78:9a:bc"; wireless_mac = "12:34:56:78:9a:bc";
if (!Common::StringToMacAddress(wireless_mac, mac)) if (!Common::StringToMacAddress(wireless_mac, mac))

View File

@ -171,7 +171,7 @@ IPCCommandResult NetSSL::IOCtlV(const IOCtlVRequest& request)
// I don't trust SSL to be deterministic, and this is never going to sync // I don't trust SSL to be deterministic, and this is never going to sync
// as such (as opposed to forwarding IPC results or whatever), so - // as such (as opposed to forwarding IPC results or whatever), so -
if (Core::g_want_determinism) if (Core::WantsDeterminism())
return GetDefaultReply(IPC_EACCES); return GetDefaultReply(IPC_EACCES);
switch (request.request) switch (request.request)

View File

@ -42,9 +42,9 @@ namespace Device
BluetoothEmu::BluetoothEmu(u32 device_id, const std::string& device_name) BluetoothEmu::BluetoothEmu(u32 device_id, const std::string& device_name)
: BluetoothBase(device_id, device_name) : BluetoothBase(device_id, device_name)
{ {
SysConf sysconf{Core::g_want_determinism ? Common::FromWhichRoot::FROM_SESSION_ROOT : SysConf sysconf{Core::WantsDeterminism() ? Common::FromWhichRoot::FROM_SESSION_ROOT :
Common::FromWhichRoot::FROM_CONFIGURED_ROOT}; Common::FromWhichRoot::FROM_CONFIGURED_ROOT};
if (!Core::g_want_determinism) if (!Core::WantsDeterminism())
BackUpBTInfoSection(&sysconf); BackUpBTInfoSection(&sysconf);
_conf_pads BT_DINF; _conf_pads BT_DINF;

View File

@ -107,7 +107,7 @@ bool USBHost::ShouldAddDevice(const USB::Device& device) const
// This is called from the scan thread. Returns false if we failed to update the device list. // This is called from the scan thread. Returns false if we failed to update the device list.
bool USBHost::UpdateDevices(const bool always_add_hooks) bool USBHost::UpdateDevices(const bool always_add_hooks)
{ {
if (Core::g_want_determinism) if (Core::WantsDeterminism())
return true; return true;
DeviceChangeHooks hooks; DeviceChangeHooks hooks;
@ -201,7 +201,7 @@ void USBHost::DispatchHooks(const DeviceChangeHooks& hooks)
void USBHost::StartThreads() void USBHost::StartThreads()
{ {
if (Core::g_want_determinism) if (Core::WantsDeterminism())
return; return;
if (!m_scan_thread_running.IsSet()) if (!m_scan_thread_running.IsSet())

View File

@ -71,7 +71,7 @@ IPCCommandResult USB_KBD::Write(const ReadWriteRequest& request)
IPCCommandResult USB_KBD::IOCtl(const IOCtlRequest& request) IPCCommandResult USB_KBD::IOCtl(const IOCtlRequest& request)
{ {
if (SConfig::GetInstance().m_WiiKeyboard && !Core::g_want_determinism && !m_MessageQueue.empty()) if (SConfig::GetInstance().m_WiiKeyboard && !Core::WantsDeterminism() && !m_MessageQueue.empty())
{ {
Memory::CopyToEmu(request.buffer_out, &m_MessageQueue.front(), sizeof(SMessageData)); Memory::CopyToEmu(request.buffer_out, &m_MessageQueue.front(), sizeof(SMessageData));
m_MessageQueue.pop(); m_MessageQueue.pop();
@ -94,7 +94,7 @@ bool USB_KBD::IsKeyPressed(int _Key)
void USB_KBD::Update() void USB_KBD::Update()
{ {
if (!SConfig::GetInstance().m_WiiKeyboard || Core::g_want_determinism || !m_is_active) if (!SConfig::GetInstance().m_WiiKeyboard || Core::WantsDeterminism() || !m_is_active)
return; return;
u8 Modifiers = 0x00; u8 Modifiers = 0x00;

View File

@ -260,7 +260,7 @@ void Jit64::fmaddXX(UGeckoInstruction inst)
Force25BitPrecision(XMM1, R(XMM1), XMM0); Force25BitPrecision(XMM1, R(XMM1), XMM0);
break; break;
default: default:
bool special = inst.SUBOP5 == 30 && (!cpu_info.bFMA || Core::g_want_determinism); bool special = inst.SUBOP5 == 30 && (!cpu_info.bFMA || Core::WantsDeterminism());
X64Reg tmp1 = special ? XMM0 : XMM1; X64Reg tmp1 = special ? XMM0 : XMM1;
X64Reg tmp2 = special ? XMM1 : XMM0; X64Reg tmp2 = special ? XMM1 : XMM0;
if (single && round_input) if (single && round_input)
@ -276,7 +276,7 @@ void Jit64::fmaddXX(UGeckoInstruction inst)
// Note that FMA isn't necessarily less correct (it may actually be closer to correct) compared // Note that FMA isn't necessarily less correct (it may actually be closer to correct) compared
// to what the Gekko does here; in deterministic mode, the important thing is multiple Dolphin // to what the Gekko does here; in deterministic mode, the important thing is multiple Dolphin
// instances on different computers giving identical results. // instances on different computers giving identical results.
if (cpu_info.bFMA && !Core::g_want_determinism) if (cpu_info.bFMA && !Core::WantsDeterminism())
{ {
// Statistics suggests b is a lot less likely to be unbound in practice, so // Statistics suggests b is a lot less likely to be unbound in practice, so
// if we have to pick one of a or b to bind, let's make it b. // if we have to pick one of a or b to bind, let's make it b.

View File

@ -224,7 +224,7 @@ void AdvancedConfigPane::OnUpdateCPUClockControls(wxUpdateUIEvent& event)
return; return;
} }
event.Enable(!Core::g_want_determinism); event.Enable(!Core::WantsDeterminism());
} }
void AdvancedConfigPane::OnUpdateRTCDateTimeEntries(wxUpdateUIEvent& event) void AdvancedConfigPane::OnUpdateRTCDateTimeEntries(wxUpdateUIEvent& event)

View File

@ -91,7 +91,7 @@ void ControllerConfigDiag::UpdateUI()
const bool wii_game_started = const bool wii_game_started =
SConfig::GetInstance().bWii || Core::GetState() == Core::State::Uninitialized; SConfig::GetInstance().bWii || Core::GetState() == Core::State::Uninitialized;
if (Core::g_want_determinism || !wii_game_started) if (Core::WantsDeterminism() || !wii_game_started)
m_wiimote_sources[i]->Disable(); m_wiimote_sources[i]->Disable();
if (!wii_game_started || if (!wii_game_started ||
(g_wiimote_sources[i] != WIIMOTE_SRC_EMU && g_wiimote_sources[i] != WIIMOTE_SRC_HYBRID)) (g_wiimote_sources[i] != WIIMOTE_SRC_EMU && g_wiimote_sources[i] != WIIMOTE_SRC_HYBRID))
@ -179,7 +179,7 @@ wxSizer* ControllerConfigDiag::CreateGamecubeSizer()
pad_type_choices[i]->Bind(wxEVT_CHOICE, &ControllerConfigDiag::OnGameCubePortChanged, this); pad_type_choices[i]->Bind(wxEVT_CHOICE, &ControllerConfigDiag::OnGameCubePortChanged, this);
// Disable controller type selection for certain circumstances. // Disable controller type selection for certain circumstances.
if (Core::g_want_determinism) if (Core::WantsDeterminism())
pad_type_choices[i]->Disable(); pad_type_choices[i]->Disable();
// Set the saved pad type as the default choice. // Set the saved pad type as the default choice.

View File

@ -453,7 +453,7 @@ GCPadStatus Input(int chan)
pad.triggerLeft = controller_payload_copy[1 + (9 * chan) + 7]; pad.triggerLeft = controller_payload_copy[1 + (9 * chan) + 7];
pad.triggerRight = controller_payload_copy[1 + (9 * chan) + 8]; pad.triggerRight = controller_payload_copy[1 + (9 * chan) + 8];
} }
else if (!Core::g_want_determinism) else if (!Core::WantsDeterminism())
{ {
// This is a hack to prevent a desync due to SI devices // This is a hack to prevent a desync due to SI devices
// being different and returning different values. // being different and returning different values.