Add a central variable g_want_determinism which controls whether to try to make things deterministic.

It now affects the GPU determinism mode as well as some miscellaneous
things that were calling IsNetPlayRunning.  Probably incomplete.

Notably, this can change while paused, if the user starts recording a
movie.  The movie code appears to have been missing locking between
setting g_playMode and doing other things, which probably had a small
chance of causing crashes or even desynced movies; fix that with
PauseAndLock.

The next commit will add a hidden config variable to override GPU
determinism mode.
This commit is contained in:
comex
2014-09-06 17:26:40 -04:00
parent 65af90669b
commit 3a2048ea57
10 changed files with 95 additions and 8 deletions

View File

@@ -48,6 +48,7 @@
#include "Core/HW/VideoInterface.h"
#include "Core/HW/Wiimote.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb.h"
#include "Core/IPC_HLE/WII_Socket.h"
#include "Core/PowerPC/PowerPC.h"
#ifdef USE_GDBSTUB
@@ -65,6 +66,8 @@ bool g_aspect_wide;
namespace Core
{
bool g_want_determinism;
// Declarations and definitions
static Common::Timer s_timer;
static volatile u32 s_drawn_frame = 0;
@@ -177,6 +180,8 @@ bool Init()
s_emu_thread.join();
}
Core::UpdateWantDeterminism(/*initial*/ true);
INFO_LOG(OSREPORT, "Starting core = %s mode",
_CoreParameter.bWii ? "Wii" : "GameCube");
INFO_LOG(OSREPORT, "CPU Thread separate = %s",
@@ -564,6 +569,9 @@ void RequestRefreshInfo()
bool PauseAndLock(bool doLock, bool unpauseOnUnlock)
{
if (!IsRunning())
return true;
// let's support recursive locking to simplify things on the caller's side,
// and let's do it at this outer level in case the individual systems don't support it.
if (doLock ? s_pause_and_lock_depth++ : --s_pause_and_lock_depth)
@@ -702,4 +710,27 @@ void SetOnStoppedCallback(StoppedCallbackFunc callback)
s_on_stopped_callback = callback;
}
void UpdateWantDeterminism(bool initial)
{
// For now, this value is not itself configurable. Instead, individual
// settings that depend on it, such as GPU determinism mode. should have
// override options for testing,
bool new_want_determinism =
Movie::IsPlayingInput() ||
Movie::IsRecordingInput() ||
NetPlay::IsNetPlayRunning();
if (new_want_determinism != g_want_determinism || initial)
{
WARN_LOG(COMMON, "Want determinism <- %s", new_want_determinism ? "true" : "false");
bool was_unpaused = Core::PauseAndLock(true);
g_want_determinism = new_want_determinism;
WiiSockMan::GetInstance().UpdateWantDeterminism(new_want_determinism);
g_video_backend->UpdateWantDeterminism(new_want_determinism);
Core::PauseAndLock(false, was_unpaused);
}
}
} // Core