feat(rt): BuildProcedural — accept a device AABB buffer as build input (#37) #39
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!39
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-37"
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?
Summary
Mesh::BuildProcedural(and the refit path from #36) can now take the AABB build input straight from an existing device buffer instead ofmemcpy-ing a hoststd::spanthroughMesh::aabbBuffer. This is the input-source companion to #36's per-frame-cost work: together a GPU compute producer (e.g. the 3DForts GPU-resident particle system) can feed a moving procedural BLAS that builds/refits every frame with zero host involvement.Resolves #37.
API
Vulkan (
interfaces/Crafter.Graphics-Mesh.cppm):BuildProcedural(VkDeviceAddress aabbAddress, uint32 count, bool opaque, VkCommandBuffer cmd, RTBuildOptions = {}, uint32 stride = sizeof(RTAabb))RefitProcedural(VkDeviceAddress aabbAddress, uint32 count, VkCommandBuffer cmd, uint32 stride = sizeof(RTAabb))These feed the device address directly into
VkAccelerationStructureGeometryAabbsDataKHR— no copy,aabbBuffernever allocated. The caller owns the buffer's usage flags (ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY+SHADER_DEVICE_ADDRESS) and barriers the producing writes. The host-span path is refactored to shareRecordProceduralBuildFromAddressand is otherwise unchanged.WebGPU (software-RT): device-buffer
BuildProcedural/RefitProceduraltake aWebGPUBufferRef+ count +worldBounds. The boxes are copied GPU→GPU into the mesh heap (newwgpuRegisterMeshBLASDeviceAabbs/wgpuRefitMeshBLASDeviceAabbsbridge fns) and wrapped in a single root leaf bounded byworldBounds— no wasm round-trip, andblasAddrstays stable across a refit so TLAS instances remain valid.Testing
BLASBuildOptionstest (gatescrafter-build test): a device-local AABB buffer filled via a staging copy + barrier (standing in for a GPU compute producer) is fed into the new device-address build/refit. Asserts the build/refit succeed, the in-place UPDATE keeps the AS handle +blasAddr, the hostaabbBufferis never allocated (proof of zero-copy), and the Vulkan validation layer reports zero errors.3 passed.examples/RTVolumeextended on both backends: a compute shader (aabbs.comp.{glsl,wgsl}) writes the procedural box into a device buffer thatBuildProceduralconsumes by device address/handle with no host copy; the WebGPU path refits from it each frame (breathing box). Verified rendering on Vulkan (native) and WebGPU (browser).Screenshots
Vulkan (native)
WebGPU (browser)
A compute shader (aabbs.comp.{glsl,wgsl}) writes the procedural box into a device buffer that BuildProcedural consumes by device address/handle with no host copy; the WebGPU path also refits from it each frame so the box breathes. Verified rendering on both Vulkan (native) and WebGPU (browser). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>