Format the tree the way the gate asks for it

`cargo fmt --check` is a required step and had drifted across 45 files. Most of
it arrived this week: several operations were written in parallel worktrees and
merged by hand, and a hand-merge resolves conflicts without ever running the
formatter over the result.

No behaviour changes — this is `cargo fmt --all` and nothing else, kept as its
own commit so the next reader can skip it wholesale rather than search it for
one that matters.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-22 21:16:34 +02:00
co-authored by Claude Opus 5
parent d04087af83
commit c75849040c
45 changed files with 545 additions and 257 deletions
+59 -17
View File
@@ -112,11 +112,7 @@ fn split(pixels: &[u8], width: u32, x: u32, y: u32) -> (f32, [f32; 3]) {
}
/// Upload an image built from a per-pixel closure.
fn upload(
ctx: &GpuContext,
size: u32,
f: impl Fn(u32, u32) -> [u8; 3],
) -> DemosaicedImage {
fn upload(ctx: &GpuContext, size: u32, f: impl Fn(u32, u32) -> [u8; 3]) -> DemosaicedImage {
let data: Vec<u8> = (0..size * size)
.flat_map(|i| {
let (x, y) = (i % size, i / size);
@@ -248,7 +244,11 @@ fn modulation(
let mut count = 0.0;
for x in margin..(width - margin) {
let value = sample(linear(pixels, width, x, row));
let sign = if (x / half_period) % 2 == 0 { 1.0 } else { -1.0 };
let sign = if (x / half_period) % 2 == 0 {
1.0
} else {
-1.0
};
total += value * sign;
count += 1.0;
}
@@ -305,7 +305,13 @@ fn chroma_noise_reduction_never_moves_lightness() {
let mut off = AdjustPass::new(&ctx);
let plain = render(&ctx, &mut off, &graph_with(0.0, 0.0), &source, (SIZE, SIZE));
let mut on = AdjustPass::new(&ctx);
let chroma = render(&ctx, &mut on, &graph_with(0.0, 100.0), &source, (SIZE, SIZE));
let chroma = render(
&ctx,
&mut on,
&graph_with(0.0, 100.0),
&source,
(SIZE, SIZE),
);
let colour_before = modulation(&plain, SIZE, 4, chroma_r);
let colour_after = modulation(&chroma, SIZE, 4, chroma_r);
@@ -338,7 +344,13 @@ fn luminance_noise_reduction_never_moves_colour() {
let mut off = AdjustPass::new(&ctx);
let plain = render(&ctx, &mut off, &graph_with(0.0, 0.0), &source, (SIZE, SIZE));
let mut on = AdjustPass::new(&ctx);
let luma = render(&ctx, &mut on, &graph_with(100.0, 0.0), &source, (SIZE, SIZE));
let luma = render(
&ctx,
&mut on,
&graph_with(100.0, 0.0),
&source,
(SIZE, SIZE),
);
// The colour difference — not the raw channel, which follows lightness.
let row = SIZE / 2;
@@ -413,10 +425,10 @@ fn the_same_edit_denoises_the_same_at_two_resolutions() {
let Some(ctx) = ctx() else { return };
const SOURCE: u32 = 256;
const HALF_PERIOD: u32 = 8; // in source pixels
// Six code values of swing. Small on purpose: the colour difference has to
// land near the filter's threshold, because a larger one is a colour
// boundary and the whole point of a bilateral is that it refuses to cross
// those. There would be nothing to measure at either resolution.
// Six code values of swing. Small on purpose: the colour difference has to
// land near the filter's threshold, because a larger one is a colour
// boundary and the whole point of a bilateral is that it refuses to cross
// those. There would be nothing to measure at either resolution.
let source = chroma_pattern(&ctx, SOURCE, HALF_PERIOD, 6);
// Sixty percent is an eight-source-pixel radius, which halves to exactly
@@ -430,14 +442,26 @@ fn the_same_edit_denoises_the_same_at_two_resolutions() {
let proxy_size = SOURCE / 2;
let mut proxy_pass = AdjustPass::new(&ctx);
let proxy = render(&ctx, &mut proxy_pass, &graph, &source, (proxy_size, proxy_size));
let proxy = render(
&ctx,
&mut proxy_pass,
&graph,
&source,
(proxy_size, proxy_size),
);
let proxy_amp = modulation(&proxy, proxy_size, HALF_PERIOD / 2, chroma_r);
// Both must be doing something: two flat images would agree perfectly and
// prove nothing. About 0.0098 of 0.0188, by the derivation above.
let untouched = {
let mut pass = AdjustPass::new(&ctx);
let plain = render(&ctx, &mut pass, &graph_with(0.0, 0.0), &source, (SOURCE, SOURCE));
let plain = render(
&ctx,
&mut pass,
&graph_with(0.0, 0.0),
&source,
(SOURCE, SOURCE),
);
modulation(&plain, SOURCE, HALF_PERIOD, chroma_r)
};
assert!(
@@ -486,7 +510,13 @@ fn each_amount_costs_only_the_dispatches_it_needs() {
for (luminance, chroma, expected) in [(60.0, 0.0, 1), (0.0, 60.0, 2), (60.0, 60.0, 3)] {
let mut pass = AdjustPass::new(&ctx);
render(&ctx, &mut pass, &graph_with(luminance, chroma), &source, (SIZE, SIZE));
render(
&ctx,
&mut pass,
&graph_with(luminance, chroma),
&source,
(SIZE, SIZE),
);
assert_eq!(
pass.detail_dispatches(),
expected,
@@ -496,7 +526,13 @@ fn each_amount_costs_only_the_dispatches_it_needs() {
}
let mut neutral = AdjustPass::new(&ctx);
let a = render(&ctx, &mut neutral, &graph_with(0.0, 0.0), &source, (SIZE, SIZE));
let a = render(
&ctx,
&mut neutral,
&graph_with(0.0, 0.0),
&source,
(SIZE, SIZE),
);
assert_eq!(neutral.detail_dispatches(), 0);
assert_eq!(neutral.detail_allocations(), 0, "nothing was allocated");
@@ -504,7 +540,13 @@ fn each_amount_costs_only_the_dispatches_it_needs() {
// touch the image, and a stage that ran and wrote back the same values
// would still have quantised twice.
let mut absent = AdjustPass::new(&ctx);
let b = render(&ctx, &mut absent, &EditGraph::default_chain(), &source, (SIZE, SIZE));
let b = render(
&ctx,
&mut absent,
&EditGraph::default_chain(),
&source,
(SIZE, SIZE),
);
assert_eq!(a, b, "a neutral denoiser changed the picture");
}