Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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