Jump to content
  • Advertisement
Sign in to follow this  
DiPharoH

number of verices and framerate

This topic is 3409 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am using direct3d 9 to view direct3d ,odels in .x format when i draw a simple model if it have small vertices number i get 800 fps but i developed a model with 70,000 vertices when i deaw it i get 15 fps so please can you tell me what is the most decent number of ertices i should make my models do to get a decent fps or i should do some thing with the rendering states i tried modifying the presentation interval to the values ONE IMMEDIATE DEFAULT no big difference that's my specs geforce 8400 GS 4G RAM dual-core 2.5 GHZ 2m cashe memory so what??? please

Share this post


Link to post
Share on other sites
Advertisement
We can't know if there's something wrong in your program just like that. You should try loading the model in "DirectX Viewer" (see Tools section in the SDK). This way you will see if the problem is the model or your application.

I think your video card should be able to handle much more.

You should use immediate.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dunge
We can't know if there's something wrong in your program just like that. You should try loading the model in "DirectX Viewer" (see Tools section in the SDK). This way you will see if the problem is the model or your application.

I think your video card should be able to handle much more.

You should use immediate.

i can view it very perfectly with the directx viewer
but in the directx viewer it uses cull mode and i donot use cull mode in my program
ok
here is all my direct3d init code
[source lang = cpp]

d3d = Direct3DCreate9(D3D_SDK_VERSION);
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = FALSE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hWnd;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
///////////
d3ddev->CreateDepthStencilSurface(SCREEN_WIDTH,
SCREEN_HEIGHT,
D3DFMT_D16,
D3DMULTISAMPLE_NONE,
0,
TRUE,
&z_buffer,
NULL);


d3ddev->SetRenderState(D3DRS_LIGHTING, TRUE);
d3ddev->SetRenderState(D3DRS_ZENABLE, TRUE);
d3ddev->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(150, 150, 150));
d3ddev->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
///////////////////////
//then i render every frame like that
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
D3DXMatrixPerspectiveFovLH(&matProjection,
D3DXToRadian(45),
SCREEN_WIDTH / SCREEN_HEIGHT,
1.0f,
2000.0f);

d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection);


DrawMesh1();






d3ddev->EndScene();

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


Share this post


Link to post
Share on other sites
You only need to call clear once:
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

From the code you have posted there is nothing wrong. But you omitted the interesting part which is how you laod and draw your mesh. Maybe you do not optimize the mesh after loading and end up with a bad vertex cache hit ratio, maybe you are drawing the mesh manually triangle by triangle, .... there are lots of ways to keep your graphics card from reaching top performance with just a few lines of code [grin]

Share this post


Link to post
Share on other sites
Quote:
Original post by Waterwalker
You only need to call clear once:
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

From the code you have posted there is nothing wrong. But you omitted the interesting part which is how you laod and draw your mesh. Maybe you do not optimize the mesh after loading and end up with a bad vertex cache hit ratio, maybe you are drawing the mesh manually triangle by triangle, .... there are lots of ways to keep your graphics card from reaching top performance with just a few lines of code [grin]

thanks mate you sound confidente but i swear it still 15 fps
here is how i load and draw
and what you mean triangle by triangle
i load it once like that

D3DXLoadMeshFromX("sand.x",
D3DXMESH_SYSTEMMEM,
d3ddev,
NULL,
&bufmat1,
NULL,
&numMat1,
&mesh1
);


D3DXMATERIAL* tempMat1 = (D3DXMATERIAL*)bufmat1->GetBufferPointer();


mat1 = new D3DMATERIAL9[numMat1];
text1 = new LPDIRECT3DTEXTURE9[numMat1];
for(DWORD i = 0; i < numMat1; i++)
{
mat1 = tempMat1.MatD3D;
mat1.Ambient = mat1.Diffuse;
if(FAILED(D3DXCreateTextureFromFile(d3ddev,
(tempMat1.pTextureFilename),
&text1)))
text1 = NULL;
}
//////////////
//then i draw it every frame like that

for(DWORD i = 0; i < numMat1; i++)
{
d3ddev->SetMaterial(&mat1);

if(text1 != NULL)
{
d3ddev->SetTexture(0, text1);
}
mesh1->DrawSubset(i);
}



Share this post


Link to post
Share on other sites
Ok, this seems to be pretty straightforward and appears to be ok. However, there is still plenty of room to annoy your graphics card.

First, make sure to call ID3DXMesh::OptimizeInplace on your mesh. If you have a mesh that has a bad ordering of faces and vertices you can end up retransforming lots of vertices multiple times because of cache misses. This optimization reorders your vertices and faces to minimize the load on the transformation pipe of your graphics adapter (try googling for "tipsify mesh" to learn more).

Second, output how many materials you have. Each time you call drawSubset issues a new draw call to the driver which can easily become the bottleneck of your application if you end up issuing hundreds of draw calls for a single mesh due to apparently different materials. If you really have too many materials thus resulting in too many draw calls then using a texture atlas (if you have too many different textures) or reducing different materials (if you have too many different material colors for your subeset) can help improving the performance.

The second point does not seem to be too relevant in this case since the DX viewer renders the mesh ok. But before analyzing more you should tell us the number of drawSubset calls you issue each frame.

Share this post


Link to post
Share on other sites
whatever mate thanks for caring
i modelled a simple plane with 100,000 polys
when i draw it it give 15 fps
it's a plane i mean the vertices are a ligned
and i also tried loading 10 meshes every mesh has 10,000 polys it was the same
so do you think i still need to use that function that rearrange the mesh vertices
here is the model if you wanna see for your self
http://rapidshare.com/files/223021627/model.x.html
please see it

Share this post


Link to post
Share on other sites
A quick glance at the docs says your the loop counter to use with DrawSubset should be accessed via GetAttributeTable

Share this post


Link to post
Share on other sites
I am not sure but you use D3DXMESH_SYSTEMMEM for creating the mesh, so each time it must send it to the video buffer would that make it slow ?

my 2 cents

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!