mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-26 09:20:46 +01:00
Release kept filter fields when a stroke begins during a sliced pass (#475)
Fields kept for the coming composites stayed allocated for as long as a stroke lasted while tiles still followed, because the end-of-pass cleanup only runs when none do. A stroke already kept them from being used; now it also drops them. The test keeps fields first, then starts the stroke.
This commit is contained in:
1 parent
1a742d3fa4
commit
74d213272d
2 files changed
+31
No files matched your search
@@ -1700,6 +1700,12 @@ pub fn composite_tiles_cached(inp: &Inputs, out: &mut Composite, tiles: &[(u32,
|
||||
let holds = below.is_some() && inp.preview.is_none() && has_neighbourhood(inp, &set.stack);
|
||||
let key = if holds { StackKey::new(inp.project, inp.pixels, inp.baked, inp.images, inp.ts, &set.stack).map(Arc::new) } else { None };
|
||||
let size = (inp.gbuf.width, inp.gbuf.height);
|
||||
// Fields kept before a stroke began are not used under it, nor held while it lasts
|
||||
if key.is_none()
|
||||
&& let Some(cache) = below.as_deref_mut()
|
||||
{
|
||||
cache.held = None;
|
||||
}
|
||||
for (at, block) in &blocks {
|
||||
let lacks = |tile: &(u32, u32)| below.as_deref().zip(split.as_deref()).is_none_or(|(cache, _)| cache.tile(*tile).is_none());
|
||||
let fresh: Vec<(u32, u32)> = block.iter().copied().filter(lacks).collect();
|
||||
|
||||
@@ -706,3 +706,28 @@ fn tiles_the_cache_drops_during_a_kept_run_are_filtered_again() {
|
||||
assert!(above.len() > bottom.len());
|
||||
assert!(out == want, "a tile dropped from the cache was composited with fields that lack the layers off the hot path");
|
||||
}
|
||||
|
||||
/// A stroke that starts while fields are kept must not leave them allocated for as long as it lasts, even though tiles still follow.
|
||||
#[test]
|
||||
fn a_live_stroke_releases_the_fields_kept_before_it_started() {
|
||||
let mut f = fixture();
|
||||
let top = heavy_stack(&mut f);
|
||||
let all = all_tiles(RES, RES);
|
||||
let (first, rest) = all.split_at(3);
|
||||
let mut cache = BelowCache::default();
|
||||
cache.set_hot(Some(top));
|
||||
|
||||
cache.ahead = rest.to_vec();
|
||||
run(&f, 0, first, Some(&mut cache));
|
||||
assert!(cache.holds_fields());
|
||||
|
||||
// The stroke begins with tiles still following: the pass is not over, so nothing else would clear them
|
||||
let preview = stroke(top);
|
||||
let mut live = run_with(&f, 0, first, Some(&mut cache), Some(&preview));
|
||||
assert!(!cache.holds_fields(), "fields kept before the stroke stay allocated while it lasts");
|
||||
let (images, baked) = (Default::default(), Default::default());
|
||||
let mut inp = inputs(&f, 0, &images, &baked);
|
||||
inp.preview = Some(&preview);
|
||||
composite_tiles_cached(&inp, &mut live, rest, Some(&mut cache));
|
||||
assert!(live == run_with(&f, 0, &all, None, Some(&preview)), "a stroke that starts during a sliced pass differs");
|
||||
}
|
||||
Reference in new issue
Block a user