While thinking about how to optimise draw call for one of our scene with a lot of textures and thus a lot of draw calls, we came up with the idea of using multiple textures samplers in QuadBatch.
The changes would be :
- when checking for a state change, if the texture is different that the previous one AND there is a free texture sample slot available (fs0-x) bind the texture to a free slot and allow to continue batching (the other part of the test remains the same). Whenever all slots are used, finish batch and start over.
- set the texture sample slot to use thru a vertex attribute
- use a more complex shader with AGAL2 IF statements to use the correct texture
I know the IF statement and the longer shader will be a slower than the current basic shader for QuadBatch but my guess is that the reduction of draw calls will be worth it.
Before we try to implement it, do you guys have comments on that ?