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.
This commit is contained in:
comex 2014-08-24 16:27:32 -04:00
parent f52888d3ec
commit 14125cf951
3 changed files with 28 additions and 27 deletions

View File

@ -317,7 +317,7 @@ void STACKALIGN GatherPipeBursted()
} }
if (IsOnThread()) if (IsOnThread())
SetCpStatus(true); SetCPStatusFromCPU();
// update the fifo pointer // update the fifo pointer
if (fifo.CPWritePointer >= fifo.CPEnd) if (fifo.CPWritePointer >= fifo.CPEnd)
@ -361,30 +361,17 @@ void UpdateInterruptsFromVideoBackend(u64 userdata)
CoreTiming::ScheduleEvent_Threadsafe(0, et_UpdateInterrupts, 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 // 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;
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;
} }
} }
else else
@ -394,6 +381,20 @@ void SetCpStatus(bool isCPUThread)
fifo.bFF_Breakpoint = false; 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 bpInt = fifo.bFF_Breakpoint && fifo.bFF_BPInt;
bool ovfInt = fifo.bFF_HiWatermark && fifo.bFF_HiWatermarkInt; bool ovfInt = fifo.bFF_HiWatermark && fifo.bFF_HiWatermarkInt;
@ -408,15 +409,14 @@ void SetCpStatus(bool isCPUThread)
{ {
if (!interrupt || bpInt || undfInt || ovfInt) if (!interrupt || bpInt || undfInt || ovfInt)
{ {
if (!isCPUThread) if (Core::IsGPUThread())
{ {
// GPU thread: // Schedule the interrupt asynchronously
interruptWaiting = true; interruptWaiting = true;
CommandProcessor::UpdateInterruptsFromVideoBackend(userdata); CommandProcessor::UpdateInterruptsFromVideoBackend(userdata);
} }
else else
{ {
// CPU thread:
interruptSet = interrupt; interruptSet = interrupt;
INFO_LOG(COMMANDPROCESSOR,"Interrupt set"); INFO_LOG(COMMANDPROCESSOR,"Interrupt set");
ProcessorInterface::SetInterrupt(INT_CAUSE_CP, interrupt); ProcessorInterface::SetInterrupt(INT_CAUSE_CP, interrupt);

View File

@ -135,7 +135,8 @@ void DoState(PointerWrap &p);
void RegisterMMIO(MMIO::Mapping* mmio, u32 base); void RegisterMMIO(MMIO::Mapping* mmio, u32 base);
void SetCpStatus(bool isCPUThread = false); void SetCPStatusFromGPU();
void SetCPStatusFromCPU();
void GatherPipeBursted(); void GatherPipeBursted();
void UpdateInterrupts(u64 userdata); void UpdateInterrupts(u64 userdata);
void UpdateInterruptsFromVideoBackend(u64 userdata); void UpdateInterruptsFromVideoBackend(u64 userdata);

View File

@ -148,7 +148,7 @@ void RunGpuLoop()
VideoFifo_CheckAsyncRequest(); VideoFifo_CheckAsyncRequest();
CommandProcessor::SetCpStatus(); CommandProcessor::SetCPStatusFromGPU();
Common::AtomicStore(CommandProcessor::VITicks, CommandProcessor::m_cpClockOrigin); Common::AtomicStore(CommandProcessor::VITicks, CommandProcessor::m_cpClockOrigin);
@ -184,7 +184,7 @@ void RunGpuLoop()
Common::AtomicStore(fifo.SafeCPReadPointer, fifo.CPReadPointer); 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. // 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 // If we don't, s_swapRequested or s_efbAccessRequested won't be set to false
@ -247,5 +247,5 @@ void RunGpu()
fifo.CPReadWriteDistance -= 32; fifo.CPReadWriteDistance -= 32;
} }
CommandProcessor::SetCpStatus(); CommandProcessor::SetCPStatusFromGPU();
} }