mirror of https://github.com/PCSX2/pcsx2.git
Changed the Sleep() behavior as posted by Jake.Stine in Issue 29. Improves smoothness in games running fullspeed, and lets pcsx2 use the cpu time it needs :)
(Note: You'll see constantly 100% cpu usage now, but pcsx2 doesn't do any "more" work.) git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@237 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
parent
39f363262b
commit
d72cacbdd4
|
@ -175,7 +175,7 @@ void FrameLimiter()
|
|||
if ((diff>>3)>iTicks) iExpectedEnd=iEnd;
|
||||
}
|
||||
else do {
|
||||
Sleep(1);
|
||||
_TIMESLICE();
|
||||
iEnd = GetCPUTicks();
|
||||
} while (iEnd<iExpectedEnd);
|
||||
|
||||
|
|
|
@ -162,11 +162,7 @@ void WriteFIFO(u32 mem, u64 *value) {
|
|||
//commiting every 16 bytes
|
||||
while( FIFOto_write((void*)value, 1) == 0 ) {
|
||||
SysPrintf("IPU sleeping\n");
|
||||
#ifdef _WIN32
|
||||
Sleep(1);
|
||||
#else
|
||||
usleep(500);
|
||||
#endif
|
||||
_TIMESLICE();
|
||||
}
|
||||
} else {
|
||||
SysPrintf("WriteFIFO Unknown %x\n", mem);
|
||||
|
|
41
pcsx2/GS.cpp
41
pcsx2/GS.cpp
|
@ -230,11 +230,7 @@ void gsWaitGS()
|
|||
}
|
||||
else {
|
||||
while( g_pGSRingPos != g_pGSWritePos ) {
|
||||
#ifdef _WIN32
|
||||
Sleep(1);
|
||||
#else
|
||||
usleep(500);
|
||||
#endif
|
||||
_TIMESLICE();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -305,11 +301,7 @@ u8* GSRingBufCopy(void* mem, u32 size, u32 type)
|
|||
while( writepos < tempbuf || tempbuf == GS_RINGBUFFERBASE ) {
|
||||
if( !CHECK_DUALCORE ) {
|
||||
GS_SETEVENT();
|
||||
#ifdef _WIN32
|
||||
Sleep(1);
|
||||
#else
|
||||
usleep(500);
|
||||
#endif
|
||||
_TIMESLICE();
|
||||
}
|
||||
tempbuf = *(volatile PU8*)&g_pGSRingPos;
|
||||
|
||||
|
@ -329,11 +321,7 @@ u8* GSRingBufCopy(void* mem, u32 size, u32 type)
|
|||
while(tempbuf == GS_RINGBUFFERBASE && tempbuf != *(volatile PU8*)&g_pGSWritePos) {
|
||||
if( !CHECK_DUALCORE ) {
|
||||
GS_SETEVENT();
|
||||
#ifdef _WIN32
|
||||
Sleep(1);
|
||||
#else
|
||||
usleep(500);
|
||||
#endif
|
||||
_TIMESLICE();
|
||||
}
|
||||
|
||||
tempbuf = *(volatile PU8*)&g_pGSRingPos;
|
||||
|
@ -343,11 +331,7 @@ u8* GSRingBufCopy(void* mem, u32 size, u32 type)
|
|||
while( writepos < tempbuf && (writepos+size >= tempbuf || (writepos+size == GS_RINGBUFFEREND && tempbuf == GS_RINGBUFFERBASE)) ) {
|
||||
if( !CHECK_DUALCORE ) {
|
||||
GS_SETEVENT();
|
||||
#ifdef _WIN32
|
||||
Sleep(1);
|
||||
#else
|
||||
usleep(500);
|
||||
#endif
|
||||
_TIMESLICE();
|
||||
}
|
||||
tempbuf = *(volatile PU8*)&g_pGSRingPos;
|
||||
|
||||
|
@ -373,11 +357,7 @@ void GSRingBufSimplePacket(int type, int data0, int data1, int data2)
|
|||
do {
|
||||
if( !CHECK_DUALCORE ) {
|
||||
GS_SETEVENT();
|
||||
#ifdef _WIN32
|
||||
Sleep(1);
|
||||
#else
|
||||
usleep(500);
|
||||
#endif
|
||||
_TIMESLICE();
|
||||
}
|
||||
tempbuf = *(volatile PU8*)&g_pGSRingPos;
|
||||
|
||||
|
@ -397,11 +377,7 @@ void GSRingBufSimplePacket(int type, int data0, int data1, int data2)
|
|||
while(tempbuf == GS_RINGBUFFERBASE && tempbuf != *(volatile PU8*)&g_pGSWritePos) {
|
||||
if( !CHECK_DUALCORE ) {
|
||||
GS_SETEVENT();
|
||||
#ifdef _WIN32
|
||||
Sleep(1);
|
||||
#else
|
||||
usleep(500);
|
||||
#endif
|
||||
_TIMESLICE();
|
||||
}
|
||||
|
||||
tempbuf = *(volatile PU8*)&g_pGSRingPos;
|
||||
|
@ -1471,6 +1447,7 @@ int HasToExit()
|
|||
}
|
||||
|
||||
#if defined(_WIN32) && !defined(WIN32_PTHREADS)
|
||||
//#pragma optimize ("",off) //needed for a working PGO build
|
||||
DWORD WINAPI GSThreadProc(LPVOID lpParam)
|
||||
{
|
||||
HANDLE handles[2] = { g_hGsEvent, g_hVuGSExit };
|
||||
|
@ -1744,7 +1721,7 @@ ExitGS:
|
|||
GSclose();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//#pragma optimize ("",on) //needed for a working PGO build
|
||||
int gsFreeze(gzFile f, int Mode) {
|
||||
|
||||
gzfreeze(PS2MEM_GS, 0x2000);
|
||||
|
@ -1836,4 +1813,4 @@ void RunGSState(gzFile f)
|
|||
|
||||
#endif
|
||||
|
||||
#undef GIFchain
|
||||
#undef GIFchain
|
||||
|
|
10
pcsx2/Misc.h
10
pcsx2/Misc.h
|
@ -363,5 +363,15 @@ extern __forceinline long InterlockedExchangeAdd(long volatile* Addend, long Val
|
|||
//#define InterlockedExchangePointerAdd InterlockedExchangeAdd
|
||||
//#endif
|
||||
|
||||
// Timeslice releaser for those many idle loop spots through out PCSX2.
|
||||
static __forceinline void _TIMESLICE()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
Sleep(0);
|
||||
#else
|
||||
usleep(500);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* __MISC_H__ */
|
||||
|
||||
|
|
|
@ -140,7 +140,16 @@ void RunExecute(int run) {
|
|||
if( GSsetGameCRC != NULL )
|
||||
GSsetGameCRC(ElfCRC, g_ZeroGSOptions);
|
||||
|
||||
if (run) Cpu->Execute();
|
||||
if (run)
|
||||
{
|
||||
// This makes sure the Windows Kernel is using high resolution
|
||||
// timeslices for Sleep calls.
|
||||
// (may not make much difference on most desktops but
|
||||
// can improve performance a lot on laptops).
|
||||
timeBeginPeriod( 1 );
|
||||
Cpu->Execute();
|
||||
timeEndPeriod( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
int Slots[5] = { -1, -1, -1, -1, -1 };
|
||||
|
@ -419,7 +428,7 @@ BOOL SysLoggedSetLockPagesPrivilege ( HANDLE hProcess, BOOL bEnable);
|
|||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
|
||||
char *lang;
|
||||
int i;
|
||||
|
||||
|
||||
#ifdef PCSX2_VIRTUAL_MEM
|
||||
LPVOID lpMemReserved;
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue