From 33bc8652e2b0f3854ba02dc827c2ef8e5d257e70 Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Mon, 18 Jan 2010 04:49:45 +0000 Subject: [PATCH] newVif: Cleaned up some code and added some Cleanup code. :D git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2448 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/Vif1Dma.cpp | 5 +++++ pcsx2/x86/VifUnpackSSE_Dynarec.cpp | 31 ++++++++---------------------- pcsx2/x86/newVif.h | 2 ++ pcsx2/x86/newVif_Unpack.cpp | 7 ++++--- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/pcsx2/Vif1Dma.cpp b/pcsx2/Vif1Dma.cpp index a8a116d734..2fd333f16a 100644 --- a/pcsx2/Vif1Dma.cpp +++ b/pcsx2/Vif1Dma.cpp @@ -1187,6 +1187,11 @@ void vif1Reset() vif1.done = true; cpuRegs.interrupt &= ~((1 << 1) | (1 << 10)); //Stop all vif1 DMA's + +#if newVif1 + extern void resetNewVif(int idx); + resetNewVif(1); +#endif } void SaveStateBase::vif1Freeze() diff --git a/pcsx2/x86/VifUnpackSSE_Dynarec.cpp b/pcsx2/x86/VifUnpackSSE_Dynarec.cpp index 8c7d29e808..bd63080ea8 100644 --- a/pcsx2/x86/VifUnpackSSE_Dynarec.cpp +++ b/pcsx2/x86/VifUnpackSSE_Dynarec.cpp @@ -25,32 +25,18 @@ static __aligned16 nVifBlock _vBlock = {0}; static __pagealigned u8 nVifMemCmp[__pagesize]; -static void emitCustomCompare() { - HostSys::MemProtectStatic(nVifMemCmp, Protect_ReadWrite, false); - memset8<0xcc>(nVifMemCmp); - xSetPtr(nVifMemCmp); - - xMOVAPS (xmm0, ptr32[ecx]); - xPCMP.EQD(xmm0, ptr32[edx]); - xMOVMSKPS(eax, xmm0); - xAND (eax, 0x7); // ignore top 4 bytes (recBlock pointer) - - xRET(); - HostSys::MemProtectStatic(nVifMemCmp, Protect_ReadOnly, true); -} - void dVifInit(int idx) { - nVif[idx].idx = idx; - nVif[idx].VU = idx ? &VU1 : &VU0; - nVif[idx].vif = idx ? &vif1 : &vif0; - nVif[idx].vifRegs = idx ? vif1Regs : vif0Regs; - nVif[idx].vuMemEnd = idx ? ((u8*)(VU1.Mem + 0x4000)) : ((u8*)(VU0.Mem + 0x1000)); - nVif[idx].vuMemLimit= idx ? 0x3ff0 : 0xff0; + nVif[idx].numBlocks = 0; nVif[idx].vifCache = new BlockBuffer(_1mb*4); // 4mb Rec Cache nVif[idx].vifBlocks = new HashBucket<_tParams>(); nVif[idx].recPtr = nVif[idx].vifCache->getBlock(); nVif[idx].recEnd = &nVif[idx].recPtr[nVif[idx].vifCache->getSize()-(_1mb/4)]; // .25mb Safe Zone - //emitCustomCompare(); +} + +void dVifClose(int idx) { + nVif[idx].numBlocks = 0; + safe_delete(nVif[idx].vifCache); + safe_delete(nVif[idx].vifBlocks); } // Loads Row/Col Data from vifRegs instead of g_vifmask @@ -287,8 +273,7 @@ _f void dVifUnpack(int idx, u8 *data, u32 size, bool isFill) { } return; } - static int recBlockNum = 0; - DevCon.WriteLn("nVif: Recompiled Block! [%d]", recBlockNum++); + DevCon.WriteLn("nVif: Recompiled Block! [%d]", nVif[idx].numBlocks++); //DevCon.WriteLn(L"[num=% 3d][upkType=0x%02x][scl=%d][cl=%d][wl=%d][mode=%d][m=%d][mask=%s]", // _vBlock.num, _vBlock.upkType, _vBlock.scl, _vBlock.cl, _vBlock.wl, _vBlock.mode, // doMask >> 4, doMask ? wxsFormat( L"0x%08x", _vBlock.mask ).c_str() : L"ignored" diff --git a/pcsx2/x86/newVif.h b/pcsx2/x86/newVif.h index bf3e840836..648a300151 100644 --- a/pcsx2/x86/newVif.h +++ b/pcsx2/x86/newVif.h @@ -34,6 +34,7 @@ extern void mVUmergeRegs(int dest, int src, int xyzw, bool modXYZW = 0); extern void _nVifUnpack (int idx, u8 *data, u32 size, bool isFill); extern void dVifUnpack (int idx, u8 *data, u32 size, bool isFill); extern void dVifInit (int idx); +extern void dVifClose (int idx); extern void VifUnpackSSE_Init(); #define VUFT VIFUnpackFuncTable @@ -92,6 +93,7 @@ struct nVifStruct { u8* recEnd; // End of Rec Cache BlockBuffer* vifCache; // Block Buffer HashBucket<_tParams>* vifBlocks; // Vif Blocks + int numBlocks; // # of Blocks Recompiled }; extern __aligned16 nVifStruct nVif[2]; diff --git a/pcsx2/x86/newVif_Unpack.cpp b/pcsx2/x86/newVif_Unpack.cpp index f81d62a651..52da05bc9d 100644 --- a/pcsx2/x86/newVif_Unpack.cpp +++ b/pcsx2/x86/newVif_Unpack.cpp @@ -89,9 +89,12 @@ void initNewVif(int idx) { nVif[idx].partTransfer = 0; VifUnpackSSE_Init(); - if (newVifDynaRec) dVifInit(idx); + if (newVifDynaRec) dVifInit(idx); } +void closeNewVif(int idx) { if (newVifDynaRec) dVifClose(idx); } +void resetNewVif(int idx) { closeNewVif(idx); initNewVif(idx); } + static _f u8* setVUptr(int vuidx, const u8* vuMemBase, int offset) { return (u8*)(vuMemBase + ( offset & (vuidx ? 0x3ff0 : 0xff0) )); } @@ -103,7 +106,6 @@ static _f void incVUptr(int vuidx, u8* &ptr, const u8* vuMemBase, int amount) { int diff = ptr - (vuMemBase + (vuidx ? 0x4000 : 0x1000)); if (diff >= 0) { ptr = (u8*)(vuMemBase + diff); - DevCon.WriteLn("wrap!"); } } @@ -113,7 +115,6 @@ static _f void incVUptrBy16(int vuidx, u8* &ptr, const u8* vuMemBase) { vif->tag.addr += 16; if( ptr == (vuMemBase + (vuidx ? 0x4000 : 0x1000)) ) { ptr -= (vuidx ? 0x4000 : 0x1000); - DevCon.WriteLn("wrap!"); } }