On GitHub: https://github.com/wraitii/0ad/tree/instancing
This uses GL_ARB_draw_instanced to render some models using instancing instead of individual draw calls.
Batch size is calculated by hwdetect.js, and can be reset via the "max_matrix_uniform" config value.
Cuts draw calls anywhere between 50 and 75% on a typical frame (F11 to check).
Other approaches would be to use vertex attributes with divisor (good support), or uniform buffer objects or just buffer textures, but those have much lower support (according to https://feedback.wildfiregames.com/results/ )
ISSUES:
- Limited instancing of animated models (most unit meshes...). This could be fixed with more extensions. For now, I think it instances trireme oars OK since those are animated in perfect sync.
TODO:
- Separate the renderer-only changes from the instancing changes.
Good stuff to test:
- Gaul barracks.
- Sahydian buttes or whatever it's called.
- Combat demo huge (with gpuskinning=true)
----
Personal profiling shows a 10-20% perf difference, depending on the map.