I'm trying to understand batching and I'm not sure to understand how to do that, can I have more informations please? Here is what I found for the moment:

Batching informations

There is many types of batching:

  • Sprite batching
  • Geometry batching
  • ???

Sprite batching

This method is useful to draw all sprites with only one draw call. To do that, a SpriteBatcher class need to get all the mesh with the same Material and the same Geometry (sprite = square geometry).

  1. Get Sprites with same Material
  2. Send all Sprite's matrix to a Sprite shader (http://antonholmquist.com/blog/sprite-batching-opengl-es-2-0/)

Geometry batching (With static geometry)

Merge meshes's geometry, so you we can draw all meshes in one draw call.

  1. Get all static meshes
  2. Merge meshes's geometry and calculate their position with there matrix (Compute a single VBO and IBO)
  3. Hide original mesh to avoid twice draw.

Am I right with that? Thanks!


1 Answer 1


Batching is a way of grouping geometry together (they should be compatible, e.g. the same material, context states, etc. ) to use as few draw calls as possible. In this way, you could fully exploit GPU throughput, so as to improve performance.

One method to achieve this is to consolidate geometry by dynamic vertex/index buffer. The definition of a dynamic buffer is as below

A resource that is accessible by both the GPU (read only) and the CPU (write only). A dynamic resource is a good choice for a resource that will be updated by the CPU at least once per frame. To update a dynamic resource, use a Map method.

Some steps to improve performance by using this method,

  1. Do a benchmark on the GPU, to have a better understanding of the throughput.
  2. Create dynamic vertex/index buffer with a reasonable size according to the benchmark result.
  3. Feed the geometries with compatible appearance, rendering states, vertex formats and primitive type to the dynamic vertex and index buffer.
  4. Continue to feed geometries as talked above until the buffer is full or the coming geometries are not compatible, then call graphics draw method to flush the buffer.
  5. Usually, can have a few other than one dynamic vertex/index buffer set, so if geometry can't be feed into the current buffer, then can use another one instead. until all buffers are occupied, then flush.

Hope this can help.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .