From 14125cf9519d3ca17d2ea160e83112cf8b7b27a2 Mon Sep 17 00:00:00 2001 From: comex Date: Sun, 24 Aug 2014 16:27:32 -0400 Subject: [PATCH] Refactor SetCpStatus into two functions for from-GPU and from-CPU mode rather than a boolean parameter. This shouldn't affect functionality. I'm not sure if the breakpoint distinction is actually necessary (my commit messages from the old dc-netplay last year claim that breakpoints are broken anyway, but I don't remember why), but I don't actually need to change this part of the code (yet), so I'll stick with the trimmings change for now. --- Source/Core/VideoCommon/CommandProcessor.cpp | 46 ++++++++++---------- Source/Core/VideoCommon/CommandProcessor.h | 3 +- Source/Core/VideoCommon/Fifo.cpp | 6 +-- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Source/Core/VideoCommon/CommandProcessor.cpp b/Source/Core/VideoCommon/CommandProcessor.cpp index 9da48f5302..b54e503240 100644 --- a/Source/Core/VideoCommon/CommandProcessor.cpp +++ b/Source/Core/VideoCommon/CommandProcessor.cpp @@ -317,7 +317,7 @@ void STACKALIGN GatherPipeBursted() } if (IsOnThread()) - SetCpStatus(true); + SetCPStatusFromCPU(); // update the fifo pointer if (fifo.CPWritePointer >= fifo.CPEnd) @@ -361,30 +361,17 @@ void UpdateInterruptsFromVideoBackend(u64 userdata) CoreTiming::ScheduleEvent_Threadsafe(0, et_UpdateInterrupts, userdata); } -void SetCpStatus(bool isCPUThread) +void SetCPStatusFromGPU() { - // overflow & underflow check - fifo.bFF_HiWatermark = (fifo.CPReadWriteDistance > fifo.CPHiWatermark); - fifo.bFF_LoWatermark = (fifo.CPReadWriteDistance < fifo.CPLoWatermark); - // breakpoint - if (!isCPUThread) + if (fifo.bFF_BPEnable) { - if (fifo.bFF_BPEnable) + if (fifo.CPBreakpoint == fifo.CPReadPointer) { - if (fifo.CPBreakpoint == fifo.CPReadPointer) + if (!fifo.bFF_Breakpoint) { - if (!fifo.bFF_Breakpoint) - { - INFO_LOG(COMMANDPROCESSOR, "Hit breakpoint at %i", fifo.CPReadPointer); - fifo.bFF_Breakpoint = true; - } - } - else - { - if (fifo.bFF_Breakpoint) - INFO_LOG(COMMANDPROCESSOR, "Cleared breakpoint at %i", fifo.CPReadPointer); - fifo.bFF_Breakpoint = false; + INFO_LOG(COMMANDPROCESSOR, "Hit breakpoint at %i", fifo.CPReadPointer); + fifo.bFF_Breakpoint = true; } } else @@ -394,6 +381,20 @@ void SetCpStatus(bool isCPUThread) fifo.bFF_Breakpoint = false; } } + else + { + if (fifo.bFF_Breakpoint) + INFO_LOG(COMMANDPROCESSOR, "Cleared breakpoint at %i", fifo.CPReadPointer); + fifo.bFF_Breakpoint = false; + } + SetCPStatusFromCPU(); +} + +void SetCPStatusFromCPU() +{ + // overflow & underflow check + fifo.bFF_HiWatermark = (fifo.CPReadWriteDistance > fifo.CPHiWatermark); + fifo.bFF_LoWatermark = (fifo.CPReadWriteDistance < fifo.CPLoWatermark); bool bpInt = fifo.bFF_Breakpoint && fifo.bFF_BPInt; bool ovfInt = fifo.bFF_HiWatermark && fifo.bFF_HiWatermarkInt; @@ -408,15 +409,14 @@ void SetCpStatus(bool isCPUThread) { if (!interrupt || bpInt || undfInt || ovfInt) { - if (!isCPUThread) + if (Core::IsGPUThread()) { - // GPU thread: + // Schedule the interrupt asynchronously interruptWaiting = true; CommandProcessor::UpdateInterruptsFromVideoBackend(userdata); } else { - // CPU thread: interruptSet = interrupt; INFO_LOG(COMMANDPROCESSOR,"Interrupt set"); ProcessorInterface::SetInterrupt(INT_CAUSE_CP, interrupt); diff --git a/Source/Core/VideoCommon/CommandProcessor.h b/Source/Core/VideoCommon/CommandProcessor.h index 300893d755..a70c30fb36 100644 --- a/Source/Core/VideoCommon/CommandProcessor.h +++ b/Source/Core/VideoCommon/CommandProcessor.h @@ -135,7 +135,8 @@ void DoState(PointerWrap &p); void RegisterMMIO(MMIO::Mapping* mmio, u32 base); -void SetCpStatus(bool isCPUThread = false); +void SetCPStatusFromGPU(); +void SetCPStatusFromCPU(); void GatherPipeBursted(); void UpdateInterrupts(u64 userdata); void UpdateInterruptsFromVideoBackend(u64 userdata); diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index 3460b25956..165cd8e239 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -148,7 +148,7 @@ void RunGpuLoop() VideoFifo_CheckAsyncRequest(); - CommandProcessor::SetCpStatus(); + CommandProcessor::SetCPStatusFromGPU(); Common::AtomicStore(CommandProcessor::VITicks, CommandProcessor::m_cpClockOrigin); @@ -184,7 +184,7 @@ void RunGpuLoop() Common::AtomicStore(fifo.SafeCPReadPointer, fifo.CPReadPointer); } - CommandProcessor::SetCpStatus(); + CommandProcessor::SetCPStatusFromGPU(); // This call is pretty important in DualCore mode and must be called in the FIFO Loop. // If we don't, s_swapRequested or s_efbAccessRequested won't be set to false @@ -247,5 +247,5 @@ void RunGpu() fifo.CPReadWriteDistance -= 32; } - CommandProcessor::SetCpStatus(); + CommandProcessor::SetCPStatusFromGPU(); }