#3538: a custom config not read yet is read for its LUT files

This commit is contained in:
arnav-hiwarkar committed 2026-11-12 15:07:48 +05:30
1 parent a700c5c8db
commit 4d24233505
3 files changed
+17 -11

No files matched your search

+2 -1
View File
@@ -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 - !<ColorSpace>\n name: lin\n - !<ColorSpace>\n name: graded\n to_reference: !<FileTransform> {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();
+8 -2
View File
@@ -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<String> {
// 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))
+7 -8
View File
@@ -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);