diff --git a/crates/effects/src/ocio_config/tests.rs b/crates/effects/src/ocio_config/tests.rs index ec34b6723..31cac56c2 100644 --- a/crates/effects/src/ocio_config/tests.rs +++ b/crates/effects/src/ocio_config/tests.rs @@ -465,9 +465,10 @@ fn check_lut_files_notices_a_configs_lut() { let config = dir.join("config.ocio"); std::fs::write(&config, "ocio_profile_version: 2\ncolorspaces:\n - !\n name: lin\n - !\n name: graded\n to_reference: ! {src: watched.cube}\n").unwrap(); let src = config.to_string_lossy().into_owned(); - assert!(load_config(&src).is_ok()); + // A config not read yet is read: its files name its LUT from the first render on. let files = crate::lut_files(&src); assert!(files.contains(&lut.to_string_lossy().into_owned()), "{files:?}"); + assert!(load_config(&src).is_ok()); let before = crate::check_lut_files(); assert!(cached_files(&src).is_some(), "an unchanged config stays"); std::fs::write(&lut, "LUT_1D_SIZE 3\n0 0 0\n0.5 0.5 0.5\n1 1 1\n").unwrap(); diff --git a/crates/effects/src/utility.rs b/crates/effects/src/utility.rs index d735dc286..afb430e1d 100644 --- a/crates/effects/src/utility.rs +++ b/crates/effects/src/utility.rs @@ -359,9 +359,15 @@ pub fn lut_file(src: &str) -> Option<&str> { } /// The files a [`lut_params`] parameter set to `src` reads: the ones its cached result was read -/// from (an OCIO config's also the LUTs it names, and the places it looked for missing ones), else -/// the file it names. +/// from (an OCIO config's also the LUTs it names, and the places it looked for missing ones; an +/// `.ocio` config not read yet is read), else the file it names. pub fn lut_files(src: &str) -> Vec { + // A config not read yet is read now: the LUTs it names are its files from the first render. + if crate::ocio_config::cached_files(src).is_none() + && lut_file(src).is_some_and(|p| std::path::Path::new(p).extension().is_some_and(|e| e.eq_ignore_ascii_case("ocio"))) + { + let _ = crate::ocio_config::load_config(src); + } crate::ocio_config::cached_files(src) .or_else(|| crate::ocio::cached_files(src)) .or_else(|| file_cache::lock(LUTS.get()).files(src)) diff --git a/crates/engine/src/tests/lut_files.rs b/crates/engine/src/tests/lut_files.rs index 0153a9997..98c95652a 100644 --- a/crates/engine/src/tests/lut_files.rs +++ b/crates/engine/src/tests/lut_files.rs @@ -205,20 +205,19 @@ fn ocio_files_render_again_from_warm_caches() { "OCIO Color Space Transform", &[("config", json!(1)), ("configFile", json!(config.to_string_lossy())), ("sourceName", json!("graded")), ("destinationName", json!("lin"))], ); - assert_all(colours(&s, file), 0.0); - assert_all(colours(&s, custom), 0.0); - // (the first key of a config's layer can't know the LUTs it names before it is read) - assert_all(colours(&s, custom), 0.0); - let misses = s.layer_cache.stats().misses; - assert_all(colours(&s, file), 0.0); - assert_all(colours(&s, custom), 0.0); - assert_eq!(s.layer_cache.stats().misses, misses, "unchanged files keep the cached layers"); + // A render notes the LUT the config names (a frame on disk is made of it too). let log = ReadLog::new(); let mut r = s.renderer(RenderOpts::default()); r.reads = Some(&log); let _ = r.comp_frame(custom.1, Tick::ZERO); let files = log.into_files(); assert!(files.get(&grade.to_string_lossy()).is_some(), "the render notes the config's LUT: {files:?}"); + assert_all(colours(&s, file), 0.0); + assert_all(colours(&s, custom), 0.0); + let misses = s.layer_cache.stats().misses; + assert_all(colours(&s, file), 0.0); + assert_all(colours(&s, custom), 0.0); + assert_eq!(s.layer_cache.stats().misses, misses, "unchanged files keep the cached layers"); let generation = effectcraft_effects::lut_generation(); write(&lut, WHITE, 2_000); assert_all(colours(&s, file), 1.0);