skip to content
==> README.md <==
1# @ajax/mesh-assemble
2
3The assembler of a fleet-rendered pathtrace image, sans IO. blobd feeds it the job's committed
4results (each item's blob reference and pass-sum digest) and the blobs' bytes, and asks it what to
5fetch next and for the image.
6
7Item w = pass × tiles + tile is one tile's pass sums, computed from +0 wherever it ran. The image is
8the reference's, bit for bit, because of three rules:
9
10- **In pass order.** Each tile's pass sums are folded `acc = ((0 + P0) + P1) + ..`, every add in the
11  cluster float mode Z.
12- **Exactly once per (tile, pass).** A tile advances only by its next pass. A blob that arrives early
13  waits, and the caller fetches at most `WINDOW` passes ahead. A second copy of a folded pass is
14  dropped.
15- **Checked first.** Every payload is checked against its item's pass-sum digest (the job record's
16  `J_PART`) before it is folded. A wrong one is refused and kept in `bad`.
17
18The 8-bit pixels are re-toned when a tile changes or the job's tone map does, so the image is
19progressive and a tone-map swap never touches the accumulators. The assembler also gives the image's
20digests (as kcheck prints them), raster, PPM, BMP (`@ajax/mesh-assemble-bmp`) and sha256.
21
22## Ported from
23
24[alpha-rust-mesh](https://github.com/rsafier/alpha-rust-mesh) (Richard Safier, MIT):
25`crates/mesh-host/src/assemble.rs`: `WINDOW`, `Item`, `part_of`, `job_scene`, `renders`, `Assembly`.
26
27## Tests
28
29`tests/assemble.c`:
30- The Rust's `ordered_fold_is_the_reference_exactly_once`. Five random orders of commits and blobs,
31  with duplicates and early arrivals, fold bit for bit to the CPU reference
32  (`@ajax/mesh-ref-pathtrace`): the accumulators, pixels and digests. A tone-map swap and back keeps
33  the accumulators. A corrupted payload and a short one are refused.
34- `default_reference_digests`: the default scene's shape, `job_scene`'s refusals, `renders`, and
35  `part_of`.
36
37## Licence
38
39MIT. See the repository's LICENSE.