WebGL
Khronos
 

WebGL WEBGL_multi_draw Extension Proposed Specification

DO NOT IMPLEMENT!!!

Name

WEBGL_multi_draw

Contact

WebGL working group (public_webgl 'at' khronos.org)

Contributors

Contributors to the ANGLE_multi_draw specification

Members of the WebGL working group

Version

Last modified date: November 09, 2018
Revision: 1

Number

WebGL extension #NN

Dependencies

Written against the WebGL API 1.0 specification.

Overview

This extension exposes the ANGLE_multi_draw functionality to WebGL.

The following WebGL-specific behavioral changes apply:

Consult the above extension for documentation, issues and new functions and enumerants.

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.

When this extension is enabled:

IDL


[NoInterfaceObject]
interface WEBGL_multi_draw {
  void multiDrawArraysWEBGL(
      GLenum mode,
      (Int32Array or sequence<GLint>) firstsList, GLuint firstsOffset,
      (Int32Array or sequence<GLsizei>) countsList, GLuint countsOffset,
      GLsizei drawcount);
  void multiDrawElementsWEBGL(
      GLenum mode,
      (Int32Array or sequence<GLint>) countsList, GLuint countsOffset,
      GLenum type,
      (Int32Array or sequence<GLsizei>) offsetsList, GLuint offsetsOffset,
      GLsizei drawcount);
};

  

Sample Code

var ext = gl.getExtension("WEBGL_multi_draw");

{
  // multiDrawArrays variant.
  let firsts = new Int32Array(...);
  let counts = new Int32Array(...);
  ext.multiDrawArraysANGLE(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.multiDrawElementsANGLE(
      gl.TRIANGLES, counts, 0, gl.UNSIGNED_SHORT, offsets, 0, counts.length);
}

    
#extension GL_ANGLE_multi_draw : require
void main() {
    gl_Position = vec4(gl_DrawID, 0, 0, 1);
}
    

Conformance Tests

Security Considerations

The multi-draw APIs are subject to all of the same rules regarding out-of-range array accesses as the core WebGL APIs.

Issues

Revision History

Revision 1, 2018/11/09