diff --git a/Source/Core/Common/Src/Thread.cpp b/Source/Core/Common/Src/Thread.cpp index 56188bb9b3..24ce43950a 100644 --- a/Source/Core/Common/Src/Thread.cpp +++ b/Source/Core/Common/Src/Thread.cpp @@ -28,10 +28,6 @@ #include "Thread.h" -#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32) -HANDLE g_hEventOnIdle=NULL; -#endif - namespace Common { #ifdef _WIN32 diff --git a/Source/Core/Common/Src/Thread.h b/Source/Core/Common/Src/Thread.h index 73c273fdf4..33f62fea9c 100644 --- a/Source/Core/Common/Src/Thread.h +++ b/Source/Core/Common/Src/Thread.h @@ -33,13 +33,6 @@ #include "Common.h" -// for testing purpose -//#define THREAD_VIDEO_WAKEUP_ONIDLE - -#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32) -extern HANDLE g_hEventOnIdle; -#endif - namespace Common { class CriticalSection diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index aff3575444..469878154f 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -367,17 +367,10 @@ THREAD_RETURN EmuThread(void *pArg) } else { -#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32) - g_hEventOnIdle = CreateEvent( NULL, FALSE, FALSE, "EventOnIdle"); - if (g_hEventOnIdle == NULL) PanicAlert("EmuThread() -> Create EventOnIdle error"); -#endif cpuThread = new Common::Thread(CpuThread, pArg); PluginVideo::Video_Prepare(); //wglMakeCurrent Common::SetCurrentThreadName("Video thread"); PluginVideo::Video_EnterLoop(); -#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32) - CloseHandle(g_hEventOnIdle); -#endif } // Wait for CPU thread to exit - it should have been signaled to do so by now diff --git a/Source/Core/Core/Src/HW/CommandProcessor.cpp b/Source/Core/Core/Src/HW/CommandProcessor.cpp index 8bc3bd4ded..6ffc1f2609 100644 --- a/Source/Core/Core/Src/HW/CommandProcessor.cpp +++ b/Source/Core/Core/Src/HW/CommandProcessor.cpp @@ -248,11 +248,12 @@ void Read16(u16& _rReturnValue, const u32 _Address) //TODO?: if really needed //m_CPStatusReg.CommandIdle = fifo.CPCmdIdle; // uncomment: change a bit the behaviour MP1. Not very useful though - //m_CPStatusReg.ReadIdle = fifo.CPReadIdle; + m_CPStatusReg.ReadIdle = fifo.CPReadIdle; + //m_CPStatusReg.CommandIdle = fifo.CPReadIdle; // hack: CPU will always believe fifo is empty and on idle - m_CPStatusReg.ReadIdle = 1; - m_CPStatusReg.CommandIdle = 1; + //m_CPStatusReg.ReadIdle = 1; + //m_CPStatusReg.CommandIdle = 1; _rReturnValue = m_CPStatusReg.Hex; LOG(COMMANDPROCESSOR, "\t iBP %s | fREADIDLE %s | fCMDIDLE %s | iOvF %s | iUndF %s" diff --git a/Source/Core/Core/Src/HW/PixelEngine.cpp b/Source/Core/Core/Src/HW/PixelEngine.cpp index 54d193033e..4bf51dfdf7 100644 --- a/Source/Core/Core/Src/HW/PixelEngine.cpp +++ b/Source/Core/Core/Src/HW/PixelEngine.cpp @@ -163,14 +163,17 @@ void UpdateInterrupts() CPeripheralInterface::SetInterrupt(CPeripheralInterface::INT_CAUSE_PE_FINISH, false); } -// TODO(mb2): Refactor SetTokenINT_OnMainThread(u64 userdata, int cyclesLate). Cleanup++ +// TODO(mb2): Refactor SetTokenINT_OnMainThread(u64 userdata, int cyclesLate). +// Think about the right order between tokenVal and tokenINT... one day maybe. +// Cleanup++ + // Called only if BPMEM_PE_TOKEN_INT_ID is ack by GP void SetToken_OnMainThread(u64 userdata, int cyclesLate) { //if (userdata >> 16) //{ g_bSignalTokenInterrupt = true; - _dbg_assert_msg_(PIXELENGINE, (CommandProcessor::fifo.PEToken == (userdata&0xFFFF)), "WTF? BPMEM_PE_TOKEN_INT_ID's token != BPMEM_PE_TOKEN_ID's token" ); + //_dbg_assert_msg_(PIXELENGINE, (CommandProcessor::fifo.PEToken == (userdata&0xFFFF)), "WTF? BPMEM_PE_TOKEN_INT_ID's token != BPMEM_PE_TOKEN_ID's token" ); LOGV(PIXELENGINE, 1, "VIDEO Plugin raises INT_CAUSE_PE_TOKEN (btw, token: %04x)", CommandProcessor::fifo.PEToken); UpdateInterrupts(); //} diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp index 72304a1a19..246aa6eca3 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit_LoadStore.cpp @@ -164,10 +164,7 @@ namespace Jit64 { gpr.Flush(FLUSH_ALL); fpr.Flush(FLUSH_ALL); - if (Core::GetStartupParameter().bUseDualCore) - CALL((void *)&PowerPC::OnIdleDC); - else - ABI_CallFunctionC((void *)&PowerPC::OnIdle, PowerPC::ppcState.gpr[a] + (s32)(s16)inst.SIMM_16); + ABI_CallFunctionC((void *)&PowerPC::OnIdle, PowerPC::ppcState.gpr[a] + (s32)(s16)inst.SIMM_16); MOV(32, M(&PowerPC::ppcState.pc), Imm32(js.compilerPC + 12)); JMP(Asm::testExceptions, true); js.compilerPC += 8; diff --git a/Source/Core/Core/Src/PowerPC/PowerPC.cpp b/Source/Core/Core/Src/PowerPC/PowerPC.cpp index cc4e7c7da7..94d678e881 100644 --- a/Source/Core/Core/Src/PowerPC/PowerPC.cpp +++ b/Source/Core/Core/Src/PowerPC/PowerPC.cpp @@ -33,8 +33,6 @@ #include "../Host.h" -#include "Thread.h" // for g_hEventOnIdle - namespace PowerPC { @@ -289,19 +287,7 @@ void OnIdle(u32 _uThreadAddr) u32 nextThread = Memory::Read_U32(_uThreadAddr); //do idle skipping if (nextThread == 0) - { CoreTiming::Idle(); - } -} - -//DualCore OnIdle -void OnIdleDC(void) -{ -#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32) - if (g_hEventOnIdle==NULL) PanicAlert("Idle() -> EventOnIdle NULL"); - if (! SetEvent(g_hEventOnIdle) ) { PanicAlert("Idle() -> SetEvent EventOnIdle failed");} -#endif - CoreTiming::Idle(); } } // namespace diff --git a/Source/Core/Core/Src/PowerPC/PowerPC.h b/Source/Core/Core/Src/PowerPC/PowerPC.h index ab3dbf2605..e34ad92bdc 100644 --- a/Source/Core/Core/Src/PowerPC/PowerPC.h +++ b/Source/Core/Core/Src/PowerPC/PowerPC.h @@ -86,7 +86,6 @@ namespace PowerPC void Stop(); void OnIdle(u32 _uThreadAddr); - void OnIdleDC(void); } // Easy register access macros. diff --git a/Source/Core/VideoCommon/Src/Fifo.cpp b/Source/Core/VideoCommon/Src/Fifo.cpp index 3f454088fe..0773ed3f37 100644 --- a/Source/Core/VideoCommon/Src/Fifo.cpp +++ b/Source/Core/VideoCommon/Src/Fifo.cpp @@ -89,10 +89,6 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) { SCPFifoStruct &_fifo = *video_initialize.pCPFifo; u32 distToSend; -#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32) - HANDLE hEventOnIdle= OpenEventA(EVENT_ALL_ACCESS,FALSE,(LPCSTR)"EventOnIdle"); - if (hEventOnIdle==NULL) PanicAlert("Fifo_EnterLoop() -> EventOnIdle NULL"); -#endif #ifdef _WIN32 // TODO(ector): Don't peek so often! @@ -101,16 +97,8 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) while (fifoStateRun) #endif { -#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32) - if (MsgWaitForMultipleObjects(1, &hEventOnIdle, FALSE, 1L, QS_ALLEVENTS) == WAIT_ABANDONED) - break; -#endif if (_fifo.CPReadWriteDistance < _fifo.CPLoWatermark) -#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32) - continue; -#else Common::SleepCurrentThread(1); -#endif //etc... // check if we are able to run this buffer @@ -121,18 +109,15 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) #else Common::InterlockedExchange((int*)&_fifo.CPReadIdle, 0); #endif -#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32) - while(_fifo.CPReadWriteDistance > 0) -#else + //video_initialize.pLog("RUN...........................",FALSE); while(_fifo.bFF_GPReadEnable && (_fifo.CPReadWriteDistance > 0) ) -#endif { // read the data and send it to the VideoPlugin - u8 *uData = video_initialize.pGetMemoryPointer(_fifo.CPReadPointer); - u32 readPtr = _fifo.CPReadPointer; + u8 *uData = video_initialize.pGetMemoryPointer(readPtr); + // if we are on BP mode we must send 32B chunks to Video plugin for BP checking - // TODO (mb2): test & check if MP1/MP2 are ok with that (It may happens the whole fifo RW dist is send too iirc). + // TODO (mb2): test & check if MP1/MP2 realy need this now. if (_fifo.bFF_BPEnable) { if (readPtr == _fifo.CPBreakpoint) @@ -148,20 +133,28 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) } distToSend = 32; readPtr += 32; - if ( readPtr > _fifo.CPEnd) + if ( readPtr >= _fifo.CPEnd) readPtr = _fifo.CPBase; } else { +#if 0 // ugly random GP slowdown for testing DC robustness... TODO: remove when completly sure DC is ok + int r=rand();if ((r&0xF)==r) Common::SleepCurrentThread(r); + distToSend = 32; + readPtr += 32; + if ( readPtr >= _fifo.CPEnd) + readPtr = _fifo.CPBase; +#else // sending the whole CPReadWriteDistance distToSend = _fifo.CPReadWriteDistance; - if ( (distToSend+readPtr) > _fifo.CPEnd) // TODO: better? + if ( (distToSend+readPtr) >= _fifo.CPEnd) // TODO: better? { distToSend =_fifo.CPEnd - readPtr; readPtr = _fifo.CPBase; } else readPtr += distToSend; +#endif } Video_SendFifoData(uData, distToSend); #ifdef _WIN32 @@ -172,7 +165,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) Common::InterlockedExchangeAdd((int*)&_fifo.CPReadWriteDistance, -distToSend); #endif } - //video_initialize.pLog("IDLE",FALSE); + //video_initialize.pLog("..........................IDLE",FALSE); #ifdef _WIN32 InterlockedExchange((LONG*)&_fifo.CPReadIdle, 1); #else @@ -180,8 +173,5 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) #endif } } -#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32) - CloseHandle(hEventOnIdle); -#endif }