SpriteBatch vs. per‑sprite draw calls for animated tiles under a 100‑draw‑call limit
0 reputation · 19 Jan 2022, 21:08 UTC
Goal: Determine whether to render a layer of 500 identical moving sprites each frame using a single SpriteBatch or individual love.graphics.draw calls while staying under a fixed draw‑call budget of 100 calls per frame.
Constraints: SpriteBatch reduces draw calls but requires updating its vertex buffer each frame when sprite positions change; frequent :setBuffer or :add calls can add CPU overhead. Per‑sprite draw calls keep overhead low for few sprites but increase draw‑call count and state changes, potentially exceeding the budget.
Uncertainty: At what sprite count or movement frequency does the CPU cost of rebuilding a dynamic SpriteBatch outweigh the savings from fewer draw calls? Does the 'stream' usage hint mitigate this cost for rapidly changing data? How does packing multiple textures into an atlas affect the decision when the sprites share different images?