Skip to main content

Module rt_refit

Module rt_refit 

Source
Expand description

Backend-agnostic refit cadence for the per-frame skinned bottom-level acceleration structures. A skinned object’s BLAS traces vertices a compute pass re-poses every frame, so it has to be updated every frame – but while the triangle set is unchanged that update can be a REFIT (Vulkan’s VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, DXR’s PERFORM_UPDATE), which re-fits the existing tree’s bounding volumes in place instead of rebuilding it from scratch.

A refit keeps the tree the last full build produced, so traversal quality decays as the pose drifts away from the one that tree was built for; this module bounds that with a periodic full rebuild. It owns only the pure decision – the descriptors, the allocation and the recorded build are per-backend (directx/raytrace.rs, vulkan/raytrace.rs). Split out so the cadence is unit-testable without a GPU.

Consumed by the DirectX + Vulkan backends. The Metal backend keeps its own equivalent copy (metal/rt_ring.rs), the same split rt_topology already has.

Structs§

SkinnedRefit
One ring slot’s refit bookkeeping: the geometry its BLAS were last built over, whether they hold a tree a refit can update, and how many consecutive refits have run since the last full build.
SkinnedShape
The geometry one skinned BLAS is built over: its slice of the shared skinned index buffer plus the vertex range the deformed buffer spans. Equal signatures mean the same triangles addressing the same vertex range with only the positions moved, which is exactly when a refit is legal; anything else (a mesh hot-reload, a different mesh becoming visible, a grown deformed buffer) changes the geometry description and needs a full rebuild. vertex_extent is carried because both APIs require the vertex count to match the structure being updated, even though the vertex buffer’s address may move.

Enums§

BlasUpdate
Whether a slot’s skinned BLAS can be refit from this frame’s pose or must be rebuilt from scratch.

Constants§

REFIT_LIMIT
Full rebuilds per ring slot: after this many consecutive refits the next skinned update rebuilds that slot’s BLAS from scratch. Each slot counts independently and they are touched on different frames, so the rebuilds stagger rather than landing on one frame.