1) XFB in DC proposal. This impact video plugin interface. WARNING: XFB_Draw is not CPU->VI dependent anymore. It's up to GP now. Except for some 2D homebrews which never use GPfifo&CP but direcly XFB. Well, in other words: emulated VSync is uncorrelated with CPU timings now. Tell me if it's too much hacky.

2) DC/GPfifo work: GP quicker to react. PeekMessages at a more steady rate.
3) Fix XFB address to avoid crash like with Animal Crossing gc. TODO: VI regs need proper typedef and logic.
4) Few misc. changes on the fly.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2001 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
memberTwo.mb2
2009-01-24 14:43:17 +00:00
parent fa7e857161
commit 1e7655b5db
15 changed files with 148 additions and 47 deletions

View File

@ -426,8 +426,8 @@ THREAD_RETURN EmuThread(void *pArg)
}
else
{
cpuThread = new Common::Thread(CpuThread, pArg);
Plugins.GetVideo()->Video_Prepare(); //wglMakeCurrent
cpuThread = new Common::Thread(CpuThread, pArg);
Common::SetCurrentThreadName("Video thread");
Plugins.GetVideo()->Video_EnterLoop();
}

View File

@ -151,6 +151,13 @@ u16 m_tokenReg;
SCPFifoStruct fifo; //This one is shared between gfx thread and emulator thread
static u32 fake_GPWatchdogLastToken = 0;
static BOOL fake_CommandProcessorNotUsed = TRUE; // This is used by VI when homebrews use directly XFB without FIFO and CP
// hack: This is used by VI when homebrews use directly XFB without FIFO and CP
BOOL IsCommandProcessorNotUsed()
{
return fake_CommandProcessorNotUsed;
}
void DoState(PointerWrap &p)
{
@ -221,7 +228,7 @@ void Init()
fifo.CPReadIdle = 1;
et_UpdateInterrupts = CoreTiming::RegisterEvent("UpdateInterrupts", UpdateInterrupts_Wrapper);
fake_CommandProcessorNotUsed = TRUE;
}
void Shutdown()
@ -411,6 +418,7 @@ void Write16(const u16 _Value, const u32 _Address)
case CTRL_REGISTER:
{
fake_CommandProcessorNotUsed = FALSE;
UCPCtrlReg tmpCtrl(_Value);
Common::SyncInterlockedExchange((LONG*)&fifo.bFF_GPReadEnable, tmpCtrl.GPReadEnable);

View File

@ -79,6 +79,9 @@ bool AllowIdleSkipping();
void IncrementGPWDToken();
void WaitForFrameFinish();
// hack: This is used by VI when homebrews use directly XFB without FIFO and CP
BOOL IsCommandProcessorNotUsed();
} // end of namespace CommandProcessor
#endif

View File

@ -810,7 +810,8 @@ u8 *GetPointer(const u32 _Address)
_dbg_assert_msg_(MEMMAP, 0, "Memory", "GetPointer from IO Bridge doesnt work");
return NULL;
default:
PanicAlert("Tried to get pointer for unknown address %08x", _Address);
if (!PanicYesNo("Tried to get pointer for unknown address %08x\n Continue?", _Address))
Crash();
break;
}
return NULL;

View File

@ -20,6 +20,8 @@
#include "../PowerPC/PowerPC.h"
#include "../Core.h" // <- for Core::GetStartupParameter().bUseDualCore
#include "CommandProcessor.h" // <- for homebrew's XFB draw hack
#include "PeripheralInterface.h"
#include "VideoInterface.h"
#include "Memmap.h"
@ -513,30 +515,45 @@ void Update()
u8* xfbPtr = 0;
int yOffset = 0;
if (NextXFBRender == 1)
// (mb2) hack: We request XFB updates from CPUthread (here) only when homebrews use directly XFB without FIFO and CP
if (CommandProcessor::IsCommandProcessorNotUsed())
{
NextXFBRender = LinesPerField;
u32 addr = (VideoInterface::m_FrameBufferTop.Hex & 0xFFFFFFF);
if (VideoInterface::m_FrameBufferTop.Hex & 0x10000000)
addr = addr << 5;
xfbPtr = Memory::GetPointer(addr);
}
else
{
NextXFBRender = 1;
u32 addr = (VideoInterface::m_FrameBufferBottom.Hex & 0xFFFFFFF);
// check the top buffer address not the bottom
if (VideoInterface::m_FrameBufferTop.Hex & 0x10000000)
addr = addr << 5;
xfbPtr = Memory::GetPointer(addr);
yOffset = -1;
}
Common::PluginVideo* video = CPluginManager::GetInstance().GetVideo();
if (xfbPtr && video->IsValid())
{
int fbWidth = m_VIHorizontalStepping.FieldSteps * 16;
int fbHeight = (m_VIHorizontalStepping.FbSteps / m_VIHorizontalStepping.FieldSteps) * m_VIVerticalTimingRegister.ACV;
video->Video_UpdateXFB(xfbPtr, fbWidth, fbHeight, yOffset);
if (NextXFBRender == 1)
{
NextXFBRender = LinesPerField;
// TODO: proper VI regs typedef and logic for XFB to work.
// eg. Animal Crossing gc have smth in TFBL.XOF bitfield.
// "XOF - Horizontal Offset of the left-most pixel within the first word of the fetched picture."
u32 addr = (m_FrameBufferTop.Hex & 0x00FFFFFF);
if (m_FrameBufferTop.Hex & 0x10000000)
addr = addr << 5;
xfbPtr = Memory::GetPointer(addr);
_dbg_assert_msg_(VIDEOINTERFACE, xfbPtr, "Bad top XFB address");
}
else
{
NextXFBRender = 1;
// TODO: proper VI regs typedef and logic for XFB to work.
u32 addr = (m_FrameBufferBottom.Hex & 0x00FFFFFF);
// check the top buffer address not the bottom <- (mb2) why not on the bottom one?
if (m_FrameBufferTop.Hex & 0x10000000)
addr = addr << 5;
xfbPtr = Memory::GetPointer(addr);
_dbg_assert_msg_(VIDEOINTERFACE, xfbPtr, "Bad bottom XFB address");
yOffset = -1;
}
Common::PluginVideo* video = CPluginManager::GetInstance().GetVideo();
if (xfbPtr && video->IsValid())
{
int fbWidth = m_VIHorizontalStepping.FieldSteps * 16;
int fbHeight = (m_VIHorizontalStepping.FbSteps / m_VIHorizontalStepping.FieldSteps) * m_VIVerticalTimingRegister.ACV;
if (Core::GetStartupParameter().bUseDualCore)
// scheduled on EmuThread in DC mode
video->Video_UpdateXFB(xfbPtr, fbWidth, fbHeight, yOffset, TRUE);
else
// otherwise do it now from here (CPUthread)
video->Video_UpdateXFB(xfbPtr, fbWidth, fbHeight, yOffset, FALSE);
}
}
}