[Public WebGL] New multi_draw extensions

David Catuhe ([email protected]) [email protected]
Fri Feb 22 10:29:49 PST 2019


Just created an issue to support them ☺
https://github.com/BabylonJS/Babylon.js/issues/5962

From: [email protected] <[email protected]> On Behalf Of Austin Eng ([email protected])
Sent: Friday, February 22, 2019 10:22 AM
To: [email protected]
Subject: [Public WebGL] New multi_draw extensions

Resending this because the previous email was likely marked as spam.


WebGL community,


Two new extensions are in development which provide better batching for draw calls:


WEBGL_multi_draw<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.khronos.org%2Fregistry%2Fwebgl%2Fextensions%2FWEBGL_multi_draw%2F&data=02%7C01%7CDavid.Catuhe%40microsoft.com%7C4c54708001614a10ee7008d698f2c671%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C1%7C636864565827877052&sdata=oYroh5487exlCENjZut9gykdUB5lnAW5XisTlKfrCKQ%3D&reserved=0>

WEBGL_multi_draw_instanced<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.khronos.org%2Fregistry%2Fwebgl%2Fextensions%2FWEBGL_multi_draw_instanced%2F&data=02%7C01%7CDavid.Catuhe%40microsoft.com%7C4c54708001614a10ee7008d698f2c671%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C1%7C636864565827887075&sdata=GFhC79S%2BQffghxQPAzORD%2FqbU8v7%2BIjR%2FsZs10nwKLA%3D&reserved=0>


Compared to instancing, which is available as an extension in WebGL 1.0 and is core in WebGL 2.0, multi_draw provides more flexibility. It essentially allows the parameters to multiple calls to drawArrays and drawElements to be assembled in arrays, and sent down to the WebGL implementation with one call. This eliminates a large amount of overhead when repeatedly calling from the JavaScript application down into the WebGL implementation.


Per-draw-call data can be sent down in multiple ways, including in uniform buffers (WebGL 2.0) indexed by a new gl_DrawID variable available in shaders.


A few examples of how these APIs can be used are in this repository:

https://github.com/kenrussell/webgl-animometer<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fkenrussell%2Fwebgl-animometer&data=02%7C01%7CDavid.Catuhe%40microsoft.com%7C4c54708001614a10ee7008d698f2c671%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C1%7C636864565827887075&sdata=PGDYjqGg8csrwGJb31ReaHd90ETLn%2Bde39PfbzJTK5w%3D&reserved=0>


The potential speedups are dramatic. Microbenchmarks<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.google.com%2Fpresentation%2Fd%2F1iznxalgXLLSWVNHQ6le9Gzv_TYzsD5R_gg8yT5ckf2A%2Fedit%3Fusp%3Dsharing&data=02%7C01%7CDavid.Catuhe%40microsoft.com%7C4c54708001614a10ee7008d698f2c671%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C1%7C636864565827897079&sdata=RPVG5I2J7JplW49LiCYwj2q2EtVCGSSZ6xlXYOYSNMI%3D&reserved=0> show anywhere from a 2-3x speedup to a 70x (!) speedup in Chrome, compared to making tiny individual draw calls from JavaScript. Prototypes in other browsers show ~4x speedups too; the benefits are universal.


Please give these extensions a try. They’re currently available in Chrome Canary on all platforms by enabling WebGL draft extensions in about:flags, and are coming to more browsers soon. A BaseVertex variant of the extensions is also planned.


We would appreciate your feedback on how well the multi_draw extensions work for your applications, and any suggestions for continued enhancement.


Thanks to Kai Ninomiya from Google for support in developing these extensions!



- Austin Eng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20190222/58ee4e5a/attachment.html>


More information about the public_webgl mailing list