Sweet!
Right. glMultiDrawArraysIndirect() or glMultiDrawElementsIndirect() should fix that right up. Just put one instance per sub-draw record, and lookup your bindless texture handle using gl_DrawID
.
A related note that you probably won’t care about for a long while…:
While instanced draw calls or MDI (MultiDrawIndirect) draw calls can be very efficient and save a lot of needless CPU time dispatching draw work, using them with trivial instances (few vertices per instance or sub-draw) probably won’t max out your GPU’s vertex throughput. There are several options to achieve higher vertex throughput, but they’re more complex -to- considerably more complex to implement than simple instancing or MDI. You almost certainly don’t need this right now. In case you (or someone reading this thread later) cares, here’s a thread on that…