Use the batching algorithm described here https://nical.github.io/drafts/gui-gpu-notes.html by tracking an AABB for each batch and only starting a new batch if the next primitive overlaps