ReorderingMTGS:

* Added a few assertions to detect when PATH transfers are started that violate other pending PATH transfers.
 * Removed a lot of obsolete code from vif1's DIRECT handler (Vif_Codes.cpp)
 * Add alignment to Path1buffer to avoid SSE alignment faults.

git-svn-id: http://pcsx2.googlecode.com/svn/branches/ReorderingMTGS@3503 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-07-16 16:48:08 +00:00
parent d10b60d560
commit 32942ec9a6
4 changed files with 40 additions and 73 deletions

View File

@ -36,7 +36,7 @@ static u32 gifqwc = 0;
static bool gifmfifoirq = false; static bool gifmfifoirq = false;
//Just some temporary bits to store Path1 transfers if another is in progress. //Just some temporary bits to store Path1 transfers if another is in progress.
u8 Path1Buffer[0x1000000]; __aligned16 u8 Path1Buffer[0x1000000];
u32 Path1WritePos = 0; u32 Path1WritePos = 0;
u32 Path1ReadPos = 0; u32 Path1ReadPos = 0;
@ -65,7 +65,6 @@ void gsPath1Interrupt()
uint count = GIFPath_CopyTag(GIF_PATH_1, ((u128*)Path1Buffer) + Path1ReadPos, size); uint count = GIFPath_CopyTag(GIF_PATH_1, ((u128*)Path1Buffer) + Path1ReadPos, size);
GetMTGS().SendDataPacket(); GetMTGS().SendDataPacket();
pxAssume( count == size );
Path1ReadPos += count; Path1ReadPos += count;
if(GSTransferStatus.PTH1 == STOPPED_MODE) if(GSTransferStatus.PTH1 == STOPPED_MODE)

View File

@ -290,7 +290,7 @@ extern void gifMFIFOInterrupt();
//Just some temporary bits to store Path1 transfers if another is in progress. //Just some temporary bits to store Path1 transfers if another is in progress.
extern void gsPath1Interrupt(); extern void gsPath1Interrupt();
extern u8 Path1Buffer[0x1000000]; extern __aligned16 u8 Path1Buffer[0x1000000];
extern u32 Path1WritePos; extern u32 Path1WritePos;
extern u32 Path1ReadPos; extern u32 Path1ReadPos;
#endif #endif

View File

@ -134,6 +134,7 @@ template<int idx> _f int _vifCode_Direct(int pass, u8* data, bool isDirectHL) {
} }
pass2 { pass2 {
vif1Only(); vif1Only();
nVifStruct& v = nVif[1];
if (GSTransferStatus.PTH3 < IDLE_MODE || gifRegs->stat.P1Q == true) if (GSTransferStatus.PTH3 < IDLE_MODE || gifRegs->stat.P1Q == true)
{ {
@ -167,79 +168,34 @@ template<int idx> _f int _vifCode_Direct(int pass, u8* data, bool isDirectHL) {
return 0; return 0;
} }
// HACK ATTACK!
// we shouldn't be clearing the queue flag here at all. Ideally, the queue statuses
// should be checked, handled, and cleared from the EOP check in GIFPath only. --air
gifRegs->stat.clear_flags(GIF_STAT_P2Q); gifRegs->stat.clear_flags(GIF_STAT_P2Q);
nVifStruct& v = nVif[1]; // the tag size should ALWAYS be 128 bits (qwc). If it isn't, it means there's a serious bug
const int ret = aMin(vif1.vifpacketsize, vif1.tag.size); // somewhere in the VIF (likely relating to +/-'ing the tag.size during processing).
u32 size = ret << 2; pxAssumeMsg( (vif1.tag.size & 1) == 0, "Invalid Vif1 DIRECT packet size detected!" );
//gifRegs->stat.APATH = GIF_APATH2; //Flag is cleared in vif1interrupt to simulate it being in progress. const int minSize = aMin(vif1.vifpacketsize, vif1.tag.size)/4;
uint ret;
//In the original code we were saving this data, it seems if it does happen, its just blank, so we ignore it. if (!minSize)
DevCon.Warning("VIF DIRECT (PATH2): No Data Transfer?");
if (!size) { DevCon.WriteLn("Path2: No Data Transfer?"); } GetMTGS().PrepDataPacket(GIF_PATH_2, minSize);
ret = GIFPath_CopyTag(GIF_PATH_2, (u128*)data, minSize)*4;
GetMTGS().SendDataPacket();
vif1.tag.size -= ret;
if(vif1.vifpacketsize < 4 && v.bSize < 16) if(vif1.tag.size == 0)
{ {
nVifStruct& v = nVif[idx]; vif1.cmd = 0;
gifRegs->stat.clear_flags(GIF_STAT_APATH2 | GIF_STAT_OPH);
memcpy(&v.buffer[v.bPtr], data, vif1.vifpacketsize << 2); }
v.bSize += vif1.vifpacketsize << 2; vif1.vifstalled = true;
v.bPtr += vif1.vifpacketsize << 2; return ret;
vif1.tag.size -= vif1.vifpacketsize;
if(vif1.tag.size == 0)
{
DevCon.Warning("Missaligned packet on DIRECT end!");
vif1.cmd = 0;
}
return vif1.vifpacketsize;
}
else
{
nVifStruct& v = nVif[idx];
if(v.bSize)
{
int ret = 0;
if(v.bSize < 16)
{
if(((16 - v.bSize) >> 2) > vif1.vifpacketsize) DevCon.Warning("Not Enough Data!");
ret = (16 - v.bSize) >> 2;
memcpy(&v.buffer[v.bPtr], data, ret << 2);
vif1.tag.size -= ret;
v.bSize = 0;
v.bPtr = 0;
}
GetMTGS().PrepDataPacket(GIF_PATH_2, 1);
GIFPath_CopyTag(GIF_PATH_2, (u128*)v.buffer, 1);
GetMTGS().SendDataPacket();
if(vif1.tag.size == 0)
{
vif1.cmd = 0;
}
vif1.vifstalled = true;
return ret;
}
else
{
GetMTGS().PrepDataPacket(GIF_PATH_2, size/16);
uint count = GIFPath_CopyTag(GIF_PATH_2, (u128*)data, size/16) * 4;
GetMTGS().SendDataPacket();
vif1.tag.size -= count;
if(vif1.tag.size == 0)
{
vif1.cmd = 0;
}
vif1.vifstalled = true;
return count;
}
}
} }
return 0; return 0;
} }

