From e04d57ce03e93322b880badf69f49e9de9735ce8 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 8 Nov 2026 16:09:53 +0100 Subject: [PATCH] Footage cache (#3271): FootageSource::aux stays every channel; effects doc stays generated MediaPool::aux (no render asks for it: renders ask for what their effects read) again gives every channel, the picture's too, so the pinned OpenEXR golden hashes stay as they were; 'all channels' without the picture applies to the effects' requests. docs/effects.md is generated: the note on static channel selection lives in docs/footage.md. --- crates/media/src/exr_planes.rs | 17 ++++++++++++++++- crates/media/src/exr_planes/tests.rs | 10 +++++----- crates/media/src/pool.rs | 7 +++++-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/crates/media/src/exr_planes.rs b/crates/media/src/exr_planes.rs index 08e36cc35..682c94c80 100644 --- a/crates/media/src/exr_planes.rs +++ b/crates/media/src/exr_planes.rs @@ -1247,13 +1247,28 @@ pub(crate) fn picture_rows(path: &str, source: &ExrSource, op: AlphaOp, rows: (i /// The channels `need` reads of the OpenEXR at `path` (all for [`AuxNeed::All`]), from the /// store. `None` when it isn't a readable OpenEXR (or the request was called off). pub(crate) fn aux(path: &str, source: &ExrSource, need: &AuxNeed) -> Option> { + aux_of(path, source, need, false) +} + +/// Every channel of the OpenEXR at `path`, the picture's too ([`FootageSource::aux`]: no render +/// asks for that; a render asks for what its effects read, [`aux`]). +/// +/// [`FootageSource::aux`]: effectcraft_render::FootageSource::aux +pub(crate) fn every_channel(path: &str, source: &ExrSource) -> Option> { + aux_of(path, source, &AuxNeed::All, true) +} + +fn aux_of(path: &str, source: &ExrSource, need: &AuxNeed, with_picture: bool) -> Option> { for _ in 0..2 { let since = drop_generation(); let (index, opened) = exr_index::get_opened(path, source).ok()?; - let want = match need_ids(&index, need) { + let mut want = match need_ids(&index, need) { Some(ids) => Want { all: false, ids }, None => Want { all: true, ids: BTreeSet::new() }, }; + if with_picture { + want.ids.extend(index.picture_ids().unwrap_or_default()); + } match store().get_opened(path, source, &index, &want, Use::Other, opened, since) { Ok(b) => return Some(b.aux.clone()), Err(Refused::Changed) => continue, diff --git a/crates/media/src/exr_planes/tests.rs b/crates/media/src/exr_planes/tests.rs index a10f8cd5a..47b533ea6 100644 --- a/crates/media/src/exr_planes/tests.rs +++ b/crates/media/src/exr_planes/tests.rs @@ -181,7 +181,7 @@ fn multipart_channels_are_found_by_their_stored_names() { assert_eq!(aux.manifest(&layer).map(<[_]>::len), Some(1)); // The names alone, from the headers. let names = pool.aux_names(ItemId(1), &f, Tick::ZERO).unwrap(); - assert_eq!(names.names(), aux.listed.iter().map(String::as_str).collect::>()); + assert_eq!(names.names(), aux.names()); assert!(names.channels.iter().all(|(_, p)| p.is_empty()), "no pixels decoded"); } @@ -527,10 +527,10 @@ fn given_aux_footage_decodes_once_from_the_first_frame() { pool.set_aux_footage(&[given.to_string()]); take_decodes(); pool.frame_at(&f[given], Tick::ZERO).unwrap(); - assert!(pool.aux(ItemId(1), &f[given], Tick::ZERO).unwrap().get("diffuse.R").is_some()); + assert!(pool.aux_for(ItemId(1), &f[given], Tick::ZERO, &AuxNeed::All).unwrap().get("diffuse.R").is_some()); assert_eq!(take_decodes(), [0, 1], "the picture and the channels share one decode"); pool.frame_at(&f[learned], Tick::ZERO).unwrap(); - pool.aux(ItemId(2), &f[learned], Tick::ZERO).unwrap(); + pool.aux_for(ItemId(2), &f[learned], Tick::ZERO, &AuxNeed::All).unwrap(); assert_eq!(take_decodes(), [0, 2]); let d = decodes_of(learned); assert_eq!(d[0].channels.len(), 4, "the picture alone"); @@ -708,8 +708,8 @@ fn a_new_aux_footage_set_returns_to_picture_only() { pool.set_aux_footage(&[]); assert!(!shared().is_held(&paths[0]), "no longer kept once no effect reads it"); assert_eq!(frame(1), Some(4), "no longer given: the picture alone"); - // Learned by `aux()`, then a new set without it: picture only again. - pool.aux(ItemId(1), &f, at(1)).unwrap(); + // Learned by `aux_for()`, then a new set without it: picture only again. + pool.aux_for(ItemId(1), &f, at(1), &AuxNeed::All).unwrap(); assert_eq!(frame(2), Some(all), "learned"); pool.set_aux_footage(&[]); assert_eq!(frame(3), Some(4), "a new set drops what was learned"); diff --git a/crates/media/src/pool.rs b/crates/media/src/pool.rs index 040796d97..bc0993d9c 100644 --- a/crates/media/src/pool.rs +++ b/crates/media/src/pool.rs @@ -1698,8 +1698,11 @@ impl FootageSource for MediaPool { wanted.needs = needs; } - fn aux(&self, item: ItemId, footage: &Footage, t: Tick) -> Option> { - self.aux_for(item, footage, t, &AuxNeed::All) + /// Every channel, the picture's too (no render asks for that: renders ask for what their + /// effects read, [`FootageSource::aux_for`]). + fn aux(&self, _item: ItemId, footage: &Footage, t: Tick) -> Option> { + let path = self.aux_path(footage, t)?; + crate::exr_planes::every_channel(&path, &self.inner.exr_source(&path)) } fn aux_names(&self, _item: ItemId, footage: &Footage, t: Tick) -> Option> {