Repository navigation
The live passes from one place: live.wgsl's declarations read at build time, a table for the rest, a layout a pass - #68
Merged
Merged
Conversation
…d time, a table for the rest, a layout a pass A buffer and a pass more took seven edits that had to agree (the declaration, the layout's entries, the pass list, the buffers' sizes and order, the bind group's entries, the dispatch grid in two copies, the merged layout's table). Now: - build.rs reads live.wgsl with naga (a build dependency at wgpu's version, 30: the browser's build carries none of it) into each binding's name, number, kind and element stride, and the bindings each entry point uses. - live/layout.rs holds what the shader cannot say: what each binding is bound to and how many elements a buffer of the passes' own holds (RESOURCES), the passes' order and grids (PASSES); layout::check holds it to the shader (a unit test, and every view as it starts). - Natively each pass has a bind group layout and a bind group of its own, of the bindings its entry point uses. The browser's layout is still the merged one for all passes: post binds 13 storage buffers, compose 11, dtemporal 10 (the other 36 at most eight). - Targets allocates from the table (`buf(name)`); `pass_grid` is `layout::Grid::size`. Checks: cargo test 125 passed; render-identity against the build before, native (171 identical, 19 within spread) and THREERT_MERGED=1 (172, 18): nothing changed; the passes after the trace 6.03-6.09 ms on both builds (Bistro, 1440p at 0.375, alternated). The wasm32 library and the web crate build. Co-Authored-By: Claude Opus 5.5 <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.
Step 1 of the plan for the live passes' layout. Adding a buffer and a pass in #67 took seven edits that had to agree with one another:
live.wgsl;Tier R1: no picture changes.
The change
renderer/build.rsreadsshaders/live.wgslwith naga when the crate is built. naga is the compiler wgpu uses, at the same version (30). It is a build dependency, so the browser's wasm build carries none of it. From the shader it gets each binding's name, number, kind and element stride, and the bindings each entry point uses.renderer/src/live/layout.rsholds only what the shader cannot say:RESOURCES: what each binding is bound to (a buffer of the passes' own, the frame's parameters, the trace's samples, the kernel's outputs, the LUT), and how many elements an own buffer holds (per output pixel ×k, quarter grid, bloom pyramid, or the length the shader declares);PASSES: the passes' order and the grid each runs over.layout::checkholds the table to the shader: every binding has one resource of a fitting kind, and every entry point is a pass, each exactly once. It runs as a unit test and at every view's start, and names what disagrees.post(13, most of them its debug view modes),compose(11) anddtemporal(10). Step 2 rearranges those three; then the browser can use the same layout andmerged.rs's live half goes.Targetsallocates from the table (buf(name)), andpass_gridbecamelayout::Grid::size.From now on, a buffer or a pass more means its declaration in
live.wgsland a line inlive/layout.rs.Merge gate (R1)
cargo test --releaseTHREERT_MERGED=1npmROADMAP § 1a records the step.
🤖 Generated with Claude Code
Note
Medium Risk
Refactors core live-rendering bind layouts and buffer wiring across all passes; mitigated by layout/shader validation and reported render-identity parity, but mistakes here would surface as subtle GPU bugs.
Overview
Centralizes live GPU pass layout so
live.wgslis the source of truth for bindings and entry-point usage, with a small Rust table only for what WGSL cannot express (buffer sizes, pass order, dispatch grids).Adds
renderer/build.rs(naga build dependency) to generateBINDINGSandENTRY_POINTSfrom the shader at compile time.renderer/src/live/layout.rsholdsRESOURCES,PASSES, andlayout::checkto keep the table and shader in sync (unit test + called at view startup).pass_gridand scattered manual layout tables are replaced bylayout::Gridand generated metadata.Natively, each of the 39 compute passes now gets its own bind group layout and bind group (only the bindings that entry point uses); dispatch uses the per-pass grid from
PASSES. Web builds still use the merged single layout untilpost,compose, anddtemporalare refactored.Targetsstops hard-coding one field per buffer: allocation and bind groups are driven from the layout table (buf(name),bind_groups).LoadedScenecarriesbgs: Vec<_>instead of one sharedbg;frame.rsbindsself.sc.bgs[k]per pass. Docs (ROADMAP, RUNTIME) note the change; wasm lockfile picks up naga as a build-only dep.Reviewed by Cursor Bugbot for commit 74c6daa. Bugbot is set up for automated code reviews on this repo. Configure here.