Reverted the FIFO thread change

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4937 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
skidau 2010-01-23 21:06:12 +00:00
parent 0128e92068
commit 1f37bb2177
3 changed files with 79 additions and 126 deletions

View File

@ -39,12 +39,8 @@ static u8 *videoBuffer;
static Common::EventEx fifo_run_event; static Common::EventEx fifo_run_event;
// STATE_TO_SAVE // STATE_TO_SAVE
static int size = 0; static int size = 0;
} // namespace } // namespace
Common::Thread *g_hFifoThread = NULL;
SVideoInitialize video_initialize;
void Fifo_DoState(PointerWrap &p) void Fifo_DoState(PointerWrap &p)
{ {
CommandProcessor::FifoCriticalEnter(); CommandProcessor::FifoCriticalEnter();
@ -136,134 +132,94 @@ void Fifo_SendFifoData(u8* _uData, u32 len)
OpcodeDecoder_Run(g_bSkipCurrentFrame); OpcodeDecoder_Run(g_bSkipCurrentFrame);
} }
inline void Fifo_Run() // Description: Main FIFO update loop
// Purpose: Keep the Core HW updated about the CPU-GPU distance
void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
{ {
fifoStateRun = true;
SCPFifoStruct &_fifo = CommandProcessor::fifo; SCPFifoStruct &_fifo = CommandProcessor::fifo;
s32 distToSend; s32 distToSend;
// check if we are able to run this buffer
while (_fifo.bFF_GPReadEnable && ((!_fifo.bFF_BPEnable && _fifo.CPReadWriteDistance) || (_fifo.bFF_BPEnable && !_fifo.bFF_Breakpoint)))
{
if (!fifoStateRun)
break;
CommandProcessor::FifoCriticalEnter();
// Create pointer to video data and send it to the VideoPlugin
u32 readPtr = _fifo.CPReadPointer;
u8 *uData = video_initialize.pGetMemoryPointer(readPtr);
// If we are in BP mode we only send 32B chunks to Video plugin for BP checking
if (_fifo.bFF_BPEnable)
{
// Sometimes we have already exceeded the BP even before it is set
// so careful check is required
if (
(readPtr == _fifo.CPBreakpoint) ||
//(readPtr <= _fifo.CPBreakpoint && readPtr + 32 > _fifo.CPBreakpoint) ||
(readPtr <= _fifo.CPWritePointer && _fifo.CPWritePointer < _fifo.CPBreakpoint) ||
(readPtr <= _fifo.CPWritePointer && readPtr > _fifo.CPBreakpoint) ||
(readPtr > _fifo.CPBreakpoint && _fifo.CPBreakpoint > _fifo.CPWritePointer)
)
{
Common::AtomicStore(_fifo.bFF_Breakpoint, 1);
CommandProcessor::UpdateInterruptsFromVideoPlugin(true);
CommandProcessor::FifoCriticalLeave();
break;
}
distToSend = 32;
if ( readPtr >= _fifo.CPEnd)
readPtr = _fifo.CPBase;
else
readPtr += 32;
}
// If we are not in BP mode we send all the chunk we have to speed up
else
{
distToSend = _fifo.CPReadWriteDistance;
// send 1024B chunk max length to have better control over PeekMessages' period
distToSend = distToSend > 1024 ? 1024 : distToSend;
// add 32 bytes because the cp end points to the start of the last 32 byte chunk
if ((distToSend + readPtr) >= (_fifo.CPEnd + 32)) // TODO: better?
{
distToSend =(_fifo.CPEnd + 32) - readPtr;
readPtr = _fifo.CPBase;
}
else
readPtr += distToSend;
}
// Execute new instructions found in uData
Fifo_SendFifoData(uData, distToSend);
Common::AtomicStore(_fifo.CPReadPointer, readPtr);
Common::AtomicAdd(_fifo.CPReadWriteDistance, -distToSend);
CommandProcessor::FifoCriticalLeave();
}
CommandProcessor::SetFifoIdleFromVideoPlugin();
}
// Regular thread
THREAD_RETURN fifo_thread(void* lpParameter)
{
while (fifoStateRun) while (fifoStateRun)
{ {
Fifo_Run(); video_initialize.pPeekMessages();
// Must use YieldCPU() in this loop. SLEEP(1) will make MP2 VideoFifo_CheckEFBAccess();
// hang on boot. VideoFifo_CheckSwapRequest();
// check if we are able to run this buffer
while (_fifo.bFF_GPReadEnable && ((!_fifo.bFF_BPEnable && _fifo.CPReadWriteDistance) || (_fifo.bFF_BPEnable && !_fifo.bFF_Breakpoint)))
{
if (!fifoStateRun)
break;
CommandProcessor::FifoCriticalEnter();
// Create pointer to video data and send it to the VideoPlugin
u32 readPtr = _fifo.CPReadPointer;
u8 *uData = video_initialize.pGetMemoryPointer(readPtr);
// NOTICE_LOG(BOOT, "readPtr: %08x uData %08x", readPtr, uData);
// If we are in BP mode we only send 32B chunks to Video plugin for BP checking
if (_fifo.bFF_BPEnable)
{
// Sometimes we have already exceeded the BP even before it is set
// so careful check is required
if (
(readPtr == _fifo.CPBreakpoint) ||
//(readPtr <= _fifo.CPBreakpoint && readPtr + 32 > _fifo.CPBreakpoint) ||
(readPtr <= _fifo.CPWritePointer && _fifo.CPWritePointer < _fifo.CPBreakpoint) ||
(readPtr <= _fifo.CPWritePointer && readPtr > _fifo.CPBreakpoint) ||
(readPtr > _fifo.CPBreakpoint && _fifo.CPBreakpoint > _fifo.CPWritePointer)
)
{
Common::AtomicStore(_fifo.bFF_Breakpoint, 1);
CommandProcessor::UpdateInterruptsFromVideoPlugin(true);
CommandProcessor::FifoCriticalLeave();
break;
}
distToSend = 32;
if ( readPtr >= _fifo.CPEnd)
readPtr = _fifo.CPBase;
else
readPtr += 32;
}
// If we are not in BP mode we send all the chunk we have to speed up
else
{
distToSend = _fifo.CPReadWriteDistance;
// send 1024B chunk max length to have better control over PeekMessages' period
distToSend = distToSend > 1024 ? 1024 : distToSend;
// add 32 bytes because the cp end points to the start of the last 32 byte chunk
if ((distToSend + readPtr) >= (_fifo.CPEnd + 32)) // TODO: better?
{
distToSend =(_fifo.CPEnd + 32) - readPtr;
readPtr = _fifo.CPBase;
}
else
readPtr += distToSend;
}
// Execute new instructions found in uData
Fifo_SendFifoData(uData, distToSend);
Common::AtomicStore(_fifo.CPReadPointer, readPtr);
Common::AtomicAdd(_fifo.CPReadWriteDistance, -distToSend);
CommandProcessor::FifoCriticalLeave();
// Those two are pretty important and must be called in the FIFO Loop.
// If we don't, s_swapRequested (OGL only) or s_efbAccessRequested won't be set to false
// leading the CPU thread to wait in Video_BeginField or Video_AccessEFB thus slowing things down.
VideoFifo_CheckEFBAccess();
VideoFifo_CheckSwapRequest();
}
CommandProcessor::SetFifoIdleFromVideoPlugin();
if (EmuRunning) if (EmuRunning)
Common::YieldCPU(); Common::YieldCPU();
else else
fifo_run_event.MsgWait(); fifo_run_event.MsgWait();
} }
return 0;
} }
// Description: Main FIFO update loop
// Purpose: Keep the Core HW updated about the CPU-GPU distance
void Fifo_EnterLoop(const SVideoInitialize &video_init)
{
fifoStateRun = true;
video_initialize = video_init;
if (g_ActiveConfig.bUseFIFOThread) // threaded mode
{
g_hFifoThread = new Common::Thread(fifo_thread, NULL);
while (fifoStateRun)
{
video_initialize.pPeekMessages();
// The two VideoFifo checks below are pretty important and must be
// called in the FIFO Loop. If we don't, s_swapRequested (OGL only)
// or s_efbAccessRequested won't be set to false leading the CPU
// thread to wait in Video_BeginField or Video_AccessEFB thus slowing
// things down.
VideoFifo_CheckEFBAccess();
VideoFifo_CheckSwapRequest();
SLEEP(1);
}
}
else
{
while (fifoStateRun)
{
video_initialize.pPeekMessages();
VideoFifo_CheckEFBAccess();
VideoFifo_CheckSwapRequest();
Fifo_Run();
if (EmuRunning)
Common::YieldCPU();
else
fifo_run_event.MsgWait();
}
}
}

