From 690e76a51fdca3b636fd0326dd8890fc850b6765 Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Sat, 22 Aug 2026 19:21:59 +0200 Subject: [PATCH] Let the fully-active chain test account for both stages Activating every operation now activates a kernel too, and a kernel emits no block in the fused shader. Assert that each operation reaches exactly one of the fused pass and the detail chain, rather than counting fused blocks against the length of the chain. --- core/dr-pipeline/src/lib.rs | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/core/dr-pipeline/src/lib.rs b/core/dr-pipeline/src/lib.rs index a763ef9..a651c3a 100644 --- a/core/dr-pipeline/src/lib.rs +++ b/core/dr-pipeline/src/lib.rs @@ -107,12 +107,38 @@ mod tests { let g = fully_active(); assert!(!g.is_neutral()); let shader = g.compose(); - // Counted against the chain rather than a literal, so adding an - // operation does not require editing this test. + + // The chain has two kinds of operation in it and they arrive in + // different places: a point operation is a block in the fused shader, + // while a neighbourhood operation is a pass of the detail chain and + // contributes no fused block at all — it reads pixels it is not + // writing, and a fused fragment is handed a colour with no coordinate. + // + // So the assertion is that each operation reaches exactly one of the + // two, checked against the chain rather than a literal, and phrased so + // that adding either kind extends it without an edit here. + let scale = g.render_scale((4000, 3000), (4000, 3000)); + let detail = g.compose_detail(scale); + let mut fused_blocks = 0; + for desc in g.descriptors() { + let id = desc.id.0; + let point = shader.source.contains(&format!("---- {id} ----")); + let neighbourhood = detail + .passes + .iter() + .any(|p| p.label.starts_with(&format!("{id}/"))); + assert!( + point ^ neighbourhood, + "{id} reaches {} of the two stages; an active operation \ + belongs to exactly one", + if point { "both" } else { "neither" } + ); + fused_blocks += usize::from(point); + } assert_eq!( shader.source.matches("---- ").count(), - g.descriptors().len(), - "every operation in the chain should appear" + fused_blocks, + "the fused shader carries a block nothing in the chain asked for" ); }