Revert most of r3855.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3875 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Nolan Check
2009-07-23 21:17:14 +00:00
parent 3c9b5bbf7b
commit ce8b679d76
6 changed files with 27 additions and 35 deletions

View File

@ -40,7 +40,6 @@
#include <unistd.h> #include <unistd.h>
#ifdef _POSIX_THREADS #ifdef _POSIX_THREADS
#include <pthread.h> #include <pthread.h>
#include <sched.h>
#elif GEKKO #elif GEKKO
#include <ogc/lwp_threads.h> #include <ogc/lwp_threads.h>
#else #else
@ -176,15 +175,14 @@ void InitThreading();
void SleepCurrentThread(int ms); void SleepCurrentThread(int ms);
// YieldCPU: Use this function during a spin-wait to make the current thread // YieldCPU: Use this function during a spin-wait to make the current thread
// relax while another thread is working. // relax while another thread is working. This may be more efficient than using
// If you find yourself calling this function, please consider using an event- // events because event functions use kernel calls.
// based design instead.
inline void YieldCPU() inline void YieldCPU()
{ {
#ifdef _WIN32 #ifdef _WIN32
SwitchToThread(); YieldProcessor();
#elif defined _POSIX_THREADS #elif defined(_M_IX86) || defined(_M_X64)
sched_yield(); _mm_pause();
#endif #endif
} }

View File

@ -336,7 +336,6 @@ 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,7 +152,6 @@ 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)
{ {
@ -192,7 +191,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))
s_fifoIdleEvent.MsgWait(); Common::YieldCPU();
fake_GPWatchdogLastToken = fifo.Fake_GPWDToken; fake_GPWatchdogLastToken = fifo.Fake_GPWDToken;
} }
@ -223,14 +222,11 @@ void Init()
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()
{ {
s_fifoIdleEvent.Shutdown();
} }
void Read16(u16& _rReturnValue, const u32 _Address) void Read16(u16& _rReturnValue, const u32 _Address)
@ -381,7 +377,7 @@ void Write16(const u16 _Value, const u32 _Address)
// (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 && !(fifo.bFF_BPEnable && fifo.bFF_Breakpoint) ) while (fifo.bFF_GPReadEnable && fifo.CPReadWriteDistance > 0 && !(fifo.bFF_BPEnable && fifo.bFF_Breakpoint) )
s_fifoIdleEvent.MsgWait(); Common::YieldCPU();
} }
} }
@ -737,9 +733,4 @@ 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,7 +81,6 @@ void CatchUpGPU();
void GatherPipeBursted(); void GatherPipeBursted();
void UpdateInterrupts(); void UpdateInterrupts();
void UpdateInterruptsFromVideoPlugin(); void UpdateInterruptsFromVideoPlugin();
void SetFifoIdleFromVideoPlugin();
bool AllowIdleSkipping(); bool AllowIdleSkipping();

View File

@ -125,6 +125,9 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
while (fifoStateRun) while (fifoStateRun)
{ {
video_initialize.pPeekMessages();
VideoFifo_CheckEFBAccess();
VideoFifo_CheckSwapRequest();
s_criticalFifo.Enter(); s_criticalFifo.Enter();
@ -133,27 +136,38 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
{ {
Common::AtomicStore(_fifo.CPReadIdle, 0); Common::AtomicStore(_fifo.CPReadIdle, 0);
do while (_fifo.bFF_GPReadEnable && _fifo.CPReadWriteDistance)
{ {
if(!fifoStateRun) if(!fifoStateRun)
break; break;
u32 readPtr = _fifo.CPReadPointer; u32 readPtr = _fifo.CPReadPointer;
s32 distToSend;
// Only send 32 bytes at a time if breakpoint is enabled.
if (_fifo.bFF_BPEnable)
distToSend = 32;
else
{
distToSend = _fifo.CPReadWriteDistance;
if ((distToSend + readPtr) >= _fifo.CPEnd)
distToSend = _fifo.CPEnd - readPtr;
}
u8 *uData = video_initialize.pGetMemoryPointer(readPtr); u8 *uData = video_initialize.pGetMemoryPointer(readPtr);
// Execute new instructions found in uData // Execute new instructions found in uData
Fifo_SendFifoData(uData, 32); Fifo_SendFifoData(uData, distToSend);
readPtr += 32; readPtr += distToSend;
if (readPtr >= _fifo.CPEnd) if (readPtr >= _fifo.CPEnd)
readPtr = _fifo.CPBase; readPtr = _fifo.CPBase;
Common::AtomicStore(_fifo.CPReadPointer, readPtr); Common::AtomicStore(_fifo.CPReadPointer, readPtr);
Common::AtomicAdd(_fifo.CPReadWriteDistance, -32); Common::AtomicAdd(_fifo.CPReadWriteDistance, -distToSend);
if (_fifo.bFF_BPEnable && (readPtr == _fifo.CPBreakpoint)) if (_fifo.bFF_BPEnable && (readPtr == _fifo.CPBreakpoint))
{ {
_fifo.bFF_Breakpoint = 1; Common::AtomicStore(_fifo.bFF_Breakpoint, 1);
video_initialize.pUpdateInterrupts(); video_initialize.pUpdateInterrupts();
} }
@ -161,18 +175,12 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
VideoFifo_CheckEFBAccess(); VideoFifo_CheckEFBAccess();
VideoFifo_CheckSwapRequest(); VideoFifo_CheckSwapRequest();
} while (_fifo.bFF_GPReadEnable && _fifo.CPReadWriteDistance && !(_fifo.bFF_BPEnable && _fifo.bFF_Breakpoint)); }
Common::AtomicStore(_fifo.CPReadIdle, 1); Common::AtomicStore(_fifo.CPReadIdle, 1);
video_initialize.pSetFifoIdle();
} }
else else
{
Common::YieldCPU(); Common::YieldCPU();
video_initialize.pPeekMessages();
VideoFifo_CheckEFBAccess();
VideoFifo_CheckSwapRequest();
}
s_criticalFifo.Leave(); s_criticalFifo.Leave();
} }

View File

@ -21,7 +21,6 @@ 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
{ {
@ -83,8 +82,6 @@ typedef struct
TUpdateFPSDisplay pUpdateFPSDisplay; TUpdateFPSDisplay pUpdateFPSDisplay;
TKeyPressed pKeyPress; TKeyPressed pKeyPress;
TSetFifoIdle pSetFifoIdle;
SCPFifoStruct *pCPFifo; SCPFifoStruct *pCPFifo;
void *pMemoryBase; void *pMemoryBase;
bool bWii; bool bWii;