(no functional changes) Many code cleanups of the MTGS, and removed the PCSX2_PUBLIC define. I was stupid when I created it and didn't realize the PCSX2_DEVBUILD define is basically the same thing.

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@365 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
Jake.Stine 2008-11-27 15:22:19 +00:00 committed by Gregory Hainaut
parent 97d72e2474
commit 98beccb2bc
5 changed files with 80 additions and 109 deletions

View File

@ -123,18 +123,14 @@ void* GSThreadProc(void* idp);
int g_FFXHack=0; int g_FFXHack=0;
static bool gsHasToExit=false; static bool gsHasToExit=false;
//static LONG g_pGSvSyncCount = 0;
#ifdef PCSX2_DEVBUILD #ifdef PCSX2_DEVBUILD
static LONG g_pGSvSyncCount = 0;
// GS Playback // GS Playback
int g_SaveGSStream = 0; // save GS stream; 1 - prepare, 2 - save int g_SaveGSStream = 0; // save GS stream; 1 - prepare, 2 - save
int g_nLeftGSFrames = 0; // when saving, number of frames left int g_nLeftGSFrames = 0; // when saving, number of frames left
gzFile g_fGSSave; gzFile g_fGSSave;
// MTGS recording
FILE* g_fMTGSWrite = NULL, *g_fMTGSRead = NULL;
u32 g_MTGSDebug = 0, g_MTGSId = 0;
#endif #endif
u32 CSRw; u32 CSRw;
@ -194,7 +190,7 @@ std::list<long> ringposStack;
CRITICAL_SECTION stackLock; CRITICAL_SECTION stackLock;
#endif #endif
#ifndef PCSX2_PUBLIC #ifdef _DEBUG
// debug variable used to check for bad code bits where copies are started // debug variable used to check for bad code bits where copies are started
// but never closed, or closed without having been started. (GSRingBufCopy calls // but never closed, or closed without having been started. (GSRingBufCopy calls
// should always be followed by acall to GSRINGBUF_DONECOPY) // should always be followed by acall to GSRINGBUF_DONECOPY)
@ -219,17 +215,10 @@ void gsInit()
memcpy(g_MTGSMem, PS2MEM_GS, sizeof(g_MTGSMem)); memcpy(g_MTGSMem, PS2MEM_GS, sizeof(g_MTGSMem));
g_pGSWritePos = GS_RINGBUFFERBASE; g_pGSWritePos = GS_RINGBUFFERBASE;
//InterlockedExchangePointer((volatile PVOID*)&g_pGSWritePos, GS_RINGBUFFERBASE);
if( GSsetBaseMem != NULL ) if( GSsetBaseMem != NULL )
GSsetBaseMem(g_MTGSMem); GSsetBaseMem(g_MTGSMem);
//#if defined(_DEBUG) && defined(PCSX2_DEVBUILD)
// assert( g_fMTGSWrite == NULL && g_fMTGSRead == NULL );
// g_fMTGSWrite = fopen("mtgswrite.txt", "w");
// g_fMTGSRead = fopen("mtgsread.txt", "w");
//#endif
gsHasToExit=false; gsHasToExit=false;
#if defined(_WIN32) && !defined(WIN32_PTHREADS) #if defined(_WIN32) && !defined(WIN32_PTHREADS)
@ -299,11 +288,8 @@ void GSRINGBUF_DONECOPY(const u8 *mem, u32 size)
{ {
const u8* temp = mem + size; const u8* temp = mem + size;
#ifndef PCSX2_PUBLIC
// make sure a previous copy block has been started somewhere. // make sure a previous copy block has been started somewhere.
assert( g_mtgsCopyLock == 1 ); assert( (--g_mtgsCopyLock) == 0 );
g_mtgsCopyLock = 0;
#endif
assert( temp <= GS_RINGBUFFEREND); assert( temp <= GS_RINGBUFFEREND);
if( temp == GS_RINGBUFFEREND ) if( temp == GS_RINGBUFFEREND )
@ -370,16 +356,6 @@ void gsShutdown()
SysMunmap((uptr)GS_RINGBUFFERBASE, GS_RINGBUFFERSIZE); SysMunmap((uptr)GS_RINGBUFFERBASE, GS_RINGBUFFERSIZE);
#endif #endif
//#if defined(_DEBUG) && defined(PCSX2_DEVBUILD)
// if( g_fMTGSWrite != NULL ) {
// fclose(g_fMTGSWrite);
// g_fMTGSWrite = NULL;
// }
// if( g_fMTGSRead != NULL ) {
// fclose(g_fMTGSRead);
// g_fMTGSRead = NULL;
// }
//#endif
} }
else else
GSclose(); GSclose();
@ -395,11 +371,8 @@ u8* GSRingBufCopy(void* mem, u32 size, u32 type)
u8* writepos = g_pGSWritePos; u8* writepos = g_pGSWritePos;
#ifndef PCSX2_PUBLIC
// Checks if a previous copy is still active, and asserts if so. // Checks if a previous copy is still active, and asserts if so.
assert( g_mtgsCopyLock == 0 ); assert( (++g_mtgsCopyLock) == 1 );
g_mtgsCopyLock = 1;
#endif
assert( size < GS_RINGBUFFERSIZE ); assert( size < GS_RINGBUFFERSIZE );
assert( writepos < GS_RINGBUFFEREND ); assert( writepos < GS_RINGBUFFEREND );
@ -548,15 +521,17 @@ void gsReset()
#endif #endif
gsHasToExit=false; gsHasToExit=false;
g_pGSRingPos = g_pGSWritePos; g_pGSRingPos = g_pGSWritePos;
//g_pGSvSyncCount = 0;
#ifdef _DEBUG
g_mtgsCopyLock = 0;
#endif
#ifdef PCSX2_DEVBUILD
g_pGSvSyncCount = 0;
#endif
} }
memset(g_path, 0, sizeof(g_path)); memset(g_path, 0, sizeof(g_path));
memset(s_byRegs, 0, sizeof(s_byRegs)); memset(s_byRegs, 0, sizeof(s_byRegs));
#ifndef PCSX2_PUBLIC
g_mtgsCopyLock = 0;
#endif
#ifndef PCSX2_VIRTUAL_MEM #ifndef PCSX2_VIRTUAL_MEM
memset(g_RealGSMem, 0, 0x2000); memset(g_RealGSMem, 0, 0x2000);
@ -1476,7 +1451,7 @@ void gifMFIFOInterrupt()
mfifoGIFtransfer(0); mfifoGIFtransfer(0);
return; return;
} }
#ifndef PCSX2_PUBLIC #ifdef PCSX2_DEVBUILD
if(gifdone == 0 || gif->qwc > 0) { if(gifdone == 0 || gif->qwc > 0) {
SysPrintf("gifMFIFO Panic > Shouldnt go here!\n"); SysPrintf("gifMFIFO Panic > Shouldnt go here!\n");
cpuRegs.interrupt &= ~(1 << 11); cpuRegs.interrupt &= ~(1 << 11);
@ -1507,11 +1482,10 @@ extern "C" void GSPostVsyncEnd()
if( CHECK_MULTIGS ) if( CHECK_MULTIGS )
{ {
//while( *(volatile LONG*)&g_pGSvSyncCount >= 8 ) #ifdef PCSX2_DEVBUILD
// gsSetEventWait(); InterlockedIncrement( (volatile LONG*)&g_pGSvSyncCount );
SysPrintf( " Sending VSync : %d \n", *(volatile LONG*)&g_pGSvSyncCount );
//InterlockedIncrement( (volatile LONG*)&g_pGSvSyncCount ); #endif
//SysPrintf( " Sending VSync : %d \n", *(volatile LONG*)&g_pGSvSyncCount );
GSRingBufSimplePacket(GS_RINGTYPE_VSYNC, (*(u32*)(PS2MEM_GS+0x1000)&0x2000), 0, 0); GSRingBufSimplePacket(GS_RINGTYPE_VSYNC, (*(u32*)(PS2MEM_GS+0x1000)&0x2000), 0, 0);
if( !CHECK_DUALCORE ) GS_SETEVENT(); if( !CHECK_DUALCORE ) GS_SETEVENT();
} }
@ -1577,25 +1551,6 @@ void* GSThreadProc(void* lpParam)
{ {
break; //exit thread and close gs break; //exit thread and close gs
} }
else
{
/*if( !g_gsFlushing ) && (*(volatile int*)&g_pGSvSyncCount) == 0 )
{
// not enough frames queued up. But if the buffer's filling we should start
// purging the ring buffer anyway:
const long writepos = (long)(*(volatile PU8*)&g_pGSWritePos);
long delta = writepos - (long)g_pGSRingPos;
if( delta < 0 )
{
delta = (writepos - (long)GS_RINGBUFFERBASE) + ((long)(GS_RINGBUFFEREND - g_pGSRingPos));
}
if( delta < (long)(GS_RINGBUFFERSIZE / 2) ) continue;
}*/
//SysPrintf( "Accumulated : %d\n", *(volatile int*)&g_pGSvSyncCount );
}
} }
#else #else
if( !CHECK_DUALCORE ) { if( !CHECK_DUALCORE ) {
@ -1650,19 +1605,16 @@ void* GSThreadProc(void* lpParam)
case GS_RINGTYPE_P1: case GS_RINGTYPE_P1:
{ {
int qsize = (tag>>16); int qsize = (tag>>16);
// MTGS_RECREAD(g_pGSRingPos+16, (qsize<<4));
// make sure that tag>>16 is the MAX size readable // make sure that tag>>16 is the MAX size readable
GSgifTransfer1((u32*)(g_pGSRingPos+16) - 0x1000 + 4*qsize, 0x4000-qsize*16); GSgifTransfer1((u32*)(g_pGSRingPos+16) - 0x1000 + 4*qsize, 0x4000-qsize*16);
ringposinc += qsize<<4; ringposinc += qsize<<4;
break; break;
} }
case GS_RINGTYPE_P2: case GS_RINGTYPE_P2:
// MTGS_RECREAD(g_pGSRingPos+16, ((tag>>16)<<4));
GSgifTransfer2((u32*)(g_pGSRingPos+16), tag>>16); GSgifTransfer2((u32*)(g_pGSRingPos+16), tag>>16);
ringposinc += (tag>>16)<<4; ringposinc += (tag>>16)<<4;
break; break;
case GS_RINGTYPE_P3: case GS_RINGTYPE_P3:
// MTGS_RECREAD(g_pGSRingPos+16, ((tag>>16)<<4));
GSgifTransfer3((u32*)(g_pGSRingPos+16), tag>>16); GSgifTransfer3((u32*)(g_pGSRingPos+16), tag>>16);
ringposinc += (tag>>16)<<4; ringposinc += (tag>>16)<<4;
break; break;
@ -1671,11 +1623,12 @@ void* GSThreadProc(void* lpParam)
if( PAD1update != NULL ) PAD1update(0); if( PAD1update != NULL ) PAD1update(0);
if( PAD2update != NULL ) PAD2update(1); if( PAD2update != NULL ) PAD2update(1);
//SysPrintf( " Receiving VSync : %d \n", *(volatile LONG*)&g_pGSvSyncCount ); # ifdef PCSX2_DEVBUILD
//InterlockedDecrement( (volatile LONG*)&g_pGSvSyncCount ); //SysPrintf( " Processing VSync : %d \n", *(volatile LONG*)&g_pGSvSyncCount );
InterlockedDecrement( (volatile LONG*)&g_pGSvSyncCount );
// vSyncCount should never dip below zero. // vSyncCount should never dip below zero.
//assert( *(volatile LONG*)&g_pGSvSyncCount >= 0 ); assert( *(volatile LONG*)&g_pGSvSyncCount >= 0 );
# endif
break; break;
case GS_RINGTYPE_FRAMESKIP: case GS_RINGTYPE_FRAMESKIP:
@ -1817,14 +1770,14 @@ void* GSThreadProc(void* lpParam)
#endif #endif
} }
// some debug/troubleshooting code:
// buffer is empty so our vsync must be zero. // buffer is empty so our vsync must be zero.
#ifdef PCSX2_DEVBUILD
//SysPrintf( "Discharged : %d\n", *(volatile int*)&g_pGSvSyncCount ); //SysPrintf( "Discharged : %d\n", *(volatile int*)&g_pGSvSyncCount );
//if( *(volatile LONG*)&g_pGSvSyncCount != 0 ) if( *(volatile LONG*)&g_pGSvSyncCount != 0 )
// SysPrintf( "MTGS > vSync count mismatch: %d\n", g_pGSvSyncCount ); SysPrintf( "MTGS > vSync count mismatch: %d\n", g_pGSvSyncCount );
InterlockedExchange( (volatile LONG*)&g_pGSvSyncCount, 0 );
//InterlockedExchange( (volatile LONG*)&g_pGSvSyncCount, 0 ); #endif
// process vu1
} }
GSclose(); GSclose();

