feat(vulkan-rt): BLAS build options — fast-build/fast-trace + in-place refit (#36) #38
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!38
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-36"
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?
Resolves #36.
BLAS builds can now be tuned and refit.
API
Mesh::Build/Mesh::BuildProceduraltake anRTBuildOptions:preference→VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR(default, slower build / faster traversal) or…PREFER_FAST_BUILD_BIT_KHR.allowUpdate→VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_KHR, required before a BLAS can be refit.New
Mesh::Refit(verts, indices, cmd)/Mesh::RefitProcedural(aabbs, cmd):allowUpdateand the topology is unchanged, they record an in-placeUPDATE-mode build (src == dst) — much cheaper than a rebuild, and the AS handle +blasAddrare preserved so TLAS instances referencing the mesh stay valid. This mirrors the existing TLAS refit path.allowUpdate, or vertex/primitive count changed) they fall back to a full rebuild.The shared build tail also now destroys a stale AS handle on re-
Build(it was previously leaked) and guards the in-place update with an acceleration-structure read→write barrier.Cross-backend
The portable
RTBuildPreference/RTBuildOptionstypes and theRefit/RefitProceduralmethods also exist on the WebGPU backend so portable code compiles unchanged. The software BVH has no hardware AS, so the preference is a no-op and a "refit" rebuilds the host BVH (documented: this re-registers the handle, unlike the in-place Vulkan path).Testing
crafter-build test— 3 passed (MouseScroll,PushConstantRewrite,BLASBuildOptions).The new
BLASBuildOptionstest drives the real hardware AS-build path on the GPU (headless — a BLAS build only needs the queue + command pool). It builds and refits both triangle and procedural BLASes and asserts:ALLOW_UPDATEbits land inMesh::buildFlags;allowUpdaterefit keeps the same AS handle andblasAddr(proves the in-placeUPDATEpath);VK_LAYER_KHRONOS_validationon an RTX 4090.To support that last check,
Device::validationErrorCountnow counts ERROR-severity debug-messenger messages.🤖 Generated with Claude Code
Mesh::Build / BuildProcedural now take an RTBuildOptions { preference, allowUpdate }. `preference` maps to PREFER_FAST_TRACE (default) or PREFER_FAST_BUILD; `allowUpdate` sets ALLOW_UPDATE so the BLAS can be refit later. Adds Mesh::Refit / RefitProcedural: when the original build opted into allowUpdate and the topology is unchanged, they record an in-place UPDATE-mode build (src == dst) — much cheaper than a rebuild, and the AS handle + blasAddr are preserved so TLAS instances stay valid. They fall back to a full rebuild otherwise. The shared build tail also now destroys a stale AS handle on re-Build (previously leaked) and guards the in-place update with an AS read→write barrier. The portable RTBuildPreference/RTBuildOptions types and Refit methods also exist on the WebGPU backend for API symmetry; the software BVH has no hardware AS, so the preference is a no-op and a "refit" rebuilds the BVH (re-registering the handle). Also adds Device::validationErrorCount, bumped by the debug-messenger callback on ERROR-severity messages, so tests can assert a Vulkan operation produced no validation errors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>