What is Batch Rendering?


i’d like to know what is meant by “batch rendering”. i’ve read several sites online (including that), couldn’t figure it out. what i learnt is to optimize drawing, i have to reduce state changes and drawcalls as well as cpu <–> gpu data transfers (like uploading bufferdata, uniforms etc). and of course eliminate (implicit) syncronization when downloading data wherever possible.

currently i’m using 1 VAO + VBO for all model meshes, and 1 progam (phong) to shade meshes, and sorting my stuff like that:

/* to draw 1 mesh */
struct DrawArrays {
GLenum Mode;
GLint First;
GLsizei Count;

struct RenderState {
bool WireFrame; /* for glPolygonMode() */
bool TwoSided; /* for culling */
bool Blending; /* for "simple" transparency */

struct MaterialData {
vec3 Ambient, Diffuse, Specular, Emissive;
float Shininess;

struct Material {
RenderState State;
MaterialData Data;

/* to draw 1 model */
struct ModelInstance {
/* location, orientation, size */
mat4 Transformation;
/* currently sorted by material */
list< pair<Material, vector<DrawArrays>> > Components;
/* later i'll add bones */

all the “Components” for a model instance are generated once when i initialize the application and are then stored.

so what i’m trying to do is to only upload materialdata once, and draw all meshes that use this material. later i’m trying to map them to renderstates to reduce GL state changes and maybe but all these drawcommands into a GL_DRAW_INDIRECT_BUFFER do reduce them to 1 “drawcommand”.

is this a kind of “batch rendering” (since i’m sort of “batching” drawcalls) or am i missing something? or is instanced rendering meant by “batching”?


Two things, batch (noun) and batch (verb).

Batch (noun) = Draw call (Reference from GDC 2003)
Batch (verb) = Merging draw calls to reduce total draw call count (and often reduce state changes). Aka batching.

From what I know, there are mainly two distinct ways to do batching.

Dynamic batching implies to dynamically (for each frames) fill the index arrays, so that is sent only what the application expects.

Static batching may have different aspects. One of them is to pre-calculate all the indices at some ‘map compilation time’. This could generate several different arrays for the same geometry. At rendering time, the application only chooses the right one to use.

The first one might look more slow at first glance. But if it allows to do less draw calls, and eliminates more invisible triangles and to sort them better, some performance gain might be noticeable.

This is batching; everything else is just a collection of techniques to enable batching.