Skip to content

Performance guide

Marc Flerackers edited this page Jun 12, 2024 · 1 revision

Performance guide

Sprites

From slowest to fastest, drawing multiple sprites:

  • Using objects with a sprite or uvquad component. Objects are really handy when you need to assign specific behavior and/or want to reuse components, but they come at a cost. Objects are good for units or objects you can manipulate.
  • Using drawSprite or drawUVQuad in a for loop. This is faster since it loses all the overhead objects bring with them. UVQuads are slightly faster since they don't need to resolve a sprite. This is good for dynamic tile maps or particle systems.
  • Drawing a mesh. Not publicly available yet, but a mesh can save you al of of time, especially a static mesh since it can be cached on the GPU. This is good for static tile maps or any other static content.
  • Rendering sprites using a shader. Only one quad is drawn, all the rest is processed in the shader. The speed gain depends on the kind of hardware which is used and how many samples can be processed simultaneously.

Batching

When using individual objects, beware of the ordering. If you mix sprite and polygon (triangle, rect, polygon, circle) based objects, batching will be disabled since each change of texture, blend mode or shader means that all draw operations are flushed to the GPU. To make best use of batching, make sure to draw sprites and other drawables grouped.

Clone this wiki locally