what are all ways QueryPerformanceTimer can go wrong?

Started by
11 comments, last by Kest 17 years, 6 months ago
Quote:Original post by crowley9
According to AMD and MS, these timing issues are only supposed to affect RDTSC calls that are made directly. AMD and MS recommed using QPC, however, some people are still seeing issues. These can apparently be resolved with a processor driver update.

See more info here:
http://developer.amd.com/assets/TSC_Dual-Core_Utility.pdf
Unfortunately, end users are unlikely to have the driver installed, and when they see your game twitching like crazy, they'll blame it on you... That's the exact reason I refuse to install it - I want to see what happens to my code when it's run on a PC without the driver.
Advertisement
... Damn, this sounds like just the sort of thing where Boost would give you a hand up, but it looks like boost::timer always wraps std::clock() which is not terribly good :(
You can completely customize timeGetTime() timers as well. Here's one with a callback for a 1 millisecond delay and the highest resolution possible (normally 1 millisecond):
// Some variables to put somewhere:MMRESULT timer_id = 0;TIMECAPS timer_caps;unsigned int volatile GlobalInternalTimerValue = 0;// Timer init:if( timeGetDevCaps(&timer_caps,sizeof(TIMECAPS)) != TIMERR_NOERROR)  return Error("Unable to retrieve timing capabilities");if( timeBeginPeriod(timer_caps.wPeriodMin) != TIMERR_NOERROR )  return Error("Unable to set timer resolution" );timer_id = timeSetEvent(1,timer_caps.wPeriodMin,timer_func,0,TIME_PERIODIC);if( timer_id == 0 )  return Error("Unable to create timer");// Timer callback:void CALLBACK timer_func(unsigned int,unsigned int,DWORD,DWORD,DWORD){  GlobalInternalTimerValue++;}// Timer release:unsigned int hr = timeEndPeriod( timer_caps.wPeriodMin );// make sure hr == TIMERR_NOERRORhr = timeKillEvent( timer_id );// make sure hr == TIMERR_NOERROR

Like timeGetTime(), you need to use mmsystem.

I've been using this same timer since way back (nine years I think) when I did my first game programming on a 32MB 233mhz laptop. It worked flawlessly then, and it still does so.

This topic is closed to new replies.

Advertisement