DirectX FPS

Started by
13 comments, last by yahastu 16 years, 6 months ago
I measured that I am getting 50-55 FPS in my game. I am measuring the FPS by looking over the last 200 frames, computing it using clock() and time(), both give the same answer. I thought this was a bit low because I'm not doing too much...rendering some text, a few thousand points, mesh, fog, thats basically it. Well, I did some profiling...and it turns out that I get the exact same FPS when I remove EVERYTHING from my render loop leaving just: dxDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(154,168,214), 1.0f, 0); dxDevice->BeginScene(); //nothing dxDevice->EndScene(); dxDevice->Present(NULL, NULL, NULL, NULL); Literally, theres nothing else in the timing loop. Yes, I am running in Release mode, and every single speed optimization that Visual studio can do is turned on. If I comment out dxDevice->Present, then it jumps up to like 600 FPS, and then if I turn off the others it goes up to practically infinity (as expected). What I dont understand is...why is this the bottleneck? And rendering a large mesh with 1024 tex + text overlays + dynamic generation of point sprites...none of these things even make a noticeable increase in the FPS. So it seems that 50 is the BEST possible fps I can achieve under any circumstances then....yet I have seen higher FPS reported to me in games and demos that other people have compiled! Im using: Geforce 6600GT 128MB 3 GB ram Athlon 3800+ 2.01 GHz dual core proc
Advertisement
You probably have v-sync enabled (meaning that your frame rate is limited to your monitor's refresh rate) - you'll want to check what your presentation interval is set at under your D3D device settings. To force v-sync off you'll want to set the presentation interval to 'immediate' - search your DX SDK docs for presentation interval and everything should be there :)
Yes!!! Thank you!
Hey, have you got your presentation parameters set to vsync by any chance?

i.e. (in MDX for example)

D3DPresentParameters.PresentationInterval = PresentInterval.Default; //this will vsync it to your monitor refresh rate (around 60Hz).

D3DPresentParameters.PresentationInterval = PresentInterval.Immediate; //this will throw frames out as fast as it can (eg much > 60Hz).

[edit]: snap boersch :) i was way to slow on that one
Just to add to this - the presentation interval parameters tend to be more of a hint than a requirement. Look in your hardware's control panel applet and you'll probably find a "always off"/"application preference"/"always on" switch.

The point being that it's best not to rely on V-SYNC being enabled or disabled.

hth
Jack

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

Not alot of point in turning it off really though. Sure it helps to give a rough indication of the preformance without any real profiling but apart from that what does it matter if you're window refreshes 50 times a second or 200 if you're monitor is onlt refreshing at 50 anyway? Hopefully you're not relying on any peticular frame rate for timing otherwise its not going to run the same on your system as on another one.
APE
Naku,

When I set PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; as suggested, my framerate jumps up to around 215. I suppose there is no way to know for sure if the screen is really refreshing that fast...but there is a very noticeable improvement. My monitor refreshes at 75 Hz anyway, not 50 Hz!

JollyJeffers,

Interesting...I have the nVIDIA display desktop manager thing in my system tray, but I was unable to find the setting you are talking about.
Naku,

When I set PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; as suggested, my framerate jumps up to around 215. I suppose there is no way to know for sure if the screen is really refreshing that fast...but there is a very noticeable improvement. My monitor refreshes at 75 Hz anyway, not 50 Hz!

JollyJeffers,

Interesting...I have the nVIDIA display desktop manager thing in my system tray, but I was unable to find the setting you are talking about.
Naku,

When I set PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; as suggested, my framerate jumps up to around 215. I suppose there is no way to know for sure if the screen is really refreshing that fast...but there is a very noticeable improvement. My monitor refreshes at 75 Hz anyway, not 50 Hz!

JollyJeffers,

Interesting...I have the nVIDIA display desktop manager thing in my system tray, but I was unable to find the setting you are talking about.
I was calculating my fps similar to that until I thought of a much better way:

(not exact code off the top of my head)
static int fps = 0;
SetTimer(0, 1000);

gameloop()
{
fps++;
if (WM_TIMER == msg.message)
{
DisplayFPS();
fps = 0;
}

}

This topic is closed to new replies.

Advertisement