summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorcomex <comexk@gmail.com>2014-09-06 17:26:40 -0400
committercomex <comexk@gmail.com>2014-09-28 21:34:31 -0400
commit3a2048ea570b428ea34adbfea6b71280e1ae5cc0 (patch)
treef5d4207a6b17c315c46af6e4bedf48ddea46efb2 /Source/Core/VideoCommon
parent65af90669bd5f9e02bbaa994d51d5c83d147b868 (diff)
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.
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/Fifo.cpp28
-rw-r--r--Source/Core/VideoCommon/Fifo.h1
-rw-r--r--Source/Core/VideoCommon/MainBase.cpp5
-rw-r--r--Source/Core/VideoCommon/VideoBackendBase.h4
4 files changed, 37 insertions, 1 deletions
diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp
index 87764ec85c..a47438c41e 100644
--- a/Source/Core/VideoCommon/Fifo.cpp
+++ b/Source/Core/VideoCommon/Fifo.cpp
@@ -11,13 +11,16 @@
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
+#include "Core/NetPlayProto.h"
#include "Core/HW/Memmap.h"
#include "VideoCommon/CommandProcessor.h"
+#include "VideoCommon/CPMemory.h"
#include "VideoCommon/DataReader.h"
#include "VideoCommon/Fifo.h"
#include "VideoCommon/OpcodeDecoding.h"
#include "VideoCommon/PixelEngine.h"
+#include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VideoConfig.h"
bool g_bSkipCurrentFrame = false;
@@ -31,7 +34,7 @@ static u8 s_fifo_aux_data[FIFO_SIZE];
static u8* s_fifo_aux_write_ptr;
static u8* s_fifo_aux_read_ptr;
-bool g_use_deterministic_gpu_thread = true; // XXX
+bool g_use_deterministic_gpu_thread;
// STATE_TO_SAVE
static std::mutex s_video_buffer_lock;
@@ -413,3 +416,26 @@ void RunGpu()
}
CommandProcessor::SetCPStatusFromGPU();
}
+
+void Fifo_UpdateWantDeterminism(bool want)
+{
+ // We are paused (or not running at all yet) and have m_csHWVidOccupied, so
+ // it should be safe to change this.
+ g_use_deterministic_gpu_thread = want && SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread;
+
+ // Hack: For now movies are an exception to this being on (but not
+ // to wanting determinism in general). Once vertex arrays are
+ // fixed, there should be no reason to want this off for movies by
+ // default, so this can be removed.
+ if (NetPlay::IsNetPlayRunning())
+ g_use_deterministic_gpu_thread = false;
+
+ if (g_use_deterministic_gpu_thread)
+ {
+ // These haven't been updated in non-deterministic mode.
+ s_video_buffer_seen_ptr = g_video_buffer_pp_read_ptr = g_video_buffer_read_ptr;
+ CopyPreprocessCPStateFromMain();
+ VertexLoaderManager::MarkAllDirty();
+ }
+
+}
diff --git a/Source/Core/VideoCommon/Fifo.h b/Source/Core/VideoCommon/Fifo.h
index 175d6b6e4a..40a5ad84b7 100644
--- a/Source/Core/VideoCommon/Fifo.h
+++ b/Source/Core/VideoCommon/Fifo.h
@@ -27,6 +27,7 @@ u8* GetVideoBufferEndPtr();
void Fifo_DoState(PointerWrap &f);
void Fifo_PauseAndLock(bool doLock, bool unpauseOnUnlock);
+void Fifo_UpdateWantDeterminism(bool want);
// Used for diagnostics.
enum SyncGPUReason {
diff --git a/Source/Core/VideoCommon/MainBase.cpp b/Source/Core/VideoCommon/MainBase.cpp
index 082c81c2ea..d775cfe64c 100644
--- a/Source/Core/VideoCommon/MainBase.cpp
+++ b/Source/Core/VideoCommon/MainBase.cpp
@@ -309,3 +309,8 @@ void VideoBackendHardware::RegisterCPMMIO(MMIO::Mapping* mmio, u32 base)
CommandProcessor::RegisterMMIO(mmio, base);
}
+void VideoBackendHardware::UpdateWantDeterminism(bool want)
+{
+ Fifo_UpdateWantDeterminism(want);
+}
+
diff --git a/Source/Core/VideoCommon/VideoBackendBase.h b/Source/Core/VideoCommon/VideoBackendBase.h
index 6ab9fce8f2..7d62dda37b 100644
--- a/Source/Core/VideoCommon/VideoBackendBase.h
+++ b/Source/Core/VideoCommon/VideoBackendBase.h
@@ -116,6 +116,8 @@ public:
virtual void DoState(PointerWrap &p) = 0;
virtual void CheckInvalidState() = 0;
+
+ virtual void UpdateWantDeterminism(bool want) {}
};
extern std::vector<VideoBackend*> g_available_video_backends;
@@ -151,6 +153,8 @@ class VideoBackendHardware : public VideoBackend
void PauseAndLock(bool doLock, bool unpauseOnUnlock=true) override;
void DoState(PointerWrap &p) override;
+ void UpdateWantDeterminism(bool want) override;
+
bool m_invalid;
public: