More WebGPU optimizations by davepagurek · Pull Request #8510 · processing/p5.js
Changes:
-
Sets up caching of bind groups. In order to do this, I've removed the assumption that all struct uniforms are in group 0, which lets us cache more groups, and leave one group remaining for the stuff that changes a lot.
-
More caching for other WebGPU properties: we don't update shaders in the current draw if the shader options are the same as before.
-
Avoids re-packing the same data twice by caching the packed version
-
Optimizes
drawBuffers, which is run many times per frame. Cache keys are numbers instead of strings; buffers are saved and reused instead of using a new array each time; loops are reorganized to avoid needing to use intermediate maps. -
4000 spheres with different colors with strokes: WebGL is 10fps, WebGPU is 14fps
-
4000 spheres with different colors with no strokes: WebGL is 20fps, WebGPU is 19fps
-
4000 spheres with the same color: WebGL is 29fps, WebGPU is 29fps
Test sketch: https://editor.p5js.org/davepagurek/sketches/lD-JsoCI4
PR Checklist
-
npm run lintpasses - Inline reference is included / updated
- Unit tests are included / updated