I'm getting massive performance loss when rendering a medium-sized scene with a reasonable(?) amount of meshes.
The stats for all rendered (non-occluded) objects in the scene are:
Triangles: 204432
Vertices: 68449
Shader Changes (glUseProgram): 3
Material Changes (glBindTexture): 239
Meshes: 7153
Render Duration: 23ms (~43fps)
I know that rendering a lot of low-poly meshes is a lot more expensive than rendering a handful of high-poly meshes, but still, 7153 meshes with an average of ~28 triangles doesn't seem like a big deal to me, and yet the performance goes down the drain.
Before rendering, all of my meshes are first sorted by shader, then by material. The main render process is as follows:
foreach shader
glUseProgram(shader)
foreach material
glBindTexture(material)
foreach mesh
glBindVertexArray(vao) // Vertex Array (Vertex +UV +Normal Buffers)
glBindBuffer(ibo) // Index Buffer
glDrawElements(GL_TRIANGLES,vertexCount,GL_UNSIGNED_INT,(void*)0)
end
end
end
(Pseudo Code)
I have a decent graphics card (AMD Radeon R9 200 Series) which I believe should be able to handle a lot more stress than this. I've spent hours profiling with both CPU and GPU profilers, debugging, trying various optimization methods, but the bottleneck is definitely the central rendering process (Code above).
Is the amount of meshes really the problem here? If not, what could be causing this massive decrease in performance?
I'm not looking for culling methods, right now I'm just trying to improve my rendering pipeline.