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.DBatch 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:
- No- Limited instancing of animated models (most unit meshes, oars of new triremes...)...). This could be fixed with more extensions. This is fixable with a fair bit more workFor now, at least to an extent (I think the oars might be doable anyways)I think it instances trireme oars OK since those are animated in perfect sync.
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.