View File

@ -66,36 +66,6 @@ extern u8 g_RealGSMem[0x2000];
u8* GSRingBufCopy(void* mem, u32 size, u32 type); u8* GSRingBufCopy(void* mem, u32 size, u32 type);
void GSRingBufSimplePacket(int type, int data0, int data1, int data2); void GSRingBufSimplePacket(int type, int data0, int data1, int data2);
//#ifdef PCSX2_DEVBUILD
// use for debugging MTGS
//extern FILE* g_fMTGSWrite, *g_fMTGSRead;
//extern u32 g_MTGSDebug, g_MTGSId;
//static __forceinline void MTGS_RECWRITE(const u8 *start, u32 size) {
// if( g_MTGSDebug & 1 ) {
// const u32* pstart = (u32*)(start);
// u32 cursize = (size);
// fprintf(g_fMTGSWrite, "*%x-%x (%d)\n", (u32)(uptr)(start), (u32)(size), ++g_MTGSId);
// if( g_MTGSDebug & 2 ) fflush(g_fMTGSWrite);
// }
//}
//static __forceinline void MTGS_RECREAD( const u8* start, u32 size) {
// if( g_MTGSDebug & 1 ) {
// const u32* pstart = (u32*)(start);
// u32 cursize = (size);
// fprintf(g_fMTGSRead, "*%x-%x (%d)\n", (u32)(uptr)(start), (u32)(size), ++g_MTGSId);
// if( g_MTGSDebug & 4 ) fflush(g_fMTGSRead);
// }
//}
//#else
//#define MTGS_RECWRITE 0&&
//#define MTGS_RECREAD 0&&
//#endif
#if defined(_WIN32) && !defined(WIN32_PTHREADS) #if defined(_WIN32) && !defined(WIN32_PTHREADS)
#define GS_SETEVENT() SetEvent(g_hGsEvent) #define GS_SETEVENT() SetEvent(g_hGsEvent)

