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.
I can batch up to 64 (atm) draws in one call. 32 seems sufficient for 0 A.D.
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:
- No instancing of animated models (most unit meshes, oars of new triremes...). This is fixable with a fair bit more work, at least to an extent (I think the oars might be doable anyways).
TODO:
- the pgl stuff isn't working for me so far
- gpu skinning isn't working.
- Separate the renderer-only changes from the instancing changes.
Good stuff to test:
- Gaul barracks.
- Sahydian buttes or whatever it's called.