Skip to content

Conversation

@Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Sep 3, 2025

Fixed #31814.

Description

The PR makes sure the internal attributes in InstanceNode honor the update ranges setup of the app level attributes.

@AndreyPrakhov With this PR, the bufferSubData() performance in your fiddle improves significantly. Do you mind testing if everything works on the functional side as expected?

@github-actions
Copy link

github-actions bot commented Sep 3, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.91
79.11
338.91
79.11
+0 B
+0 B
WebGPU 581.32
160.08
581.53
160.13
+211 B
+47 B
WebGPU Nodes 579.93
159.84
580.14
159.88
+211 B
+47 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 470.78
113.9
470.78
113.9
+0 B
+0 B
WebGPU 650.92
175.81
651.13
175.86
+211 B
+51 B
WebGPU Nodes 605.02
164.95
605.23
165
+211 B
+48 B

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Sep 3, 2025

Side note: When the instanced mesh only holds a small number of instances, InstanceNode uses buffer() which results in a UBO where update ranges are not supported yet. However, the update ranges mechanism is especially important when large attribute data should receive (small) partial updates. This use case should be supported now.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Sep 3, 2025

@sunag What was the reason for using UBOs for instanceMatrixNode in the first place? Why not just always using attributes?

Copy link

@AndreyPrakhov AndreyPrakhov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything is great. It works as expected.

@sunag
Copy link
Collaborator

sunag commented Sep 4, 2025

@sunag What was the reason for using UBOs for instanceMatrixNode in the first place? Why not just always using
attributes?

The idea was to eliminate some extra computations; the official WebGPU instancing example also uses a UBO, but the performance issue can be much broader, as the PR itself shows. I don’t think anything prevents us from using only attributes if that yields better results.

@sunag sunag merged commit 787ba7e into mrdoob:dev Sep 4, 2025
9 checks passed
@Mugen87
Copy link
Collaborator Author

Mugen87 commented Sep 4, 2025

In this case, I would say let's keep the status quo since the UBO usage only works with a small number of instances. There is probably no measurable performance difference in updating the entire small buffer or only a portion but loosing the optimization from #28726. If someone shows us the difference, we can of course always use attributes.

@Mugen87 Mugen87 added this to the r181 milestone Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebGPURenderer: updateRanges are ignored when using instancing.

3 participants