View File

@ -509,7 +509,7 @@ static __forceinline void _cpuBranchTest_Shared()
} }
#ifndef PCSX2_NORECBUILD #ifndef PCSX2_NORECBUILD
#ifndef PCSX2_PUBLIC #ifdef PCSX2_DEVBUILD
extern u8 g_globalXMMSaved; extern u8 g_globalXMMSaved;
X86_32CODE(extern u8 g_globalMMXSaved;) X86_32CODE(extern u8 g_globalMMXSaved;)
#endif #endif
@ -520,7 +520,7 @@ u32 g_MTGSVifStart = 0, g_MTGSVifCount=0;
void cpuBranchTest() void cpuBranchTest()
{ {
#ifndef PCSX2_NORECBUILD #ifndef PCSX2_NORECBUILD
#ifndef PCSX2_PUBLIC #ifdef PCSX2_DEVBUILD
// dont' remove this check unless doing an official release // dont' remove this check unless doing an official release
if( g_globalXMMSaved X86_32CODE(|| g_globalMMXSaved) ) if( g_globalXMMSaved X86_32CODE(|| g_globalMMXSaved) )
SysPrintf("frozen regs have not been restored!!!\n"); SysPrintf("frozen regs have not been restored!!!\n");
@ -552,7 +552,7 @@ void cpuBranchTest()
} }
#ifndef PCSX2_NORECBUILD #ifndef PCSX2_NORECBUILD
#ifndef PCSX2_PUBLIC #ifdef PCSX2_DEVBUILD
assert( !g_globalXMMSaved X86_32CODE(&& !g_globalMMXSaved) ); assert( !g_globalXMMSaved X86_32CODE(&& !g_globalMMXSaved) );
#endif #endif
g_EEFreezeRegs = 1; g_EEFreezeRegs = 1;

