EXT_multi_draw_arrays WebGL working group (public_webgl 'at' khronos.org) Contributors to the EXT_multi_draw_arrays specification Members of the WebGL working group NN

This extension exposes the EXT_multi_draw_arrays functionality to WebGL.

CAD vendors rendering large models comprised of many individual parts face scalability issues issuing large numbers of draw calls from WebGL. This extension reduces draw call overhead by allowing better batching.

The multiDrawArraysEXT and multiDrawElementsEXT entry points are added. These provide a counterpoint to instanced rendering and are more flexible for certain scenarios. The offset arguments to multiDrawArraysEXT and multiDrawElementsEXT choose the starting offset into their respective typed arrays or sequences. This primarily avoids allocation of temporary typed array views.
[NoInterfaceObject] interface EXT_multi_draw_arrays { void multiDrawArraysEXT(GLenum mode, (Int32Array or sequence<GLint>) firstsList, GLuint firstsOffset, (Int32Array or sequence<GLsizei>) countsList, GLuint countsOffset, GLsizei drawcount); void multiDrawElementsEXT(GLenum mode, (Int32Array or sequence<GLint>) countsList, GLuint countsOffset, GLenum type, (Int32Array or sequence<GLsizei>) offsetsList, GLuint offsetsOffset, GLsizei drawcount); }; The multi-draw APIs are subject to all of the same rules regarding out-of-range array accesses as the core WebGL APIs.
var ext = gl.getExtension("EXT_multi_draw_arrays");
{
  // multiDrawArrays variant.
  let firsts = new Int32Array(...);
  let counts = new Int32Array(...);
  ext.multiDrawArraysEXT(gl.TRIANGLES, firsts, 0, counts, 0, firsts.length);
}

{
  // multiDrawElements variant.
  // Assumes that the indices which have been previously uploaded to the
  // ELEMENT_ARRAY_BUFFER are to be treated as UNSIGNED_SHORT.
  let counts = new Int32Array(...);
  let offsets = new Int32Array(...);
  ext.multiDrawElementsEXT(gl.TRIANGLES, counts, 0, gl.UNSIGNED_SHORT, offsets, 0,
                           counts.length);
}
    
Initial version.