Skip to main content
GameDev.net gamedev.net
🔒 Locked

Scene Rendering and FPS

Started by andyb716 Oct 8, 2004 at 1:49 PM 8 replies 1.2k views
Original Post
andyb716
andyb716
Hi, I have a question about FPS in the scene rendering. this is my frame function, when I take out the render method the FPS jump up to the millions. when I do the scene rendering it drops down to 30. Is that expected. I'm not even doing any rendering just clearing the target and zbuffer, begin scene, end scene and present. Any comments would be appreciated, thanks.

bool Frame(){

	startTime = timeGetTime();

	app.display.Render();

	FPS++;

	endTime = timeGetTime();

	Duration += endTime - startTime;

	if(Duration >= 1000){

		Duration = 0;

		char buf[256];

		sprintf(buf, "FPS=%d", FPS);

		app.window.SetTitle(buf);

		FPS = 0;

	}

	return true;
}

bool XDisplayManager::Render(){

	m_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
						m_BgColor, 1.0f, 0);

	m_pD3DDevice->BeginScene();

	m_pD3DDevice->EndScene();

	m_pD3DDevice->Present(NULL, NULL, NULL, NULL);

	return true;

}


Mushu
Mushu
Well, since the render stuff is takes the blunt of the time if you have v-sync enabled (means it has to wait for the monitor to refresh before drawing the backbuffer to the front buffer)!, which I'm guessing you do; taking it out allows everything do be done without the delay. Which makes it run really fast.
andyb716
andyb716
How do I know if I have v-sync enabled. Is it enabled by default, because I dont think I set it anywhere.
Mushu
Mushu
As I remember the defaults are driver-specific.

When you set up your device, in the D3DPRESENT_PARAMETERS, specify

D3DPRESENT_PARAMETERS.SwapEffect = D3DSWAPEFFECT_COPY;

That should work.
Namethatnobodyelsetook
Namethatnobodyelsetook
Set present params presentinterval to D3DPRESENTINTERVAL_ONE when creating or reseting your device for vsync.

For non-vsync use D3DPRESENTINTERVAL_IMMEDIATE. I also tend to use SWAPEFFECT_DISCARD.

I doubt that 30Hz is vsync though, if all you're doing is clearing... unless you set the present interval to two, or the rest of your app is taking too long to run.
andyb716
andyb716
I put a SUCCEEDED around the clear and begin scene and that doubled my FPS. And I tried D3DPRESENT_INTERVAL_IMMEDIATE and that doubled it again so now Im getting 170 FPS, thanks alot guys.
Axiverse
Axiverse
Hmm... 170 is still pretty slow for a blank present... Or is that just me?
Namethatnobodyelsetook
Namethatnobodyelsetook
For reference, on a GeForce 3 (plain, not Ti200 or Ti500), just clearing and presenting in 32 bit I tend to get ~1000 FPS... Not sure what the OP's card is.
Axiverse
Axiverse
I have a crappy old GeForce 2 and i can still get around 700 to 800...
andyb716
andyb716
Am I calculating FPS right? Yah it really does seem slow for doing nothing butting clearing. I have an nvidia gforce 2 mx 400

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.