View File

@ -2213,7 +2213,7 @@ __forceinline void vif1Interrupt() {
return; return;
} }
#ifndef PCSX2_PUBLIC #ifdef PCSX2_DEVBUILD
if(vif1ch->qwc > 0) SysPrintf("VIF1 Ending with QWC left\n"); if(vif1ch->qwc > 0) SysPrintf("VIF1 Ending with QWC left\n");
if(vif1.cmd != 0) SysPrintf("vif1.cmd still set %x\n", vif1.cmd); if(vif1.cmd != 0) SysPrintf("vif1.cmd still set %x\n", vif1.cmd);
#endif #endif

View File

@ -359,7 +359,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
EnableFiberSafeOptimizations="true" EnableFiberSafeOptimizations="true"
PreprocessorDefinitions="PCSX2_PUBLIC" PreprocessorDefinitions="NDEBUG"
EnableEnhancedInstructionSet="0" EnableEnhancedInstructionSet="0"
/> />
<Tool <Tool
@ -609,6 +609,14 @@
<File <File
RelativePath="..\..\GS.cpp" RelativePath="..\..\GS.cpp"
> >
<FileConfiguration
Name="Release (to Public)|Win32"
>
<Tool
Name="VCCLCompilerTool"
AssemblerOutput="4"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\..\GS.h" RelativePath="..\..\GS.h"
@ -1126,6 +1134,46 @@
<File <File
RelativePath="..\..\x86\iFPU.c" RelativePath="..\..\x86\iFPU.c"
> >
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AssemblerOutput="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AssemblerOutput="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug TLB|Win32"
>
<Tool
Name="VCCLCompilerTool"
AssemblerOutput="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release TLB|Win32"
>
<Tool
Name="VCCLCompilerTool"
AssemblerOutput="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release (to Public)|Win32"
>
<Tool
Name="VCCLCompilerTool"
AssemblerOutput="0"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\..\x86\iFPU.h" RelativePath="..\..\x86\iFPU.h"