WEBGL_multi_draw extension

Draw Calls and WebGL Performance

In WebGL-based applications, each draw call represents a request to render a mesh or a part of a mesh. Drawing multiple objects with separate draw calls can quickly become a performance bottleneck, especially when dealing with scenes containing a large number of objects or complex animations. Reducing the number of draw calls is critical for achieving smooth and responsive 3D experiences on the web.

Link: Optimize Your Scene

WEBGL_multi_draw Extension

The WEBGL_multi_draw extension is an WebGL extension that allows multiple draw calls to be batched together into a single call. This extension has the potential to significantly reduce the overhead associated with issuing individual draw calls, leading to improved rendering performance.

Link:

Alternatives

Impl state

Notes

Currently in angle, WEBGL_multi_draw functions are implemented in a loop for d3d11 and others

3 Likes

cc @Evgeni_Popov :slight_smile:

According to poki’s report Poki for Developers - Reach the world on web WEBGL_multi_draw has a good support on target devices

Yes, it could be interesting to support this extension (even more so when WebGPU supports it), but we’ll have to find a good design to add it to the engine, as we don’t want to add too much javascript code to support it, which would cancel out the benefit of using the new API…

Maybe something like BatchedMesh of three.js, or InstancedMesh with count and offset. Also, a static api like MergeMeshes would help to convert meshes imported from existing assets.

Status update: Google is implementing this (even the spec not ratified yet)

https://issues.chromium.org/issues/369246557/dependencies

2 Likes

Is there any plan to support this? Or are we waiting for webgpu’s multi draw indirect feature to land?

We would prefer to rely on the webgpu implementation if there are no strong webgl needs for it.

1 Like

WebGPU mdi proposal is staled for almost a year and a half, no change to that PR since Nov 19, 2024, and no sign in recent meetings that the work group is pushing this forward in recent weeks.
Another thing to highlight is that the main bottleneck of browser-based rendering is bind instead of draw, see here for a profile. the performance gain of WEBGL_multi_draw is mainly from 2 sources, one is batching js-cpp call conversion and webgl validation, the other is it forces the rendering model of bind once, draw many. Bindless is also part of focused plan of the workgroup in recent weeks.

1 Like