# Framerate Question...

This topic is 4405 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have a function that waits for my timer to hit 1000 then displays the number of frames rendered.. my fps
void D3D::Draw_FPS()
{
if (_frame_info.fps_timer.get() >= 1000)
{
_frame_info.fps = _frame_info.fps_Counter;
std::cout	<< "FPS [" << _frame_info.fps-1
<< "]  DCalls p/f [" << _frame_info.draw_calls / _frame_info.fps
<< "]  DCalls p/s [" << _frame_info.draw_calls
<< "]  Verts p/f  [" << _frame_info.verts_drawn / _frame_info.fps
<< "]  Faces p/f  [" << _frame_info.faces_drawn / _frame_info.fps << "]" << std::endl; //

_frame_info.fps_timer.start();
_frame_info.fps_Counter = 1;

_frame_info.draw_calls = 1;
_frame_info.faces_drawn = 1;
_frame_info.verts_drawn = 1;
}else{
_frame_info.fps_Counter += 1;
//std::cout << _frame_info.fps_Counter << std::endl;
}
}


Sometimes the output is 34 about.. and sometimes i get around 60. All im rendering is a stinking teapot. What is weird is that if I uncomment the std::cout in that else statement i can see the frames getting counted up to 59. Is it possible to render to fast and choke Direct3D?? Is slowing down enogh to do the cout enough to let Direct3D catch up?? In my main render loop I sleep(0) and I have PresentationInterval set to D3DPRESENT_INTERVAL_DEFAULT. And if I set this to immediate I get about 800 fps. Anyone have any ideas?? Thanks.

##### Share on other sites
D3DPRESENT_INTERVAL_IMMEDIATE removes VSync wait so it is normal that it changes your fps.
1-try with D3DPRESENT_INTERVAL_ONE.
2-display an averadge FPS over 10 frames to have a suitable value.

##### Share on other sites
Try D3DPRESENT_INTERVAL_ONE instead of D3DPRESENT_INTERVAL_DEFAULT. D3DPRESENT_INTERVAL_ONE is suppose to be a bit more accurate:
Quote:
 MSDND3DPRESENT_INTERVAL_DEFAULT uses the default system timer resolution whereas the D3DPRESENT_INTERVAL_ONE calls timeBeginPeriod to enhance system timer resolution. This improves the quality of vertical sync, but consumes slightly more processing time. Both parameters attempt to synchronize vertically.
The reason I think that the accuracy might help is because in some cases, being inaccurate by just a wee bit too much can cause your framerate to get cut in half. The reason why is this: Normally, when using VSync, it will try to match 60 Hz (assuming that is what the monitor's refresh rate is set at). This takes 16.67 milliseconds per frame. Sometimes, however, execution between one frame and the next might take a bit longer, for example 18 or 19 milliseconds. When this happens, the vertical retrace period is missed, and so Direct3D needs to wait for the next one, which is ~15 milliseconds away. So the total frame time for that frame ends up being 33.33 milliseconds long or so. If this happens nearly every time, you'll wind up with roughly 30 frames per second instead of 60, all because you were a couple of milliseconds late every time. The reason you were late every time might be due to inaccuracies in Direct3D trying to estimate when to present. More accuracy might solve the problem.

##### Share on other sites
Using D3DPRESENT_INTERVAL_IMMEDIATE tells D3D to Present() as fast as possible, so this is the one I´d choose for measuring performance through FPS.
D3DPRESENT_INTERVAL_ONE or D3DPRESENT_INTERVAL_DEFAULT synchronises your presentation interval with the refresh rate of your screen, which in case of a 60 Hz refresh rate of your screen, caps your FPS to 60 and with the example Agony posted in mind, it might drop even lower. D3DPRESENT_INTERVAL_DEFAULT, as Agony said, should be less accurate than D3DPRESENT_INTERVAL_ONE.
So all in all I´d say if you want to measure the performance using FPS you should use D3DPRESENT_INTERVAL_IMMEDIATE.

##### Share on other sites
Nice... with DEFAULT I get around 36...
Changing it to INTERVAL_ONE... an even 60!!!! Nice!

Thanks.. Do I have to Caps check that for lower cards?
THe docs say its always available.

##### Share on other sites
There is a listing of available presentation intervals in the caps, but I think as long as you D3DPRESENT_INTERVAL_IMMEDIATE and/or D3DPRESENT_INTERVAL_ONE you should be fine with every graphics card you come across and should not have to check for that in the caps.

1. 1
2. 2
3. 3
4. 4
frob
14
5. 5

• 16
• 12
• 20
• 12
• 19
• ### Forum Statistics

• Total Topics
632168
• Total Posts
3004529

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!