mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
DC fix: Since game's frame-finish-watchdog have nothing to do with RTC, the faked GP watchdog moved in scheduler. DC should work for everyone now, we just may need to adjust FAKE_GP_WATCHDOG_PERIOD. TODO if it worth it: the actual re-scheduling of the new callback is stupid, so... + Some clean up. + Remove the unused GPUCallBack.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1210 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -85,47 +85,6 @@ void Video_SendFifoData(u8* _uData, u32 len)
|
||||
OpcodeDecoder_Run();
|
||||
}
|
||||
|
||||
// for GP watchdog hack
|
||||
THREAD_RETURN GPWatchdogThread(void *pArg)
|
||||
{
|
||||
const SCPFifoStruct &_fifo = *(SCPFifoStruct*)pArg;
|
||||
u32 lastToken = 0;
|
||||
u32 currentToken = 0;
|
||||
int FourMsCount = 0;
|
||||
|
||||
Common::SetCurrentThreadName("GPWatchdogThread");
|
||||
|
||||
while (_fifo.bFF_GPReadEnable != ~0UL) // blah
|
||||
{
|
||||
// 4 ms should be enough insignificant
|
||||
Common::SleepCurrentThread(4);
|
||||
currentToken = _fifo.Fake_GPWDToken;
|
||||
if (lastToken == currentToken)
|
||||
{
|
||||
FourMsCount++;
|
||||
// Threshold quite arbitrary.
|
||||
// Assuming the PPC-frame-finish-watchdog use RTC(TOCHECK) and throw its exception after several times the normal frame rate
|
||||
// I tested higher frame-periode-factor but 3 might be safe enough for DC stability for everyone.
|
||||
// I may be wrong, so TOTEST on different machine like hell !!!
|
||||
if (FourMsCount >= 3*16/4)// frame_periode_factor(3) * frame_periode(~16ms) / ms_step(4)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
InterlockedExchange((LONG*)&_fifo.Fake_GPWDInterrupt, 1);
|
||||
#else
|
||||
Common::InterlockedExchange((int*)&_fifo.Fake_GPWDInterrupt, 1);
|
||||
#endif
|
||||
//__Log(LogTypes::VIDEO,"!!! Watchdog hit",_fifo.CPReadWriteDistance);
|
||||
}
|
||||
}
|
||||
else
|
||||
FourMsCount = 0;
|
||||
|
||||
lastToken = currentToken;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
||||
{
|
||||
SCPFifoStruct &_fifo = *video_initialize.pCPFifo;
|
||||
@ -135,18 +94,6 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
||||
if (hEventOnIdle==NULL) PanicAlert("Fifo_EnterLoop() -> EventOnIdle NULL");
|
||||
#endif
|
||||
|
||||
// for GP watchdog hack
|
||||
Common::Thread *watchdogThread = NULL;
|
||||
watchdogThread = new Common::Thread(GPWatchdogThread, (void*)&_fifo);
|
||||
// TODO (mb2): figure out why doesn't work on core 2 ???
|
||||
// may have to force it for DualCores
|
||||
//watchdogThread->SetAffinity(1);
|
||||
#ifdef _WIN32
|
||||
SetThreadPriority(watchdogThread, THREAD_PRIORITY_ABOVE_NORMAL);
|
||||
#else
|
||||
//TODO
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
// TODO(ector): Don't peek so often!
|
||||
while (video_initialize.pPeekMessages())
|
||||
@ -158,7 +105,6 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
||||
if (MsgWaitForMultipleObjects(1, &hEventOnIdle, FALSE, 1L, QS_ALLEVENTS) == WAIT_ABANDONED)
|
||||
break;
|
||||
#endif
|
||||
//if (_fifo.CPReadWriteDistance < 1)
|
||||
if (_fifo.CPReadWriteDistance < _fifo.CPLoWatermark)
|
||||
#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32)
|
||||
continue;
|
||||
@ -180,16 +126,13 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
||||
u8 *uData = video_initialize.pGetMemoryPointer(_fifo.CPReadPointer);
|
||||
|
||||
u32 readPtr = _fifo.CPReadPointer;
|
||||
// if we are on BP mode we must send 32B chunks to Video plugin
|
||||
// for BP checking
|
||||
// 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).
|
||||
if (_fifo.bFF_BPEnable)
|
||||
{
|
||||
distToSend = 32;
|
||||
readPtr += 32;
|
||||
if (readPtr == _fifo.CPBreakpoint)
|
||||
{
|
||||
video_initialize.pLog("!!! BP irq raised",FALSE);
|
||||
//PanicAlert("!!! BP irq raised");
|
||||
#ifdef _WIN32
|
||||
InterlockedExchange((LONG*)&_fifo.bFF_Breakpoint, 1);
|
||||
#else
|
||||
@ -198,11 +141,16 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
||||
video_initialize.pUpdateInterrupts();
|
||||
break;
|
||||
}
|
||||
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;
|
||||
@ -210,8 +158,6 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
||||
else
|
||||
readPtr += distToSend;
|
||||
}
|
||||
// TODO (mb2): add warning comments here for BP irq
|
||||
// sending the whole CPReadWriteDistance most of the time
|
||||
Video_SendFifoData(uData, distToSend);
|
||||
#ifdef _WIN32
|
||||
InterlockedExchange((LONG*)&_fifo.CPReadPointer, readPtr);
|
||||
@ -226,11 +172,5 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
||||
#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32)
|
||||
CloseHandle(hEventOnIdle);
|
||||
#endif
|
||||
// for GP watchdog DC hack
|
||||
// dummy finish signal to watchdog
|
||||
_fifo.bFF_GPReadEnable = ~0;
|
||||
if(watchdogThread)
|
||||
watchdogThread->WaitForDeath();
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user