Timer issue when develop in VC8

Started by
2 comments, last by jollyjeffers 17 years, 4 months ago
hi there i am a newbie to directx. now, i'm using directx to display stereoscopic images which require high accurate timer. say i need to display 60 fps, 30 fps for left eye and 30 fps for right eye. i am using mfc right now. i tried normal timer, multimedia timer and QueryPerformanceCounter() and QueryPerformanceFrequency(). Non of them can give me satified performance. (maybe due to the way i used them??) i found a demo which had very accuate timer which used DXUT. i just wonder is there any way out there i can use? thanks a lot!!!
Advertisement
I'm going to move this over to 'General Programming' as it seems the core issue is about timing rather than DirectX. Figure it'll be the better place to discuss a more general Windows issue [smile]

Quote:Original post by agouwin
i am using mfc right now. i tried normal timer, multimedia timer and QueryPerformanceCounter() and QueryPerformanceFrequency(). Non of them can give me satified performance. (maybe due to the way i used them??)
I've not used MFC much (can't say I ever liked it) but QPC() always worked fine for me - apart from the odd multicore glitch I've never had it's resolution be a problem. Some more information on how, where and when you use it might be beneficial.

Quote:Original post by agouwin
i found a demo which had very accuate timer which used DXUT. i just wonder is there any way out there i can use?
DXUT is effectively open-source so you can find out how its timer works. I had a quick look now and you can start from DXUT.cpp in %DXSDK_DIR%\Samples\C++\DXUT\Core\ and trace the various declarations around - it's a bit tedious but eventually you'll just find it uses QPC/QPF under the covers.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

thanks. i am looking at it. looks like i have to do some hacking.

one more question:
this is one part of my code:

QueryPerformanceCounter(&temp_reading);
//pass_time = (double)(quad1-quad2)*ratio;
QueryPerformanceCounter(&this_reading);
->breakpoint

then i set a break point afterwards. the reading is this_reading.QuadPart-last_reading.QuadPart = 48809883, divided by the frequency, then it's around 14ms, how could it be so long?

really confused. i am using p4 HT 3.4ghz cpu, is it anything with it??

zhaoyi

Quote:Original post by jollyjeffers
I'm going to move this over to 'General Programming' as it seems the core issue is about timing rather than DirectX. Figure it'll be the better place to discuss a more general Windows issue [smile]

Quote:Original post by agouwin
i am using mfc right now. i tried normal timer, multimedia timer and QueryPerformanceCounter() and QueryPerformanceFrequency(). Non of them can give me satified performance. (maybe due to the way i used them??)
I've not used MFC much (can't say I ever liked it) but QPC() always worked fine for me - apart from the odd multicore glitch I've never had it's resolution be a problem. Some more information on how, where and when you use it might be beneficial.

Quote:Original post by agouwin
i found a demo which had very accuate timer which used DXUT. i just wonder is there any way out there i can use?
DXUT is effectively open-source so you can find out how its timer works. I had a quick look now and you can start from DXUT.cpp in %DXSDK_DIR%\Samples\C++\DXUT\Core\ and trace the various declarations around - it's a bit tedious but eventually you'll just find it uses QPC/QPF under the covers.

hth
Jack
Quote:Original post by agouwin
one more question:
this is one part of my code:

QueryPerformanceCounter(&temp_reading);
//pass_time = (double)(quad1-quad2)*ratio;
QueryPerformanceCounter(&this_reading);
->breakpoint

then i set a break point afterwards. the reading is this_reading.QuadPart-last_reading.QuadPart = 48809883, divided by the frequency, then it's around 14ms, how could it be so long?
I forget the exact details (although I think they're left intentionally unspecified) but QPC returns just the CPU counter - it's not necessarily a unit of time in itself and might just be the current program counter or other per-cycle incremented counter. Because of this you have to use QPF to translate this arbitrary counter to a usable time value...

The CPU used shouldn't really matter - although there are reports of problems on AMD's multi-core CPU's (which was fixed with a patch iirc) and some problems with "speed step" type CPU's (common in laptops). Searching the internet (there was a really good thread on the DirectXDev mailing list a while back) should reveal more details.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement