DC + fifo: small fix/correction ;). Remove old stupid OnIdleDC stuff. Interesting: DSPnull with DC + IdleSkipping show invalid read addr sometimes.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1286 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
memberTwo.mb2 2008-11-24 16:33:38 +00:00
parent f1a3212ef3
commit 0f13d327b8
9 changed files with 25 additions and 67 deletions

View File

@ -28,10 +28,6 @@
#include "Thread.h"
#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32)
HANDLE g_hEventOnIdle=NULL;
#endif
namespace Common
{
#ifdef _WIN32

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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();
//}

View File

@ -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;

View File

@ -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

View File

@ -86,7 +86,6 @@ namespace PowerPC
void Stop();
void OnIdle(u32 _uThreadAddr);
void OnIdleDC(void);
}
// Easy register access macros.

View File

@ -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
}