Skip to content

A posed skinned model is posed in place under software traversal - #184

Merged
yujiaxu-ops merged 9 commits into
mainfrom
skinned-sw
Nov 21, 2026
Merged

yujiaxu-ops merged 9 commits into
mainfrom
skinned-sw

Conversation

@yujiaxu-ops

@yujiaxu-ops yujiaxu-ops commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Under software traversal a mesh that deforms was written out into the still scene's tree, so every pose of a skinned model rebuilt the scene. Now it is a unit as any mesh, posed in place.

  • Its tree. The shape of a tree built once over its model's bind pose, one shape for every placement of the model (the skinning pass's corners and each such mesh's triangles are in that tree's order), with the boxes of its pose.
  • A new pose. The model's corners placed on the CPU, the tree's boxes taken again (units::refit: a leaf's from its triangles, an interior node's from its children), the nodes written where they lie, the unit's new bounds to the top tree. The skinning pass writes the triangles and attributes as under hardware traversal, without the BLAS input (override BLAS).
  • Hidden, shown, removed: as any unit.

Why the boxes alone: a tree made again for a pose costs sixty times as much (a character of 13,744 triangles, one core: 3.0 ms against 0.05) and traces 5 % faster where characters fill the view; the clip's first pose is no better a shape than the bind pose.

Still a rebuild under software traversal: a skinned model added. Its triangles and its tree need room, which a scene has there only with geometry of its own to edit, and which does not grow there.

Measured

Software traversal, 1280 x 720:

main this
a game with a character posed every frame: CPU a frame 30.6 ms, every frame a rebuild 3.2 ms, none
a crowd of 150 walkers: a frame 2.0 s, every frame a rebuild 7.6 ms of commit, none
trace, nothing moving, four characters filling the view 4.67 ms 5.20 ms
trace, nothing moving, the crowd standing in a street 85.2 to 85.5 ms 84.6 to 84.8 ms
  • Of the 11 % on the four characters, 6.5 % is the scene having units at all (its kernel had no unit walk before) and 4.9 % the kept shape: the same units with trees built for the pose trace in 4.97 ms. Builds in turn after a run thrown away.
  • What a pose costs the CPU: the corners' positions (0.2 ms a character of 13,744 triangles, one core) and the boxes (0.05). The crowd's commit is 7.6 ms, against 3.3 under hardware traversal, whose BLASes the GPU builds.

Hardware traversal is as it was: the pose path there is main's. GPU time a frame at 1080p on twelve scenes, alternated against main after a run thrown away: all within 0.8 %, the crowd of skinned walkers +0.0, +0.0, +0.5 and -0.2 % in four pairs measured alike. The pictures are main's.

Checks

  • Tests under both traversals: four models of two files, each mesh's triangles, attributes and previous vertices on the GPU against the CPU skin, after poses in place and after a build; under software traversal each mesh's tree read back (its model's links, a leaf's box its triangles', an interior node's its children's), its bounds its root's, its unit's leaf of the top tree; the motion vectors of a pose no longer than the furthest a corner went; one hidden, posed while hidden, shown; one removed. A unit test of the boxes taken again (corners that are not finite too).
  • The unit tests and the render tests, natively and under software traversal, beside main's on the same machine: 215 unit tests pass both ways (three more of them run under software traversal than did); 264 render tests natively; under software traversal the 23 that fail on main, and no other.
  • 22 mutations of the new logic: 20 fail a test under software traversal, one natively (the pass bound again when the scene's buffers grow, which they do under hardware traversal alone), and one is equivalent (the pass writing the BLAS input under software traversal: the writes fall in a spare word no one reads; the constant saves the work). Three lines that told the traversals apart where no test could were taken out: the pose path is one for both.
  • The page's test in Chrome passes as before (hello world; no browser test has a skinned model yet).
  • Not run on Vulkan yet.

🤖 Generated with Claude Code


Note

Medium Risk
Changes the live commit path for animated meshes, GPU skinning bindings, and BVH correctness under software traversal; broad test coverage mitigates risk, with a known ~11% static trace cost when many skinned units are present.

Overview
Software traversal no longer flattens deforming skinned meshes into the static scene tree on every pose (which forced full rebuilds). They are units like rigid meshes: one BVH shape from the model’s bind pose, boxes refit on the CPU each pose (units::refit), nodes uploaded with write_nodes, and the top tree updated from the unit bounds—while the skinning pass still updates triangles/attributes.

The skin compute shader gains a BLAS pipeline override so software traversal skips BLAS vertex writes; skin_pass binds a stub buffer when there is no hardware accel. Scene/load plumbing keeps skin_sources, skin_rest, and skin_trees on the CPU for in-place repose (repose_skinned).

Edits/docs/tests: pose, hide/show, and remove skinned models in place under both traversals where tests previously skipped software paths; adding a new skinned model under software traversal still triggers rebuild when edit room cannot grow. ROADMAP and RUNTIME document behavior and measured CPU gains (e.g. per-frame character pose ~30.6 ms → ~3.2 ms) with a small static-trace cost when units are used.

Reviewed by Cursor Bugbot for commit 0f66ea3. Bugbot is set up for automated code reviews on this repo. Configure here.

yujiaxu-ops and others added 9 commits November 21, 2026 23:23
Made again, or its boxes taken again in a kept tree, and how much worse such a tree walks (ignored; THREERT_SKIN_GLB).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Its mesh was written out as world-space triangles in the still tree, and every pose rebuilt the scene. Now it has a
tree as any unit's mesh: the shape of the tree over its model's bind pose (one shape a model; the model's corners
and the mesh's triangles in its order), its boxes the pose's. A new pose takes the boxes again on the CPU from the
corners placed by the pose, and the skinning pass writes the triangles (it has a variant without BLAS output).
Hidden, shown and removed, it is a unit's.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… motion held by tests

The pass-against-the-CPU-skin test runs under both traversals: under software
traversal each mesh's tree is read back (its model's links, the pose's boxes),
its bounds and its unit's leaf of the top tree checked, after poses in place
and after a build. A unit test of the refit. The runtime doc's table.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…rsal

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…and it

Two branches by traversal that mutation showed no test could tell apart:
the commit ignores the list of meshes to build under software traversal,
as it does for other edits; the pass's bind group is made again in one
place, with the BLAS input or what stands there.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tions

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@yujiaxu-ops
yujiaxu-ops marked this pull request as ready for review November 21, 2026 17:08
@yujiaxu-ops
yujiaxu-ops merged commit d2d6f27 into main Nov 21, 2026
9 checks passed
@yujiaxu-ops
yujiaxu-ops deleted the skinned-sw branch November 21, 2026 17:18
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.

1 participant