Experimental commit and one fix for my last commit.

I think that isFifoBusy bring better sync with VI (video interface) because the CPU emulated threads are waiting for DrawDone in BP Register. So, I do some modifications.
1) Rename "IsFifoBusy" by "isPossibleWaitingSetDrawDone"
2) Only activate isPossibleWaitingSetDrawDone when bFF_GPLinkEnable is true in fifo loop "Inmediate mode" that is because in theory this drawsync function is using in this mode.
3) Deactivate isPossibleWaitingSetDrawDone also in SetFinish in PixelEngine, beside when 32 block is finish.

Please regression in yours games thats can bring some FPS more above all with VPS frame limiter ON (Auto, 60, 50, etc).

- Fix waiting in AbortFrame(), please test mp1/mp2 is fixed again.

Good look! 

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7123 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Marcos Vitali 2011-02-10 04:47:02 +00:00
parent 464d352d46
commit 86278642dc
10 changed files with 26 additions and 16 deletions

View File

@ -55,6 +55,7 @@ struct SCPFifoStruct
// So no possiblity to ack the Token irq by the scheduler until some sort of PPC watchdog do its mess.
volatile u16 PEToken;
volatile u32 bFF_GPLinkEnable;
volatile u32 bFF_GPReadEnable;
volatile u32 bFF_BPEnable;
volatile u32 bFF_BPInt;
@ -113,7 +114,7 @@ public:
static void Video_GatherPipeBursted();
virtual void Video_WaitForFrameFinish() = 0;
virtual bool Video_IsFifoBusy() = 0;
virtual bool Video_IsPossibleWaitingSetDrawDone() = 0;
virtual void Video_AbortFrame() = 0;
static void PopulateList();
@ -145,7 +146,7 @@ class VideoBackendHLE : public VideoBackend
void Video_SetRendering(bool bEnabled);
void Video_WaitForFrameFinish();
bool Video_IsFifoBusy();
bool Video_IsPossibleWaitingSetDrawDone();
void Video_AbortFrame();
};

View File

