From ce8b679d76d7100c50859cc39ede7f9fa006fa28 Mon Sep 17 00:00:00 2001 From: Nolan Check Date: Thu, 23 Jul 2009 21:17:14 +0000 Subject: [PATCH] Revert most of r3855. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3875 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/Thread.h | 12 +++----- Source/Core/Core/Src/Core.cpp | 1 - Source/Core/Core/Src/HW/CommandProcessor.cpp | 13 ++------ Source/Core/Core/Src/HW/CommandProcessor.h | 1 - Source/Core/VideoCommon/Src/Fifo.cpp | 32 ++++++++++++-------- Source/PluginSpecs/pluginspecs_video.h | 3 -- 6 files changed, 27 insertions(+), 35 deletions(-) diff --git a/Source/Core/Common/Src/Thread.h b/Source/Core/Common/Src/Thread.h index 8cd29726e0..b51d4185ca 100644 --- a/Source/Core/Common/Src/Thread.h +++ b/Source/Core/Common/Src/Thread.h @@ -40,7 +40,6 @@ #include #ifdef _POSIX_THREADS #include -#include #elif GEKKO #include #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 } diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 8b0b6b9a92..fb76515b9c 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -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]; diff --git a/Source/Core/Core/Src/HW/CommandProcessor.cpp b/Source/Core/Core/Src/HW/CommandProcessor.cpp index ebcc55a91b..6e7493a762 100644 --- a/Source/Core/Core/Src/HW/CommandProcessor.cpp +++ b/Source/Core/Core/Src/HW/CommandProcessor.cpp @@ -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 diff --git a/Source/Core/Core/Src/HW/CommandProcessor.h b/Source/Core/Core/Src/HW/CommandProcessor.h index 0aa434cdcd..e80a980798 100644 --- a/Source/Core/Core/Src/HW/CommandProcessor.h +++ b/Source/Core/Core/Src/HW/CommandProcessor.h @@ -81,7 +81,6 @@ void CatchUpGPU(); void GatherPipeBursted(); void UpdateInterrupts(); void UpdateInterruptsFromVideoPlugin(); -void SetFifoIdleFromVideoPlugin(); bool AllowIdleSkipping(); diff --git a/Source/Core/VideoCommon/Src/Fifo.cpp b/Source/Core/VideoCommon/Src/Fifo.cpp index 0365238a05..1f7a3488ee 100644 --- a/Source/Core/VideoCommon/Src/Fifo.cpp +++ b/Source/Core/VideoCommon/Src/Fifo.cpp @@ -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(); } diff --git a/Source/PluginSpecs/pluginspecs_video.h b/Source/PluginSpecs/pluginspecs_video.h index dcace79a5a..b455049c6f 100644 --- a/Source/PluginSpecs/pluginspecs_video.h +++ b/Source/PluginSpecs/pluginspecs_video.h @@ -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;