Size repeated subtree cuts from the active tile batch

This commit is contained in:
chasse20 committed 2026-11-22 04:00:03 -05:00
1 parent f8846fa811
commit 03cfaf2e14
5 files changed
+103 -40

No files matched your search

@@ -51,10 +51,14 @@ fn stamp_field(pair: u32, markers: &[(u32, u32, bool)]) -> Image {
}
let subtree = draw / 1344;
let group = subtree / 4;
let extras = match group {
g if g == pair => 75,
g if g == pair + 1 => 106,
0..48 => 27 + (30 * group + 64) % 67,
let extras = match (pair, group) {
(60, 60) => 81,
(60, 61) => 100,
(60, 0..48) => 40 + (26 * group + 63) % 83,
(60, _) => 45 + (9 * group + 8) % 37,
(_, g) if g == pair => 75,
(_, g) if g == pair + 1 => 106,
(_, 0..48) => 27 + (30 * group + 64) % 67,
_ => 45 + (15 * group + 11) % 37,
};
let quota = extras / 4 + u32::from((subtree % 4 + group) % 4 < extras % 4);
@@ -97,6 +101,17 @@ fn a_full_pair_defers_individual_copies_after_two_batches() {
let variables = BTreeMap::from([("$tiling".into(), Value::Int(1))]);
// Each pair of numbered stamps overlaps at one pixel. The final bit is set when the negative stamp draws first.
let pair58 = [(322546, 46225, true), (322547, 1168, true), (322548, 2154, true), (322559, 818, true), (5359, 322551, false), (10731, 11628, false)];
let pair60 = [
(90032, 332682, false),
(90033, 281378, false),
(90034, 302451, false),
(90047, 303240, false),
(90046, 303080, false),
(90045, 303435, false),
(90044, 302501, false),
(333311, 212967, true),
(333298, 89032, true),
];
let pair62 = [
(344050, 272241, true),
(344051, 258965, true),
@@ -107,12 +122,12 @@ fn a_full_pair_defers_individual_copies_after_two_batches() {
(263407, 257852, true),
(268779, 333188, false),
];
for (group, markers) in [(58, pair58.as_slice()), (62, pair62.as_slice())] {
for (group, seed, markers) in [(58, 653180, pair58.as_slice()), (60, 1763066, pair60.as_slice()), (62, 653180, pair62.as_slice())] {
let inputs = [None, Some(stamp_field(group, markers))];
let context = CookContext {
w: 128,
h: 128,
seed: 653180,
seed,
format: OutputFormat::F32,
tile: true,
inputs: &inputs,
+16 -11
View File
@@ -104,18 +104,27 @@ impl TileCopies {
self.paired_batches.map_or(ordinary, PairedBatches::layout)
}
fn split_fits_subtree(&self, parents: usize, cut: u32) -> bool {
let subtree = parents / self.parents_per_subtree;
if parents.is_multiple_of(self.parents_per_subtree) {
// The first part of a repeated endpoint may fill its final subtree exactly.
return self.subtree_ends.partition_point(|&end| end < cut) + 1 == subtree;
}
self.subtree_ends.partition_point(|&end| end <= cut) == subtree
&& (self.parents_per_subtree != DEPTH_FOUR_PARENTS
|| subtree.checked_sub(1).and_then(|i| self.subtree_ends.get(i)).is_some_and(|&lower| cut > lower))
}
pub(super) fn boundaries(&self, layout: &[(usize, usize)], draws_per_parent: usize) -> Option<Vec<DrawPosition>> {
let mut cuts = vec![None; layout.len() + 1];
let mut order = vec![0; layout.len()];
cuts[0] = Some(0_u32);
for (run, &(parents, rank)) in layout.iter().enumerate() {
*order.get_mut(rank)? = run;
if parents % self.parents_per_subtree == 0 {
cuts[run + 1] = if layout.get(run + 1).is_some_and(|&(next, _)| next == parents) {
Some(self.paired_batches?.prefix_end(parents, &self.subtree_ends)?)
} else {
self.subtree_ends.get(parents / self.parents_per_subtree - 1).copied()
};
// A repeated endpoint leaves the first part for the active batch to size.
let split = layout.get(run + 1).is_some_and(|&(next, _)| next == parents);
if !split && parents.is_multiple_of(self.parents_per_subtree) {
cuts[run + 1] = self.subtree_ends.get((parents / self.parents_per_subtree).checked_sub(1)?).copied();
}
}
@@ -133,11 +142,7 @@ impl TileCopies {
let capacity = length.div_ceil(COPIES_PER_BATCH).checked_mul(COPIES_PER_BATCH)?;
let end = start.checked_add(capacity - drawn % COPIES_PER_BATCH)?;
// Crossing the measured subtree interval can change the order of the later runs.
let subtree = self.subtree_ends.partition_point(|boundary| *boundary <= end);
if subtree != parents / self.parents_per_subtree {
return None;
}
if self.parents_per_subtree == DEPTH_FOUR_PARENTS && self.subtree_ends.get(subtree.checked_sub(1)?) == Some(&end) {
if !self.split_fits_subtree(parents, end) {
return None;
}
cuts[run + 1] = Some(end);
@@ -1,8 +1,9 @@
use super::{COPIES_PER_BATCH, DEPTH_FOUR_PARENTS, DEPTH_THREE_PARENTS};
use super::DEPTH_THREE_PARENTS;
#[derive(Clone, Copy)]
pub(super) enum PairedBatches {
ThirdFromEnd,
Penultimate,
Final,
}
@@ -10,6 +11,7 @@ impl PairedBatches {
pub(super) fn ending_at(parents: usize) -> Option<Self> {
match parents / DEPTH_THREE_PARENTS {
60 => Some(Self::ThirdFromEnd),
62 => Some(Self::Penultimate),
64 => Some(Self::Final),
_ => None,
}
@@ -18,30 +20,10 @@ impl PairedBatches {
pub(super) fn layout(self) -> &'static [(usize, usize)] {
match self {
Self::ThirdFromEnd => THIRD_PAIR_FROM_END,
Self::Penultimate => PENULTIMATE_PAIR,
Self::Final => FINAL_PAIR,
}
}
// A repeated endpoint separates a filled prefix from its later continuation.
// The last pair can also leave enough copies to fill a batch inside group 48.
pub(super) fn prefix_end(self, parents: usize, subtree_ends: &[u32]) -> Option<u32> {
let end_of_group = |completed: usize| subtree_ends.get(completed * (DEPTH_THREE_PARENTS / DEPTH_FOUR_PARENTS) - 1).copied();
let groups = parents / DEPTH_THREE_PARENTS;
let cut = match (self, groups) {
(Self::ThirdFromEnd, 60) | (Self::Final, 64) => end_of_group(groups - 2)?.checked_add(2 * COPIES_PER_BATCH)?,
(Self::Final, 49) => {
let final_pair = end_of_group(64)?.checked_sub(end_of_group(62)?)?;
let continuation = final_pair.checked_sub(2 * COPIES_PER_BATCH)?;
end_of_group(48)?.checked_add(COPIES_PER_BATCH.checked_sub(continuation)?)?
}
_ => return None,
};
// A prefix ending in a different depth-four subtree can change the remaining order.
let subtree = parents / DEPTH_FOUR_PARENTS;
let lower = *subtree_ends.get(subtree.checked_sub(2)?)?;
let upper = *subtree_ends.get(subtree.checked_sub(1)?)?;
(lower < cut && cut <= upper).then_some(cut)
}
}
// Depth-seven parent endpoints and compositing ranks measured with original square overlaps.
@@ -103,6 +85,57 @@ const THIRD_PAIR_FROM_END: &[(usize, usize)] = &[
(16384, 22),
];
const PENULTIMATE_PAIR: &[(usize, usize)] = &[
(64, 15),
(192, 36),
(1927, 16),
(2048, 37),
(3844, 6),
(4096, 17),
(4160, 9),
(4288, 33),
(4288, 40),
(6022, 10),
(6144, 28),
(7942, 2),
(8192, 19),
(8256, 12),
(8384, 29),
(10118, 13),
(10240, 35),
(12034, 4),
(12288, 25),
(12352, 23),
(12359, 30),
(12416, 34),
(12480, 45),
(12673, 24),
(12800, 41),
(13058, 1),
(13312, 8),
(13376, 20),
(13440, 38),
(13504, 47),
(13703, 21),
(13824, 44),
(14081, 3),
(14336, 11),
(14400, 26),
(14464, 39),
(14528, 42),
(14724, 27),
(14848, 43),
(15105, 5),
(15360, 14),
(15617, 7),
(15680, 31),
(15684, 18),
(15808, 46),
(15872, 32),
(16129, 0),
(16384, 22),
];
const FINAL_PAIR: &[(usize, usize)] = &[
(64, 15),
(192, 31),
+10
View File
@@ -256,6 +256,16 @@ The one-processor comparison gains 63 exact pixels, reaching 4,272,117/4,272,384
On one processor, alternate the old and new release builds four times each after warmup for the tiled F32 source at 64² seed 42, 64 × 32 seed 187476 and 128² seed 187695. Median elapsed cook times changed from 2,586 to 3,221 ms, 2,529 to 2,903 ms and 2,187 to 3,055 ms during the concurrent verification run. A second interleaved series measured total process CPU time for all three settings, including package loading and readback. Its median changed from 13.602 to 13.680 seconds. All 434 node and evaluator release tests, formatting, strict workspace Clippy, dependency layers and WebAssembly passed.
### A late copy in the penultimate horizontal subtree pair
At 256 × 128 and seed 186864, the horizontal Dirt Gradient generator submits 10,926 copies from depth-three groups 60 and 61. Two batches take 10,920 of them. A subsequent batch fills three copies before the end of the depth-four subtree containing depth-seven parent 4287. Number stamps from zero in depth-first order. Stamps 90,045 through 90,047 resume after the 15,696th parent marker, between logical stamps 303,723 and 266,133. For a run covering N depth-seven parents, round its nominal 21N copies up to a multiple of 5,460 and subtract the occupancy of the active batch. A repeated parent endpoint can therefore leave a later continuation inside the same subtree. Apply the cut only when it falls in the measured subtree interval.
Pair distinct square markers in an original 128² F32 field, starting from white with gains −1 and 2⁻²⁵. Merging the ordered groups required 32 frames and 38,221 reads, including all 32,766 adjacent checks in both polarities. A further 1,432 reads located individual copy boundaries. Compare the first and last deferred stamps to sparse parent markers and their neighbors in both polarities, 2,066 reads each. The two internal comparisons confirm the order of the three stamps. The original 256 × 128 generator now matches 32,768/32,768 pixels. Four independently weighted square inputs using the same copy counts match 36,864/36,864 pixels.
For the regression, use the [same square tree and per-subtree distribution](#individual-tile-copies-after-two-full-horizontal-batches) at seed 1763066. In group g below 48 put 40 + (26g + 63) mod 83 squares over the seam. Elsewhere use 45 + (9g + 8) mod 37, replacing the counts for groups 60 and 61 by 81 and 100. This leaves 15 deferred copies. Check nine marker pairs with both gain assignments. The previous renderer returned 2⁻²⁵ on the first readout where the reference returned zero. Both 128² fields now agree on 32,768/32,768 pixels. Vary the selected pair from 168 to 207 extra copies across 13 further distributions, leaving zero through 44 deferred copies. All 26 F32 fields at 128² and 128 × 64 match 319,488/319,488 pixels. The 60 previous weighted controls and four signed fields for the neighboring pairs match 737,280/737,280 and 65,536/65,536 pixels. Reopen seven settings from four MaterialCraft saves spanning the original distribution, two independent distributions and the signed regression. Both applications reproduce their own buffers and agree on 90,112/90,112 pixels. Maximum error is zero in each of these comparisons.
All nine horizontal generator settings now match 175,104/175,104 pixels, gaining 19,043 exact pixels. The untiled and neighboring generator controls match 525,312/525,312. Both-axis tiling still matches 42,464/175,104, maximum 1.34110451e−7. Across the [111 whole-root settings](#individual-tile-copies-after-two-full-horizontal-batches), one processor matches 2,862,824/2,863,360 pixels and eight match 2,862,731/2,863,360. Maximum error is zero in U8, two codes in U16, .00048828125 in F16 and 1.96099281e−5 or 2.03251839e−5 in F32 on one or eight processors respectively. For 28 reopened whole-root settings, both applications reproduce their original buffers and agree with each other on 430,274/430,336 pixels. Dirt Gradient remains in progress. All 434 node and evaluator release tests passed, together with formatting, strict workspace Clippy, dependency layers and WebAssembly.
## 2026-11-21 root comparisons
### Connected quadrant depth and amplified spot patterns
+1 -1
View File
@@ -255,7 +255,7 @@ Creased matches 10,947,840/10,947,840 pixels across 100 distinct settings throug
| [dirt_3.sbs/dirt_3](../assets/sbs/dirt_3.sbs) | 0 | Yes | [In progress · 68 single-processor settings exact, 2,316,526/2,316,544 pixels on eight processors](parity-fixes.md#three-terminal-children-in-seven-level-quadrant-trees) · [Earlier distinct settings](parity-fixes.md#original-and-reopened-dirt-moisture-and-cellular-noise-fields) · [Earlier measurements](parity-fixes.md#wave-frequency-and-phase-in-directional-noise) · [Earlier isolation](parity-fixes.md#bounds-and-pixel-coordinates-of-rotated-pattern-stamps) · [Six reference repeats](parity-fixes.md#repeated-dirt-pattern-stages) · [2,316,511/2,316,544 pixels across 68 single-processor settings](parity-fixes.md#single-processor-comparisons-for-clouds-2-and-five-dirt-fields) |
| [dirt_5.sbs/dirt_5](../assets/sbs/dirt_5.sbs) | 0 | Yes | [In progress · 2,662,656/2,662,656 pixels on one processor, 2,661,672/2,662,656 on eight across 95 settings](parity-fixes.md#three-active-quadrant-levels-in-dirt-5-and-dirt-gradient) · [2,005,576/2,006,016 pixels across 40 new renders](parity-fixes.md#wave-frequency-and-phase-in-directional-noise) · [Earlier measurements](parity-fixes.md#stored-opacity-across-pattern-depths) · [Six reference repeats](parity-fixes.md#repeated-dirt-pattern-stages) · [2,299,232/2,300,160 pixels across 67 single-processor settings](parity-fixes.md#single-processor-comparisons-for-clouds-2-and-five-dirt-fields) |
| [dirt_6.sbs/dirt_6](../assets/sbs/dirt_6.sbs) | 0 | Yes | [In progress · 2,593,024/2,593,024 pixels across 84 single-processor settings, 2,591,547/2,593,024 on eight](parity-fixes.md#individual-tile-copies-across-a-pattern-draw-boundary) · [Previous four-child generator results](parity-fixes.md#wrapped-draw-order-for-four-children-below-depth-seven) · [Earlier measurements](parity-fixes.md#original-and-reopened-dirt-moisture-and-cellular-noise-fields) · [Earlier measurements](parity-fixes.md#wave-frequency-and-phase-in-directional-noise) · [Earlier isolation](parity-fixes.md#drawing-axis-aligned-stamps-smaller-than-one-pixel) · [Six reference repeats](parity-fixes.md#repeated-dirt-pattern-stages) · [2,298,882/2,300,160 pixels across 67 single-processor settings](parity-fixes.md#single-processor-comparisons-for-clouds-2-and-five-dirt-fields) · [untiled generator measurements and four-format reopens](parity-fixes.md#untiled-draw-order-for-two-and-four-children-below-depth-seven) |
| [dirt_gradient.sbs/dirt_gradient](../assets/sbs/dirt_gradient.sbs) | 0 | Yes | [In progress · 2,862,824/2,863,360 pixels on one processor, 2,862,731/2,863,360 on eight across 111 settings](parity-fixes.md#individual-tile-copies-after-two-full-horizontal-batches) · [Previous 111-setting comparison](parity-fixes.md#paired-subtree-capacity-in-horizontally-tiled-dirt-gradient) · [Five of nine horizontal generator settings exact](parity-fixes.md#the-first-subtree-pair-in-the-final-dirt-gradient-quadrant) · [2,662,010/2,662,656 pixels on one processor, 2,662,090/2,662,656 on eight across 95 settings](parity-fixes.md#three-active-quadrant-levels-in-dirt-5-and-dirt-gradient) · [2,005,640/2,006,016 pixels across 40 new renders](parity-fixes.md#wave-frequency-and-phase-in-directional-noise) · [Earlier measurements](parity-fixes.md#draw-order-at-six-quadrant-subdivisions) · [Six reference repeats](parity-fixes.md#repeated-dirt-pattern-stages) · [2,299,615/2,300,160 pixels across 67 single-processor settings](parity-fixes.md#single-processor-comparisons-for-clouds-2-and-five-dirt-fields) |
| [dirt_gradient.sbs/dirt_gradient](../assets/sbs/dirt_gradient.sbs) | 0 | Yes | [In progress · 2,862,824/2,863,360 pixels on one processor, 2,862,731/2,863,360 on eight across 111 settings](parity-fixes.md#a-late-copy-in-the-penultimate-horizontal-subtree-pair) · [Earlier horizontal comparison](parity-fixes.md#individual-tile-copies-after-two-full-horizontal-batches) · [Previous 111-setting comparison](parity-fixes.md#paired-subtree-capacity-in-horizontally-tiled-dirt-gradient) · [Five of nine horizontal generator settings exact](parity-fixes.md#the-first-subtree-pair-in-the-final-dirt-gradient-quadrant) · [2,662,010/2,662,656 pixels on one processor, 2,662,090/2,662,656 on eight across 95 settings](parity-fixes.md#three-active-quadrant-levels-in-dirt-5-and-dirt-gradient) · [2,005,640/2,006,016 pixels across 40 new renders](parity-fixes.md#wave-frequency-and-phase-in-directional-noise) · [Earlier measurements](parity-fixes.md#draw-order-at-six-quadrant-subdivisions) · [Six reference repeats](parity-fixes.md#repeated-dirt-pattern-stages) · [2,299,615/2,300,160 pixels across 67 single-processor settings](parity-fixes.md#single-processor-comparisons-for-clouds-2-and-five-dirt-fields) |
| [exposure.sbs/exposure](../assets/sbs/exposure.sbs) | 1 | No | [Parity: 4 cases](parity-fixes.md#verified-cases) |
| [extend_shape.sbs/extend_shape_color](../assets/sbs/extend_shape.sbs) | 1 | No | [Parity: 4 cases](parity-fixes.md#verified-cases) |
| [extend_shape.sbs/extend_shape_grayscale](../assets/sbs/extend_shape.sbs) | 1 | No | [Parity: 4 cases](parity-fixes.md#verified-cases) |