diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 6dbc75468d..5607a80dc2 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -599,7 +599,7 @@ static void EmuThread(std::unique_ptr boot, WindowSystemInfo wsi wiifs_guard.Dismiss(); // This adds the SyncGPU handler to CoreTiming, so now CoreTiming::Advance might block. - system.GetFifo().Prepare(); + system.GetFifo().Prepare(system); // Setup our core if (Config::Get(Config::MAIN_CPU_CORE) != PowerPC::CPUCore::Interpreter) @@ -624,7 +624,7 @@ static void EmuThread(std::unique_ptr boot, WindowSystemInfo wsi s_cpu_thread = std::thread(cpuThreadFunc, savestate_path, delete_savestate); // become the GPU thread - system.GetFifo().RunGpuLoop(); + system.GetFifo().RunGpuLoop(system); // We have now exited the Video Loop INFO_LOG_FMT(CONSOLE, "{}", StopMessage(false, "Video Loop Ended")); @@ -769,7 +769,7 @@ static bool PauseAndLock(bool do_lock, bool unpause_on_unlock) // video has to come after CPU, because CPU thread can wait for video thread // (s_efbAccessRequested). auto& system = Core::System::GetInstance(); - system.GetFifo().PauseAndLock(do_lock, false); + system.GetFifo().PauseAndLock(system, do_lock, false); ResetRumble(); @@ -1034,7 +1034,7 @@ void UpdateWantDeterminism(bool initial) ios->UpdateWantDeterminism(new_want_determinism); auto& system = Core::System::GetInstance(); - system.GetFifo().UpdateWantDeterminism(new_want_determinism); + system.GetFifo().UpdateWantDeterminism(system, new_want_determinism); // We need to clear the cache because some parts of the JIT depend on want_determinism, // e.g. use of FMA. diff --git a/Source/Core/Core/CoreTiming.cpp b/Source/Core/Core/CoreTiming.cpp index a25700f6ad..1d4f085b99 100644 --- a/Source/Core/Core/CoreTiming.cpp +++ b/Source/Core/Core/CoreTiming.cpp @@ -355,7 +355,7 @@ void CoreTimingManager::Idle() // the VI will be desynchronized. So, We are waiting until the FIFO finish and // while we process only the events required by the FIFO. auto& system = Core::System::GetInstance(); - system.GetFifo().FlushGpu(); + system.GetFifo().FlushGpu(system); } PowerPC::UpdatePerformanceMonitor(PowerPC::ppcState.downcount, 0, 0); diff --git a/Source/Core/DolphinQt/Host.cpp b/Source/Core/DolphinQt/Host.cpp index 0b7207cb49..01dcc46dc1 100644 --- a/Source/Core/DolphinQt/Host.cpp +++ b/Source/Core/DolphinQt/Host.cpp @@ -114,10 +114,11 @@ static void RunWithGPUThreadInactive(std::function f) // the CPU and GPU threads are the same thread, and we already checked for the GPU thread.) const bool was_running = Core::GetState() == Core::State::Running; - auto& fifo = Core::System::GetInstance().GetFifo(); - fifo.PauseAndLock(true, was_running); + auto& system = Core::System::GetInstance(); + auto& fifo = system.GetFifo(); + fifo.PauseAndLock(system, true, was_running); f(); - fifo.PauseAndLock(false, was_running); + fifo.PauseAndLock(system, false, was_running); } else { diff --git a/Source/Core/VideoCommon/AsyncRequests.cpp b/Source/Core/VideoCommon/AsyncRequests.cpp index 7e3b329ad6..aca5be57a4 100644 --- a/Source/Core/VideoCommon/AsyncRequests.cpp +++ b/Source/Core/VideoCommon/AsyncRequests.cpp @@ -92,7 +92,7 @@ void AsyncRequests::PushEvent(const AsyncRequests::Event& event, bool blocking) m_queue.push(event); auto& system = Core::System::GetInstance(); - system.GetFifo().RunGpu(); + system.GetFifo().RunGpu(system); if (blocking) { m_cond.wait(lock, [this] { return m_queue.empty(); }); diff --git a/Source/Core/VideoCommon/CommandProcessor.cpp b/Source/Core/VideoCommon/CommandProcessor.cpp index 663539a678..529c82db04 100644 --- a/Source/Core/VideoCommon/CommandProcessor.cpp +++ b/Source/Core/VideoCommon/CommandProcessor.cpp @@ -223,7 +223,7 @@ void CommandProcessorManager::RegisterMMIO(Core::System& system, MMIO::Mapping* mmio->Register(base | STATUS_REGISTER, MMIO::ComplexRead([](Core::System& system, u32) { auto& cp = system.GetCommandProcessor(); - system.GetFifo().SyncGPUForRegisterAccess(); + system.GetFifo().SyncGPUForRegisterAccess(system); cp.SetCpStatusRegister(system); return cp.m_cp_status_reg.Hex; }), @@ -235,7 +235,7 @@ void CommandProcessorManager::RegisterMMIO(Core::System& system, MMIO::Mapping* UCPCtrlReg tmp(val); cp.m_cp_ctrl_reg.Hex = tmp.Hex; cp.SetCpControlRegister(system); - system.GetFifo().RunGpu(); + system.GetFifo().RunGpu(system); })); mmio->Register(base | CLEAR_REGISTER, MMIO::DirectRead(&m_cp_clear_reg.Hex), @@ -244,7 +244,7 @@ void CommandProcessorManager::RegisterMMIO(Core::System& system, MMIO::Mapping* UCPClearReg tmp(val); cp.m_cp_clear_reg.Hex = tmp.Hex; cp.SetCpClearRegister(); - system.GetFifo().RunGpu(); + system.GetFifo().RunGpu(system); })); mmio->Register(base | PERF_SELECT, MMIO::InvalidRead(), MMIO::Nop()); @@ -284,7 +284,7 @@ void CommandProcessorManager::RegisterMMIO(Core::System& system, MMIO::Mapping* { fifo_rw_distance_hi_r = MMIO::ComplexRead([](Core::System& system, u32) { const auto& fifo = system.GetCommandProcessor().GetFifo(); - system.GetFifo().SyncGPUForRegisterAccess(); + system.GetFifo().SyncGPUForRegisterAccess(system); if (fifo.CPWritePointer.load(std::memory_order_relaxed) >= fifo.SafeCPReadPointer.load(std::memory_order_relaxed)) { @@ -306,16 +306,16 @@ void CommandProcessorManager::RegisterMMIO(Core::System& system, MMIO::Mapping* { fifo_rw_distance_hi_r = MMIO::ComplexRead([](Core::System& system, u32) { const auto& fifo = system.GetCommandProcessor().GetFifo(); - system.GetFifo().SyncGPUForRegisterAccess(); + system.GetFifo().SyncGPUForRegisterAccess(system); return fifo.CPReadWriteDistance.load(std::memory_order_relaxed) >> 16; }); } mmio->Register(base | FIFO_RW_DISTANCE_HI, fifo_rw_distance_hi_r, MMIO::ComplexWrite([WMASK_HI_RESTRICT](Core::System& system, u32, u16 val) { auto& fifo = system.GetCommandProcessor().GetFifo(); - system.GetFifo().SyncGPUForRegisterAccess(); + system.GetFifo().SyncGPUForRegisterAccess(system); WriteHigh(fifo.CPReadWriteDistance, val & WMASK_HI_RESTRICT); - system.GetFifo().RunGpu(); + system.GetFifo().RunGpu(system); })); mmio->Register( @@ -330,12 +330,12 @@ void CommandProcessorManager::RegisterMMIO(Core::System& system, MMIO::Mapping* { fifo_read_hi_r = MMIO::ComplexRead([](Core::System& system, u32) { auto& fifo = system.GetCommandProcessor().GetFifo(); - system.GetFifo().SyncGPUForRegisterAccess(); + system.GetFifo().SyncGPUForRegisterAccess(system); return fifo.SafeCPReadPointer.load(std::memory_order_relaxed) >> 16; }); fifo_read_hi_w = MMIO::ComplexWrite([WMASK_HI_RESTRICT](Core::System& sys, u32, u16 val) { auto& fifo = sys.GetCommandProcessor().GetFifo(); - sys.GetFifo().SyncGPUForRegisterAccess(); + sys.GetFifo().SyncGPUForRegisterAccess(sys); WriteHigh(fifo.CPReadPointer, val & WMASK_HI_RESTRICT); fifo.SafeCPReadPointer.store(fifo.CPReadPointer.load(std::memory_order_relaxed), std::memory_order_relaxed); @@ -345,12 +345,12 @@ void CommandProcessorManager::RegisterMMIO(Core::System& system, MMIO::Mapping* { fifo_read_hi_r = MMIO::ComplexRead([](Core::System& system, u32) { const auto& fifo = system.GetCommandProcessor().GetFifo(); - system.GetFifo().SyncGPUForRegisterAccess(); + system.GetFifo().SyncGPUForRegisterAccess(system); return fifo.CPReadPointer.load(std::memory_order_relaxed) >> 16; }); fifo_read_hi_w = MMIO::ComplexWrite([WMASK_HI_RESTRICT](Core::System& sys, u32, u16 val) { auto& fifo = sys.GetCommandProcessor().GetFifo(); - sys.GetFifo().SyncGPUForRegisterAccess(); + sys.GetFifo().SyncGPUForRegisterAccess(sys); WriteHigh(fifo.CPReadPointer, val & WMASK_HI_RESTRICT); }); } @@ -374,10 +374,10 @@ void CommandProcessorManager::GatherPipeBursted(Core::System& system) (ProcessorInterface::Fifo_CPUBase == fifo.CPBase.load(std::memory_order_relaxed)) && fifo.CPReadWriteDistance.load(std::memory_order_relaxed) > 0) { - system.GetFifo().FlushGpu(); + system.GetFifo().FlushGpu(system); } } - system.GetFifo().RunGpu(); + system.GetFifo().RunGpu(system); return; } @@ -405,7 +405,7 @@ void CommandProcessorManager::GatherPipeBursted(Core::System& system) fifo.CPReadWriteDistance.fetch_add(GPFifo::GATHER_PIPE_SIZE, std::memory_order_seq_cst); - system.GetFifo().RunGpu(); + system.GetFifo().RunGpu(system); ASSERT_MSG(COMMANDPROCESSOR, fifo.CPReadWriteDistance.load(std::memory_order_relaxed) <= @@ -442,7 +442,7 @@ void CommandProcessorManager::UpdateInterrupts(Core::System& system, u64 userdat } system.GetCoreTiming().ForceExceptionCheck(0); m_interrupt_waiting.Clear(); - system.GetFifo().RunGpu(); + system.GetFifo().RunGpu(system); } void CommandProcessorManager::UpdateInterruptsFromVideoBackend(Core::System& system, u64 userdata) @@ -583,7 +583,7 @@ void CommandProcessorManager::SetCpStatusRegister(Core::System& system) (fifo.CPReadPointer.load(std::memory_order_relaxed) == fifo.CPWritePointer.load(std::memory_order_relaxed)); m_cp_status_reg.CommandIdle = !fifo.CPReadWriteDistance.load(std::memory_order_relaxed) || - system.GetFifo().AtBreakpoint() || + Fifo::AtBreakpoint(system) || !fifo.bFF_GPReadEnable.load(std::memory_order_relaxed); m_cp_status_reg.UnderflowLoWatermark = fifo.bFF_LoWatermark.load(std::memory_order_relaxed); m_cp_status_reg.OverflowHiWatermark = fifo.bFF_HiWatermark.load(std::memory_order_relaxed); @@ -610,7 +610,7 @@ void CommandProcessorManager::SetCpControlRegister(Core::System& system) if (fifo.bFF_GPReadEnable.load(std::memory_order_relaxed) && !m_cp_ctrl_reg.GPReadEnable) { fifo.bFF_GPReadEnable.store(m_cp_ctrl_reg.GPReadEnable, std::memory_order_relaxed); - system.GetFifo().FlushGpu(); + system.GetFifo().FlushGpu(system); } else { diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index d222157b93..547d6488d7 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -64,14 +64,14 @@ void FifoManager::DoState(PointerWrap& p) p.Do(m_syncing_suspended); } -void FifoManager::PauseAndLock(bool doLock, bool unpauseOnUnlock) +void FifoManager::PauseAndLock(Core::System& system, bool doLock, bool unpauseOnUnlock) { if (doLock) { SyncGPU(SyncGPUReason::Other); EmulatorState(false); - if (!Core::System::GetInstance().IsDualCoreMode() || m_use_deterministic_gpu_thread) + if (!system.IsDualCoreMode() || m_use_deterministic_gpu_thread) return; m_gpu_mainloop.WaitYield(std::chrono::milliseconds(100), Host_YieldToUI); @@ -83,7 +83,7 @@ void FifoManager::PauseAndLock(bool doLock, bool unpauseOnUnlock) } } -void FifoManager::Init() +void FifoManager::Init(Core::System& system) { if (!m_config_callback_id) m_config_callback_id = Config::AddConfigChangedCallback([this] { RefreshConfig(); }); @@ -92,7 +92,7 @@ void FifoManager::Init() // Padded so that SIMD overreads in the vertex loader are safe m_video_buffer = static_cast(Common::AllocateMemoryPages(FIFO_SIZE + 4)); ResetVideoBuffer(); - if (Core::System::GetInstance().IsDualCoreMode()) + if (system.IsDualCoreMode()) m_gpu_mainloop.Prepare(); m_sync_ticks.store(0); } @@ -120,15 +120,14 @@ void FifoManager::Shutdown() // May be executed from any thread, even the graphics thread. // Created to allow for self shutdown. -void FifoManager::ExitGpuLoop() +void FifoManager::ExitGpuLoop(Core::System& system) { - auto& system = Core::System::GetInstance(); auto& command_processor = system.GetCommandProcessor(); auto& fifo = command_processor.GetFifo(); // This should break the wait loop in CPU thread fifo.bFF_GPReadEnable.store(0, std::memory_order_relaxed); - FlushGpu(); + FlushGpu(system); // Terminate GPU thread loop m_emu_running_state.Set(); @@ -212,7 +211,7 @@ void* FifoManager::PopFifoAuxBuffer(size_t size) } // Description: RunGpuLoop() sends data through this function. -void FifoManager::ReadDataFromFifo(u32 readPtr) +void FifoManager::ReadDataFromFifo(Core::System& system, u32 readPtr) { if (GPFifo::GATHER_PIPE_SIZE > static_cast(m_video_buffer + FIFO_SIZE - m_video_buffer_write_ptr)) @@ -229,14 +228,13 @@ void FifoManager::ReadDataFromFifo(u32 readPtr) m_video_buffer_read_ptr = m_video_buffer; } // Copy new video instructions to m_video_buffer for future use in rendering the new picture - auto& system = Core::System::GetInstance(); auto& memory = system.GetMemory(); memory.CopyFromEmu(m_video_buffer_write_ptr, readPtr, GPFifo::GATHER_PIPE_SIZE); m_video_buffer_write_ptr += GPFifo::GATHER_PIPE_SIZE; } // The deterministic_gpu_thread version. -void FifoManager::ReadDataFromFifoOnCPU(u32 readPtr) +void FifoManager::ReadDataFromFifoOnCPU(Core::System& system, u32 readPtr) { u8* write_ptr = m_video_buffer_write_ptr; if (GPFifo::GATHER_PIPE_SIZE > static_cast(m_video_buffer + FIFO_SIZE - write_ptr)) @@ -264,7 +262,6 @@ void FifoManager::ReadDataFromFifoOnCPU(u32 readPtr) return; } } - auto& system = Core::System::GetInstance(); auto& memory = system.GetMemory(); memory.CopyFromEmu(m_video_buffer_write_ptr, readPtr, GPFifo::GATHER_PIPE_SIZE); m_video_buffer_pp_read_ptr = OpcodeDecoder::RunFifo( @@ -285,13 +282,13 @@ void FifoManager::ResetVideoBuffer() // Description: Main FIFO update loop // Purpose: Keep the Core HW updated about the CPU-GPU distance -void FifoManager::RunGpuLoop() +void FifoManager::RunGpuLoop(Core::System& system) { AsyncRequests::GetInstance()->SetEnable(true); AsyncRequests::GetInstance()->SetPassthrough(false); m_gpu_mainloop.Run( - [this] { + [this, &system] { // Run events from the CPU thread. AsyncRequests::GetInstance()->PullEvents(); @@ -314,7 +311,6 @@ void FifoManager::RunGpuLoop() } else { - auto& system = Core::System::GetInstance(); auto& command_processor = system.GetCommandProcessor(); auto& fifo = command_processor.GetFifo(); command_processor.SetCPStatusFromGPU(system); @@ -322,14 +318,14 @@ void FifoManager::RunGpuLoop() // check if we are able to run this buffer while (!command_processor.IsInterruptWaiting() && fifo.bFF_GPReadEnable.load(std::memory_order_relaxed) && - fifo.CPReadWriteDistance.load(std::memory_order_relaxed) && !AtBreakpoint()) + fifo.CPReadWriteDistance.load(std::memory_order_relaxed) && !AtBreakpoint(system)) { if (m_config_sync_gpu && m_sync_ticks.load() < m_config_sync_gpu_min_distance) break; u32 cyclesExecuted = 0; u32 readPtr = fifo.CPReadPointer.load(std::memory_order_relaxed); - ReadDataFromFifo(readPtr); + ReadDataFromFifo(system, readPtr); if (readPtr == fifo.CPEnd.load(std::memory_order_relaxed)) readPtr = fifo.CPBase.load(std::memory_order_relaxed); @@ -396,9 +392,9 @@ void FifoManager::RunGpuLoop() AsyncRequests::GetInstance()->SetPassthrough(true); } -void FifoManager::FlushGpu() +void FifoManager::FlushGpu(Core::System& system) { - if (!Core::System::GetInstance().IsDualCoreMode() || m_use_deterministic_gpu_thread) + if (!system.IsDualCoreMode() || m_use_deterministic_gpu_thread) return; m_gpu_mainloop.Wait(); @@ -409,9 +405,8 @@ void FifoManager::GpuMaySleep() m_gpu_mainloop.AllowSleep(); } -bool FifoManager::AtBreakpoint() const +bool AtBreakpoint(Core::System& system) { - auto& system = Core::System::GetInstance(); auto& command_processor = system.GetCommandProcessor(); const auto& fifo = command_processor.GetFifo(); return fifo.bFF_BPEnable.load(std::memory_order_relaxed) && @@ -419,9 +414,8 @@ bool FifoManager::AtBreakpoint() const fifo.CPBreakpoint.load(std::memory_order_relaxed)); } -void FifoManager::RunGpu() +void FifoManager::RunGpu(Core::System& system) { - auto& system = Core::System::GetInstance(); const bool is_dual_core = system.IsDualCoreMode(); // wake up GPU thread @@ -442,20 +436,19 @@ void FifoManager::RunGpu() } } -int FifoManager::RunGpuOnCpu(int ticks) +int FifoManager::RunGpuOnCpu(Core::System& system, int ticks) { - auto& system = Core::System::GetInstance(); auto& command_processor = system.GetCommandProcessor(); auto& fifo = command_processor.GetFifo(); bool reset_simd_state = false; int available_ticks = int(ticks * m_config_sync_gpu_overclock) + m_sync_ticks.load(); while (fifo.bFF_GPReadEnable.load(std::memory_order_relaxed) && - fifo.CPReadWriteDistance.load(std::memory_order_relaxed) && !AtBreakpoint() && + fifo.CPReadWriteDistance.load(std::memory_order_relaxed) && !AtBreakpoint(system) && available_ticks >= 0) { if (m_use_deterministic_gpu_thread) { - ReadDataFromFifoOnCPU(fifo.CPReadPointer.load(std::memory_order_relaxed)); + ReadDataFromFifoOnCPU(system, fifo.CPReadPointer.load(std::memory_order_relaxed)); m_gpu_mainloop.Wakeup(); } else @@ -466,7 +459,7 @@ int FifoManager::RunGpuOnCpu(int ticks) FPURoundMode::LoadDefaultSIMDState(); reset_simd_state = true; } - ReadDataFromFifo(fifo.CPReadPointer.load(std::memory_order_relaxed)); + ReadDataFromFifo(system, fifo.CPReadPointer.load(std::memory_order_relaxed)); u32 cycles = 0; m_video_buffer_read_ptr = OpcodeDecoder::RunFifo( DataReader(m_video_buffer_read_ptr, m_video_buffer_write_ptr), &cycles); @@ -505,7 +498,7 @@ int FifoManager::RunGpuOnCpu(int ticks) return -available_ticks + GPU_TIME_SLOT_SIZE; } -void FifoManager::UpdateWantDeterminism(bool want) +void FifoManager::UpdateWantDeterminism(Core::System& system, bool want) { // We are paused (or not running at all yet), so // it should be safe to change this. @@ -523,7 +516,7 @@ void FifoManager::UpdateWantDeterminism(bool want) break; } - gpu_thread = gpu_thread && Core::System::GetInstance().IsDualCoreMode(); + gpu_thread = gpu_thread && system.IsDualCoreMode(); if (m_use_deterministic_gpu_thread != gpu_thread) { @@ -543,7 +536,7 @@ void FifoManager::UpdateWantDeterminism(bool want) * @ticks The gone emulated CPU time. * @return A good time to call WaitForGpuThread() next. */ -int FifoManager::WaitForGpuThread(int ticks) +int FifoManager::WaitForGpuThread(Core::System& system, int ticks) { int old = m_sync_ticks.fetch_add(ticks); int now = old + ticks; @@ -554,7 +547,7 @@ int FifoManager::WaitForGpuThread(int ticks) // Wakeup GPU if (old < m_config_sync_gpu_min_distance && now >= m_config_sync_gpu_min_distance) - RunGpu(); + RunGpu(system); // If the GPU is still sleeping, wait for a longer time if (now < m_config_sync_gpu_min_distance) @@ -575,11 +568,11 @@ void FifoManager::SyncGPUCallback(Core::System& system, u64 ticks, s64 cyclesLat auto& fifo = system.GetFifo(); if (!system.IsDualCoreMode() || fifo.m_use_deterministic_gpu_thread) { - next = fifo.RunGpuOnCpu((int)ticks); + next = fifo.RunGpuOnCpu(system, (int)ticks); } else if (fifo.m_config_sync_gpu) { - next = fifo.WaitForGpuThread((int)ticks); + next = fifo.WaitForGpuThread(system, (int)ticks); } fifo.m_syncing_suspended = next < 0; @@ -587,21 +580,20 @@ void FifoManager::SyncGPUCallback(Core::System& system, u64 ticks, s64 cyclesLat system.GetCoreTiming().ScheduleEvent(next, fifo.m_event_sync_gpu, next); } -void FifoManager::SyncGPUForRegisterAccess() +void FifoManager::SyncGPUForRegisterAccess(Core::System& system) { SyncGPU(SyncGPUReason::Other); - if (!Core::System::GetInstance().IsDualCoreMode() || m_use_deterministic_gpu_thread) - RunGpuOnCpu(GPU_TIME_SLOT_SIZE); + if (!system.IsDualCoreMode() || m_use_deterministic_gpu_thread) + RunGpuOnCpu(system, GPU_TIME_SLOT_SIZE); else if (m_config_sync_gpu) - WaitForGpuThread(GPU_TIME_SLOT_SIZE); + WaitForGpuThread(system, GPU_TIME_SLOT_SIZE); } // Initialize GPU - CPU thread syncing, this gives us a deterministic way to start the GPU thread. -void FifoManager::Prepare() +void FifoManager::Prepare(Core::System& system) { - m_event_sync_gpu = - Core::System::GetInstance().GetCoreTiming().RegisterEvent("SyncGPUCallback", SyncGPUCallback); + m_event_sync_gpu = system.GetCoreTiming().RegisterEvent("SyncGPUCallback", SyncGPUCallback); m_syncing_suspended = true; } } // namespace Fifo diff --git a/Source/Core/VideoCommon/Fifo.h b/Source/Core/VideoCommon/Fifo.h index ab028a5c7f..1db91eeb91 100644 --- a/Source/Core/VideoCommon/Fifo.h +++ b/Source/Core/VideoCommon/Fifo.h @@ -47,12 +47,12 @@ public: FifoManager& operator=(FifoManager&& other) = delete; ~FifoManager(); - void Init(); + void Init(Core::System& system); void Shutdown(); - void Prepare(); // Must be called from the CPU thread. + void Prepare(Core::System& system); // Must be called from the CPU thread. void DoState(PointerWrap& f); - void PauseAndLock(bool doLock, bool unpauseOnUnlock); - void UpdateWantDeterminism(bool want); + void PauseAndLock(Core::System& system, bool doLock, bool unpauseOnUnlock); + void UpdateWantDeterminism(Core::System& system, bool want); bool UseDeterministicGPUThread() const { return m_use_deterministic_gpu_thread; } // In deterministic GPU thread mode this waits for the GPU to be done with pending work. @@ -60,26 +60,25 @@ public: // In single core mode, this runs the GPU for a single slice. // In dual core mode, this synchronizes with the GPU thread. - void SyncGPUForRegisterAccess(); + void SyncGPUForRegisterAccess(Core::System& system); void PushFifoAuxBuffer(const void* ptr, size_t size); void* PopFifoAuxBuffer(size_t size); - void FlushGpu(); - void RunGpu(); + void FlushGpu(Core::System& system); + void RunGpu(Core::System& system); void GpuMaySleep(); - void RunGpuLoop(); - void ExitGpuLoop(); + void RunGpuLoop(Core::System& system); + void ExitGpuLoop(Core::System& system); void EmulatorState(bool running); - bool AtBreakpoint() const; void ResetVideoBuffer(); private: void RefreshConfig(); - void ReadDataFromFifo(u32 readPtr); - void ReadDataFromFifoOnCPU(u32 readPtr); - int RunGpuOnCpu(int ticks); - int WaitForGpuThread(int ticks); + void ReadDataFromFifo(Core::System& system, u32 readPtr); + void ReadDataFromFifoOnCPU(Core::System& system, u32 readPtr); + int RunGpuOnCpu(Core::System& system, int ticks); + int WaitForGpuThread(Core::System& system, int ticks); static void SyncGPUCallback(Core::System& system, u64 ticks, s64 cyclesLate); static constexpr u32 FIFO_SIZE = 2 * 1024 * 1024; @@ -127,4 +126,6 @@ private: int m_config_sync_gpu_min_distance = 0; float m_config_sync_gpu_overclock = 0.0f; }; + +bool AtBreakpoint(Core::System& system); } // namespace Fifo diff --git a/Source/Core/VideoCommon/VideoBackendBase.cpp b/Source/Core/VideoCommon/VideoBackendBase.cpp index 29915c2803..4f79af81f7 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.cpp +++ b/Source/Core/VideoCommon/VideoBackendBase.cpp @@ -84,7 +84,7 @@ std::string VideoBackendBase::BadShaderFilename(const char* shader_stage, int co void VideoBackendBase::Video_ExitLoop() { auto& system = Core::System::GetInstance(); - system.GetFifo().ExitGpuLoop(); + system.GetFifo().ExitGpuLoop(system); } // Run from the CPU thread (from VideoInterface.cpp) @@ -324,7 +324,7 @@ void VideoBackendBase::InitializeShared() auto& system = Core::System::GetInstance(); auto& command_processor = system.GetCommandProcessor(); command_processor.Init(system); - system.GetFifo().Init(); + system.GetFifo().Init(system); PixelEngine::Init(); BPInit(); VertexLoaderManager::Init();