Run the view transform after the detail stage, in a pass of its own
The fused pass stops at "linear working values" when a sharpener, a blur or a repair follows, and the detail passes convolve what it hands on. Until now it handed on the rendering: the base curve, and since the last commit the view transform, ran before the store. So every kernel worked on display-referred values while its comments promised the opposite — D19's second finding. A fused pass composed for a detail stage now stops before the view transform, and carries a second shader, `ComposedShader::view`, composed from the same inputs. It runs the same prologue, for the positions a fragment reads (a film's grain seeds from `source_px`) and the corners it blacks out, takes its colour from the detail stage's result bound where the sample cache would be, and runs the view transform, the output transform and the mask reveal. `render_detailed` dispatches it after the last detail pass, in the same encoder. So no detail pass encodes any more. Every pass writes an intermediate, the last one included, which retires three things that existed only to make the last pass encode: `writes_output` and the runner's second layout, the body-less resolve pass for an active kernel with nothing to draw at this scale, and capture sharpening's pass-through, which now emits no pass at all. An empty chain is a whole render: the view pass reads the fused result directly. The detail stage no longer takes an output space either, so `compose_detail_for` folds into `compose_detail` and the space is named once, on the fused half. The cost is one full-render read and write per frame when a detail stage exists, and a third intermediate for a one-pass chain.
This commit is contained in:
@@ -127,3 +127,52 @@ fn the_rendering_is_monotone_through_the_whole_range() {
|
||||
last = got;
|
||||
}
|
||||
}
|
||||
|
||||
/// Render `graph` over a flat frame through `render_detailed`, the path every
|
||||
/// frontend takes, and return the centre pixel's red.
|
||||
fn rendered_detailed(ctx: &GpuContext, level: u16, graph: &EditGraph) -> (u8, AdjustPass) {
|
||||
let source = Demosaicer::new(ctx)
|
||||
.expect("demosaicer")
|
||||
.run(&flat_raw(level))
|
||||
.expect("demosaic");
|
||||
let shader = graph.compose_for(dr_types::ColourSpace::Srgb);
|
||||
let detail = graph.compose_detail(source.size(), (SIZE, SIZE));
|
||||
let key = graph.invalidation().through(dr_pipeline::Affects::Colour);
|
||||
let mut adjust = AdjustPass::new(ctx);
|
||||
adjust
|
||||
.render_detailed(&source, &shader, SIZE, SIZE, None, &detail, key)
|
||||
.expect("render");
|
||||
let (pixels, _, _) = adjust.export_pixels().expect("readback");
|
||||
let centre = ((SIZE / 2) * SIZE + SIZE / 2) * 4;
|
||||
(pixels[centre as usize], adjust)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_detail_stage_renders_through_the_view_pass_unchanged() {
|
||||
// TRACES: FR-DEV-3j | FR-DEV-2
|
||||
// With a detail stage the view transform is a dispatch of its own after
|
||||
// it (D19). Sharpening a flat field changes nothing, so the same frame
|
||||
// with and without it must render the same: the view pass read the detail
|
||||
// stage's result, applied the view transform once, and encoded once.
|
||||
let Some(ctx) = ctx() else {
|
||||
eprintln!("skipping: no GPU adapter");
|
||||
return;
|
||||
};
|
||||
let plain = rendered(&ctx, 8_520, &EditGraph::default_chain());
|
||||
|
||||
let mut sharpened = EditGraph::default_chain();
|
||||
let id = dr_pipeline::ops::capture_sharpen::ID;
|
||||
sharpened.set_param(id, dr_pipeline::ops::capture_sharpen::AMOUNT, 100.0);
|
||||
sharpened.set_param(id, dr_pipeline::ops::capture_sharpen::RADIUS, 1.0);
|
||||
let (detailed, pass) = rendered_detailed(&ctx, 8_520, &sharpened);
|
||||
|
||||
assert!(
|
||||
pass.detail_dispatches() > 0,
|
||||
"the premise: a detail stage ran"
|
||||
);
|
||||
assert_eq!(pass.view_dispatches(), 1);
|
||||
assert!(
|
||||
detailed.abs_diff(plain) <= 1,
|
||||
"with a detail stage {detailed}, without {plain}"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user