Skip to content

Fix GPU queries of multi-geometry BatchedMesh - #912

Merged
gkjohnson merged 3 commits into
gkjohnson:masterfrom
VoidingWarranties:fix-batched-blas-offsets
Aug 1, 2026
Merged

Fix GPU queries of multi-geometry BatchedMesh#912
gkjohnson merged 3 commits into
gkjohnson:masterfrom
VoidingWarranties:fix-batched-blas-offsets

Conversation

@VoidingWarranties

Copy link
Copy Markdown
Contributor

A non-indirect MeshBVH built with a range stores absolute offsets in its leaves, but the BLAS packing in BVHComputeData.update computes geometryOffset as 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/
Screenshot 2026-07-25 at 17 50 52

And for completeness here's the original JSFiddle: https://jsfiddle.net/8xm250v3/1/
Screenshot 2026-07-25 at 17 51 48

VoidingWarranties and others added 3 commits July 25, 2026 18:42
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.
@gkjohnson

Copy link
Copy Markdown
Owner

Thanks!

@gkjohnson
gkjohnson merged commit fa1f19e into gkjohnson:master Aug 1, 2026
6 checks passed
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.

BVHComputeData reads the wrong triangles for every BatchedMesh geometry after the first

2 participants