Repository navigation
Units: in-place edits under software traversal (a two-level tree); hello world in Chrome 0.84 ms a frame a body moves (was 16.7) - #21
Merged
Conversation
…versal (units, a top tree after the still scene's) Co-Authored-By: Claude <noreply@anthropic.com>
…lk (trace_units.wgsl) and its transcription against brute force renderer/src/units.rs: a mesh's tree (SAH as the still scene's, median splits when deeper than the stack allows), the top tree (median splits, one unit a leaf), the checks a tree passes before it is written (children after their parent and inside the tree, every node reached once, leaves inside their mesh, depth), where trees go in the node buffer (first fit, runs joined when trees go). Room holds leaves that end. renderer/shaders/trace_units.wgsl: the walk (not yet spliced into any kernel). Tests, no GPU: the walk transcribed statement for statement (with a check that the statements are still the shader's), every read bounds-checked and every iteration counted, over 12 random scenes under 568 random edits (meshes and units added, moved, removed, overlapping, emptied): the closest hit is brute force's to the bit, any-hit walks find something exactly when there is something; broken trees are refused. Co-Authored-By: Claude <noreply@anthropic.com>
…raversal; the kernel's source gets the unit walk by a source feature (WIP: edits in place not wired yet; nothing run on a GPU) prepare (software traversal): a tree for each instanced mesh that keeps its shape, its pool triangles in the tree's order with their cutout flag, the trees and the top tree after the still tree's nodes with room (FILL), each unit's record with its tree's root and shadow flag; meshes that deform are still flattened; THREERT_UNITS=0 flattens everything as before. gpu.rs: F_UNITS (kernel_source splices shaders/trace_units.wgsl into the software traversal and calls it after the still scene's walk; pathtrace.wgsl is not edited), Uploaded::units, Top (the TLAS or the units, for edits), retop, write_tree. Tests (CPU, naga): the splice is inside the software traversal only and comes out again leaving the file; the merged layout with units is valid WGSL with 8 storage buffers; the loop guard opens the unit walk's loops. Co-Authored-By: Claude <noreply@anthropic.com>
…nced and edit_geometry go through gpu::Top (the TLAS or the units); a scene with units is the flattened scene to every ray, on the CPU (WIP: nothing run on a GPU) Co-Authored-By: Claude <noreply@anthropic.com>
… record names a tree that is gone or sits past the kernel's records; freed trees are filled with leaves that end; the units' words move to Params.motion.z/.w (.y is render --signals'); an instance of a deforming mesh is no unit and rebuilds; the first instanced mesh of a scene without units says so (WIP: nothing run on a GPU) Co-Authored-By: Claude <noreply@anthropic.com>
…L.md's browser statements); a scene with more instances than a top tree holds is flattened, as before (WIP: nothing run on a GPU) Co-Authored-By: Claude <noreply@anthropic.com>
…h's); binned SAH over the catalog's large models is 35 and 42 deep, which 30 sent to median splits (WIP: nothing run on a GPU) Co-Authored-By: Claude <noreply@anthropic.com>
…triangle without area (the empty tree's leaf named triangle 0, which there is a mesh's first, in model space: seen on the first GPU run, geometry/instanced darker towards the origin); a CPU test of such a scene, with rays through the origin Co-Authored-By: Claude <noreply@anthropic.com>
…ftware traversal's room does not grow: a second copy of a still model rebuilt the scene); the grown emitter buffer keeps its usage (the merged layout copies the tables each frame: an emitter added in place died in wgpu validation); refused-room reasons name software traversal Found by the single edit tests on the GPU, software traversal with the guard, one command each. Co-Authored-By: Claude <noreply@anthropic.com>
…he guarded ones alone for a kernel not yet run unguarded) Co-Authored-By: Claude <noreply@anthropic.com>
…box's click does: a check (Chrome: a frame in which a body moves 0.84 ms of page time, was 16.7; a click's box 0.6-0.8 ms, was 18-24) Co-Authored-By: Claude <noreply@anthropic.com>
…n when the top tree is built (a mesh written again where it was kept the bounds it had: voxel/cut-falls-live under software traversal, a part that fell 0.2 m cut off at its old box; found by the atomic suite); a CPU test. test-render: a live test's frames the loop guard stopped fail the run Co-Authored-By: Claude <noreply@anthropic.com>
…', 'Measured'; ROADMAP step 7b's status, acceptance and open points; VOXEL's browser statement): hello world in Chrome 0.84 ms a frame a body moves (16.7), the voxel level 310.9 MiB and 2.5-4.5 ms an explosion (2,098 MiB, 7 s), a still frame's trace 16-71 % longer than flattened, the guard 11 % of Kabukichō's trace Co-Authored-By: Claude <noreply@anthropic.com>
…tware traversal offline flattens as before units unless THREERT_UNITS=1: the reference render and the catalog's byte gate keep main's kernel and bytes with nothing set); a native kernel with units has the loop guard with nothing set (65,536; THREERT_LOOP_GUARD=0 takes it out; a kernel without units as before) Co-Authored-By: Claude <noreply@anthropic.com>
…rsal with units': where units are used, what a still frame costs, what was not run; ROADMAP step 7b: the two decisions, the cost table as the first open point, the runs not made one by one; Known issues: the 23 atomic tests that fail under software traversal on main, hardware traversal's five bundles that do not repeat); the frame log's guard is null while the scene's kernel has none Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Software traversal edits in place. ROADMAP § 6 step 7b, design A of the note agreed before it: the still scene stays the one flat tree it was; a model instance stays an instance, a unit, with its mesh's tree in model space, found through a top tree walked after the still one. A browser has no ray queries, so this is the browser's path; natively it is
THREERT_HWRT=0.renderer/src/units.rs: mesh trees (relocatable: child indices count from the root), the top tree (median splits, rebuilt whole when a unit is added, moved or removed, as the TLAS is), where they sit in the node buffer, and the checks made on the CPU wherever a tree is written.renderer/shaders/trace_units.wgsl: the unit walk, spliced into software traversal by a source feature (F_UNITS) for scenes that have units.pathtrace.wgslis not edited. No new binding: the merged layout still has 8 storage buffers; the top tree's root and the unit count travel in two free words of the frame's parameters, a unit's tree root and shadow flag in two free words of the instance record.gpu::Top(the TLAS or the units):move_instances,update_instancedandedit_geometryare one path under both traversals. In place now under software traversal: a unit moves; an instance of a known mesh is added or removed; a new mesh is added; a mesh changes (a voxel edit); a mesh is removed.threert-render render) under software traversal flattens every instance as before this PR, kernel and bytes main's, with nothing set.THREERT_UNITS=1gives an offline render units;THREERT_UNITS=0flattens a session too (the A/B).THREERT_LOOP_GUARD=0takes it out). A native kernel without units has none by default, as before: no existing byte changes. A stop does what it did: an offline render fails, a session logs it (guardin the frame log),test-renderfails the run.What it costs (the next item's work, "Open" 1)
Software traversal, live, 1280 × 720 traced at half, Apple M5 Pro, the loop guard on in both columns:
What it buys
Not run (outside the GPU runs agreed for this step; each is asked for before it is made)
THREERT_UNITS=1) or live, except Kabukichō:instancing(1,000 units),khronos-*,zero-day,zero-day-animated(3,991 overlapping units), Bistro.For the other line
the_default_sources_are_untouched: SHA-256 for both traversals and every combination of source features);preparetakes no new branch under it; its layouts and buffers are as they were.THREERT_HWRT=0, or a browser): a scene with model instances now keeps them as units, its kernel gets one extra call (trace_units) after the still walk, and natively that kernel has the loop guard. Kabukichō live: frame GPU 17.2 ms where main's is 14.1 (trace +16 % for units, +11 % for the guard), triangle data 55 MiB instead of 634, first frame 1.55 s instead of 3.3.THREERT_UNITS=0is main's kernel;THREERT_LOOP_GUARD=0takes the guard out.Measured (Apple M5 Pro; natively
THREERT_HWRT=0withTHREERT_LOOP_GUARD=65536; "flat" =THREERT_UNITS=0; live views 1280 × 720 traced at half; other applications held part of the GPU; made while an offline render had units by default too)Hello world in Chrome 157 (
tools/web-hello.ts --frames), ms p50 / p95:The scripted test passes at 640 × 360 and 1280 × 720, report and clicks the native run's number for number; it now checks that no frame rebuilds the scene and only the first box's click does.
Hello world natively:
tools/physics-hello.tspasses under software traversal, the two checks that failed there among them (commitsrebuild, in place × 4). A frame in which a body moves: commit 0.02 ms (flat 8.65); a click's commit 0.25–0.35 ms (9.1–9.6). The trace 1.40–1.42 ms against 1.01–1.04.The voxel level (10,459 units of 6,410 meshes; flattened 13.2 M triangles):
Kabukichō (352 units of 19 meshes):
THREERT_UNITS=1)The guard and the merged layout on Kabukichō (flat, main's kernel; frame GPU / the trace): as written 14.11 / 10.78; merged 14.29 / 10.91; with the guard 15.35 / 12.01; merged with the guard 15.66 / 12.28. The guard: +1.23 ms of trace (11 %). The merged layout: +0.13 ms.
The atomic tests under software traversal (the first whole run on this machine; a family a command, guard on; made while offline tests had units too): 147 of 170 pass, as written and merged alike. The 23 that fail fail on main's build too, with the same values:
particles/count-zero,particles/emissive-spark,particles/emissive-spark-nominal,particles/emissive-unsampled,particles/follow-emitter,particles/hidden-in-place-live,particles/instance-data,particles/lit-normal,particles/lit-orientation,particles/motion-repose,particles/node-custom,particles/quad-placement,particles/shown-in-place-live;gpu-particles/beside-particles,gpu-particles/plane,gpu-particles/voxels,gpu-particles/voxels-live,gpu-particles/voxels-side;translucent/depth,translucent/order.volume/lighting,volume/lighting-offline(6 for 1). Main's, on this basis: both measure one translucent particle in a closed cube with one 6-nit wall behind it (their features areparticles,translucency); without the particle the region is the wall. (This PR's text before called these two unexplained by a missing feature; that was wrong: they are the same missing particles.)surface/windows(0.3934 for 0.4234). Main's, on this basis: the scene is one plane with the library's facade windows and no instance, so nothing of this PR is in its kernel (the source is main's byte for byte), and main's build reads the same 0.3934 in both layouts. Its cause was not looked for.The last three are in ROADMAP "Known issues" now, as the other line's.
Full tables: docs/RUNTIME.md "Software traversal with units", "Measured".
What the GPU runs found (both fixed, each with a CPU test)
voxel/cut-falls-live: a falling part was cut off at the box it had before it fell. Found by the atomic suite. A unit's box is now its mesh's tree's bounds, read when the top tree is built.tools/test-render.tsnow fails a run in which the loop guard stopped a live test's frames (it only printed it).meshes[k].lo/histale, under both traversals (object entry size, pick bounds). It is main's behaviour; changing it changes hardware traversal.Why the loops end
Every index the walk reads is checked on the CPU where it is written: a child index is greater than its parent's and inside its tree's range, a leaf's triangles inside its mesh's and at most 16, a top leaf's record a unit's. A tree that fails is not uploaded; the scene is rebuilt. Room not yet used holds leaves that end, not zeros. The stack is 64 entries (18 for the top tree: 2^18 units; 46 for a mesh's; a deeper SAH tree is rebuilt by median splits). The CPU tests transcribe the two walks from the shaders line for line and run random scenes under random edits against brute force. In every GPU run the guard stopped nothing.
Tier: R1
The renderer's library changed; hardware traversal, every offline render and every scene without instances are unchanged. No existing shader file changed.
Merge gate (run again on the defaults as they are now; perf smoke and the hardware catalog not run again, as agreed)
Current with main: head f45708e, main a707e1c,
behind_by0.npm run typecheck: pass.npm test: 127 / 127.CPU: the sources handed to wgpu with nothing set are main's hashes (
the_default_sources_are_untouched); an offline render of a scene with instances has no unit, noF_UNITS, and the flattened scene's triangle and node bytes (an_offline_render_has_no_units_unless_told); a kernel with units has the guard at 65,536 with nothing set, none atTHREERT_LOOP_GUARD=0, and naga validates it (a_kernel_with_units_has_the_loop_guard).cargo test --release(renderer): 78 passed, 2 ignored, the five that open the GPU among them.Byte identity against main a707e1c, software traversal,
THREERT_UNITSnot set (offline, 320 × 180, 4 spp, HDR and PNG): 23 / 23. Both builds ran withTHREERT_LOOP_GUARD=65536, as every GPU run of this step; that the kernel without the guard is main's too is the hashes' test, not a render.Hello world natively with nothing set but
THREERT_HWRT=0(tools/physics-hello.ts: units and the guard by default): every check; commitsrebuild, in place × 4; 812 of 823 frames' kernel has the guard (the eleven before the first box have a kernel without units), guard count 0.test:render(hardware traversal): 170 / 170. One value moved:volume/lighting1.006 (was 1.019, alone again 1.015; a live test with the radiance cache, passing at each).Chrome, the scripted test once: every check; guard count 0 in 826 frames; no frame rebuilt the scene; the report the native run's number for number.
Hardware traversal's catalog, from the head before (0eaf44a; hardware traversal is untouched since): 18 / 23.
bistro,bistro-slice,bistro-district,zero-day,zero-day-animateddiffer from main in 1,884 / 133 / 80 / 9,507 / 8,850 of 57,600 pixels; main against main on the same five: 1,782 / 1,095 / 125 / 7,988 / 10,426. The same order of magnitude: these five do not repeat on one build under hardware traversal (ROADMAP "Known issues": the new entry with these figures, and hardware traversal's ties between coincident surfaces).Perf smoke, from the head before: the tool's verdict was FAIL, three times; read as this machine's spread with both builds alternating (A = main, B = branch):
Every figure sits at one of two levels, about 7.8 and 9–11 ms, on both builds. Why the machine has two levels I have not established.
GPU runs: one process under a lock, smallest first, with the loop guard, nothing killed, nothing retried; all returned; the one batch (
byteid.ts) was first shown to stop at a render that must fail (the guard at 16). The list and each result:out/web-probe/gpu-runs-b.md(beside the checkout). One slip: after the last doc change I ran the library's tests with a filter that matched nothing, so the five tests that open the GPU ran outside the lock script (78 passed in 3.5 s; nothing left behind).Open
THREERT_UNITS=0), at its memory and load time.🤖 Generated with Claude Code