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

View File

@ -336,7 +336,6 @@ THREAD_RETURN EmuThread(void *pArg)
VideoInitialize.pUpdateInterrupts = &(CommandProcessor::UpdateInterruptsFromVideoPlugin);
VideoInitialize.pMemoryBase = Memory::base;
VideoInitialize.pKeyPress = Callback_KeyPress;
VideoInitialize.pSetFifoIdle = &(CommandProcessor::SetFifoIdleFromVideoPlugin);
VideoInitialize.bWii = _CoreParameter.bWii;
VideoInitialize.bUseDualCore = _CoreParameter.bUseDualCore;
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
static u32 fake_GPWatchdogLastToken = 0;
static Common::Event s_fifoIdleEvent;
void DoState(PointerWrap &p)
{
@ -192,7 +191,7 @@ void IncrementGPWDToken()
void WaitForFrameFinish()
{
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;
}
@ -223,14 +222,11 @@ void Init()
fifo.CPCmdIdle = 1 ;
fifo.CPReadIdle = 1;
s_fifoIdleEvent.Init();
et_UpdateInterrupts = CoreTiming::RegisterEvent("UpdateInterrupts", UpdateInterrupts_Wrapper);
}
void Shutdown()
{
s_fifoIdleEvent.Shutdown();
}
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)
// 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) )
s_fifoIdleEvent.MsgWait();
Common::YieldCPU();
}
}
@ -737,9 +733,4 @@ void UpdateInterruptsFromVideoPlugin()
CoreTiming::ScheduleEvent_Threadsafe(0, et_UpdateInterrupts);
}
void SetFifoIdleFromVideoPlugin()
{
s_fifoIdleEvent.Set();
}
} // end of namespace CommandProcessor

View File

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

View File

@ -125,6 +125,9 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
while (fifoStateRun)
{
video_initialize.pPeekMessages();
VideoFifo_CheckEFBAccess();
VideoFifo_CheckSwapRequest();
s_criticalFifo.Enter();
@ -133,27 +136,38 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
{
Common::AtomicStore(_fifo.CPReadIdle, 0);
do
while (_fifo.bFF_GPReadEnable && _fifo.CPReadWriteDistance)
{
if(!fifoStateRun)
break;
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);
// Execute new instructions found in uData
Fifo_SendFifoData(uData, 32);
Fifo_SendFifoData(uData, distToSend);
readPtr += 32;
readPtr += distToSend;
if (readPtr >= _fifo.CPEnd)
readPtr = _fifo.CPBase;
Common::AtomicStore(_fifo.CPReadPointer, readPtr);
Common::AtomicAdd(_fifo.CPReadWriteDistance, -32);
Common::AtomicAdd(_fifo.CPReadWriteDistance, -distToSend);
if (_fifo.bFF_BPEnable && (readPtr == _fifo.CPBreakpoint))
{
_fifo.bFF_Breakpoint = 1;
Common::AtomicStore(_fifo.bFF_Breakpoint, 1);
video_initialize.pUpdateInterrupts();
}
@ -161,18 +175,12 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
VideoFifo_CheckEFBAccess();
VideoFifo_CheckSwapRequest();
} while (_fifo.bFF_GPReadEnable && _fifo.CPReadWriteDistance && !(_fifo.bFF_BPEnable && _fifo.bFF_Breakpoint));
}
Common::AtomicStore(_fifo.CPReadIdle, 1);
video_initialize.pSetFifoIdle();
}
else
{
Common::YieldCPU();
video_initialize.pPeekMessages();
VideoFifo_CheckEFBAccess();
VideoFifo_CheckSwapRequest();
}
s_criticalFifo.Leave();
}

View File

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