Footage cache (#3271): a render's channel reads are called off with the render

The cancellable footage view passed aux and aux_for straight to the source, so a viewer render called off during a channel decode kept decoding. They now go through the render's cancel flag like frame reads (a decode stops between batches; once called off none starts). A test checks a channel read runs under the flag and none starts after; it fails on the old code.
This commit is contained in:
vangel76 committed 2026-11-08 16:09:52 +01:00
1 parent c3464f640f
commit 612419f3c1
3 files changed
+41 -4

No files matched your search

+3 -2
View File
@@ -221,8 +221,9 @@ impl FootageSource for CancellableFootage<'_> {
fn audio(&self, item: ItemId, footage: &Footage, t: Tick, frames: usize, rate: u32) -> Option<Vec<f32>> {
self.inner.audio(item, footage, t, frames, rate)
}
// (decoding channels is a read like a frame's: called off with the render, between batches)
fn aux(&self, item: ItemId, footage: &Footage, t: Tick) -> Option<Arc<effectcraft_raster::AuxChannels>> {
self.inner.aux(item, footage, t)
self.read(|| self.inner.aux(item, footage, t))
}
fn aux_for(
&self,
@@ -231,7 +232,7 @@ impl FootageSource for CancellableFootage<'_> {
t: Tick,
need: &effectcraft_raster::channels3d::AuxNeed,
) -> Option<Arc<effectcraft_raster::AuxChannels>> {
self.inner.aux_for(item, footage, t, need)
self.read(|| self.inner.aux_for(item, footage, t, need))
}
fn aux_names(&self, item: ItemId, footage: &Footage, t: Tick) -> Option<Arc<effectcraft_raster::AuxChannels>> {
self.inner.aux_names(item, footage, t)
+38
View File
@@ -187,3 +187,41 @@ fn a_source_that_reads_whole_frames_keeps_the_layer_cached_under_a_region() {
}
}
}
/// #3271 review: a render's channel reads (an effect's EXR channels) are called off with the
/// render like its frame reads: they run under the render's cancel flag (a decode stops between
/// batches), and once it is set they don't start.
#[test]
fn channel_reads_are_called_off_with_the_render() {
use std::sync::atomic::{AtomicBool, Ordering};
thread_local! {
static UNDER: std::cell::Cell<bool> = const { std::cell::Cell::new(false) };
}
#[derive(Default)]
struct Channels {
reads: Mutex<Vec<bool>>,
}
impl FootageSource for Channels {
fn frame(&self, _: ItemId, _: &Footage, _: Tick) -> Option<Arc<Image>> {
None
}
fn cancellable(&self, _: &Arc<AtomicBool>, f: &mut dyn FnMut()) {
UNDER.with(|u| u.set(true));
f();
UNDER.with(|u| u.set(false));
}
fn aux_for(&self, _: ItemId, f: &Footage, _: Tick, _: &effectcraft_raster::channels3d::AuxNeed) -> Option<Arc<effectcraft_raster::AuxChannels>> {
self.reads.lock().unwrap().push(UNDER.with(|u| u.get()));
Some(Arc::new(effectcraft_raster::AuxChannels::new(f.width, f.height, 1.0)))
}
}
let inner = Channels::default();
let cancel = Arc::new(AtomicBool::new(false));
let src = crate::CancellableFootage { inner: &inner, cancel: cancel.clone() };
let f = Footage { width: 4, height: 2, ..Default::default() };
let need = effectcraft_raster::channels3d::AuxNeed::Lookups(vec![]);
assert!(src.aux_for(ItemId(1), &f, Tick::ZERO, &need).is_some());
cancel.store(true, Ordering::Relaxed);
assert!(src.aux_for(ItemId(1), &f, Tick::ZERO, &need).is_none(), "called off");
assert_eq!(*inner.reads.lock().unwrap(), [true], "read once, under the render's flag");
}
-2
View File
@@ -13,8 +13,6 @@ Effects are addressed by id (`ec.<category>.<name>`) or display name in commands
## 3D Channel
The parameters that pick which channels or Cryptomatte layer an effect reads are not animatable, as in After Effects (see [footage](footage.md)).
| Effect | Id | Params | GPU | 32 | Status |
|---|---|---:|:-:|:-:|---|
| 3D Channel Extract | `ec.3d.channelextract` | 6 | GPU | 32 | Implemented |