View File

@ -817,6 +817,9 @@ __forceinline int GIFPath::CopyTag(const u128* pMem128, u32 size)
gsIrq(); gsIrq();
} }
} }
// [TODO] : DMAC Arbitration rights should select the next queued GIF transfer here.
break; break;
} }
if(SIGNAL_IMR_Pending == true) if(SIGNAL_IMR_Pending == true)
@ -873,9 +876,18 @@ __forceinline int GIFPath_CopyTag(GIF_PATH pathidx, const u128* pMem, u32 size)
{ {
switch( pathidx ) switch( pathidx )
{ {
case GIF_PATH_1: return s_gifPath[GIF_PATH_1].CopyTag<GIF_PATH_1,true>(pMem, size); case GIF_PATH_1:
case GIF_PATH_2: return s_gifPath[GIF_PATH_2].CopyTag<GIF_PATH_2,false>(pMem, size); pxAssertMsg(!s_gifPath[GIF_PATH_2].IsActive(), "GIFpath conflict: Attempted to start PATH1 while PATH2 is already active.");
case GIF_PATH_3: return s_gifPath[GIF_PATH_3].CopyTag<GIF_PATH_3,true>(pMem, size); pxAssertMsg(!s_gifPath[GIF_PATH_3].IsActive(), "GIFpath conflict: Attempted to start PATH1 while PATH3 is already active.");
return s_gifPath[GIF_PATH_1].CopyTag<GIF_PATH_1,true>(pMem, size);
case GIF_PATH_2:
pxAssertMsg(!s_gifPath[GIF_PATH_1].IsActive(), "GIFpath conflict: Attempted to start PATH2 while PATH1 is already active.");
pxAssertMsg(!s_gifPath[GIF_PATH_3].IsActive(), "GIFpath conflict: Attempted to start PATH2 while PATH3 is already active.");
return s_gifPath[GIF_PATH_2].CopyTag<GIF_PATH_2,false>(pMem, size);
case GIF_PATH_3:
pxAssertMsg(!s_gifPath[GIF_PATH_1].IsActive(), "GIFpath conflict: Attempted to start PATH3 while PATH1 is already active.");
pxAssertMsg(!s_gifPath[GIF_PATH_2].IsActive(), "GIFpath conflict: Attempted to start PATH3 while PATH2 is already active.");
return s_gifPath[GIF_PATH_3].CopyTag<GIF_PATH_3,true>(pMem, size);
jNO_DEFAULT; jNO_DEFAULT;
} }