Repository navigation
Scene step D, first part: the light list holds its triangles - #147
Merged
Merged
Conversation
Light sampling read an emitter's triangle from the triangles' table as world space, so whatever emits had to be stored there in world space (flattened, or a mesh of its own written in world space). The list now has its own copy, the way real-time engines keep a light list: `Table::EmitterTris`, one `GpuEmitterTri` an emitter (v0, e1, e2 in world space; its triangle, object and light-tree path code). The kernel's emitter sampling, light LOD, cull and `emit_mis` read it. A CDF entry names its emitter; a triangle's attributes name its emitter entry (x.w, where the path code was). The copies follow what moves (`move_emitters`: the emitters the CPU moves) and what edits make (`write_emitters`). A particle's is still read where its pass places it. Nothing is placed otherwise yet. Cost: 48 B an emitter; the trace +0.07 to 0.10 ms where emitters are sampled (Bistro 7.18 -> 7.29 ms, Tokyo 4.41 -> 4.42, none without emitters), not attributed; 0.2 ms of CPU a frame for the crowd's 21,280 moving emitters, which a GPU pass is to take over. Pictures: big scenes within main's own run-to-run difference; 26 of the suite's 239 outputs differ in their last bits. Test: `the_light_list_holds_its_triangles` reads the list and the triangles back from the GPU after a load, a move and in-place edits. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
yujiaxu-ops
added a commit
that referenced
this pull request
Nov 17, 2026
What moves an emitter after the light list was written is copied into the list by a pass (`emitter_fill.wgsl`, what real-time engines call preparing the lights): a run of the list an invocation row, each emitter's rows taken again from its triangle. - The emitters of the triangles the CPU reposes: filled after a commit that moved them, in place of the CPU's rewrite (the crowd's commit back at main's level: 4.5 ms in a guarded run, 4.9 to 5.0 with the rewrite). - The particles': filled after their passes, live and offline, so the kernel reads every emitter from the list; its particle case is gone. `EmitterRuns` at prepare, `gpu::EmitterFills` a scene (with hardware ray tracing), the pipeline made once. Pictures: against #147's build 217 of 239 outputs byte-identical, 19 within their own spread, the two light-sampled particle tests in their last bits; on Vulkan 219 byte-identical, 17 within, 0 changed. Test: the readback test covers particles (collapsed as loaded, placed after a frame) and the movers through the pass; four mutants caught. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This was referenced Nov 17, 2026
yujiaxu-ops
added a commit
that referenced
this pull request
Nov 17, 2026
A model's emitting triangles were flattened at every placement (world space, for light sampling: the reason #147 took away), and a movable or posed model re-transformed them on the CPU every frame. They stay in the model's mesh now, as real-time engines have them: a static placement's, a movable model's, a rigid posed model's moving nodes'. No shader change. - Flattened a placement: Tokyo 1,800,744 -> 0 triangles, Bistro 20,638 -> 0, Zero Day 10,105 -> 4, the crowd's moving nodes 18,400 -> 0. - One case stays flattened: a triangle that emits with a cutout on exactly its vertices goes with the cutout (`flatten_coincident`, for a still placement and a rigid node alike; Zero Day has one such pair). In one BLAS the decal's pass-through stepped the ray past the emitter. The unbiased check on Zero Day is the guard. Cost and gain (trace p50, main -> this): the crowd 7.38 -> 7.37 ms and its commit 4.46 -> 3.61 ms; Bistro 7.20 -> 7.13; Zero Day 7.68 -> 7.71; Tokyo 4.45-4.50 -> 4.59-4.62 (+2.9 %: instancing its 1.8 M emitting triangles; the mechanism is not established). Taken for the standard structure; the way back is merging still geometry whole, a step of its own. Tests: `geometry/emitter-model` (analytic); the readback test with a model still, moved, and posed by a clip; a structural test of the pair rule (`panel-decal.glb`); mutants caught. Against main the new test alone differs (last bits); Vulkan agrees, natively and under software traversal. Left: an instanced object's copies (next), a deforming mesh's emitters, a model with emitters added in place (still rebuilds). Co-Authored-By: Claude Fable 5.2 <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.
Scene step D, first part (PLAN: emitters off the flattened triangles). No behaviour change intended; it prepares emitting meshes on instances.
What
Light sampling read an emitter's triangle from the triangles' table as world space, so whatever emits had to be stored there in world space: flattened, or a mesh of its own written in world space (Tokyo: 1.6 M triangles flattened for it). The light list now has its own world-space copy, the way real-time engines keep one.
Table::EmitterTris: oneGpuEmitterTrian emitter (v0, e1, e2; its triangle, object, light-tree path code).emit_misread it. A CDF entry names its emitter; a triangle's attributes name its emitter entry (x.w, where the path code was).move_emittersrewrites the copies of the emitters the CPU moves;write_emitterswrites those that edits make.Cost (Metal, 1280x720 at scale 0.75, trace p50, alternating runs)
Pictures
cargo test167 passed there; test-render fails the same five tests as main does on that machine.Tests
cargo test167 passed, test-render 239 pass.the_light_list_holds_its_triangles: reads the list and the triangles back from the GPU after a load, a move (with and without a light tree) and in-place edits (a mesh added, changed, removed; a material that starts emitting). Twelve mutants of the upkeep, each caught.Next
🤖 Generated with Claude Code
Note
Medium Risk
Touches core light sampling, MIS, and live emitter maintenance on the GPU path; behavior is intended unchanged but adds memory, a small trace cost, and Metal-only numerical drift in some outputs.
Overview
Introduces a dedicated
Table::EmitterTrislight list so emitter sampling no longer depends on emissive geometry living in the main triangles buffer in world space. Each emitter gets aGpuEmitterTri(world-space v0/e1/e2, source triangle id, object index, light-tree path code / move flag).The emitter CDF now keys entries by emitter list index; triangle
x.wstores the emitter entry + 1 (replacing path codes in attributes). The path-tracing kernel (emitter_tri_at,emitter_tri_of,emit_mis, LOD/cull, NEE) reads this table, with a particle exception still sourcing verts from the triangle buffer when placed per frame.CPU upkeep extends live loading and edits:
Preparedbuildsgpu_emitter_tris, upload/render threads the buffer through,move_emittersrewrites moving emitters, andwrite_emittersuploads new/changed entries and attribute back-pointers. Heap growth and bind rebinding cover the new section.Docs (ROADMAP, RUNTIME) and
the_light_list_holds_its_trianglesGPU readback tests lock the list against triangles after load, moves, and in-place edits.Reviewed by Cursor Bugbot for commit 0016488. Bugbot is set up for automated code reviews on this repo. Configure here.