Repository navigation
P1.4e: opt-in chunked scene copy data (past maxStorageBufferBindingSize) - #110
Open
DennisSmolek wants to merge 1 commit into
Open
DennisSmolek wants to merge 1 commit into
DennisSmolek wants to merge 1 commit into
Conversation
…KxN'), chooseSceneCopyPacking, bit-identical renders The data region splits over K storage bindings of 2^N words; word i is chunk i >> N (V515). The default packing, kernels (355 size-snapshot files) and buffers are untouched. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Part of #51 (P1.4e only; P1.4b / P1.5a are untouched).
What changed
Opt-in chunked scene copy data for scenes whose data is past
maxStorageBufferBindingSize.packing: 'split:KxN' | 'packed:KxN'(K chunks of 2^N words). The string carries the layout, so kernel options,uploadSceneCopy, thesetScenemismatch check, layout entries and storage-buffer counts need no new option.packed:KxN=rtScene(header + table, no data region) +rtSceneData0..K-1;split:KxNkeepsrtSceneTable.chooseSceneCopyPacking(device, copy, { base, chunkWordsLog2, otherStorageBuffers, stageLimit }): K from the size and the device limit; refuses (RangeError with the numbers) when table + K chunks + the kernel's other buffers exceed the stage budget, or when the table alone is over the limit.buildGpuScene({ chunkData })uses it.rtSceneWord(i):switch (i >> N)over the chunk bindings,i & mask.rtApplyScenePacking(source, packing)replaces thepacked ? rtPackSceneAccess : xpattern at every call site (megakernel, wavefront, restir, interval-batch, modules, examples).sceneCopyStorageBuffers/rtModuleStorageBuffers/rtSceneEntries/ layout entries; textures bind after the chunks.PtMegakernel/PtWavefrontadd the chunk count to Dawn's layout error.writeSceneCopyrewrites chunked buffers in place (false when K would change).Chosen design (V515): the chunk is picked by the word index (shift and mask, a power of two, so no division), not by a per-mesh chunk id. Nothing in the data layout moves: offsets, light maps, fingerprint and CPU twins are the unchunked ones; a mesh bigger than a chunk works; an index triple, a vertex or an env texel may straddle a boundary. Cost: a switch per data word read. The per-mesh id would pay once per mesh but needs a per-mesh data layout and a chunk id through
rtSIndex/rtSVertex. Built behind the same setting only if the A/B below says the switch costs.Divergences V515-V518, TASKS P1.4e, QUIET-PASS row, docs (
docs/raytracer/scene-copy.mdx), CLAUDE.md trap.How verified
node bench/size-snapshot.ts <dir> packedandsplit, base vs branch,diff -rqempty over 355 files (the 2 newchunked-*variants are extra files).scene-chunked.test.ts(raytracer, pathtracer integrator) andbench/scenes/scene-chunks.test.ts: every data word of forced-small-chunk copies reads back through the chunk twin AND through the generatedrtSceneWordtext parsed back out and evaluated; Cornell at 2^7 / 2^5 words, Sponza (when downloaded) at 2^14 / 2^21; budget refusals; kernels for both table placements, megakernel and every wavefront kernel. 618 tests in the touched packages pass;pnpm typecheckshows only the known@pmndrs/vdberrors.--page scene-copy --args chunk=7|11(both table placements, all accessors incl.rtSurfacedecode, first/last word of every chunk): 0 mismatches over 214k / 564k checks.--no-lock): Cornell 16 spppt_scene_chunk=7(5 chunks, megakernel, both placements) and=8(2 chunks, wavefront, both); Sponza-white 4 spppt_scene_chunk=21(K = 3, 8 MiB chunks), megakernel and wavefront, packed and split. All 8 pairs: 0 differing values (of 0.79 M / 2.76 M), so no contraction-level differences showed up.11 > 10storage buffers (clear error), at 2^19chooseSceneCopyPackingrefuses with the numbers.A/B left for the maintainer (timing, quiet pass; QUIET-PASS row P1.4e)
Sponza K = 3, Cornell K = 1 (control). A ratio above ~1.03 on Sponza means the per-word switch costs; then build the per-mesh chunk id (V515). No default depends on it (opt-in).
🤖 Generated with Claude Code