CP: Replace a couple spin-waits with event signals.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3828 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Nolan Check 2009-07-18 06:16:24 +00:00
parent 3ad9b0a466
commit ccfc004161
5 changed files with 19 additions and 6 deletions

View File

@ -336,6 +336,7 @@ THREAD_RETURN EmuThread(void *pArg)
VideoInitialize.pUpdateInterrupts = &(CommandProcessor::UpdateInterruptsFromVideoPlugin); VideoInitialize.pUpdateInterrupts = &(CommandProcessor::UpdateInterruptsFromVideoPlugin);
VideoInitialize.pMemoryBase = Memory::base; VideoInitialize.pMemoryBase = Memory::base;
VideoInitialize.pKeyPress = Callback_KeyPress; VideoInitialize.pKeyPress = Callback_KeyPress;
VideoInitialize.pSetFifoIdle = &(CommandProcessor::SetFifoIdleFromVideoPlugin);
VideoInitialize.bWii = _CoreParameter.bWii; VideoInitialize.bWii = _CoreParameter.bWii;
VideoInitialize.bUseDualCore = _CoreParameter.bUseDualCore; VideoInitialize.bUseDualCore = _CoreParameter.bUseDualCore;
VideoInitialize.pBBox = &PixelEngine::bbox[0]; VideoInitialize.pBBox = &PixelEngine::bbox[0];

View File

@ -152,6 +152,7 @@ u16 m_tokenReg;
SCPFifoStruct fifo; //This one is shared between gfx thread and emulator thread SCPFifoStruct fifo; //This one is shared between gfx thread and emulator thread
static u32 fake_GPWatchdogLastToken = 0; static u32 fake_GPWatchdogLastToken = 0;
static Common::Event s_fifoIdleEvent;
void DoState(PointerWrap &p) void DoState(PointerWrap &p)
{ {
@ -191,7 +192,7 @@ void IncrementGPWDToken()
void WaitForFrameFinish() void WaitForFrameFinish()
{ {
while ((fake_GPWatchdogLastToken == fifo.Fake_GPWDToken) && fifo.bFF_GPReadEnable && (fifo.CPReadWriteDistance > 0) && !(fifo.bFF_BPEnable && fifo.bFF_Breakpoint)) while ((fake_GPWatchdogLastToken == fifo.Fake_GPWDToken) && fifo.bFF_GPReadEnable && (fifo.CPReadWriteDistance > 0) && !(fifo.bFF_BPEnable && fifo.bFF_Breakpoint))
Common::YieldCPU(); s_fifoIdleEvent.MsgWait();
fake_GPWatchdogLastToken = fifo.Fake_GPWDToken; fake_GPWatchdogLastToken = fifo.Fake_GPWDToken;
} }
@ -217,18 +218,19 @@ void Init()
m_tokenReg = 0; m_tokenReg = 0;
fake_GPWatchdogLastToken = 0; fake_GPWatchdogLastToken = 0;
memset(&fifo,0,sizeof(fifo)); memset(&fifo,0,sizeof(fifo));
fifo.CPCmdIdle = 1 ; fifo.CPCmdIdle = 1 ;
fifo.CPReadIdle = 1; fifo.CPReadIdle = 1;
s_fifoIdleEvent.Init();
et_UpdateInterrupts = CoreTiming::RegisterEvent("UpdateInterrupts", UpdateInterrupts_Wrapper); et_UpdateInterrupts = CoreTiming::RegisterEvent("UpdateInterrupts", UpdateInterrupts_Wrapper);
} }
void Shutdown() void Shutdown()
{ {
#ifndef _WIN32 s_fifoIdleEvent.Shutdown();
// delete fifo.sync;
#endif
} }
void Read16(u16& _rReturnValue, const u32 _Address) void Read16(u16& _rReturnValue, const u32 _Address)
@ -378,8 +380,8 @@ void Write16(const u16 _Value, const u32 _Address)
DEBUG_LOG(COMMANDPROCESSOR, "*********************** GXSetGPFifo very soon? ***********************"); DEBUG_LOG(COMMANDPROCESSOR, "*********************** GXSetGPFifo very soon? ***********************");
// (mb2) We don't sleep here since it could be a perf issue for super monkey ball (yup only this game IIRC) // (mb2) We don't sleep here since it could be a perf issue for super monkey ball (yup only this game IIRC)
// Touching that game is a no-go so I don't want to take the risk :p // Touching that game is a no-go so I don't want to take the risk :p
while (fifo.bFF_GPReadEnable && fifo.CPReadWriteDistance > 0 ) while (fifo.bFF_GPReadEnable && fifo.CPReadWriteDistance > 0 && !(fifo.bFF_BPEnable && fifo.bFF_Breakpoint) )
Common::YieldCPU(); s_fifoIdleEvent.MsgWait();
} }
} }
@ -739,4 +741,9 @@ void UpdateInterruptsFromVideoPlugin()
CoreTiming::ScheduleEvent_Threadsafe(0, et_UpdateInterrupts); CoreTiming::ScheduleEvent_Threadsafe(0, et_UpdateInterrupts);
} }
void SetFifoIdleFromVideoPlugin()
{
s_fifoIdleEvent.Set();
}
} // end of namespace CommandProcessor } // end of namespace CommandProcessor

View File

@ -81,6 +81,7 @@ void CatchUpGPU();
void GatherPipeBursted(); void GatherPipeBursted();
void UpdateInterrupts(); void UpdateInterrupts();
void UpdateInterruptsFromVideoPlugin(); void UpdateInterruptsFromVideoPlugin();
void SetFifoIdleFromVideoPlugin();
bool AllowIdleSkipping(); bool AllowIdleSkipping();

View File

@ -191,6 +191,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
} }
Common::AtomicStore(_fifo.CPReadIdle, 1); Common::AtomicStore(_fifo.CPReadIdle, 1);
video_initialize.pSetFifoIdle();
} }
else else
{ {

View File

@ -21,6 +21,7 @@ typedef unsigned int (*TPeekMessages)(void);
typedef void (*TUpdateInterrupts)(void); typedef void (*TUpdateInterrupts)(void);
typedef void (*TUpdateFPSDisplay)(const char* text); // sets the window title typedef void (*TUpdateFPSDisplay)(const char* text); // sets the window title
typedef void (*TKeyPressed)(int keycode, bool shift, bool control); // sets the window title typedef void (*TKeyPressed)(int keycode, bool shift, bool control); // sets the window title
typedef void (*TSetFifoIdle)();
enum FieldType enum FieldType
{ {
@ -82,6 +83,8 @@ typedef struct
TUpdateFPSDisplay pUpdateFPSDisplay; TUpdateFPSDisplay pUpdateFPSDisplay;
TKeyPressed pKeyPress; TKeyPressed pKeyPress;
TSetFifoIdle pSetFifoIdle;
SCPFifoStruct *pCPFifo; SCPFifoStruct *pCPFifo;
void *pMemoryBase; void *pMemoryBase;
bool bWii; bool bWii;