diff options
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/AsyncRequests.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/BPStructs.cpp | 8 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/CommandProcessor.cpp | 28 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Fifo.cpp | 19 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Fifo.h | 19 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/MainBase.cpp | 8 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/OpcodeDecoding.cpp | 8 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/PixelEngine.cpp | 4 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VideoState.cpp | 4 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/XFStructs.cpp | 6 |
10 files changed, 58 insertions, 48 deletions
diff --git a/Source/Core/VideoCommon/AsyncRequests.cpp b/Source/Core/VideoCommon/AsyncRequests.cpp index 1ce7c8fdb7..bddf8e7445 100644 --- a/Source/Core/VideoCommon/AsyncRequests.cpp +++ b/Source/Core/VideoCommon/AsyncRequests.cpp @@ -81,7 +81,7 @@ void AsyncRequests::PushEvent(const AsyncRequests::Event& event, bool blocking) m_queue.push(event); - RunGpu(); + Fifo::RunGpu(); if (blocking) { m_cond.wait(lock, [this]{return m_queue.empty();}); diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index 6dc505c28e..35f017f5c5 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -177,7 +177,7 @@ static void BPWritten(const BPCmd& bp) switch (bp.newvalue & 0xFF) { case 0x02: - if (!g_use_deterministic_gpu_thread) + if (!Fifo::g_use_deterministic_gpu_thread) PixelEngine::SetFinish(); // may generate interrupt DEBUG_LOG(VIDEO, "GXSetDrawDone SetPEFinish (value: 0x%02X)", (bp.newvalue & 0xFFFF)); return; @@ -188,12 +188,12 @@ static void BPWritten(const BPCmd& bp) } return; case BPMEM_PE_TOKEN_ID: // Pixel Engine Token ID - if (!g_use_deterministic_gpu_thread) + if (!Fifo::g_use_deterministic_gpu_thread) PixelEngine::SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), false); DEBUG_LOG(VIDEO, "SetPEToken 0x%04x", (bp.newvalue & 0xFFFF)); return; case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID - if (!g_use_deterministic_gpu_thread) + if (!Fifo::g_use_deterministic_gpu_thread) PixelEngine::SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), true); DEBUG_LOG(VIDEO, "SetPEToken + INT 0x%04x", (bp.newvalue & 0xFFFF)); return; @@ -378,7 +378,7 @@ static void BPWritten(const BPCmd& bp) case BPMEM_CLEARBBOX2: // Don't compute bounding box if this frame is being skipped! // Wrong but valid values are better than bogus values... - if (!g_bSkipCurrentFrame) + if (!Fifo::g_bSkipCurrentFrame) { u8 offset = bp.address & 2; BoundingBox::active = true; diff --git a/Source/Core/VideoCommon/CommandProcessor.cpp b/Source/Core/VideoCommon/CommandProcessor.cpp index 8bca029cae..1d5e1ab172 100644 --- a/Source/Core/VideoCommon/CommandProcessor.cpp +++ b/Source/Core/VideoCommon/CommandProcessor.cpp @@ -223,7 +223,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base) UCPCtrlReg tmp(val); m_CPCtrlReg.Hex = tmp.Hex; SetCpControlRegister(); - RunGpu(); + Fifo::RunGpu(); }) ); @@ -233,7 +233,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base) UCPClearReg tmp(val); m_CPClearReg.Hex = tmp.Hex; SetCpClearRegister(); - RunGpu(); + Fifo::RunGpu(); }) ); @@ -265,17 +265,17 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base) : MMIO::DirectRead<u16>(MMIO::Utils::HighPart(&fifo.CPReadWriteDistance)), MMIO::ComplexWrite<u16>([](u32, u16 val) { WriteHigh(fifo.CPReadWriteDistance, val); - SyncGPU(SYNC_GPU_OTHER); + Fifo::SyncGPU(Fifo::SYNC_GPU_OTHER); if (fifo.CPReadWriteDistance == 0) { GPFifo::ResetGatherPipe(); - ResetVideoBuffer(); + Fifo::ResetVideoBuffer(); } else { - ResetVideoBuffer(); + Fifo::ResetVideoBuffer(); } - RunGpu(); + Fifo::RunGpu(); }) ); mmio->Register(base | FIFO_READ_POINTER_LO, @@ -306,7 +306,7 @@ void GatherPipeBursted() // if we aren't linked, we don't care about gather pipe data if (!m_CPCtrlReg.GPLinkEnable) { - if (IsOnThread() && !g_use_deterministic_gpu_thread) + if (IsOnThread() && !Fifo::g_use_deterministic_gpu_thread) { // In multibuffer mode is not allowed write in the same FIFO attached to the GPU. // Fix Pokemon XD in DC mode. @@ -314,10 +314,10 @@ void GatherPipeBursted() (ProcessorInterface::Fifo_CPUBase == fifo.CPBase) && fifo.CPReadWriteDistance > 0) { - FlushGpu(); + Fifo::FlushGpu(); } } - RunGpu(); + Fifo::RunGpu(); return; } @@ -340,7 +340,7 @@ void GatherPipeBursted() Common::AtomicAdd(fifo.CPReadWriteDistance, GATHER_PIPE_SIZE); - RunGpu(); + Fifo::RunGpu(); _assert_msg_(COMMANDPROCESSOR, fifo.CPReadWriteDistance <= fifo.CPEnd - fifo.CPBase, "FIFO is overflowed by GatherPipe !\nCPU thread is too fast!"); @@ -367,12 +367,12 @@ void UpdateInterrupts(u64 userdata) } CoreTiming::ForceExceptionCheck(0); s_interrupt_waiting.store(false); - RunGpu(); + Fifo::RunGpu(); } void UpdateInterruptsFromVideoBackend(u64 userdata) { - if (!g_use_deterministic_gpu_thread) + if (!Fifo::g_use_deterministic_gpu_thread) CoreTiming::ScheduleEvent_Threadsafe(0, et_UpdateInterrupts, userdata); } @@ -494,7 +494,7 @@ void SetCpStatusRegister() // Here always there is one fifo attached to the GPU m_CPStatusReg.Breakpoint = fifo.bFF_Breakpoint; m_CPStatusReg.ReadIdle = !fifo.CPReadWriteDistance || (fifo.CPReadPointer == fifo.CPWritePointer); - m_CPStatusReg.CommandIdle = !fifo.CPReadWriteDistance || AtBreakpoint() || !fifo.bFF_GPReadEnable; + m_CPStatusReg.CommandIdle = !fifo.CPReadWriteDistance || Fifo::AtBreakpoint() || !fifo.bFF_GPReadEnable; m_CPStatusReg.UnderflowLoWatermark = fifo.bFF_LoWatermark; m_CPStatusReg.OverflowHiWatermark = fifo.bFF_HiWatermark; @@ -519,7 +519,7 @@ void SetCpControlRegister() if (fifo.bFF_GPReadEnable && !m_CPCtrlReg.GPReadEnable) { fifo.bFF_GPReadEnable = m_CPCtrlReg.GPReadEnable; - FlushGpu(); + Fifo::FlushGpu(); } else { diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index 6ad184cc3e..97c8902bd8 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -30,6 +30,9 @@ #include "VideoCommon/VertexManagerBase.h" #include "VideoCommon/VideoConfig.h" +namespace Fifo +{ + static constexpr u32 FIFO_SIZE = 2 * 1024 * 1024; bool g_bSkipCurrentFrame = false; @@ -66,7 +69,7 @@ static u8* s_video_buffer_pp_read_ptr; static std::atomic<int> s_sync_ticks; static Common::Event s_sync_wakeup_event; -void Fifo_DoState(PointerWrap &p) +void DoState(PointerWrap &p) { p.DoArray(s_video_buffer, FIFO_SIZE); u8* write_ptr = s_video_buffer_write_ptr; @@ -81,7 +84,7 @@ void Fifo_DoState(PointerWrap &p) p.Do(g_bSkipCurrentFrame); } -void Fifo_PauseAndLock(bool doLock, bool unpauseOnUnlock) +void PauseAndLock(bool doLock, bool unpauseOnUnlock) { if (doLock) { @@ -97,7 +100,7 @@ void Fifo_PauseAndLock(bool doLock, bool unpauseOnUnlock) } -void Fifo_Init() +void Init() { // Padded so that SIMD overreads in the vertex loader are safe s_video_buffer = (u8*)AllocateMemoryPages(FIFO_SIZE + 4); @@ -107,7 +110,7 @@ void Fifo_Init() s_sync_ticks.store(0); } -void Fifo_Shutdown() +void Shutdown() { if (s_gpu_mainloop.IsRunning()) PanicAlert("Fifo shutting down while active"); @@ -122,7 +125,7 @@ void Fifo_Shutdown() s_fifo_aux_read_ptr = nullptr; } -void Fifo_SetRendering(bool enabled) +void SetRendering(bool enabled) { g_bSkipCurrentFrame = !enabled; } @@ -450,7 +453,7 @@ void RunGpu() } } -void Fifo_UpdateWantDeterminism(bool want) +void UpdateWantDeterminism(bool want) { // We are paused (or not running at all yet), so // it should be safe to change this. @@ -492,7 +495,7 @@ void Fifo_UpdateWantDeterminism(bool want) } } -int Fifo_Update(int ticks) +int Update(int ticks) { const SConfig& param = SConfig::GetInstance(); @@ -528,3 +531,5 @@ int Fifo_Update(int ticks) return param.iSyncGpuMaxDistance - s_sync_ticks.load(); } + +} diff --git a/Source/Core/VideoCommon/Fifo.h b/Source/Core/VideoCommon/Fifo.h index a66cec7fc2..c137869414 100644 --- a/Source/Core/VideoCommon/Fifo.h +++ b/Source/Core/VideoCommon/Fifo.h @@ -9,6 +9,9 @@ class PointerWrap; +namespace Fifo +{ + extern bool g_bSkipCurrentFrame; // This could be in SConfig, but it depends on multiple settings @@ -16,11 +19,11 @@ extern bool g_bSkipCurrentFrame; extern bool g_use_deterministic_gpu_thread; extern std::atomic<u8*> g_video_buffer_write_ptr_xthread; -void Fifo_Init(); -void Fifo_Shutdown(); -void Fifo_DoState(PointerWrap &f); -void Fifo_PauseAndLock(bool doLock, bool unpauseOnUnlock); -void Fifo_UpdateWantDeterminism(bool want); +void Init(); +void Shutdown(); +void DoState(PointerWrap &f); +void PauseAndLock(bool doLock, bool unpauseOnUnlock); +void UpdateWantDeterminism(bool want); // Used for diagnostics. enum SyncGPUReason @@ -47,5 +50,7 @@ void ExitGpuLoop(); void EmulatorState(bool running); bool AtBreakpoint(); void ResetVideoBuffer(); -void Fifo_SetRendering(bool bEnabled); -int Fifo_Update(int ticks); +void SetRendering(bool bEnabled); +int Update(int ticks); + +}; diff --git a/Source/Core/VideoCommon/MainBase.cpp b/Source/Core/VideoCommon/MainBase.cpp index 2e14fb27d5..173c8f7077 100644 --- a/Source/Core/VideoCommon/MainBase.cpp +++ b/Source/Core/VideoCommon/MainBase.cpp @@ -31,7 +31,7 @@ static volatile struct void VideoBackendBase::Video_ExitLoop() { - ExitGpuLoop(); + Fifo::ExitGpuLoop(); s_FifoShuttingDown.Set(); } @@ -52,7 +52,7 @@ void VideoBackendBase::Video_EndField() { if (m_initialized && g_ActiveConfig.bUseXFB && g_renderer) { - SyncGPU(SYNC_GPU_SWAP); + Fifo::SyncGPU(Fifo::SYNC_GPU_SWAP); AsyncRequests::Event e; e.time = 0; @@ -105,7 +105,7 @@ u32 VideoBackendBase::Video_GetQueryResult(PerfQueryType type) return 0; } - SyncGPU(SYNC_GPU_PERFQUERY); + Fifo::SyncGPU(Fifo::SYNC_GPU_PERFQUERY); AsyncRequests::Event e; e.time = 0; @@ -131,7 +131,7 @@ u16 VideoBackendBase::Video_GetBoundingBox(int index) return 0; } - SyncGPU(SYNC_GPU_BBOX); + Fifo::SyncGPU(Fifo::SYNC_GPU_BBOX); AsyncRequests::Event e; u16 result; diff --git a/Source/Core/VideoCommon/OpcodeDecoding.cpp b/Source/Core/VideoCommon/OpcodeDecoding.cpp index 000711b19e..5e7b57a54a 100644 --- a/Source/Core/VideoCommon/OpcodeDecoding.cpp +++ b/Source/Core/VideoCommon/OpcodeDecoding.cpp @@ -39,8 +39,8 @@ static u32 InterpretDisplayList(u32 address, u32 size) { u8* startAddress; - if (g_use_deterministic_gpu_thread) - startAddress = (u8*)PopFifoAuxBuffer(size); + if (Fifo::g_use_deterministic_gpu_thread) + startAddress = (u8*)Fifo::PopFifoAuxBuffer(size); else startAddress = Memory::GetPointer(address); @@ -66,7 +66,7 @@ static void InterpretDisplayListPreprocess(u32 address, u32 size) { u8* startAddress = Memory::GetPointer(address); - PushFifoAuxBuffer(startAddress, size); + Fifo::PushFifoAuxBuffer(startAddress, size); if (startAddress != nullptr) { @@ -278,7 +278,7 @@ u8* OpcodeDecoder_Run(DataReader src, u32* cycles, bool in_display_list) (cmd_byte & GX_PRIMITIVE_MASK) >> GX_PRIMITIVE_SHIFT, num_vertices, src, - g_bSkipCurrentFrame, + Fifo::g_bSkipCurrentFrame, is_preprocess); if (bytes < 0) diff --git a/Source/Core/VideoCommon/PixelEngine.cpp b/Source/Core/VideoCommon/PixelEngine.cpp index 162815ac40..af261eb90f 100644 --- a/Source/Core/VideoCommon/PixelEngine.cpp +++ b/Source/Core/VideoCommon/PixelEngine.cpp @@ -298,7 +298,7 @@ void SetToken(const u16 _token, const int _bSetTokenAcknowledge) CommandProcessor::SetInterruptTokenWaiting(true); - if (!SConfig::GetInstance().bCPUThread || g_use_deterministic_gpu_thread) + if (!SConfig::GetInstance().bCPUThread || Fifo::g_use_deterministic_gpu_thread) CoreTiming::ScheduleEvent(0, et_SetTokenOnMainThread, _token | (_bSetTokenAcknowledge << 16)); else CoreTiming::ScheduleEvent_Threadsafe(0, et_SetTokenOnMainThread, _token | (_bSetTokenAcknowledge << 16)); @@ -310,7 +310,7 @@ void SetFinish() { CommandProcessor::SetInterruptFinishWaiting(true); - if (!SConfig::GetInstance().bCPUThread || g_use_deterministic_gpu_thread) + if (!SConfig::GetInstance().bCPUThread || Fifo::g_use_deterministic_gpu_thread) CoreTiming::ScheduleEvent(0, et_SetFinishOnMainThread, 0); else CoreTiming::ScheduleEvent_Threadsafe(0, et_SetFinishOnMainThread, 0); diff --git a/Source/Core/VideoCommon/VideoState.cpp b/Source/Core/VideoCommon/VideoState.cpp index 9f2b11f31c..53fa4f0c89 100644 --- a/Source/Core/VideoCommon/VideoState.cpp +++ b/Source/Core/VideoCommon/VideoState.cpp @@ -35,7 +35,7 @@ static void DoState(PointerWrap &p) p.DoMarker("texMem"); // FIFO - Fifo_DoState(p); + Fifo::DoState(p); p.DoMarker("Fifo"); CommandProcessor::DoState(p); @@ -71,7 +71,7 @@ void VideoCommon_DoState(PointerWrap &p) void VideoCommon_RunLoop(bool enable) { - EmulatorState(enable); + Fifo::EmulatorState(enable); } void VideoCommon_Init() diff --git a/Source/Core/VideoCommon/XFStructs.cpp b/Source/Core/VideoCommon/XFStructs.cpp index ecf1eda08e..4fb7333964 100644 --- a/Source/Core/VideoCommon/XFStructs.cpp +++ b/Source/Core/VideoCommon/XFStructs.cpp @@ -258,9 +258,9 @@ void LoadIndexedXF(u32 val, int refarray) u32* currData = (u32*)(&xfmem) + address; u32* newData; - if (g_use_deterministic_gpu_thread) + if (Fifo::g_use_deterministic_gpu_thread) { - newData = (u32*)PopFifoAuxBuffer(size * sizeof(u32)); + newData = (u32*)Fifo::PopFifoAuxBuffer(size * sizeof(u32)); } else { @@ -291,5 +291,5 @@ void PreprocessIndexedXF(u32 val, int refarray) u32* new_data = (u32*)Memory::GetPointer(g_preprocess_cp_state.array_bases[refarray] + g_preprocess_cp_state.array_strides[refarray] * index); size_t buf_size = size * sizeof(u32); - PushFifoAuxBuffer(new_data, buf_size); + Fifo::PushFifoAuxBuffer(new_data, buf_size); } |
