/[pcsx2_0.9.7]/trunk/pcsx2/VUmicro.h
ViewVC logotype

Diff of /trunk/pcsx2/VUmicro.h

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

--- trunk/pcsx2/VUmicro.h	2010/12/23 11:48:33	279
+++ trunk/pcsx2/VUmicro.h	2010/12/23 12:02:12	280
@@ -19,15 +19,15 @@
 #include "VUops.h"
 #include "R5900.h"
 
-static const uint VU0_MEMSIZE = 0x1000;
-static const uint VU0_PROGSIZE = 0x1000;
-static const uint VU1_MEMSIZE = 0x4000;
-static const uint VU1_PROGSIZE = 0x4000;
-
-static const uint VU0_MEMMASK = VU0_MEMSIZE-1;
-static const uint VU0_PROGMASK = VU0_PROGSIZE-1;
-static const uint VU1_MEMMASK = VU1_MEMSIZE-1;
-static const uint VU1_PROGMASK = VU1_PROGSIZE-1;
+static const uint VU0_MEMSIZE	= 0x1000;		// 4kb
+static const uint VU0_PROGSIZE	= 0x1000;		// 4kb
+static const uint VU1_MEMSIZE	= 0x4000;		// 16kb
+static const uint VU1_PROGSIZE	= 0x4000;		// 16kb
+
+static const uint VU0_MEMMASK	= VU0_MEMSIZE-1;
+static const uint VU0_PROGMASK	= VU0_PROGSIZE-1;
+static const uint VU1_MEMMASK	= VU1_MEMSIZE-1;
+static const uint VU1_PROGMASK	= VU1_PROGSIZE-1;
 
 #define vuRunCycles  (512*12)  // Cycles to run ExecuteBlockJIT() for (called from within recs)
 #define vu0RunCycles (512*12)  // Cycles to run vu0 for whenever ExecuteBlock() is called
@@ -47,9 +47,9 @@
 class BaseCpuProvider
 {
 protected:
-	// allocation counter for multiple init/shutdown calls
-	// (most or all implementations will need this!)
-	int		m_AllocCount;
+	// allocation counter for multiple calls to Reserve.  Most implementations should utilize
+	// this variable for sake of robustness.
+	u32		m_Reserved;
 
 public:
 	// this boolean indicates to some generic logging facilities if the VU's registers
@@ -60,19 +60,27 @@
 public:
 	BaseCpuProvider()
 	{
-		m_AllocCount   = 0;
+		m_Reserved = 0;
 	}
 
 	virtual ~BaseCpuProvider() throw()
 	{
-		if( m_AllocCount != 0 )
-			Console.Warning( "Cleanup miscount detected on CPU provider.  Count=%d", m_AllocCount );
+		if( m_Reserved != 0 )
+			Console.Warning( "Cleanup miscount detected on CPU provider.  Count=%d", m_Reserved );
 	}
 
 	virtual const char* GetShortName() const=0;
 	virtual wxString GetLongName() const=0;
 
-	virtual void Allocate()=0;
+	// returns the number of bytes committed to the working caches for this CPU
+	// provider (typically this refers to recompiled code caches, but could also refer
+	// to other optional growable allocations).
+	virtual size_t GetCommittedCache() const
+	{
+		return 0;
+	}
+
+	virtual void Reserve()=0;
 	virtual void Shutdown()=0;
 	virtual void Reset()=0;
 	virtual void Execute(u32 cycles)=0;
@@ -88,6 +96,15 @@
 	{
 		cpu->Execute(1024);
 	}
+
+	// Gets the current cache reserve allocated to this CPU (value returned in megabytes)
+	virtual uint GetCacheReserve() const=0;
+	
+	// Specifies the maximum cache reserve amount for this CPU (value in megabytes).
+	// CPU providers are allowed to reset their reserves (recompiler resets, etc) if such is
+	// needed to conform to the new amount requested.
+	virtual void SetCacheReserve( uint reserveInMegs ) const=0;
+
 };
 
 // --------------------------------------------------------------------------------------