View File

@ -57,8 +57,7 @@ void VideoConfig::Load(const char *ini_file)
iniFile.Get("Settings", "AspectRatio", &iAspectRatio, (int)ASPECT_AUTO); iniFile.Get("Settings", "AspectRatio", &iAspectRatio, (int)ASPECT_AUTO);
iniFile.Get("Settings", "Crop", &bCrop, false); iniFile.Get("Settings", "Crop", &bCrop, false);
iniFile.Get("Settings", "HideCursor", &bHideCursor, false); iniFile.Get("Settings", "HideCursor", &bHideCursor, false);
iniFile.Get("Settings", "UseXFB", &bUseXFB, false); iniFile.Get("Settings", "UseXFB", &bUseXFB, 0);
iniFile.Get("Settings", "UseFIFOThread", &bUseFIFOThread, false);
iniFile.Get("Settings", "AutoScale", &bAutoScale, true); iniFile.Get("Settings", "AutoScale", &bAutoScale, true);
iniFile.Get("Settings", "SafeTextureCache", &bSafeTextureCache, false); // Settings iniFile.Get("Settings", "SafeTextureCache", &bSafeTextureCache, false); // Settings
@ -131,7 +130,7 @@ void VideoConfig::GameIniLoad(const char *ini_file)
if (iniFile.Exists("Video", "DstAlphaPass")) if (iniFile.Exists("Video", "DstAlphaPass"))
iniFile.Get("Video", "DstAlphaPass", &bDstAlphaPass, false); iniFile.Get("Video", "DstAlphaPass", &bDstAlphaPass, false);
if (iniFile.Exists("Video", "UseXFB")) if (iniFile.Exists("Video", "UseXFB"))
iniFile.Get("Video", "UseXFB", &bUseXFB, false); iniFile.Get("Video", "UseXFB", &bUseXFB, 0);
if (iniFile.Exists("Video", "FIFOBPHack")) if (iniFile.Exists("Video", "FIFOBPHack"))
iniFile.Get("Video", "FIFOBPHack", &bFIFOBPhack, false); iniFile.Get("Video", "FIFOBPHack", &bFIFOBPhack, false);
if (iniFile.Exists("Video", "ProjectionHack")) if (iniFile.Exists("Video", "ProjectionHack"))
@ -154,7 +153,6 @@ void VideoConfig::Save(const char *ini_file)
iniFile.Set("Settings", "wideScreenHack", bWidescreenHack); iniFile.Set("Settings", "wideScreenHack", bWidescreenHack);
iniFile.Set("Settings", "HideCursor", bHideCursor); iniFile.Set("Settings", "HideCursor", bHideCursor);
iniFile.Set("Settings", "UseXFB", bUseXFB); iniFile.Set("Settings", "UseXFB", bUseXFB);
iniFile.Set("Settings", "UseFIFOThread", bUseFIFOThread);
iniFile.Set("Settings", "AutoScale", bAutoScale); iniFile.Set("Settings", "AutoScale", bAutoScale);
iniFile.Set("Settings", "SafeTextureCache", bSafeTextureCache); iniFile.Set("Settings", "SafeTextureCache", bSafeTextureCache);

View File

@ -81,7 +81,6 @@ struct VideoConfig
int iAspectRatio; int iAspectRatio;
bool bCrop; // Aspect ratio controls. bool bCrop; // Aspect ratio controls.
bool bUseXFB; bool bUseXFB;
bool bUseFIFOThread;
bool bAutoScale; // Removes annoying borders without using XFB. Doesn't always work perfectly. bool bAutoScale; // Removes annoying borders without using XFB. Doesn't always work perfectly.
// Enhancements // Enhancements