mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-12 06:39:14 +01:00
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:
parent
f1a3212ef3
commit
0f13d327b8
@ -28,10 +28,6 @@
|
|||||||
|
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
|
|
||||||
#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32)
|
|
||||||
HANDLE g_hEventOnIdle=NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Common
|
namespace Common
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -33,13 +33,6 @@
|
|||||||
#include "Common.h"
|
#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
|
namespace Common
|
||||||
{
|
{
|
||||||
class CriticalSection
|
class CriticalSection
|
||||||
|
@ -367,17 +367,10 @@ THREAD_RETURN EmuThread(void *pArg)
|
|||||||
}
|
}
|
||||||
else
|
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);
|
cpuThread = new Common::Thread(CpuThread, pArg);
|
||||||
PluginVideo::Video_Prepare(); //wglMakeCurrent
|
PluginVideo::Video_Prepare(); //wglMakeCurrent
|
||||||
Common::SetCurrentThreadName("Video thread");
|
Common::SetCurrentThreadName("Video thread");
|
||||||
PluginVideo::Video_EnterLoop();
|
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
|
// Wait for CPU thread to exit - it should have been signaled to do so by now
|
||||||
|
@ -248,11 +248,12 @@ void Read16(u16& _rReturnValue, const u32 _Address)
|
|||||||
//TODO?: if really needed
|
//TODO?: if really needed
|
||||||
//m_CPStatusReg.CommandIdle = fifo.CPCmdIdle;
|
//m_CPStatusReg.CommandIdle = fifo.CPCmdIdle;
|
||||||
// uncomment: change a bit the behaviour MP1. Not very useful though
|
// 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
|
// hack: CPU will always believe fifo is empty and on idle
|
||||||
m_CPStatusReg.ReadIdle = 1;
|
//m_CPStatusReg.ReadIdle = 1;
|
||||||
m_CPStatusReg.CommandIdle = 1;
|
//m_CPStatusReg.CommandIdle = 1;
|
||||||
|
|
||||||
_rReturnValue = m_CPStatusReg.Hex;
|
_rReturnValue = m_CPStatusReg.Hex;
|
||||||
LOG(COMMANDPROCESSOR, "\t iBP %s | fREADIDLE %s | fCMDIDLE %s | iOvF %s | iUndF %s"
|
LOG(COMMANDPROCESSOR, "\t iBP %s | fREADIDLE %s | fCMDIDLE %s | iOvF %s | iUndF %s"
|
||||||
|
@ -163,14 +163,17 @@ void UpdateInterrupts()
|
|||||||
CPeripheralInterface::SetInterrupt(CPeripheralInterface::INT_CAUSE_PE_FINISH, false);
|
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
|
// Called only if BPMEM_PE_TOKEN_INT_ID is ack by GP
|
||||||
void SetToken_OnMainThread(u64 userdata, int cyclesLate)
|
void SetToken_OnMainThread(u64 userdata, int cyclesLate)
|
||||||
{
|
{
|
||||||
//if (userdata >> 16)
|
//if (userdata >> 16)
|
||||||
//{
|
//{
|
||||||
g_bSignalTokenInterrupt = true;
|
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);
|
LOGV(PIXELENGINE, 1, "VIDEO Plugin raises INT_CAUSE_PE_TOKEN (btw, token: %04x)", CommandProcessor::fifo.PEToken);
|
||||||
UpdateInterrupts();
|
UpdateInterrupts();
|
||||||
//}
|
//}
|
||||||
|
@ -164,10 +164,7 @@ namespace Jit64
|
|||||||
{
|
{
|
||||||
gpr.Flush(FLUSH_ALL);
|
gpr.Flush(FLUSH_ALL);
|
||||||
fpr.Flush(FLUSH_ALL);
|
fpr.Flush(FLUSH_ALL);
|
||||||
if (Core::GetStartupParameter().bUseDualCore)
|
ABI_CallFunctionC((void *)&PowerPC::OnIdle, PowerPC::ppcState.gpr[a] + (s32)(s16)inst.SIMM_16);
|
||||||
CALL((void *)&PowerPC::OnIdleDC);
|
|
||||||
else
|
|
||||||
ABI_CallFunctionC((void *)&PowerPC::OnIdle, PowerPC::ppcState.gpr[a] + (s32)(s16)inst.SIMM_16);
|
|
||||||
MOV(32, M(&PowerPC::ppcState.pc), Imm32(js.compilerPC + 12));
|
MOV(32, M(&PowerPC::ppcState.pc), Imm32(js.compilerPC + 12));
|
||||||
JMP(Asm::testExceptions, true);
|
JMP(Asm::testExceptions, true);
|
||||||
js.compilerPC += 8;
|
js.compilerPC += 8;
|
||||||
|
@ -33,8 +33,6 @@
|
|||||||
|
|
||||||
#include "../Host.h"
|
#include "../Host.h"
|
||||||
|
|
||||||
#include "Thread.h" // for g_hEventOnIdle
|
|
||||||
|
|
||||||
namespace PowerPC
|
namespace PowerPC
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -289,19 +287,7 @@ void OnIdle(u32 _uThreadAddr)
|
|||||||
u32 nextThread = Memory::Read_U32(_uThreadAddr);
|
u32 nextThread = Memory::Read_U32(_uThreadAddr);
|
||||||
//do idle skipping
|
//do idle skipping
|
||||||
if (nextThread == 0)
|
if (nextThread == 0)
|
||||||
{
|
|
||||||
CoreTiming::Idle();
|
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
|
} // namespace
|
||||||
|
@ -86,7 +86,6 @@ namespace PowerPC
|
|||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
void OnIdle(u32 _uThreadAddr);
|
void OnIdle(u32 _uThreadAddr);
|
||||||
void OnIdleDC(void);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Easy register access macros.
|
// Easy register access macros.
|
||||||
|
@ -89,10 +89,6 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
|||||||
{
|
{
|
||||||
SCPFifoStruct &_fifo = *video_initialize.pCPFifo;
|
SCPFifoStruct &_fifo = *video_initialize.pCPFifo;
|
||||||
u32 distToSend;
|
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
|
#ifdef _WIN32
|
||||||
// TODO(ector): Don't peek so often!
|
// TODO(ector): Don't peek so often!
|
||||||
@ -101,16 +97,8 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
|||||||
while (fifoStateRun)
|
while (fifoStateRun)
|
||||||
#endif
|
#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 (_fifo.CPReadWriteDistance < _fifo.CPLoWatermark)
|
||||||
#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32)
|
|
||||||
continue;
|
|
||||||
#else
|
|
||||||
Common::SleepCurrentThread(1);
|
Common::SleepCurrentThread(1);
|
||||||
#endif
|
|
||||||
//etc...
|
//etc...
|
||||||
|
|
||||||
// check if we are able to run this buffer
|
// check if we are able to run this buffer
|
||||||
@ -121,18 +109,15 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
|||||||
#else
|
#else
|
||||||
Common::InterlockedExchange((int*)&_fifo.CPReadIdle, 0);
|
Common::InterlockedExchange((int*)&_fifo.CPReadIdle, 0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32)
|
//video_initialize.pLog("RUN...........................",FALSE);
|
||||||
while(_fifo.CPReadWriteDistance > 0)
|
|
||||||
#else
|
|
||||||
while(_fifo.bFF_GPReadEnable && (_fifo.CPReadWriteDistance > 0) )
|
while(_fifo.bFF_GPReadEnable && (_fifo.CPReadWriteDistance > 0) )
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
// read the data and send it to the VideoPlugin
|
// read the data and send it to the VideoPlugin
|
||||||
u8 *uData = video_initialize.pGetMemoryPointer(_fifo.CPReadPointer);
|
|
||||||
|
|
||||||
u32 readPtr = _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
|
// 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 (_fifo.bFF_BPEnable)
|
||||||
{
|
{
|
||||||
if (readPtr == _fifo.CPBreakpoint)
|
if (readPtr == _fifo.CPBreakpoint)
|
||||||
@ -148,20 +133,28 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
|||||||
}
|
}
|
||||||
distToSend = 32;
|
distToSend = 32;
|
||||||
readPtr += 32;
|
readPtr += 32;
|
||||||
if ( readPtr > _fifo.CPEnd)
|
if ( readPtr >= _fifo.CPEnd)
|
||||||
readPtr = _fifo.CPBase;
|
readPtr = _fifo.CPBase;
|
||||||
}
|
}
|
||||||
else
|
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
|
// sending the whole CPReadWriteDistance
|
||||||
distToSend = _fifo.CPReadWriteDistance;
|
distToSend = _fifo.CPReadWriteDistance;
|
||||||
if ( (distToSend+readPtr) > _fifo.CPEnd) // TODO: better?
|
if ( (distToSend+readPtr) >= _fifo.CPEnd) // TODO: better?
|
||||||
{
|
{
|
||||||
distToSend =_fifo.CPEnd - readPtr;
|
distToSend =_fifo.CPEnd - readPtr;
|
||||||
readPtr = _fifo.CPBase;
|
readPtr = _fifo.CPBase;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
readPtr += distToSend;
|
readPtr += distToSend;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
Video_SendFifoData(uData, distToSend);
|
Video_SendFifoData(uData, distToSend);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -172,7 +165,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
|||||||
Common::InterlockedExchangeAdd((int*)&_fifo.CPReadWriteDistance, -distToSend);
|
Common::InterlockedExchangeAdd((int*)&_fifo.CPReadWriteDistance, -distToSend);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
//video_initialize.pLog("IDLE",FALSE);
|
//video_initialize.pLog("..........................IDLE",FALSE);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
InterlockedExchange((LONG*)&_fifo.CPReadIdle, 1);
|
InterlockedExchange((LONG*)&_fifo.CPReadIdle, 1);
|
||||||
#else
|
#else
|
||||||
@ -180,8 +173,5 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined(THREAD_VIDEO_WAKEUP_ONIDLE) && defined(_WIN32)
|
|
||||||
CloseHandle(hEventOnIdle);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user