Scene Rendering and FPS

Started by
8 comments, last by andyb716 19 years, 6 months ago
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;

}


Advertisement
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.
How do I know if I have v-sync enabled. Is it enabled by default, because I dont think I set it anywhere.
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.
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.
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.
Hmm... 170 is still pretty slow for a blank present... Or is that just me?
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.
I have a crappy old GeForce 2 and i can still get around 700 to 800...
Am I calculating FPS right? Yah it really does seem slow for doing nothing butting clearing. I have an nvidia gforce 2 mx 400

This topic is closed to new replies.

Advertisement