@ -520,7 +520,7 @@ void Idle()
//When the FIFO is processing data we must not advance because in this way
//the VI will be desynchronized. So, We are waiting until the FIFO finish and
//while we process only the events required by the FIFO.
while (g_video_backend->Video_IsFifoBusy())
while (g_video_backend->Video_IsPossibleWaitingSetDrawDone())
{
ProcessFifoWaitEvents();
Common::YieldCPU();

View File

@ -111,7 +111,7 @@ static Common::CriticalSection sFifoCritical;
static bool bProcessFifoToLoWatermark = false;
static bool bProcessFifoAllDistance = false;
volatile bool isFifoBusy = false; //This state is changed when the FIFO is processing data.
volatile bool isPossibleWaitingSetDrawDone = false; //This state is changed when the FIFO is processing data.
volatile bool interruptSet= false;
volatile bool interruptWaiting= false;
volatile bool interruptTokenWaiting = false;
@ -153,7 +153,7 @@ void DoState(PointerWrap &p)
p.Do(bProcessFifoToLoWatermark);
p.Do(bProcessFifoAllDistance);
p.Do(isFifoBusy);
p.Do(isPossibleWaitingSetDrawDone);
p.Do(interruptSet);
p.Do(interruptWaiting);
p.Do(interruptTokenWaiting);
@ -477,6 +477,7 @@ void Write16(const u16 _Value, const u32 _Address)
fifo.bFF_GPReadEnable = tmpCtrl.GPReadEnable;
fifo.bFF_HiWatermarkInt = tmpCtrl.FifoOverflowIntEnable;
fifo.bFF_LoWatermarkInt = tmpCtrl.FifoUnderflowIntEnable;
fifo.bFF_GPLinkEnable = tmpCtrl.GPLinkEnable;
if(tmpCtrl.GPReadEnable && tmpCtrl.GPLinkEnable)
{
@ -816,7 +817,7 @@ void SetFifoIdleFromVideoPlugin()
void AbortFrame()
{
fifo.bFF_GPReadEnable = false;
s_fifoIdleEvent.Wait();
while(IsFifoProcesingData()) Common::YieldCPU();
GPFifo::ResetGatherPipe();
ResetVideoBuffer();
fifo.CPReadPointer = fifo.CPWritePointer;

View File

@ -30,7 +30,7 @@ namespace CommandProcessor
{
extern SCPFifoStruct fifo; //This one is shared between gfx thread and emulator thread.
extern volatile bool isFifoBusy; //This one is used for sync gfx thread and emulator thread.
extern volatile bool isPossibleWaitingSetDrawDone; //This one is used for sync gfx thread and emulator thread.
extern volatile bool interruptSet;
extern volatile bool interruptWaiting;
extern volatile bool interruptTokenWaiting;

View File

@ -33,6 +33,7 @@ namespace
{
static volatile bool fifoStateRun = false;
static volatile bool EmuRunning = false;
static volatile bool isFifoProcesingData = false;
static u8 *videoBuffer;
// STATE_TO_SAVE
static int size = 0;
@ -95,6 +96,11 @@ void Fifo_RunLoop(bool run)
EmuRunning = run;
}
bool IsFifoProcesingData()
{
return isFifoProcesingData;
}
// Description: Fifo_EnterLoop() sends data through this function.
void Fifo_SendFifoData(u8* _uData, u32 len)
{
@ -142,9 +148,8 @@ void Fifo_EnterLoop()
while (!CommandProcessor::interruptWaiting && _fifo.bFF_GPReadEnable &&
_fifo.CPReadWriteDistance && (!AtBreakpoint() || CommandProcessor::OnOverflow))
{
// while the FIFO is processing data we activate this for sync with emulator thread.
CommandProcessor::isFifoBusy = true;
isFifoProcesingData = true;
CommandProcessor::isPossibleWaitingSetDrawDone = _fifo.bFF_GPLinkEnable;
if (!fifoStateRun) break;
@ -180,9 +185,10 @@ void Fifo_EnterLoop()
// If we don't, s_swapRequested 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_CheckAsyncRequest();
CommandProcessor::isFifoBusy = false;
CommandProcessor::isPossibleWaitingSetDrawDone = false;
}
isFifoProcesingData = false;
CommandProcessor::SetFifoIdleFromVideoPlugin();

View File

@ -41,6 +41,7 @@ bool AtBreakpoint();
void Fifo_DoState(PointerWrap &f);
void ResetVideoBuffer();
void Fifo_SetRendering(bool bEnabled);
bool IsFifoProcesingData();
// Implemented by the Video Plugin
void VideoFifo_CheckAsyncRequest();

View File

@ -240,9 +240,9 @@ void VideoBackendHLE::Video_WaitForFrameFinish()
CommandProcessor::WaitForFrameFinish();
}
bool VideoBackendHLE::Video_IsFifoBusy()
bool VideoBackendHLE::Video_IsPossibleWaitingSetDrawDone()
{
return CommandProcessor::isFifoBusy;
return CommandProcessor::isPossibleWaitingSetDrawDone;
}
void VideoBackendHLE::Video_AbortFrame()

View File

@ -356,6 +356,7 @@ void SetFinish_OnMainThread(u64 userdata, int cyclesLate)
g_bSignalFinishInterrupt = 1;
UpdateInterrupts();
CommandProcessor::interruptFinishWaiting = false;
CommandProcessor::isPossibleWaitingSetDrawDone = false;
}
// SetToken

View File

@ -178,7 +178,7 @@ void VideoBackend::Video_WaitForFrameFinish(void)
{
}
bool VideoBackend::Video_IsFifoBusy(void)
bool VideoBackend::Video_IsPossibleWaitingSetDrawDone(void)
{
return false;
}

View File

@ -36,7 +36,7 @@ class VideoBackend : public VideoBackendLLE
void Video_SetRendering(bool bEnabled);
void Video_WaitForFrameFinish();
bool Video_IsFifoBusy();
bool Video_IsPossibleWaitingSetDrawDone();
void Video_AbortFrame();
void UpdateFPSDisplay(const char*);