Fix GPU queries of multi-geometry BatchedMesh - #912
Merged
gkjohnson merged 3 commits intoAug 1, 2026
Conversation
A non-indirect MeshBVH built with a range stores absolute offsets in its leaves, but appendBVHSubtree treats them as relative when packing the BLAS. As a result, every geometry after the first points at another geometry's triangles or runs past the end of the buffer. Subtract the range's triangle start from the geometry offset.
Owner
|
Thanks! |
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.
A non-indirect
MeshBVHbuilt with a range stores absolute offsets in its leaves, but the BLAS packing inBVHComputeData.updatecomputesgeometryOffsetas if leaf offsets were relative. As a result, every geometry whose range doesn't start at triangle 0 points at another geometry's triangles or runs past the end of the buffer.This PR's fix subtracts the range's triangle start from the geometry offset.
Fixes #905
I omitted a regression test because I thought tests that import the WebGPU API would cause the CI's three@0.159.0 runs to fail, and it was too awkward to be worth it to write a test that worked around that.
JSFiddle with fix: https://jsfiddle.net/8xm250v3/3/

And for completeness here's the original JSFiddle: https://jsfiddle.net/8xm250v3/1/
