perf(rt): batch the WebGPU TLAS instance upload into one writeBuffer (#131) #150
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics!150
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-131"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
In
BuildTLASUpload(implementations/Crafter.Graphics-RenderingElement3D-WebGPU.cpp), GPU-driven (transformOwnedByGpu) runs uploaded one element at a time — a separateFlushDeviceRangeof the 16 strided metadata bytes per element — each paying per-call WebGPU validation / encode / JS-boundary cost. The CPU-driven arm already batched contiguously.Found by an adversarially-verified performance audit. Currently latent:
transformOwnedByGpuis set nowhere in-repo.Fix
Upload the whole active instance range in a single
writeBuffer. Pushing the (stale) transform bytes for GPU-driven slots is harmless: the only supported way to drive a transform from the GPU is the manualUpload -> physics compute pass -> Buildsequence (see the file header), and that compute pass runs after the upload and rewrites the transform on the GPU before the TLAS build reads it. Nothing readsinstanceBufferbetween Upload and that compute pass.For the in-repo (all-CPU) usage the GPU bytes uploaded are byte-for-byte identical to before: with a single CPU-driven run the old loop already emitted exactly this one
FlushDeviceRange(0, 0, primitiveCount*64). The only behavioral change is that the latent GPU-driven path now batches into that same single write.Testing
crafter-build test— 24 passed.Screenshots
Resolves #131
🤖 Generated with Claude Code