From 6d5bddb40dd05f36b7b049186fb5b3e1c897da83 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 30 Nov 2026 18:27:53 +0000 Subject: [PATCH 1/2] Tests: focus the Relight halo seam comparison (#15934) --- crates/algo/src/relight.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/algo/src/relight.rs b/crates/algo/src/relight.rs index d36454d238..c8d8ae863d 100644 --- a/crates/algo/src/relight.rs +++ b/crates/algo/src/relight.rs @@ -524,17 +524,25 @@ mod tests { #[test] fn tiles_match_a_full_apply_past_the_old_halo() { // Default softness on a 1600 px short side: σ = 32, reach 129 px. The previous - // 97 px halo left a gap, so 128 px tiles seamed. Tile 128 vs one full-frame tile. + // 97 px halo left a gap, so 128 px tiles seamed. let size = 1600; + let tile = 128; let bounds = Rect::new(0, 0, size, size); let s = shaded_sphere(SampleType::F32, size); let p = relight_p(180.0, 40.0, 60.0, 40.0, 0.0, 25.0); assert!(read_radius(sigma(25.0, bounds)) > 97); - let area = output_area(&p, s.content_bounds(), bounds, None); - let full = apply_tiled(&s, &p, area, bounds, None, 4096, None); - let tiled = apply_tiled(&s, &p, area, bounds, None, 128, None); - let inner = Rect::new(0, 0, size, size); - let d = max_diff(&full.read_region(inner), &tiled.read_region(inner)); + let layer = output_area(&p, s.content_bounds(), bounds, None); + // Keep the full-layer grid at the sphere's upper edge. The window includes a seam + // in each direction, partial tiles, and the top edge of the document. + let (x, y) = (layer.x0 + 6 * tile, layer.y0 + tile); + let side = tile + tile / 2; + let area = Rect::new(x, y, x + side, y + side); + let full = apply_tiled(&s, &p, area, bounds, None, side, None); + let tiled = apply_tiled(&s, &p, area, bounds, None, tile, None); + let inside = area.intersect(&bounds); + let expected = full.read_region(inside); + assert!(max_diff(&expected, &s.read_region(inside)) > 1e-4, "the window must be relit"); + let d = max_diff(&expected, &tiled.read_region(inside)); assert!(d <= 1e-4, "tile seam {d}"); } From 83956bb358e0fb3a59d7e94b4c59b4b10b94e652 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 30 Nov 2026 22:44:35 +0000 Subject: [PATCH 2/2] Tests: preserve full-frame Relight parity coverage --- crates/algo/src/relight.rs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/crates/algo/src/relight.rs b/crates/algo/src/relight.rs index c8d8ae863d..efa96684e8 100644 --- a/crates/algo/src/relight.rs +++ b/crates/algo/src/relight.rs @@ -524,25 +524,29 @@ mod tests { #[test] fn tiles_match_a_full_apply_past_the_old_halo() { // Default softness on a 1600 px short side: σ = 32, reach 129 px. The previous - // 97 px halo left a gap, so 128 px tiles seamed. + // 97 px halo left a gap, so 128 px tiles seamed. Tile 128 vs one full-frame tile. let size = 1600; - let tile = 128; let bounds = Rect::new(0, 0, size, size); let s = shaded_sphere(SampleType::F32, size); let p = relight_p(180.0, 40.0, 60.0, 40.0, 0.0, 25.0); assert!(read_radius(sigma(25.0, bounds)) > 97); - let layer = output_area(&p, s.content_bounds(), bounds, None); - // Keep the full-layer grid at the sphere's upper edge. The window includes a seam - // in each direction, partial tiles, and the top edge of the document. - let (x, y) = (layer.x0 + 6 * tile, layer.y0 + tile); - let side = tile + tile / 2; - let area = Rect::new(x, y, x + side, y + side); - let full = apply_tiled(&s, &p, area, bounds, None, side, None); - let tiled = apply_tiled(&s, &p, area, bounds, None, tile, None); - let inside = area.intersect(&bounds); - let expected = full.read_region(inside); - assert!(max_diff(&expected, &s.read_region(inside)) > 1e-4, "the window must be relit"); - let d = max_diff(&expected, &tiled.read_region(inside)); + let area = output_area(&p, s.content_bounds(), bounds, None); + let full = apply_tiled(&s, &p, area, bounds, None, 4096, None); + // Keep every tile that contributes checked pixels, including each edge tile's + // original rectangle and halo. The remaining tiles lie wholly outside the canvas. + let tile = 128; + let tile_start = |pixel: i32, origin: i32| origin + (pixel - origin).div_euclid(tile) * tile; + let visible_tiles = Rect::new( + tile_start(bounds.x0, area.x0), + tile_start(bounds.y0, area.y0), + tile_start(bounds.x1 - 1, area.x0) + tile, + tile_start(bounds.y1 - 1, area.y0) + tile, + ) + .intersect(&area); + let tiled = apply_tiled(&s, &p, visible_tiles, bounds, None, tile, None); + let center = size / 2; + assert!(max_diff(&full.pixel(center, center), &s.pixel(center, center)) > 1e-4, "the full frame must be relit"); + let d = max_diff(&full.read_region(bounds), &tiled.read_region(bounds)); assert!(d <= 1e-4, "tile seam {d}"); }