Skip to content

Textures, models, functions and lights come in place; the kernel is made beside the frames - #199

Merged
yujiaxu-ops merged 10 commits into
mainfrom
step-g
Nov 23, 2026
Merged

yujiaxu-ops merged 10 commits into
mainfrom
step-g

Conversation

@yujiaxu-ops

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

Copy link
Copy Markdown
Collaborator

Textures, models, functions and lights come in place; the kernel is made beside the frames

A game that brought a texture, a model, a material function or a light while it ran had the scene built again from the world, and a feature a scene first used had the next frame wait for the driver's compile. On Bistro (2.8 M triangles, 960 x 540, an M5 Pro), the frame the edit landed in:

main this
fog appears (a kernel variant not compiled before) 0.8 to 2.4 s no long frame (28 ms at most)
a mesh with a new 256 x 256 texture 4.5 to 4.6 s 39 to 56 ms
a mesh with a new material function 2.3 to 4.2 s no long frame (19 ms)
a model the scene has not (15 k triangles, five 2048 x 2048 textures) 4.8 to 5.2 s 223 to 233 ms, then 85 to 138 ms
a point light comes 1.5 s no long frame (19 to 26 ms)
the light goes 1.3 s no long frame (17 to 22 ms)

Frames are 16.6 ms; each cell is the longest frame within 1.5 s of the edit, over two or three runs.

  • Texture pages keep where each texture lies and what they have free (texpack::Atlas). A texture is placed among them and written there (Gpu::place_texture); pages without room grow by a layer or a side with a copy on the GPU. New pixels of the same size go over the old ones.
  • Materials come and change with their maps and their function (World::set_material, set_texture: in place).
  • A still model the scene has not got: its materials and textures in a pass before the edit (place_models), its mesh by make_mesh, the code a scene mesh's edit used, moved out of edit_geometry unchanged.
  • Material functions are numbered in the order they come (set_functions); the kernel with them is another module.
  • A kernel variant is made on another thread (Gpu::warm_kernel); the view runs the one it has until every pipeline a frame asks of the new one is there (choose_kernel). The caches are looked up without a lock held over a compile. In lockstep and in a browser the frame makes its kernel itself, as before.
  • The scene's first cutout, function or mixed-glass caster on an instance asks for its kernel feature instead of a rebuild.
  • Lights that are the light table's alone come, go and change class in place; the table is listed as a build lists it. New groups and cameras that are not the scene's draw nothing.

docs/RUNTIME.md "What comes in place" has the rules and what still rebuilds: particle systems, volumes and grids and their functions; geometry functions; a posed model the scene has not got; any new model under software traversal; a rect light's card; lights past what the kernel sums exactly; the scene's first instance, procedural object, instance colours or vertex colours.

Until a new variant is ready, what it draws is missing: fog comes a moment late, a material of a new function is drawn as one without.

Not in this PR

  • Nothing is freed: a texture or a material nothing uses any more keeps its place until the scene loads again.
  • Images are decoded on the frame's thread (the model's frame above).

