Skip to main content
gamedev.net
🔒 Locked

Low frame rate

Started by ayush3017 Jun 27, 2010 at 8:00 AM 5 replies 1.7k views
Original Post
ayush3017
ayush3017
Hello everybody. I just discovered that my frame is too low in drawing my game. For drawing just 60000 tris it has dropped to 79fps. No advanced shaders just a normal map one. I am using Hardware vertex processing. I am drawing buildings in a group of 3 to 4.Also if I attach models in 3Ds MAX and then draw them it jumps to 130fps. And thats also low. This is my drawing code:

void main::DrawScene(LPDIRECT3DDEVICE9 device, float dt)
{
device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
angle += 0.1f;

updateCamera(1);

D3DXMATRIX V;
TheCamera.getViewMatrix(&V);


//device->SetTransform(D3DTS_VIEW, &V);

device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(80, 133, 183), 1.0f, 0);
device->BeginScene();


D3DXMATRIX rotation, translation, world, translation1;
D3DXMatrixRotationY(&rotation, angle);

D3DXMatrixTranslation(&translation, 0, 0, 0);
D3DXMatrixMultiply(&world, &translation, &rotation);


D3DXMATRIX viewProjection;
D3DXMATRIX worldInverseMatrix;
D3DXMATRIX worldViewProjection;

D3DXMatrixMultiply(&viewProjection, &V, &projectionMatrix);
D3DXMatrixMultiply(&worldViewProjection, &world, &viewProjection);

effect->SetTechnique(hTech);

D3DXMatrixInverse(&worldInverseMatrix, 0, &world);

effect->SetValue(hLight, &mLight, sizeof(DirLight));
effect->SetMatrix(hWorldInv, &worldInverseMatrix);
effect->SetMatrix(hWVP, &worldViewProjection);
effect->SetValue(hEyePosW, TheCamera.pos, sizeof(D3DXVECTOR3));



UINT numPasses = 0;
effect->Begin(&numPasses, 0);

effect->BeginPass(0);

for(UINT j = 0; j < mSceneMtrls[0].size(); ++j)
{
effect->SetValue(hMtrl, &mSceneMtrls[0][j], sizeof(Mtrl));

effect->SetTexture(hTextureMap, Textures[0][j]);
effect->SetTexture(hNormalMap, NormalMaps[0][j]);

effect->CommitChanges();
finalMesh->DrawSubset(j);
}

for(int x=1 ; x<7 ; x++)
{

for(UINT j = 0; j < mSceneMtrls[x].size(); ++j)
{
effect->SetValue(hMtrl, &mSceneMtrls[x][j], sizeof(Mtrl));

effect->SetTexture(hTextureMap, Textures[x][j]);
effect->SetTexture(hNormalMap, NormalMaps[x][j]);

effect->CommitChanges();
section5Models[x-1]->DrawSubset(j);
}
}

effect->EndPass();

effect->End();

drawText1Object.Draw(fps, triangleCount, params.BackBufferWidth, params.BackBufferHeight, "Windowed", TheCamera.pos, 45.0f);

device->EndScene();
device->Present(NULL, NULL, NULL, NULL);
}

Here are presentation parameters:
params.Windowed = true;
params.BackBufferFormat = D3DFMT_UNKNOWN;
params.SwapEffect = D3DSWAPEFFECT_DISCARD;
params.EnableAutoDepthStencil = TRUE;
params.AutoDepthStencilFormat = D3DFMT_D24S8;
params.Flags = D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL;;
params.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

I have also measured with fraps and its the same. Its strange that the frame rate is same on any resolution either 800X600 or 1280X1024, windowed or fullscreen. What could be the cause of such a low frame rate??
Thanks.
Demirug
Demirug
If the resolution doesn’t matter you are CPU or vertex processing limited.
How many times do you call DrawSubset per Frame?
ayush3017
ayush3017
I used OptimizeInplace with D3DXMESHOPT_VERTEXCACHE and my frame rate jumped to 450fps. Also DrawSubset is being called 183 times pf. I don't think 183 calls is a problem. Is there any way to reduce that(by attaching the meshes with similar texture or what?)
Atrix256
Atrix256
I think you are worrying about something that isn't really a problem.

you are still above 60 fps, why are you worried about performance?

You'll want vsync on for your game to look decent and that will cap it at a maximum of 60 fps.

Also, when talking about performance you should talk about miliseconds per frame, not frames per second, here's why...

If each frame of your game takes 5 miliseconds, thats 200fps.

if each frame takes 10 miliseconds thats 100fps.

If each frame takes 15ms thats 66fps

at 20ms, thats 50fps

at 25ms, that's 40fps.

So you can see it's not a linear relationship between ms and fps.

This is important because if you do an optimization and you say "Hey i gained 5fps, rad!" 5 fps isn't really a meaningful measurement of savings.

If you say it saved you 2ms, that is a meaningful measurement though.

But yeah... why are you wasting your time worrying about optimization when you are at 79fps?
Jason Z
Jason Z
Especially if you attach the models together and then are significantly faster, I would say that you are CPU/draw call bound. What hardware are you developing on? Have you tried out the standard tests with nVPerfHud or PIX?
Jason Zink :: DirectX MVP   Direct3D 11 engine on CodePlex: Hieroglyph 3 Direct3D Books: 
21st Century Moose
21st Century Moose
One reason I can think of to worry about optimization is to give headroom for adding other stuff. If these 60,000 tris were the only thing that the OP wanted to draw, then yeah, it's OK. What if you turned around a corner and the number was 120,000? Or what if the OP wanted to add some of those advanced shaders (that there are currently none of) to a version 2.0?
Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls. 
ayush3017
ayush3017
My one city block consists of 60000 tris. There are approx. 75 such blocks in my game. Cars and peds are also to be considered. Each car is of 40000tris. Thats why I was worried. Considering advanced shaders as GI or AO the frame rate would gradually drop.

Topic Locked

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

Sign in to reply to this topic.