0
\$\begingroup\$

We're having issues with low FPS in a third-person shooter 3D game. This happens when you have too many polygons on screen. The FPS is locked to 60, and the gameplay is fine, but the moment when you have like 900 entities on screen, the FPS immediately drops to 45 or 50.

IDirect3DDevice9::DrawIndexedPrimitive is normally called 200-900 times to render the entities, however, when you render more polygons than usual, let's say 500,000 more vertices then it's called 6000-7000 times and the FPS drops to 45-50. I ran a profiler and saw this function eating up the CPU, consuming around 19% of the resources.

I have some ideas to deal this issue, but I need some advice. Possible solutions that I can think of:

Secondary thread for rendering

I'm not sure if introducing multi-threading will fix the problem, but I'm hopeful.

Upgrading to Directx11

If this can help, then can someone explain how we need to render the vertex buffers of entites? This how we do it now for every entity:

d3dDevice->Clear(0,NULL,D3DCLEAR_TARGET, D3DCOLOR_XRGB(255,255,255),1.0f,0);

// Turn on wireframe mode
d3dDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
d3dDevice->BeginScene();

for (DWORD i=0; i<numMaterials; i++)
{
    // Set the material and texture for this subset
    d3dDevice->SetMaterial(&meshMaterials[i]);
    d3dDevice->SetTexture(0,meshTextures[i]);

    // Draw the mesh subset
    mesh->DrawSubset( i );
}

d3dDevice->EndScene();
d3dDevice->Present(NULL, NULL, NULL, NULL);

Both

Upgrade to Directx11 and use a secondary thread for rendering?

\$\endgroup\$
11
  • 1
    \$\begingroup\$ Because I don't currently have the time to write examples, I won't post this as an answer. I think you should take a look at "instancing". Basically, it allows you to draw the same thing in different places in a single draw call. \$\endgroup\$
    – Peethor
    Apr 28, 2019 at 16:36
  • \$\begingroup\$ @Peethor That sounds like a good idea, but what if the objects have different geometries? We're not using instancing atm, we'll use it for rendering trees. \$\endgroup\$
    – ryspbsk
    Apr 28, 2019 at 16:53
  • \$\begingroup\$ Different geometry == different draw calls. But in many games, you'd be drawing things like scenery (trees, boxes, tables) a lot. Having one draw call per model instead of one draw call per object can save a lot of time. \$\endgroup\$
    – Peethor
    Apr 28, 2019 at 17:03
  • \$\begingroup\$ You're right. That makes sense. I guess this is the answer then. \$\endgroup\$
    – ryspbsk
    Apr 28, 2019 at 17:15
  • \$\begingroup\$ Feel free to add it as such for future reference when you've got something working! \$\endgroup\$
    – Peethor
    Apr 28, 2019 at 17:31

0

You must log in to answer this question.

Browse other questions tagged .