I've got a minecraftish game that's running nice and smooth with a total of 9.3 million triangles, about 50-70fps average. Then if I try to render 9.9 million triangles I get hell and it drops to < 1 fps. I'm drawing them exactly the same way, it's definitely the drawing as I have a vertex buffer for each chunk, then I run through them all, check if they're in sight and if they are I draw them. It works fine at high fps until I have just those few extra triangles which destroy the FPS.
Edit: Added drawing code:
First I loop through all the chunks. I check if they're visible and if they are I mark them as visible then draw them.
foreach (Chunk chunk in GlobalWorld.LoadedChunks)
{
if (chunk == null || !chunk.DrawThis)
continue;
if (!player.ViewFrustrum.Intersects(chunk.Bounding))
{
chunk.IsInSight = false;
continue;
}
chunk.IsInSight = true;
GlobalGame.graphicsDevice.SetVertexBuffer(chunk.VertexBuffer);
GlobalGame.graphicsDevice.Indices = chunk.IndexBuffer;
ChunkShader.Parameters["xWorld"].SetValue(chunk.WorldMatrix);
ChunkShader.CurrentTechnique.Passes[0].Apply();
GlobalGame.graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, chunk.VertexBuffer.VertexCount, 0, chunk.IndexBuffer.IndexCount / 3);
}
Then after that I draw all the transparent parts of the chunk (so they don't conflict with other chunks). I already made clear if they're visible above so I just check if that bool is true.
foreach (Chunk chunk in GlobalWorld.LoadedChunks)
{
if (chunk == null || !chunk.IsInSight || !chunk.DrawThisTransparent)
continue;
GlobalGame.graphicsDevice.SetVertexBuffer(chunk.TransparentVertexBuffer);
GlobalGame.graphicsDevice.Indices = chunk.TransparentIndexBuffer;
ChunkTransparencyShader.Parameters["xWorld"].SetValue(chunk.WorldMatrix);
ChunkTransparencyShader.CurrentTechnique.Passes[0].Apply();
GlobalGame.graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, chunk.TransparentVertexBuffer.VertexCount, 0, chunk.TransparentIndexBuffer.IndexCount / 3);
}
With 3721 chunks loaded it runs fine with them all being drawn at the same time. With 3844 chunks being loaded it runs fine unless you view all of them. Now that's only just over 100 more chunks yet it's dropping from 60fps to < 1 fps.