From 7d023d044561e64fd40559042c4e0ec66665c4a8 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Mon, 9 Nov 2026 19:29:21 +0100 Subject: [PATCH] #3298: the Render Queue run's layer caches are in the common memory budget; a footage layer read by rows is never the shared picture (test) --- crates/engine/src/render_queue.rs | 15 ++++++++--- crates/render/src/tests/footage_size.rs | 33 +++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/render_queue.rs b/crates/engine/src/render_queue.rs index 7c10af40c..f6a4eff80 100644 --- a/crates/engine/src/render_queue.rs +++ b/crates/engine/src/render_queue.rs @@ -47,16 +47,23 @@ pub struct ExportJob<'a> { /// What the jobs of one Render Queue run keep between them (#3335): a layer cache per /// compositor (a buffer an effect made on the GPU is not the CPU's), together at the budget -/// each job's single cache had before. +/// each job's single cache had before. Both are in the memory accountant's common budget +/// (#3301): they give way with the other caches when it is full. pub struct RunCaches { - pub gpu: effectcraft_render::LayerCache, - pub cpu: effectcraft_render::LayerCache, + pub gpu: std::sync::Arc, + pub cpu: std::sync::Arc, } impl Default for RunCaches { fn default() -> Self { let half = effectcraft_render::LayerCache::default().budget() / 2; - RunCaches { gpu: effectcraft_render::LayerCache::new(half), cpu: effectcraft_render::LayerCache::new(half) } + let (gpu, cpu) = (std::sync::Arc::new(effectcraft_render::LayerCache::new(half)), std::sync::Arc::new(effectcraft_render::LayerCache::new(half))); + let accountant = effectcraft_render::memory::Accountant::global(); + for cache in [&gpu, &cpu] { + let holder: std::sync::Arc = cache.clone(); + accountant.register(&holder); + } + RunCaches { gpu, cpu } } } diff --git a/crates/render/src/tests/footage_size.rs b/crates/render/src/tests/footage_size.rs index 004164859..31f843ed2 100644 --- a/crates/render/src/tests/footage_size.rs +++ b/crates/render/src/tests/footage_size.rs @@ -188,6 +188,39 @@ fn a_source_that_reads_whole_frames_keeps_the_layer_cached_under_a_region() { } } +/// #3301 merge with #3333: under a viewer region of interest, a footage layer read by rows is +/// never offered as the shared decoded picture (the GPU would upload a part of the frame as the +/// whole); without a region it is. +#[test] +fn a_footage_layer_read_by_rows_is_not_the_shared_picture() { + struct Rows; + impl FootageSource for Rows { + fn frame(&self, item: ItemId, f: &Footage, t: Tick) -> Option> { + Clip { sizes: None }.frame(item, f, t) + } + fn frame_rows(&self, item: ItemId, f: &Footage, t: Tick, _: Option<(u32, u32)>, _: crate::FloatCurve, _: (i64, i64)) -> Option> { + Clip { sizes: None }.frame(item, f, t) + } + fn reads_rows(&self, _: &Footage, _: Tick) -> bool { + true + } + } + let (mut p, cid) = project(BitDepth::Bpc32, false); + let Some(LayerSource::Footage { item }) = p.comp(cid).map(|c| c.layers[0].source.clone()) else { panic!("footage layer") }; + if let Some(ItemKind::Footage(f)) = p.item_mut(item).map(|it| &mut it.kind) { + f.kind = FootageKind::Still; + f.path = "/still.exr".into(); + } + let comp = p.comp(cid).unwrap(); + let ctx = crate::EvalCtx::new(&p, cid, comp, Tick::ZERO); + let whole = Renderer::new(&p, &Rows, RenderOpts::default()); + assert!(whole.footage_picture(&ctx, &comp.layers[0]).is_some(), "no region: the shared picture"); + let region = Renderer::new(&p, &Rows, RenderOpts { roi: Some([0.0, 0.0, 96.0, 10.0]), ..Default::default() }); + let Some(ItemKind::Footage(f)) = p.item(item).map(|it| &it.kind) else { panic!("footage") }; + assert!(region.footage_rows(&ctx, &comp.layers[0], f).is_some(), "read by rows"); + assert!(region.footage_picture(&ctx, &comp.layers[0]).is_none(), "a part of the frame is never shared"); +} + /// #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.