Original Post
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.
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.