// // Lock the viewport window and set the approprite Screen and RealScreen fields // of Viewport. Returns 1 if locked successfully, 0 if failed. Note that a // lock failing is not a critical error; it's a sign that a DirectDraw mode // has ended or the user has closed a viewport window. // UBOOL UXViewport::Lock( FPlane FlashScale, FPlane FlashFog, FPlane ScreenClear, DWORD RenderLockFlags, BYTE* HitData, INT* HitSize ) { guard(UXViewport::LockWindow); UXClient* Client = GetOuterUXClient(); clock(Client->DrawCycles); // Success here, so pass to superclass. unclock(Client->DrawCycles); return UViewport::Lock(FlashScale,FlashFog,ScreenClear,RenderLockFlags,HitData,HitSize); unguard; }
void CalculateCPUSpeed () { LARGE_INTEGER freq; QueryPerformanceFrequency (&freq); if (freq.QuadPart != 0 && CPU.bRDTSC) { LARGE_INTEGER count1, count2; DWORD minDiff; cycle_t ClockCalibration = 0; // Count cycles for at least 55 milliseconds. // The performance counter is very low resolution compared to CPU // speeds today, so the longer we count, the more accurate our estimate. // On the other hand, we don't want to count too long, because we don't // want the user to notice us spend time here, since most users will // probably never use the performance statistics. minDiff = freq.LowPart * 11 / 200; // Minimize the chance of task switching during the testing by going very // high priority. This is another reason to avoid timing for too long. SetPriorityClass (GetCurrentProcess (), REALTIME_PRIORITY_CLASS); SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL); clock (ClockCalibration); QueryPerformanceCounter (&count1); do { QueryPerformanceCounter (&count2); } while ((DWORD)((unsigned __int64)count2.QuadPart - (unsigned __int64)count1.QuadPart) < minDiff); unclock (ClockCalibration); QueryPerformanceCounter (&count2); SetPriorityClass (GetCurrentProcess (), NORMAL_PRIORITY_CLASS); SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_NORMAL); CyclesPerSecond = (double)ClockCalibration * (double)freq.QuadPart / (double)((__int64)count2.QuadPart - (__int64)count1.QuadPart); SecondsPerCycle = 1.0 / CyclesPerSecond; } else { Printf ("Can't determine CPU speed, so pretending.\n"); } Printf ("CPU Speed: %f MHz\n", CyclesPerSecond / 1e6); }
void DObject::EndFrame () { clock (StaleCycles); if (ToDestroy.Size ()) { StaleCount += (int)ToDestroy.Size (); DestroyScan (); //Printf ("Destroyed %d objects\n", ToDestroy.Size()); DObject *obj; while (ToDestroy.Pop (obj)) { if (obj) { obj->ObjectFlags |= OF_Cleanup; delete obj; } } } unclock (StaleCycles); }