2d: Use dynamic buffers for instance data #104566
Closed
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.
Important
Depends on
Summary
This PR updates the 2D canvas renderer to utilise dynamic buffers for instance data, per the changes in 7861cdd.
I modified the Canvas 2D renderer to use dynamic buffers for the
InstanceData(similar to what @darksylinc did for forward / mobile renderers). This change removes two copies, so the instance data is written once (on UMA devices):InstanceDatato the GPU, andI modified the 1x1 sprite benchmark in @Calinou's comment, to draw 20,000 textured rectangles, which still batches, but reduces the CPU bottleneck of rendering 20,000 individual canvas items, to demonstrate the advantages of this PR. TileMaps is an example that will benefit from these changes.
Modified code
About a 10% improvement. The average FPS went from 3161 FPS to 3487 FPS