WebGPUTextureUtils: Fix readback buffer size.#31765
Merged
Mugen87 merged 1 commit intomrdoob:devfrom Aug 28, 2025
Merged
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
mrdoob
reviewed
Aug 28, 2025
| const readBuffer = device.createBuffer( | ||
| { | ||
| size: width * height * bytesPerTexel, | ||
| size: ( height - 1 ) * bytesPerRow + width * bytesPerTexel, // see https://github.com/mrdoob/three.js/issues/31658#issuecomment-3229442010 |
Owner
There was a problem hiding this comment.
Is this more readable?
( width * bytesPerTexel ) + ( ( height - 1 ) * bytesPerRow )
Collaborator
Author
There was a problem hiding this comment.
IMO, the "( height - 1 ) * bytesPerRow" bit should come first since "( width * bytesPerTexel )" represents the last row of data.
Owner
There was a problem hiding this comment.
Then this?
( height - 1 ) * bytesPerRow + ( width * bytesPerTexel )Or even this?
( ( height - 1 ) * bytesPerRow ) + ( width * bytesPerTexel )
Collaborator
Author
There was a problem hiding this comment.
I vote for the last one!
Collaborator
Author
There was a problem hiding this comment.
Updated: 6c7d807
Definitely improves code clarity 👍 .
Owner
|
Thanks @greggman! |
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.
Fixed #31658.
Description
Turns out we have a bug in our readback buffer size computation in the WebGPU backend. We must honor the row padding in the buffer computation except for the last row. Credits to @greggman who explained the fix at the Chromium bug tracker and here: #31658 (comment) 🙌 !