Skip to content

Conversation

zonkypop
Copy link
Contributor

Description
Currently when using updateRanges with the WebGPU renderer, the updates are being copied to the start of the buffer.

This PR sets the correct buffer destination offset for: device.queue.writeBuffer, so updateRanges work the same as the WebGLRenderer.

Copy link

github-actions bot commented Feb 26, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 336.16
78.31
336.16
78.31
+0 B
+0 B
WebGPU 522.64
145.1
522.67
145.12
+36 B
+15 B
WebGPU Nodes 522.11
145
522.14
145.01
+36 B
+16 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 465.27
112.2
465.27
112.2
+0 B
+0 B
WebGPU 593.11
160.72
593.14
160.74
+36 B
+18 B
WebGPU Nodes 548.23
150.16
548.27
150.17
+36 B
+17 B

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 26, 2025

Do you mind demonstrating the current issue with a fiddle so it is easier for us to reproduce the bug and validate your fix?

Use https://jsfiddle.net/xno7bmw0/ as a start template.

@zonkypop
Copy link
Contributor Author

Do you mind demonstrating the current issue with a fiddle so it is easier for us to reproduce the bug and validate your fix?

Here's a fiddle: https://jsfiddle.net/zonkypop/0s6u4dac/11/

You can see the difference by changing: forceWebGL: true

Tested on macOS and Linux WebGPU

@zonkypop zonkypop force-pushed the WebGPU-updateRanges-fix branch from 1310834 to 2850320 Compare February 27, 2025 22:05
@Mugen87 Mugen87 added this to the r175 milestone Feb 28, 2025
@Mugen87 Mugen87 changed the title WebGPUAttributeUtils: use correct buffer offset for updateRanges WebGPUAttributeUtils: Use correct buffer offset for updateRanges. Feb 28, 2025
@Mugen87 Mugen87 merged commit eaf72e6 into mrdoob:dev Feb 28, 2025
11 of 12 checks passed
zonkypop added a commit to zonkypop/three.js that referenced this pull request Feb 28, 2025
…rdoob#30617)

* WebGPU: use correct destination offset for updateRanges

* Take into account BYTES_PER_ELEMENT for updateRanges

* Update WebGPUAttributeUtils.js

---------

Co-authored-by: Michael Herzog <[email protected]>
@Spiri0
Copy link
Contributor

Spiri0 commented May 1, 2025

This is exactly what I was looking for to update individual parts of a storage buffer on the CPU side. I've solved this problem with a workaround so far. UpdateRanges is better.

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.

3 participants