Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ To go back: restore `pnpm-workspace.yaml` and `pnpm install --offline` (or onlin
equal split per pixel on 6 of 8 scenes and differ by <= 3.2e-7 relative (1-3 ulp, relMSE 3e-17) on IORTestGrid (both schedulers) and env-sphere (wavefront): not addressing (every accessor is bit-exact
in `--page scene-copy packing=both`), a different compiled kernel contracts some float ops differently. `DEFAULT_SCENE_PACKING` is still `split`; `writeSceneCopy(device, buffers, copy)` rewrites a rebuilt copy
in place for either packing (the packed one rewrites the whole buffer: the data region moves when the table length changes).
- Host-kernel buffer budget (issue #36): `rtModuleStorageBuffers(options)` (or `GpuScene.storageBuffers`, `rtSceneStorageBuffers({ format, scenePacking, walkPacking })` before any kernel exists) is the number to add to a pasted module's own bindings; pass `walkPacking: 'packed'` to `rtModuleWgsl` AND `rtWalkEntries` AND bind `rtWalkBindGroupEntries(scene)`, or the layout and the kernel disagree (`PtMegakernel` / `PtWavefront` / the batch tracers ignore it). bvh's trace buffers are STORAGE | COPY_DST only (no COPY_SRC), so `rtPackWalk` copies with a compute pass; a `walk.update(encoder)` is needed after every `SceneTrees` update. `walkPacking: 'shared'` (option 2, `rtPackShared`, V595) puts the scene copy in the same buffer: the module needs the `scene` option, `scene.packing` is `'shared'` (what `GpuScene.packing` says; the scene copy then has no buffer bindings, its texture bindings start at the scene slot's `firstBinding`, `rtSceneCopyLayoutEntries(first, textures, 'shared')`), your own `rtSceneTable` / `rtSceneData` text goes through `rtPackSceneAccess(source, 'shared')`, and `PtMegakernel` / `PtWavefront` throw for such a scene. Check page: `--page shared-buffer-check`.
- Optional integrator outputs (R10 hooks, R4 counters, AOVs; `integrator/outputs-wgsl.ts`): their template text must emit nothing (no blank line, no `\n`) when off. Two traps hit while adding them: a gated block ending in a
newline placed before the original newline adds a blank line (the megakernel stayed identical but the wavefront shade kernel grew by one `\n`), so put the leading `\n` inside the gate for end-of-line additions
(`x;${on ? `\n y;` : ''}`). `node bench/size-snapshot.ts` now writes the `wf-*` wavefront kernels too (`bench/kernel-variants.ts` `wavefrontKernelVariants`): `diff -r` two snapshot directories, ignore `Only in`.
Expand Down
2 changes: 2 additions & 0 deletions DIVERGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,5 @@ why, so each one can be revisited later. One row per divergence. Kinds: **platfo
| V343 | 2026-11-26 | Pharr, Wronski, Salvi, Fajardo 2024 (stochastic texture filtering, Listing 1 / S.1: one uniform reused across the axes by rescaling); Wronski, Pharr, Akenine-Moller 2025 (texel sharing between wave lanes) | `volumes.densityFilter: 'stochastic'` (V7.6): stochastic trilinear density, one texel per lookup. Differences: THREE draws from the tracking stream (one per axis) instead of one rescaled uniform; zero outside the grid without a read; no texel sharing between lanes; no tricubic. | Simplification (independent 24-bit draws keep each axis' probability exact to 2^-24 with no division by a small fraction, and need no change to the megakernel / wavefront stream protocol; the two saved PCG steps were not measured). Sharing: the 2025 paper's own supplement reports block artifacts for ray-marched volumes, and our lanes are not neighbouring pixels after the first vertex. |
| V345 | 2026-11-30 | Our own dense grid lookup and brick DDA (`ptVolDensity`, `ptDdaInit` / `ptDdaNext`, V3.2 / P5.v6) | `volumes.gridSource: 'nanovdb'` (VDB-P1.7) replaces both with `@pmndrs/vdb`'s WGSL (`vdbSample`, `vdbMajorantInit` / `vdbMajorantNext`) over the same voxels and the same cells. Two differences per path: the pool's walk never returns a zero-length segment at a cell corner (ours can, and `ptVolSampleBrick` / `ptVolTrBrick` stop on one), and the NanoVDB reader adds the eight taps in another order. Images are therefore not bit-equal to the dense kernel (77-86% of pixels are; relMSE 1e-15 to 1e-6 at equal seeds). The accessor was created per lookup in the first build; since pmndrs/vdb P1.16 (2026-11-30) the kernels keep one per ray segment, made at its first lookup, and the module caches the lower node (`cache: 'lower'`): the same values, images bit-identical to the first build's. | simplification / sibling | the timing A/B of the reader options (quiet pass, VDB-P1.10); cache `'lowerLeaf'` once VDB-P1.14 is understood |
| V344 | 2026-11-26 | pmndrs/upscaler defaults (`RuntimeSettings.autoExposure` on) | The NRC / Classroom chain (`nrc-pipeline`, hero) runs the temporal upscaler with `autoExposure: false`, `exposure: 1` (page control **Auto pre-exposure**, `?upAutoExposure=1` for the sibling's default). | Quality. On a dim interior (mean luminance 0.12) the metered pre-exposure lifts the image so the brightest denoised pixels (10-20) sit at the top of the upscaler's invertible tonemap, where its Catmull-Rom history resample overshoots and `tonemapInvert` turns that into values up to 139 while the camera moves (17 hot pixels per 1920 x 1080 frame, both arms; 0 and max 11 with it off; nothing with a still camera either way). Sharpness 0, locks off and shading-change detection off do not remove it; history 4 nearly does. Off also darkens less against the denoised frame (-4% vs -6..7%; N11.5). Numbers: TASKS N11.11; `bench/hero/README.md` "Bright specks while moving". The cause is in the sibling (unclamped bicubic history in tonemapped space): report there. |
| V365 | 2026-12-02 | @pmndrs/bvh walk bindings (`traceModuleWgsl`: `bvhTraceNodes` / `bvhTraceTriangles` / `bvhTraceTopLevel` / `bvhTracePositions`, 3-4 storage buffers) | `walkPacking: 'packed'` (opt-in, issue #36) rewrites bvh's finished walk text to read one `rtWalk: array<vec4u>` (`rtWalk[rtWalk[0].k + e]`, floats through `bitcast<vec4f>`) and copies bvh's buffers into it with a compute pass (`rtPackWalk`); bvh's text and buffers are untouched and the default kernels are byte-identical. Costs a second copy of the walk and one header load per read | platform | bvh offers a packed trace upload (or the walk text with a single binding) itself, or the Chrome / device default storage-buffer limit rises above 8 |
| V595 | 2026-12-02 | @pmndrs/bvh walk bindings AND our packed scene copy (`rtScene`, P3.11), issue #36 option 2 | `walkPacking: 'shared'` (opt-in) puts the walk (as in V365) and the packed scene copy in ONE `rtShared: array<vec4u>` = [H0 walk offsets \| H1 scene offsets \| table \| data \| walk parts]: the table keeps a compile-time base (`rtShared[e + 2u]`), the data and the walk go through header offsets, the scene copy has no buffer or binding of its own (only its textures, which start at the scene slot's first binding). Generated text, bvh and the default / `packed` kernels are unchanged (the two rewrites are `rtPackSceneAccess(.., 'shared')` and `rtPackWalkAccess(.., 'rtShared')`) | platform | bvh offers a packed upload, or the default storage-buffer limit rises above 8 (then V365 and this go together) |
1 change: 1 addition & 0 deletions TASKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ suggestion, pros/cons and the A/B that would settle it.
| P1.11 | A/B a module-private shared traversal stack vs a function-local array (WGSL zero-initialises function arrays on every call; ThreeRT got 0.36-1.5 ms/frame back) | bvh + here | ⬜ | notes/16-threert.md §4; the walk lives in bvh (D2): raise there Issue [#50](https://github.com/pmndrs/pathtracer/issues/50). |
| P1.12 | Unit test: every `rt*`/`pt*` entry point binds ≤ 8 storage buffers (WebGPU default; Chrome often offers 10) | — | ⬜ | **Audit 2026-11-26:** related: [#36](https://github.com/pmndrs/pathtracer/issues/36) (a layout under the default 8 storage buffers). The budget is checked ad hoc today (`pt-outputs-check check=budget`, wavefront layout tests), not by one unit test. ThreeRT `every_pass_fits_a_browser`; fallback if the megakernel exceeds it: their `merged.rs` (tables in one struct of pow2 arrays) |
| P1.13 | Loop guard (iteration cap + async trip counter) and CPU validation of tree data before upload; measure cost | — | ⬜ | **Audit 2026-11-26:** the loop bound exists (bvh's own literal-bound walk loops since 0.1.1; was `rtBoundWalkLoops`, X1.i); the trip counter and CPU tree validation are open. a hung dispatch took down macOS WindowServer for ThreeRT; +11% trace natively on their big scene Issue [#50](https://github.com/pmndrs/pathtracer/issues/50). |
| P1.14 | Host-kernel storage-buffer budget (issue [#36](https://github.com/pmndrs/pathtracer/issues/36), @pmndrs/reflections): `rtModuleStorageBuffers` documented as THE number (walk + scene copy, indexed leaves included), `GpuScene.storageBuffers` / `rtSceneStorageBuffers` report it before a kernel is compiled, and an opt-in packed walk (`walkPacking: 'packed'`, `rtPackWalk`, `rtPackWalkAccess`): the module reads ONE `rtWalk` buffer, so walk + packed scene copy = 2 storage buffers (3 split + 1 = 4 today; 5 indexed) | agent:issue-36 | 🟨 | Done: the packed walk is built entirely on our side (bvh unchanged: its buffers carry STORAGE only, so a compute pass copies them, which also works on `SceneTrees.traceBuffers`); every node format (quantized, f32, bvh4, cwbvh8) and both leaf formats are text-rewritten (`walk-packing.test.ts`), GPU agreement with the split walk through `trace-core walkPacking=packed` (inline kernel vs the batch kernels, bit for bit): 6 formats x edges / cornell / quad-light / sponza-white 6 of 6 runs pass (split control 6 of 6), `SceneTrees` buffers (quantized, cwbvh8) pass; `bvh4-single-instanced` fails in about 1 of 4 runs packed AND 2 of 12 split with the known `inlineMismatch = coneMismatch` signature (Traps: trace-core flaky), packed once or twice with `surfaceMismatch` 5-10 on that format only (unexplained, likely the same flake); default kernels byte-identical (`node bench/size-snapshot.ts`, 355 files). **Open:** (a) timing of the header load per walk read, quiet-pass row P1.14; (b) option 2 of the issue (walk + scene copy in ONE buffer, 1 total) is built as `walkPacking: 'shared'` (`rtPackShared`, V595; PR for branch `issue-36-single-buffer`, depends on this one; check page `shared-buffer-check`, `trace-core walkPacking=shared`): the module then needs 1 storage buffer, textures start at the scene slot's first binding, the 128 MiB cap applies to the sum; timing of its header loads is in the quiet-pass row P1.14. Verified (load 30-50, correctness only): `--page shared-buffer-check` (rtClosest + rtShade full with a sun and a sky, host kernel with 1 buffer of its own, Cornell / quad-light / tex-checker): shared vs two-buffer vs split images identical per pixel (0 differing pixels, max rel 0), after `update(encoder)` + `writeScene` too, module declares 1 storage buffer (= `rtModuleStorageBuffers` = `GpuScene.storageBuffers.total`), oversize error names every part; `trace-core walkPacking=shared` (inline kernel on the shared buffer, SceneTrees buffers too) 3 of 3 runs pass on 6 formats x edges / cornell / quad-light / sponza-white, and the only failures with `bvh4-single-instanced` included (2 of 3 runs) are that row's known Metal flake; (c) a packed walk is a second copy of the walk and must fit one storage binding (128 MiB by default), bvh could offer a packed upload itself (docs/internal/design/trace-core.md, section "Packed walk"); (d) `PtMegakernel` / `PtWavefront` / batch tracers keep the split walk. |

## P2 — Reference path tracer (megakernel)

Expand Down
2 changes: 1 addition & 1 deletion bench/pages/nrc-reflection-consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ async function main() {
};
const [cachePipeline, envPipeline] = await Promise.all([renderer(false), renderer(true)]);
const pt = await PtMegakernel.create(device, caps, {
format: sceneFormatOf(provider.traceBuffers), layout: provider.sceneCopy.layout, scenePacking: provider.sceneCopyBuffers.packing,
format: sceneFormatOf(provider.traceBuffers), layout: provider.sceneCopy.layout, scenePacking: provider.sceneCopyBuffers.packing as 'split' | 'packed',
integrator: { counters: true },
});
pt.setFilm(width, height);
Expand Down
2 changes: 1 addition & 1 deletion bench/pages/nrc-reflection-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async function main() {
staging.unmap();

const pt = await PtMegakernel.create(device, caps, {
format: sceneFormatOf(provider.traceBuffers), layout: provider.sceneCopy.layout, scenePacking: provider.sceneCopyBuffers.packing,
format: sceneFormatOf(provider.traceBuffers), layout: provider.sceneCopy.layout, scenePacking: provider.sceneCopyBuffers.packing as 'split' | 'packed',
});
pt.setScene(provider.traceBuffers, provider.sceneCopyBuffers);
pt.setFilm(size, size);
Expand Down
2 changes: 1 addition & 1 deletion bench/pages/reflections-ab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ async function runScene(device: GPUDevice, caps: Caps, refl: Refl, desc: SceneDe
layerThickness: 1e-6, transmissionTint: true,
};
const pt = await PtMegakernel.create(device, caps, {
format: sceneFormatOf(providerB.traceBuffers), layout: providerB.sceneCopy.layout, scenePacking: providerB.sceneCopyBuffers.packing,
format: sceneFormatOf(providerB.traceBuffers), layout: providerB.sceneCopy.layout, scenePacking: providerB.sceneCopyBuffers.packing as 'split' | 'packed',
integrator: materials ? { materials } : {}, label: `reflections-ab pt ${name} ${mode}`,
});
pt.setScene(providerB.traceBuffers, providerB.sceneCopyBuffers);
Expand Down
10 changes: 10 additions & 0 deletions bench/pages/shared-buffer-check.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>shared-buffer-check</title>
</head>
<body>
<script type="module" src="./shared-buffer-check.ts"></script>
</body>
</html>
Loading
Loading