/[pcsx2_0.9.7]/trunk/pcsx2/x86/newVif_Dynarec.cpp
ViewVC logotype

Diff of /trunk/pcsx2/x86/newVif_Dynarec.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/pcsx2/x86/newVif_Dynarec.cpp	2010/12/23 11:48:33	279
+++ trunk/pcsx2/x86/newVif_Dynarec.cpp	2010/12/23 12:02:12	280
@@ -22,34 +22,37 @@
 
 static __aligned16 nVifBlock _vBlock = {0};
 
-void dVifReset(int idx) {
-	// If the VIF cache is greater than 12mb, then it's due for a complete reset back
-	// down to a reasonable starting point of 4mb.
-	if( nVif[idx].vifCache && (nVif[idx].vifCache->getAllocSize() > _1mb*12) )
-		safe_delete(nVif[idx].vifCache);
+void dVifReserve(int idx)
+{
+	if (!nVif[idx].recReserve)
+		nVif[idx].recReserve = new RecompiledCodeReserve(pxsFmt(L"VIF%u Unpack Recompiler Cache", idx));
 
-	if( !nVif[idx].vifCache )
-		nVif[idx].vifCache = new BlockBuffer(_1mb*4);
-	else
-		nVif[idx].vifCache->clear();
+	nVif[idx].recReserve->Reserve( nVif[idx].recReserveSizeMB * _1mb, idx ? HostMemoryMap::VIF1rec : HostMemoryMap::VIF0rec );
+}
+
+void dVifReset(int idx) {
 
 	if( !nVif[idx].vifBlocks )
 		nVif[idx].vifBlocks = new HashBucket<_tParams>();
 	else
 		nVif[idx].vifBlocks->clear();
 
-	nVif[idx].numBlocks =  0;
-
-	nVif[idx].recPtr	=  nVif[idx].vifCache->getBlock();
-	nVif[idx].recEnd	= &nVif[idx].recPtr[nVif[idx].vifCache->getAllocSize()-(_1mb/4)]; // .25mb Safe Zone
+	nVif[idx].recReserve->Reset();
+	nVif[idx].numBlocks		=  0;
+	nVif[idx].recWritePtr	= nVif[idx].recReserve->GetPtr();
 }
 
 void dVifClose(int idx) {
 	nVif[idx].numBlocks = 0;
-	safe_delete(nVif[idx].vifCache);
+	nVif[idx].recReserve->Reset();
+
 	safe_delete(nVif[idx].vifBlocks);
 }
 
+void dVifRelease(int idx) {
+	safe_delete(nVif[idx].recReserve);
+}
+
 VifUnpackSSE_Dynarec::VifUnpackSSE_Dynarec(const nVifStruct& vif_, const nVifBlock& vifBlock_)
 	: v(vif_)
 	, vB(vifBlock_)
@@ -201,7 +204,7 @@
 
 	u8* startmem = VU.Mem + (vif.tag.addr & (vuMemLimit-0x10));
 	u8* endmem = VU.Mem + vuMemLimit;
-	uint length = _vBlock.num * 16;
+	uint length = (_vBlock.num > 0) ? (_vBlock.num * 16) : 4096; // 0 = 256
 
 	if (!isFill) {
 		// Accounting for skipping mode: Subtract the last skip cycle, since the skipped part of the run
@@ -223,11 +226,10 @@
 // [TODO] :  Finish implementing support for VIF's growable recBlocks buffer.  Currently
 //    it clears the buffer only.
 static __fi void dVifRecLimit(int idx) {
-	if (nVif[idx].recPtr > nVif[idx].recEnd) {
-		DevCon.WriteLn("nVif Rec - Out of Rec Cache! [%x > %x]", nVif[idx].recPtr, nVif[idx].recEnd);
-		nVif[idx].vifBlocks->clear();
-		nVif[idx].recPtr = nVif[idx].vifCache->getBlock();
-		nVif[idx].recEnd = &nVif[idx].recPtr[nVif[idx].vifCache->getAllocSize()-(_1mb/4)]; // .25mb Safe Zone
+	if (nVif[idx].recWritePtr > (nVif[idx].recReserve->GetPtrEnd() - _256kb)) {
+		DevCon.WriteLn("nVif Recompiler Cache Reset! [0x%08x > 0x%08x]", nVif[idx].recWritePtr, nVif[idx].recReserve->GetPtrEnd());
+		nVif[idx].recReserve->Reset();
+		nVif[idx].recWritePtr = nVif[idx].recReserve->GetPtr();
 	}
 }
 
@@ -277,11 +279,11 @@
 
 	if (dVifExecuteUnpack<idx>(data, isFill)) return;
 
-	xSetPtr(v.recPtr);
+	xSetPtr(v.recWritePtr);
 	_vBlock.startPtr = (uptr)xGetAlignedCallTarget();
 	v.vifBlocks->add(_vBlock);
 	VifUnpackSSE_Dynarec( v, _vBlock ).CompileRoutine();
-	nVif[idx].recPtr = xGetPtr();
+	nVif[idx].recWritePtr = xGetPtr();
 
 	// [TODO] : Ideally we should test recompile buffer limits prior to each instruction,
 	//   which would be safer and more memory efficient than using an 0.25 meg recEnd marker.

 

  ViewVC Help
Powered by ViewVC 1.1.22