Tests

  • Each kind of edit against a build of the edited world, state and picture: textures_come_and_change_in_place, a_model_the_scene_has_not_got_comes_in_place, material_functions_come_and_change_in_place, lights_come_and_go_in_place.
  • a_new_kernel_variant_is_made_while_the_frames_go_on; texpack: a_texture_is_placed_among_the_packed_ones; the world's rules.
  • a_translucent_particles_material_takes_another_function_in_place: the translucency pass has its particles' functions alone, so the kernel is made again where those are others (found by review: it kept the old dispatch).
  • Mutations: 26 (8 of the atlas and the world's rules, 18 of the GPU paths). 25 failed a test there was; one, a texture put on a shelf too low for it, none, and has its case now.

Checks

  • Unit tests 250 under each traversal; render tests 271 of 271 under hardware traversal, and under software traversal the 23 that fail on main.
  • A frame's GPU time in twelve scenes, one run against main: between -1.8 % and +0.4 %, which one run does not tell from no change. The scenes' pictures score as main's.
  • The library builds for wasm32; a browser's frame makes its kernel itself, as before.

🤖 Generated with Claude Code


Note

High Risk
Touches core live render path (GPU atlas growth, edit commit, kernel selection/pipelines) with complex concurrency; incorrect in-place updates could cause visual glitches or rare GPU/state bugs, though extensive tests mitigate this.

Overview
Live edits no longer force full scene rebuilds for textures, still models, material functions, and simple lights. Edits patch GPU tables and acceleration structures in place; only cases called out in docs (particles, volumes, posed new models, rect-light cards, etc.) still fall back to rebuild.

Texture pages keep an Atlas and grow on the GPU via copy when full. Gpu::place_texture / rewrite_texture slot new or updated images without repacking the whole set.

The live commit path places textures and model materials first, registers functions by number, and can build a new still model mesh via shared make_mesh. Kernel features such as first cutout or glass caster are requested through more_features instead of always rebuilding.

Shader compile no longer blocks frames: KernelMaker refactors pipeline creation; warm_kernel compiles on a background thread while choose_kernel keeps rendering with the previous kernel until the new variant is ready (wasm/lockstep still compile synchronously).

Lights can be added, removed, and reclassified in the light table with resorting; tables gains listing/removal helpers.

Documentation (ROADMAP, RUNTIME “What comes in place”) and broad in-place tests cover textures, models, functions, lights, and async kernel warmup.

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

yujiaxu-ops and others added 9 commits November 23, 2026 15:22
…g them again

A new texture, a material given a map, a new material with maps and a texture's new
pixels rebuilt the scene (4.5 s on Bistro: the pages packed whole). The pages keep where
each texture is and what they have free (texpack::Atlas); a texture is placed among them
and written there, the pages growing by a layer or a side with a copy on the GPU; new
pixels of the same size go over the old ones.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…s textures, its mesh

Adding a model whose file the scene did not hold rebuilt it (5.2 s on Bistro). Its
materials are made as the build makes them and its textures placed in the pages before
the edit places it; its mesh is made in the room by the code a scene's mesh is made by
(make_mesh, moved out of edit_geometry). A mesh given back is no model's any more.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A feature a scene first uses (fog, glass, a texture) changed the kernel's variant, and
the next frame waited for the driver's compile (0.8 to 2.4 s here, tens of seconds on a
phone). The view now runs the kernel it has until the scene's is made on another thread
(Gpu::warm_kernel; modules and pipelines made without a lock held). In lockstep, and in
a browser, the frame makes its kernel itself as before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ce comes in place

Each was refused for a kernel feature the scene's structure lacked (F_MASKED, F_IFUNC,
F_IGLASS) and rebuilt the scene. The three switch code on over data every scene has:
the edit asks for the feature, the commit adds it to the scene's, and the kernel's
variant with it is made as any other.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A new or changed material function rebuilt the scene (4.2 s on Bistro, and 7.9 s once a
texture had come in place: the pages packed whole). The scene keeps its functions by
number, one that comes takes the next; the kernel with them is another module, made
while the frames go on with the one the view has, where a material of a function it has
not is drawn as one without.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A light created, removed or set again as one of another class rebuilt the scene, and so
did a group (1.5 s on Bistro each). A light that is the light table's alone (not a rect
light's card, not the atmosphere's sun) has its entry added, dropped or sorted again in
place: the table is listed in a build's order, grown where it is full, and the kernel's
counts follow. Lights past what the kernel sums exactly still rebuild (the light tiles).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ild; the textures' test holds a shared slot and the grown pages' contents

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… the light table's growth; tests for a model that emits, lights among those resampled, a shelf too low

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ice is one thread's)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@yujiaxu-ops
yujiaxu-ops marked this pull request as ready for review November 23, 2026 10:19

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit eb3067f. Configure here.

Comment thread renderer/src/live/edits.rs Resolved
…is made again with the translucency pass's functions as they are now

The pass's dispatch has its particles' materials' functions alone, made when the kernel
is. A material that changed function in place kept the old one (drawn as without a
function). The kernel's functions are remade after the commit's materials, where a
function came or changed or the particles' functions are others.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@yujiaxu-ops
yujiaxu-ops merged commit 0ceebe9 into main Nov 23, 2026
9 checks passed
@yujiaxu-ops
yujiaxu-ops deleted the step-g branch November 23, 2026 10:49
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