@@ -149,13 +166,16 @@
 	const char* GetShortName() const	{ return "intVU0"; }
 	wxString GetLongName() const		{ return L"VU0 Interpreter"; }
 
-	void Allocate() { }
+	void Reserve() { }
 	void Shutdown() throw() { }
 	void Reset() { }
 
 	void Step();
 	void Execute(u32 cycles);
 	void Clear(u32 addr, u32 size) {}
+
+	uint GetCacheReserve() const { return 0; }
+	void SetCacheReserve( uint reserveInMegs ) const {}
 };
 
 class InterpVU1 : public BaseVUmicroCPU
@@ -167,13 +187,16 @@
 	const char* GetShortName() const	{ return "intVU1"; }
 	wxString GetLongName() const		{ return L"VU1 Interpreter"; }
 
-	void Allocate() { }
+	void Reserve() { }
 	void Shutdown() throw() { }
 	void Reset() { }
 
 	void Step();
 	void Execute(u32 cycles);
 	void Clear(u32 addr, u32 size) {}
+
+	uint GetCacheReserve() const { return 0; }
+	void SetCacheReserve( uint reserveInMegs ) const {}
 };
 
 // --------------------------------------------------------------------------------------
@@ -188,13 +211,16 @@
 	const char* GetShortName() const	{ return "mVU0"; }
 	wxString GetLongName() const		{ return L"microVU0 Recompiler"; }
 
-	void Allocate();
+	void Reserve();
 	void Shutdown() throw();
 
 	void Reset();
 	void Execute(u32 cycles);
 	void Clear(u32 addr, u32 size);
 	void Vsync() throw();
+
+	uint GetCacheReserve() const;
+	void SetCacheReserve( uint reserveInMegs ) const;
 };
 
 class recMicroVU1 : public BaseVUmicroCPU
@@ -206,12 +232,15 @@
 	const char* GetShortName() const	{ return "mVU1"; }
 	wxString GetLongName() const		{ return L"microVU1 Recompiler"; }
 
-	void Allocate();
+	void Reserve();
 	void Shutdown() throw();
 	void Reset();
 	void Execute(u32 cycles);
 	void Clear(u32 addr, u32 size);
 	void Vsync() throw();
+
+	uint GetCacheReserve() const;
+	void SetCacheReserve( uint reserveInMegs ) const;
 };
 
 // --------------------------------------------------------------------------------------
@@ -226,11 +255,14 @@
 	const char* GetShortName() const	{ return "sVU0"; }
 	wxString GetLongName() const		{ return L"SuperVU0 Recompiler"; }
 
-	void Allocate();
+	void Reserve();
 	void Shutdown() throw();
 	void Reset();
 	void Execute(u32 cycles);
 	void Clear(u32 Addr, u32 Size);
+
+	uint GetCacheReserve() const;
+	void SetCacheReserve( uint reserveInMegs ) const;
 };
 
 class recSuperVU1 : public BaseVUmicroCPU
@@ -241,21 +273,20 @@
 	const char* GetShortName() const	{ return "sVU1"; }
 	wxString GetLongName() const		{ return L"SuperVU1 Recompiler"; }
 
-	void Allocate();
+	void Reserve();
 	void Shutdown() throw();
 	void Reset();
 	void Execute(u32 cycles);
 	void Clear(u32 Addr, u32 Size);
+
+	uint GetCacheReserve() const;
+	void SetCacheReserve( uint reserveInMegs ) const;
 };
 
 extern BaseVUmicroCPU* CpuVU0;
 extern BaseVUmicroCPU* CpuVU1;
 
 
-extern void vuMicroMemAlloc();
-extern void vuMicroMemShutdown();
-extern void vuMicroMemReset();
-
 // VU0
 extern void vu0ResetRegs();
 extern void __fastcall vu0ExecMicro(u32 addr);

 

  ViewVC Help
Powered by ViewVC 1.1.22