Fix indeterminism in GPU thread mode.

This commit is contained in:
comex 2015-06-06 01:20:51 -04:00
parent f2631a835e
commit 9c63b78397
6 changed files with 19 additions and 4 deletions

View File

@ -29,6 +29,7 @@
#include "Core/Host.h"
#include "Core/MemTools.h"
#include "Core/Movie.h"
#include "Core/NetPlayClient.h"
#include "Core/NetPlayProto.h"
#include "Core/PatchEngine.h"
#include "Core/State.h"
@ -129,6 +130,12 @@ void SetIsFramelimiterTempDisabled(bool disable)
std::string GetStateFileName() { return s_state_filename; }
void SetStateFileName(const std::string& val) { s_state_filename = val; }
void FrameUpdateOnCPUThread()
{
if (NetPlay::IsNetPlayRunning())
NetPlayClient::SendTimeBase();
}
// Display messages and return values
// Formatted stop message

View File

@ -63,6 +63,8 @@ void SetStateFileName(const std::string& val);
void SetBlockStart(u32 addr);
void FrameUpdateOnCPUThread();
bool ShouldSkipFrame(int skipped);
void VideoThrottle();
void RequestRefreshInfo();

View File

@ -140,6 +140,8 @@ std::string GetInputDisplay()
void FrameUpdate()
{
// TODO[comex]: This runs on the GPU thread, yet it messes with the CPU
// state directly. That's super sketchy.
g_currentFrame++;
if (!s_bPolled)
g_currentLagCount++;
@ -164,9 +166,6 @@ void FrameUpdate()
FrameSkipping();
s_bPolled = false;
if (NetPlay::IsNetPlayRunning())
NetPlayClient::SendTimeBase();
}
// called when game is booting up, even if no movie is active,

View File

@ -663,6 +663,8 @@ bool NetPlayClient::StartGame(const std::string &path)
m_dialog->AppendChat(" -- STARTING GAME -- ");
m_timebase_frame = 0;
m_is_running.store(true);
NetPlay_Enable(this);
@ -1074,7 +1076,7 @@ void NetPlayClient::SendTimeBase()
*spac << (MessageId)NP_MSG_TIMEBASE;
*spac << (u32)timebase;
*spac << (u32)(timebase << 32);
*spac << (u32)Movie::g_currentFrame;
*spac << netplay_client->m_timebase_frame++;
netplay_client->SendAsync(spac);
}

View File

@ -143,6 +143,8 @@ private:
std::string m_player_name;
bool m_connecting;
TraversalClient* m_traversal_client;
u32 m_timebase_frame;
};
void NetPlay_Enable(NetPlayClient* const np);

View File

@ -11,6 +11,7 @@
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
#include "Core/State.h"
#include "Core/HW/MMIO.h"
@ -282,6 +283,8 @@ void SetFinish_OnMainThread(u64 userdata, int cyclesLate)
s_signal_finish_interrupt.store(1);
UpdateInterrupts();
CommandProcessor::SetInterruptFinishWaiting(false);
Core::FrameUpdateOnCPUThread();
}
// SetToken