| author | |
| committer | |
| log | 142f667440ff79b189144d5169789cf9415aa93f |
| tree | c102b113d31b9d01c232089135a14c6d2893c368 |
| parent | a9e082f3772c8342dd079ae2c2823f4b5e9bf91f |
| signature | Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU |
Assisted-by: claude-sonnet-5.55 files changed, 281 insertions(+), 59 deletions(-)
crates/app/src/add_tool.rs+69-1| ... | ... | @@ -11,6 +11,7 @@ pub enum ToolCategory { |
| 11 | 11 | BlurGlow, |
| 12 | 12 | TransformWarp, |
| 13 | 13 | Mask, |
| 14 | Shape2D, | |
| 14 | 15 | Particle, |
| 15 | 16 | Scene3D, |
| 16 | 17 | Utility, |
| ... | ... | @@ -26,6 +27,7 @@ impl ToolCategory { |
| 26 | 27 | Self::BlurGlow => "Blur/Glow", |
| 27 | 28 | Self::TransformWarp => "Transform/Warp", |
| 28 | 29 | Self::Mask => "Mask", |
| 30 | Self::Shape2D => "Shape", | |
| 29 | 31 | Self::Particle => "Particle", |
| 30 | 32 | Self::Scene3D => "3D", |
| 31 | 33 | Self::Utility => "Utility", |
| ... | ... | @@ -41,6 +43,7 @@ impl ToolCategory { |
| 41 | 43 | Self::BlurGlow => [0.94, 0.50, 0.28, 1.0], |
| 42 | 44 | Self::TransformWarp => [0.88, 0.72, 0.28, 1.0], |
| 43 | 45 | Self::Mask => [0.34, 0.66, 0.98, 1.0], |
| 46 | Self::Shape2D => [0.52, 0.78, 0.40, 1.0], | |
| 44 | 47 | Self::Particle => [0.88, 0.46, 0.78, 1.0], |
| 45 | 48 | Self::Scene3D => [0.30, 0.86, 0.92, 1.0], |
| 46 | 49 | Self::Utility => [0.56, 0.62, 0.72, 1.0], |
| ... | ... | @@ -64,12 +67,14 @@ pub const TOOL_CATALOG: &[ToolEntry] = &[ |
| 64 | 67 | ToolEntry { kind: "Plasma", display: "Plasma", aliases: "gradient organic", category: ToolCategory::Generator, is_generator: true }, |
| 65 | 68 | ToolEntry { kind: "TextPlus", display: "Text+", aliases: "textplus title font", category: ToolCategory::Generator, is_generator: true }, |
| 66 | 69 | ToolEntry { kind: "Loader", display: "Loader", aliases: "ld read media footage image", category: ToolCategory::Generator, is_generator: true }, |
| 70 | ToolEntry { kind: "DaySky", display: "Day Sky", aliases: "sky sun atmosphere preetham hdri", category: ToolCategory::Generator, is_generator: true }, | |
| 67 | 71 | // Composite |
| 68 | 72 | ToolEntry { kind: "Merge", display: "Merge", aliases: "mrg over blend comp", category: ToolCategory::Composite, is_generator: false }, |
| 69 | 73 | ToolEntry { kind: "Dissolve", display: "Dissolve", aliases: "dx mix crossfade", category: ToolCategory::Composite, is_generator: false }, |
| 70 | 74 | ToolEntry { kind: "ChannelBoolean", display: "Channel Booleans", aliases: "cb channel matte", category: ToolCategory::Composite, is_generator: false }, |
| 71 | 75 | ToolEntry { kind: "Switch", display: "Switch", aliases: "sw select", category: ToolCategory::Composite, is_generator: false }, |
| 72 | 76 | ToolEntry { kind: "Shadow", display: "Shadow", aliases: "drop shadow", category: ToolCategory::Composite, is_generator: false }, |
| 77 | ToolEntry { kind: "Paint", display: "Paint", aliases: "brush stroke clone retouch", category: ToolCategory::Composite, is_generator: false }, | |
| 73 | 78 | // Color |
| 74 | 79 | ToolEntry { kind: "BrightnessContrast", display: "Brightness / Contrast", aliases: "bc gain lift gamma", category: ToolCategory::Color, is_generator: false }, |
| 75 | 80 | ToolEntry { kind: "ColorCorrector", display: "Color Corrector", aliases: "cc grade wheel saturation", category: ToolCategory::Color, is_generator: false }, |
| ... | ... | @@ -84,7 +89,7 @@ pub const TOOL_CATALOG: &[ToolEntry] = &[ |
| 84 | 89 | // Keyer |
| 85 | 90 | ToolEntry { kind: "UltraKeyer", display: "Ultra Keyer", aliases: "uk chroma green blue screen", category: ToolCategory::Keyer, is_generator: false }, |
| 86 | 91 | ToolEntry { kind: "LumaKeyer", display: "Luma Keyer", aliases: "lk luminance key", category: ToolCategory::Keyer, is_generator: false }, |
| 87 | ToolEntry { kind: "Cryptomatte", display: "Cryptomatte", aliases: "crypto id matte", category: ToolCategory::Keyer, is_generator: false }, | |
| 92 | ToolEntry { kind: "Fuse.Cryptomatte", display: "Cryptomatte", aliases: "cryptomatte crypto id matte", category: ToolCategory::Keyer, is_generator: false }, | |
| 88 | 93 | // Blur / Glow |
| 89 | 94 | ToolEntry { kind: "Blur", display: "Blur", aliases: "bl gaussian defocus", category: ToolCategory::BlurGlow, is_generator: false }, |
| 90 | 95 | ToolEntry { kind: "DirectionalBlur", display: "Directional Blur", aliases: "db radial zoom motion blur", category: ToolCategory::BlurGlow, is_generator: false }, |
| ... | ... | @@ -106,11 +111,29 @@ pub const TOOL_CATALOG: &[ToolEntry] = &[ |
| 106 | 111 | ToolEntry { kind: "Displace", display: "Displace", aliases: "dsp refract warp bump", category: ToolCategory::TransformWarp, is_generator: false }, |
| 107 | 112 | ToolEntry { kind: "Vortex", display: "Vortex", aliases: "swirl twist", category: ToolCategory::TransformWarp, is_generator: false }, |
| 108 | 113 | ToolEntry { kind: "Fuse.XfChroma", display: "XfChroma", aliases: "chromatic aberration rgb split", category: ToolCategory::TransformWarp, is_generator: false }, |
| 114 | ToolEntry { kind: "PerspectivePositioner", display: "Perspective Positioner", aliases: "pp rectify quad corner", category: ToolCategory::TransformWarp, is_generator: false }, | |
| 115 | ToolEntry { kind: "GridWarp", display: "Grid Warp", aliases: "gw mesh bezier lattice", category: ToolCategory::TransformWarp, is_generator: false }, | |
| 116 | ToolEntry { kind: "Drip", display: "Drip", aliases: "ripple concentric wave", category: ToolCategory::TransformWarp, is_generator: false }, | |
| 117 | ToolEntry { kind: "Dent", display: "Dent", aliases: "pinch punch bulge lens", category: ToolCategory::TransformWarp, is_generator: false }, | |
| 118 | ToolEntry { kind: "Fuse.Duplicate", display: "Duplicate", aliases: "copies repeat array clone", category: ToolCategory::TransformWarp, is_generator: false }, | |
| 119 | ToolEntry { kind: "Fuse.KScope", display: "Kaleidoscope", aliases: "kscope mirror slices", category: ToolCategory::TransformWarp, is_generator: false }, | |
| 109 | 120 | // Mask |
| 110 | 121 | ToolEntry { kind: "EllipseMask", display: "Ellipse Mask", aliases: "el circle oval", category: ToolCategory::Mask, is_generator: true }, |
| 111 | 122 | ToolEntry { kind: "RectangleMask", display: "Rectangle Mask", aliases: "rect box square", category: ToolCategory::Mask, is_generator: true }, |
| 112 | 123 | ToolEntry { kind: "PolylineMask", display: "Polygon Mask", aliases: "poly roto spline", category: ToolCategory::Mask, is_generator: true }, |
| 113 | 124 | ToolEntry { kind: "BitmapMask", display: "Bitmap Mask", aliases: "bmp alpha luma", category: ToolCategory::Mask, is_generator: false }, |
| 125 | ToolEntry { kind: "WandMask", display: "Wand Mask", aliases: "wand magic select flood", category: ToolCategory::Mask, is_generator: false }, | |
| 126 | ToolEntry { kind: "PaintMask", display: "Paint Mask", aliases: "brush stroke matte", category: ToolCategory::Mask, is_generator: false }, | |
| 127 | // Shape | |
| 128 | ToolEntry { kind: "sRender", display: "Shape Render", aliases: "srender rasterize vector shapes", category: ToolCategory::Shape2D, is_generator: false }, | |
| 129 | ToolEntry { kind: "sEllipse", display: "Shape Ellipse", aliases: "sellipse vector circle oval", category: ToolCategory::Shape2D, is_generator: true }, | |
| 130 | ToolEntry { kind: "sRectangle", display: "Shape Rectangle", aliases: "srect vector box rounded", category: ToolCategory::Shape2D, is_generator: true }, | |
| 131 | ToolEntry { kind: "sNGon", display: "Shape NGon", aliases: "sngon vector polygon sides", category: ToolCategory::Shape2D, is_generator: true }, | |
| 132 | ToolEntry { kind: "sGrid", display: "Shape Grid", aliases: "sgrid vector cells array", category: ToolCategory::Shape2D, is_generator: true }, | |
| 133 | ToolEntry { kind: "sMerge", display: "Shape Merge", aliases: "smerge vector combine", category: ToolCategory::Shape2D, is_generator: false }, | |
| 134 | ToolEntry { kind: "sTransform", display: "Shape Transform", aliases: "stransform vector move scale rotate", category: ToolCategory::Shape2D, is_generator: false }, | |
| 135 | ToolEntry { kind: "sBoolean", display: "Shape Boolean", aliases: "sbool vector union subtract intersect xor", category: ToolCategory::Shape2D, is_generator: false }, | |
| 136 | ToolEntry { kind: "sOutline", display: "Shape Outline", aliases: "soutline vector stroke", category: ToolCategory::Shape2D, is_generator: false }, | |
| 114 | 137 | // Particle |
| 115 | 138 | ToolEntry { kind: "pEmitter", display: "pEmitter", aliases: "pe particle emit", category: ToolCategory::Particle, is_generator: true }, |
| 116 | 139 | ToolEntry { kind: "pRender", display: "pRender", aliases: "pr particle render", category: ToolCategory::Particle, is_generator: false }, |
| ... | ... | @@ -121,6 +144,7 @@ pub const TOOL_CATALOG: &[ToolEntry] = &[ |
| 121 | 144 | ToolEntry { kind: "pFriction", display: "pFriction", aliases: "particle friction", category: ToolCategory::Particle, is_generator: false }, |
| 122 | 145 | ToolEntry { kind: "pKill", display: "pKill", aliases: "particle kill", category: ToolCategory::Particle, is_generator: false }, |
| 123 | 146 | ToolEntry { kind: "pMerge", display: "pMerge", aliases: "particle merge", category: ToolCategory::Particle, is_generator: false }, |
| 147 | ToolEntry { kind: "pBounce", display: "pBounce", aliases: "particle collision rebound", category: ToolCategory::Particle, is_generator: false }, | |
| 124 | 148 | // 3D |
| 125 | 149 | ToolEntry { kind: "Renderer3D", display: "Renderer 3D", aliases: "3rn render 3d", category: ToolCategory::Scene3D, is_generator: false }, |
| 126 | 150 | ToolEntry { kind: "Merge3D", display: "Merge 3D", aliases: "3mg scene 3d", category: ToolCategory::Scene3D, is_generator: false }, |
| ... | ... | @@ -130,6 +154,22 @@ pub const TOOL_CATALOG: &[ToolEntry] = &[ |
| 130 | 154 | ToolEntry { kind: "Transform3D", display: "Transform 3D", aliases: "3xf move 3d", category: ToolCategory::Scene3D, is_generator: false }, |
| 131 | 155 | ToolEntry { kind: "LightAmbient", display: "Ambient Light", aliases: "3la light", category: ToolCategory::Scene3D, is_generator: true }, |
| 132 | 156 | ToolEntry { kind: "LightDirectional", display: "Directional Light", aliases: "3dl sun light", category: ToolCategory::Scene3D, is_generator: true }, |
| 157 | ToolEntry { kind: "Cube3D", display: "Cube 3D", aliases: "3cu box", category: ToolCategory::Scene3D, is_generator: true }, | |
| 158 | ToolEntry { kind: "SurfaceFBXMesh", display: "FBX Mesh", aliases: "3fbx obj import model", category: ToolCategory::Scene3D, is_generator: true }, | |
| 159 | ToolEntry { kind: "Text3D", display: "Text 3D", aliases: "3txt extrude title", category: ToolCategory::Scene3D, is_generator: true }, | |
| 160 | ToolEntry { kind: "LightPoint", display: "Point Light", aliases: "3pl omni light", category: ToolCategory::Scene3D, is_generator: true }, | |
| 161 | ToolEntry { kind: "LightSpot", display: "Spot Light", aliases: "3sl cone light", category: ToolCategory::Scene3D, is_generator: true }, | |
| 162 | ToolEntry { kind: "MtlBlinn", display: "Blinn Material", aliases: "blinn specular shader", category: ToolCategory::Scene3D, is_generator: true }, | |
| 163 | ToolEntry { kind: "MtlPhong", display: "Phong Material", aliases: "specular shader", category: ToolCategory::Scene3D, is_generator: true }, | |
| 164 | ToolEntry { kind: "MtlCookTorrance", display: "Cook-Torrance Material", aliases: "pbr roughness shader", category: ToolCategory::Scene3D, is_generator: true }, | |
| 165 | ToolEntry { kind: "Texture2DOperator", display: "Texture 2D", aliases: "3tex image material", category: ToolCategory::Scene3D, is_generator: false }, | |
| 166 | ToolEntry { kind: "TextureTransformOperator", display: "Texture Transform", aliases: "uv tile material", category: ToolCategory::Scene3D, is_generator: false }, | |
| 167 | ToolEntry { kind: "BumpMap", display: "Bump Map", aliases: "height normal relief", category: ToolCategory::Scene3D, is_generator: false }, | |
| 168 | ToolEntry { kind: "ReplaceMaterial3D", display: "Replace Material 3D", aliases: "3rm override shader", category: ToolCategory::Scene3D, is_generator: false }, | |
| 169 | ToolEntry { kind: "Override3D", display: "Override 3D", aliases: "3ov visibility lighting", category: ToolCategory::Scene3D, is_generator: false }, | |
| 170 | ToolEntry { kind: "Duplicate3D", display: "Duplicate 3D", aliases: "3du instance copies", category: ToolCategory::Scene3D, is_generator: false }, | |
| 171 | ToolEntry { kind: "ReplaceNormals3D", display: "Replace Normals 3D", aliases: "3rn flip normals", category: ToolCategory::Scene3D, is_generator: false }, | |
| 172 | ToolEntry { kind: "Displace3D", display: "Displace 3D", aliases: "3dp heightmap vertex", category: ToolCategory::Scene3D, is_generator: false }, | |
| 133 | 173 | // Utility |
| 134 | 174 | ToolEntry { kind: "Saver", display: "Saver", aliases: "sv write export png", category: ToolCategory::Utility, is_generator: false }, |
| 135 | 175 | ToolEntry { kind: "PipeRouter", display: "Pipe Router", aliases: "dot router wire", category: ToolCategory::Utility, is_generator: false }, |
| ... | ... | @@ -140,6 +180,10 @@ pub const TOOL_CATALOG: &[ToolEntry] = &[ |
| 140 | 180 | ToolEntry { kind: "Tracker", display: "Tracker", aliases: "tr matchmove", category: ToolCategory::Utility, is_generator: false }, |
| 141 | 181 | ToolEntry { kind: "Note", display: "Sticky Note", aliases: "comment note", category: ToolCategory::Utility, is_generator: true }, |
| 142 | 182 | ToolEntry { kind: "Underlay", display: "Underlay", aliases: "backdrop group", category: ToolCategory::Utility, is_generator: true }, |
| 183 | ToolEntry { kind: "Custom", display: "Custom Tool", aliases: "ct shader expression", category: ToolCategory::Utility, is_generator: false }, | |
| 184 | ToolEntry { kind: "Fuse.Wireless", display: "Wireless Link", aliases: "wireless jump portal", category: ToolCategory::Utility, is_generator: false }, | |
| 185 | ToolEntry { kind: "Dimension.OpticalFlow", display: "Optical Flow", aliases: "flow motion vectors retime", category: ToolCategory::Utility, is_generator: false }, | |
| 186 | ToolEntry { kind: "Dimension.CopyAux", display: "Copy Aux", aliases: "aux channels passthrough", category: ToolCategory::Utility, is_generator: false }, | |
| 143 | 187 | ]; |
| 144 | 188 | |
| 145 | 189 | /// Case-insensitive fuzzy/subsequence scoring for tool search. |
| ... | ... | @@ -549,6 +593,30 @@ mod tests { |
| 549 | 593 | assert!(res_3d.iter().any(|e| e.kind == "Camera3D")); |
| 550 | 594 | } |
| 551 | 595 | |
| 596 | #[test] | |
| 597 | fn catalog_kinds_are_unique_and_supported() { | |
| 598 | let mut seen = std::collections::HashSet::new(); | |
| 599 | for entry in TOOL_CATALOG { | |
| 600 | assert!(seen.insert(entry.kind), "duplicate catalog kind {}", entry.kind); | |
| 601 | assert!(model::is_supported_tool(entry.kind), "{} is not a supported tool", entry.kind); | |
| 602 | } | |
| 603 | for kind in [ | |
| 604 | "sRender", "sEllipse", "sBoolean", "Paint", "PaintMask", "DaySky", "Drip", "Dent", | |
| 605 | "PerspectivePositioner", "GridWarp", "Cube3D", "SurfaceFBXMesh", "MtlBlinn", | |
| 606 | "MtlPhong", "MtlCookTorrance", "LightPoint", "LightSpot", "WandMask", | |
| 607 | "Fuse.Duplicate", "Fuse.KScope", "Fuse.Wireless", "Fuse.Cryptomatte", | |
| 608 | "Dimension.OpticalFlow", "Dimension.CopyAux", "pBounce", "Custom", "Switch", | |
| 609 | ] { | |
| 610 | assert!(seen.contains(kind), "catalog is missing {kind}"); | |
| 611 | } | |
| 612 | } | |
| 613 | ||
| 614 | #[test] | |
| 615 | fn cryptomatte_search_yields_exact_fusion_id() { | |
| 616 | let res = search_tools("cryptomatte"); | |
| 617 | assert_eq!(res[0].kind, "Fuse.Cryptomatte"); | |
| 618 | } | |
| 619 | ||
| 552 | 620 | #[test] |
| 553 | 621 | fn non_matching_query_returns_empty() { |
| 554 | 622 | let res = search_tools("zzzznotatool999"); |
crates/engine/src/bin/render_check.rs+17-13| ... | ... | @@ -8,7 +8,7 @@ use std::fs::File; |
| 8 | 8 | use std::path::{Path, PathBuf}; |
| 9 | 9 | use std::time::Instant; |
| 10 | 10 | |
| 11 | fn compute_diff(pixels: &[u8], tex_size: [u32; 2], ref_path: &Path) -> Result<(f64, f64), Box<dyn std::error::Error>> { | |
| 11 | fn compute_diff(pixels: &[u8], tex_size: [u32; 2], ref_path: &Path) -> Result<(f64, f64, f64), Box<dyn std::error::Error>> { | |
| 12 | 12 | let mut ref_img = image::open(ref_path)?.to_rgba8(); |
| 13 | 13 | if [ref_img.width(), ref_img.height()] != tex_size { |
| 14 | 14 | ref_img = image::imageops::resize( |
| ... | ... | @@ -21,17 +21,19 @@ fn compute_diff(pixels: &[u8], tex_size: [u32; 2], ref_path: &Path) -> Result<(f |
| 21 | 21 | let rraw = ref_img.into_raw(); |
| 22 | 22 | let mut sum_abs = 0u64; |
| 23 | 23 | let mut sum_sq = 0u64; |
| 24 | let n = (tex_size[0] as u64) * (tex_size[1] as u64) * 3; | |
| 24 | let mut alpha_abs = 0u64; | |
| 25 | let px = (tex_size[0] as u64) * (tex_size[1] as u64); | |
| 25 | 26 | for (a, b) in pixels.chunks_exact(4).zip(rraw.chunks_exact(4)) { |
| 26 | 27 | for c in 0..3 { |
| 27 | 28 | let d = (a[c] as i32 - b[c] as i32).unsigned_abs() as u64; |
| 28 | 29 | sum_abs += d; |
| 29 | 30 | sum_sq += d * d; |
| 30 | 31 | } |
| 32 | alpha_abs += (a[3] as i32 - b[3] as i32).unsigned_abs() as u64; | |
| 31 | 33 | } |
| 32 | let mae = sum_abs as f64 / n as f64; | |
| 33 | let rmse = (sum_sq as f64 / n as f64).sqrt(); | |
| 34 | Ok((mae, rmse)) | |
| 34 | let mae = sum_abs as f64 / (px * 3) as f64; | |
| 35 | let rmse = (sum_sq as f64 / (px * 3) as f64).sqrt(); | |
| 36 | Ok((mae, rmse, alpha_abs as f64 / px as f64)) | |
| 35 | 37 | } |
| 36 | 38 | |
| 37 | 39 | fn write_png(path: &Path, size: [u32; 2], pixels: &[u8]) -> Result<(), Box<dyn std::error::Error>> { |
| ... | ... | @@ -59,10 +61,10 @@ fn run_suite(manifest_path: &Path, hiq: bool) -> Result<(), Box<dyn std::error:: |
| 59 | 61 | manifest_path.display() |
| 60 | 62 | ); |
| 61 | 63 | eprintln!( |
| 62 | "{:<6} {:<20} {:>6} {:>7} {:>7} {:>8} {:>8} {:>7} {}", | |
| 63 | "STATUS", "CASE", "FRAME", "MAE%", "RMSE", "WARM_MS", "BUST_MS", "VRAM", "UNSUPPORTED" | |
| 64 | "{:<6} {:<20} {:>6} {:>7} {:>7} {:>7} {:>8} {:>8} {:>7} {}", | |
| 65 | "STATUS", "CASE", "FRAME", "MAE%", "A_MAE%", "RMSE", "WARM_MS", "BUST_MS", "VRAM", "UNSUPPORTED" | |
| 64 | 66 | ); |
| 65 | eprintln!("{}", "-".repeat(94)); | |
| 67 | eprintln!("{}", "-".repeat(102)); | |
| 66 | 68 | |
| 67 | 69 | for (lineno, raw) in text.lines().enumerate() { |
| 68 | 70 | let line = raw.trim(); |
| ... | ... | @@ -97,8 +99,9 @@ fn run_suite(manifest_path: &Path, hiq: bool) -> Result<(), Box<dyn std::error:: |
| 97 | 99 | let (_, bust) = engine.evaluate(comp, target, frame); |
| 98 | 100 | |
| 99 | 101 | let pixels = engine.readback_rgba(&tex)?; |
| 100 | let (mae, rmse) = compute_diff(&pixels, tex.size, &ref_path)?; | |
| 102 | let (mae, rmse, alpha_mae) = compute_diff(&pixels, tex.size, &ref_path)?; | |
| 101 | 103 | let mae_pct = mae / 2.55; |
| 104 | let alpha_mae_pct = alpha_mae / 2.55; | |
| 102 | 105 | |
| 103 | 106 | let ok = mae_pct <= max_mae_pct && bust.eval_ms <= max_bust_ms; |
| 104 | 107 | if ok { |
| ... | ... | @@ -107,11 +110,12 @@ fn run_suite(manifest_path: &Path, hiq: bool) -> Result<(), Box<dyn std::error:: |
| 107 | 110 | failed += 1; |
| 108 | 111 | } |
| 109 | 112 | eprintln!( |
| 110 | "{:<6} {:<20} {:>6} {:>6.2}% {:>7.2} {:>7.2}ms {:>7.2}ms {:>5.0}MB {:?}", | |
| 113 | "{:<6} {:<20} {:>6} {:>6.2}% {:>6.2}% {:>7.2} {:>7.2}ms {:>7.2}ms {:>5.0}MB {:?}", | |
| 111 | 114 | if ok { "PASS" } else { "FAIL" }, |
| 112 | 115 | case_name, |
| 113 | 116 | frame as i64, |
| 114 | 117 | mae_pct, |
| 118 | alpha_mae_pct, | |
| 115 | 119 | rmse, |
| 116 | 120 | warm.eval_ms, |
| 117 | 121 | bust.eval_ms, |
| ... | ... | @@ -126,7 +130,7 @@ fn run_suite(manifest_path: &Path, hiq: bool) -> Result<(), Box<dyn std::error:: |
| 126 | 130 | } |
| 127 | 131 | } |
| 128 | 132 | |
| 129 | eprintln!("{}", "-".repeat(94)); | |
| 133 | eprintln!("{}", "-".repeat(102)); | |
| 130 | 134 | eprintln!("Suite summary: {passed} passed, {failed} failed"); |
| 131 | 135 | if failed > 0 { |
| 132 | 136 | std::process::exit(1); |
| ... | ... | @@ -661,9 +665,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 661 | 665 | eprintln!("Wrote {} ({}x{})", out_path.display(), tex.size[0], tex.size[1]); |
| 662 | 666 | } |
| 663 | 667 | if let Some(rp) = ref_path { |
| 664 | let (mae, rmse) = compute_diff(&pixels, tex.size, &rp)?; | |
| 668 | let (mae, rmse, alpha_mae) = compute_diff(&pixels, tex.size, &rp)?; | |
| 665 | 669 | eprintln!( |
| 666 | "Diff vs {} ({}x{}): MAE={mae:.2}/255 ({:.1}%), RMSE={rmse:.2}/255", | |
| 670 | "Diff vs {} ({}x{}): MAE={mae:.2}/255 ({:.1}%), A_MAE={alpha_mae:.2}/255, RMSE={rmse:.2}/255", | |
| 667 | 671 | rp.display(), |
| 668 | 672 | tex.size[0], |
| 669 | 673 | tex.size[1], |
scripts/diff_fuzz/matrix.py+61-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | """Exhaustive edge-case parameter matrix suites (Merge, HDR, masks, color/blur, warps, 3D, misc, paint).""" | |
| 1 | """Exhaustive edge-case parameter matrix suites (Merge, HDR, masks, color/blur, warps, 3D, misc, paint, aspect).""" | |
| 2 | 2 | |
| 3 | 3 | from typing import Dict, List, Tuple |
| 4 | 4 | |
| ... | ... | @@ -955,6 +955,62 @@ def build_matrix_paint(assets: Dict[str, str]): |
| 955 | 955 | return comp_path, "matrix_paint", [(c[0], c[1]) for c in cases] |
| 956 | 956 | |
| 957 | 957 | |
| 958 | ASPECT_SIZES = ((320, 180), (180, 320), (321, 181)) | |
| 959 | ||
| 960 | _ASPECT_SETUP = """\t\tBlackBG = Background { Inputs = { Width = Input { Value = @W@, }, Height = Input { Value = @H@, }, TopLeftAlpha = Input { Value = 1, }, }, }, | |
| 961 | \t\tWhiteFG = Background { Inputs = { Width = Input { Value = @W@, }, Height = Input { Value = @H@, }, TopLeftRed = Input { Value = 0.95, }, TopLeftGreen = Input { Value = 0.75, }, TopLeftBlue = Input { Value = 0.25, }, TopLeftAlpha = Input { Value = 1, }, }, }, | |
| 962 | \t\tSmallFG = Background { Inputs = { Width = Input { Value = @HW@, }, Height = Input { Value = @HH@, }, TopLeftRed = Input { Value = 0.2, }, TopLeftGreen = Input { Value = 0.8, }, TopLeftBlue = Input { Value = 0.5, }, TopLeftAlpha = Input { Value = 1, }, }, },""" | |
| 963 | ||
| 964 | _ASPECT_CASES = ( | |
| 965 | ("BG_Horizontal", 'Background { Inputs = { Width = Input { Value = @W@, }, Height = Input { Value = @H@, }, Type = Input { Value = FuID { "Horizontal" }, }, TopLeftRed = Input { Value = 0.9, }, TopLeftGreen = Input { Value = 0.2, }, TopLeftBlue = Input { Value = 0.1, }, TopLeftAlpha = Input { Value = 1, }, TopRightRed = Input { Value = 0.1, }, TopRightGreen = Input { Value = 0.3, }, TopRightBlue = Input { Value = 0.9, }, TopRightAlpha = Input { Value = 1, }, }, }'), | |
| 966 | ("BG_Vertical", 'Background { Inputs = { Width = Input { Value = @W@, }, Height = Input { Value = @H@, }, Type = Input { Value = FuID { "Vertical" }, }, TopLeftRed = Input { Value = 0.9, }, TopLeftGreen = Input { Value = 0.2, }, TopLeftBlue = Input { Value = 0.1, }, TopLeftAlpha = Input { Value = 1, }, BottomLeftRed = Input { Value = 0.1, }, BottomLeftGreen = Input { Value = 0.3, }, BottomLeftBlue = Input { Value = 0.9, }, BottomLeftAlpha = Input { Value = 1, }, }, }'), | |
| 967 | ("BG_FourCorner", 'Background { Inputs = { Width = Input { Value = @W@, }, Height = Input { Value = @H@, }, Type = Input { Value = FuID { "Four Corner" }, }, TopLeftRed = Input { Value = 1, }, TopLeftAlpha = Input { Value = 1, }, TopRightGreen = Input { Value = 1, }, TopRightAlpha = Input { Value = 1, }, BottomLeftBlue = Input { Value = 1, }, BottomLeftAlpha = Input { Value = 1, }, BottomRightRed = Input { Value = 1, }, BottomRightGreen = Input { Value = 1, }, BottomRightAlpha = Input { Value = 1, }, }, }'), | |
| 968 | ("EllipseMask_Circle", 'Merge { Inputs = { Background = Input { SourceOp = "BlackBG", Source = "Output", }, Foreground = Input { SourceOp = "WhiteFG", Source = "Output", }, EffectMask = Input { SourceOp = "@MASK@", Source = "Mask", }, }, }', | |
| 969 | 'EllipseMask { Inputs = { MaskWidth = Input { Value = @W@, }, MaskHeight = Input { Value = @H@, }, Width = Input { Value = 0.5, }, Height = Input { Value = 0.5, }, SoftEdge = Input { Value = 0.02, }, }, }'), | |
| 970 | ("EllipseMask_Rotated", 'Merge { Inputs = { Background = Input { SourceOp = "BlackBG", Source = "Output", }, Foreground = Input { SourceOp = "WhiteFG", Source = "Output", }, EffectMask = Input { SourceOp = "@MASK@", Source = "Mask", }, }, }', | |
| 971 | 'EllipseMask { Inputs = { MaskWidth = Input { Value = @W@, }, MaskHeight = Input { Value = @H@, }, Center = Input { Value = { 0.4, 0.55 }, }, Width = Input { Value = 0.6, }, Height = Input { Value = 0.3, }, Angle = Input { Value = 30, }, BorderWidth = Input { Value = 0.01, }, }, }'), | |
| 972 | ("RectangleMask_Rounded", 'Merge { Inputs = { Background = Input { SourceOp = "BlackBG", Source = "Output", }, Foreground = Input { SourceOp = "WhiteFG", Source = "Output", }, EffectMask = Input { SourceOp = "@MASK@", Source = "Mask", }, }, }', | |
| 973 | 'RectangleMask { Inputs = { MaskWidth = Input { Value = @W@, }, MaskHeight = Input { Value = @H@, }, Width = Input { Value = 0.6, }, Height = Input { Value = 0.4, }, CornerRadius = Input { Value = 0.1, }, SoftEdge = Input { Value = 0.02, }, }, }'), | |
| 974 | ("RectangleMask_Rotated", 'Merge { Inputs = { Background = Input { SourceOp = "BlackBG", Source = "Output", }, Foreground = Input { SourceOp = "WhiteFG", Source = "Output", }, EffectMask = Input { SourceOp = "@MASK@", Source = "Mask", }, }, }', | |
| 975 | 'RectangleMask { Inputs = { MaskWidth = Input { Value = @W@, }, MaskHeight = Input { Value = @H@, }, Center = Input { Value = { 0.55, 0.45 }, }, Width = Input { Value = 0.5, }, Height = Input { Value = 0.3, }, Angle = Input { Value = -25, }, }, }'), | |
| 976 | ("Transform_Rotation", 'Transform { Inputs = { Input = Input { SourceOp = "Grad", Source = "Output", }, Angle = Input { Value = 30, }, Size = Input { Value = 0.7, }, }, }'), | |
| 977 | ("Transform_Rotation_Aspect", 'Transform { Inputs = { Input = Input { SourceOp = "Grad", Source = "Output", }, Center = Input { Value = { 0.6, 0.45 }, }, Pivot = Input { Value = { 0.3, 0.6 }, }, Angle = Input { Value = 28, }, Aspect = Input { Value = 1.5, }, Size = Input { Value = 0.8, }, }, }'), | |
| 978 | ("Merge_Center_Size_Angle", 'Merge { Inputs = { Background = Input { SourceOp = "Grad", Source = "Output", }, Foreground = Input { SourceOp = "SmallFG", Source = "Output", }, Center = Input { Value = { 0.65, 0.4 }, }, Size = Input { Value = 0.8, }, Angle = Input { Value = 35, }, }, }'), | |
| 979 | ("DVE_Rotation", 'DVE { Inputs = { Input = Input { SourceOp = "Grad", Source = "Output", }, XRotation = Input { Value = 25, }, YRotation = Input { Value = -30, }, ZRotation = Input { Value = 15, }, ZMove = Input { Value = 1.2, }, }, }'), | |
| 980 | ("TextPlus_Centered", 'TextPlus { Inputs = { Width = Input { Value = @W@, }, Height = Input { Value = @H@, }, Font = Input { Value = "Liberation Sans", }, Style = Input { Value = "Regular", }, StyledText = Input { Value = "Aspect 321", }, Size = Input { Value = 0.18, }, Center = Input { Value = { 0.5, 0.5 }, }, }, }'), | |
| 981 | ) | |
| 982 | ||
| 983 | ||
| 984 | def _build_matrix_aspect(w: int, h: int): | |
| 985 | """Non-square and odd-dimension canvases: gradients, masks, Transform/Merge/DVE geometry and TextPlus at WxH.""" | |
| 986 | sub = {"@W@": str(w), "@H@": str(h), "@HW@": str(w // 2), "@HH@": str(h // 2)} | |
| 987 | ||
| 988 | def fill(text: str) -> str: | |
| 989 | for k, v in sub.items(): | |
| 990 | text = text.replace(k, v) | |
| 991 | return text | |
| 992 | ||
| 993 | nodes = [ | |
| 994 | fill(_ASPECT_SETUP), | |
| 995 | fill(f'\t\tGrad = {_ASPECT_CASES[0][1]},'), | |
| 996 | ] | |
| 997 | cases: List[Tuple[int, str, str]] = [] | |
| 998 | for f, (label, body, *mask) in enumerate(_ASPECT_CASES): | |
| 999 | if mask: | |
| 1000 | nodes.append(fill(f"\t\tMask_{f} = {mask[0]},")) | |
| 1001 | body = body.replace("@MASK@", f"Mask_{f}") | |
| 1002 | nodes.append(fill(f"\t\tOp_{f} = {body},")) | |
| 1003 | cases.append((f, label, f"Op_{f}")) | |
| 1004 | ||
| 1005 | prefix = f"matrix_aspect_{w}x{h}" | |
| 1006 | sw_nodes, sw_splines, out_op = build_switch_chain(cases, "BlackBG", "AS") | |
| 1007 | nodes.extend(sw_nodes) | |
| 1008 | nodes.append(make_saver(out_op, prefix)) | |
| 1009 | comp_path = ensure_dirs() / "comps" / f"{prefix}.comp" | |
| 1010 | comp_path.write_text(make_comp("\n".join(nodes + sw_splines), len(cases) - 1, w=w, h=h)) | |
| 1011 | return comp_path, prefix, [(c[0], c[1]) for c in cases] | |
| 1012 | ||
| 1013 | ||
| 958 | 1014 | MATRIX_BUILDERS = { |
| 959 | 1015 | "matrix_merge_modes": build_matrix_merge_modes, |
| 960 | 1016 | "matrix_hdr_depth": build_matrix_hdr_depth, |
| ... | ... | @@ -964,6 +1020,10 @@ MATRIX_BUILDERS = { |
| 964 | 1020 | "matrix_3d": build_matrix_3d, |
| 965 | 1021 | "matrix_misc": build_matrix_misc, |
| 966 | 1022 | "matrix_paint": build_matrix_paint, |
| 1023 | **{ | |
| 1024 | f"matrix_aspect_{w}x{h}": (lambda assets, w=w, h=h: _build_matrix_aspect(w, h)) | |
| 1025 | for w, h in ASPECT_SIZES | |
| 1026 | }, | |
| 967 | 1027 | } |
| 968 | 1028 | |
| 969 | 1029 |
scripts/diff_fuzz/runner.py+24-4| ... | ... | @@ -14,6 +14,7 @@ from .assets import ( |
| 14 | 14 | ensure_render_check, |
| 15 | 15 | make_comp, |
| 16 | 16 | make_saver, |
| 17 | read_png_rgba, | |
| 17 | 18 | build_switch_chain, |
| 18 | 19 | use_smb, |
| 19 | 20 | ) |
| ... | ... | @@ -22,6 +23,21 @@ from .fuzzer import FuzzGraph, SplineParam |
| 22 | 23 | |
| 23 | 24 | |
| 24 | 25 | |
| 26 | def alpha_mae_pct(ours_path: Path, gt_path: Path) -> float: | |
| 27 | """Mean absolute alpha error as a percentage; GT is nearest-sampled onto our size when they differ.""" | |
| 28 | ow, oh, ob = read_png_rgba(ours_path) | |
| 29 | gw, gh, gb = read_png_rgba(gt_path) | |
| 30 | if (ow, oh) == (gw, gh): | |
| 31 | total = sum(abs(a - b) for a, b in zip(ob[3::4], gb[3::4])) | |
| 32 | else: | |
| 33 | total = sum( | |
| 34 | abs(ob[(y * ow + x) * 4 + 3] - gb[(min(gh - 1, int((y + 0.5) * gh / oh)) * gw + min(gw - 1, int((x + 0.5) * gw / ow))) * 4 + 3]) | |
| 35 | for y in range(oh) | |
| 36 | for x in range(ow) | |
| 37 | ) | |
| 38 | return total / (ow * oh) / 2.55 | |
| 39 | ||
| 40 | ||
| 25 | 41 | def run_comp_both( |
| 26 | 42 | comp_path: Path, |
| 27 | 43 | prefix: str, |
| ... | ... | @@ -122,6 +138,8 @@ def run_comp_both( |
| 122 | 138 | gt_p = root / "gt" / f"{prefix}_{f:04d}.png" |
| 123 | 139 | ours_p = ours_sub / f"{f:04d}.png" |
| 124 | 140 | m = compute_diff_metrics(ours_p, gt_p) |
| 141 | if "error" not in m: | |
| 142 | m["alpha_mae_pct"] = alpha_mae_pct(ours_p, gt_p) | |
| 125 | 143 | m["frame"] = f |
| 126 | 144 | m["label"] = label |
| 127 | 145 | results[f] = m |
| ... | ... | @@ -295,11 +313,12 @@ def bisect_failing_graph( |
| 295 | 313 | |
| 296 | 314 | def print_table(title: str, rows: List[Dict[str, Any]], threshold_pct: float) -> None: |
| 297 | 315 | print(f"\n=== {title} ===") |
| 298 | print(f" {'Case':<44s} | {'MAE%':>7s} | {'MAE':>6s} | {'RMSE':>6s} | {'Status'}") | |
| 299 | print(f" {'-'*44}-+-{'-'*7}-+-{'-'*6}-+-{'-'*6}-+-{'-'*18}") | |
| 316 | print(f" {'Case':<44s} | {'MAE%':>7s} | {'A_MAE%':>7s} | {'MAE':>6s} | {'RMSE':>6s} | {'Status'}") | |
| 317 | print(f" {'-'*44}-+-{'-'*7}-+-{'-'*7}-+-{'-'*6}-+-{'-'*6}-+-{'-'*18}") | |
| 300 | 318 | for r in rows: |
| 301 | 319 | label = str(r.get("label", ""))[:44] |
| 302 | 320 | mae_pct = r.get("mae_pct", 100.0) |
| 321 | a_pct = r.get("alpha_mae_pct", 0.0) | |
| 303 | 322 | mae = r.get("mae_255", 255.0) |
| 304 | 323 | rmse = r.get("rmse_255", 255.0) |
| 305 | 324 | if r.get("error"): |
| ... | ... | @@ -308,7 +327,8 @@ def print_table(title: str, rows: List[Dict[str, Any]], threshold_pct: float) -> |
| 308 | 327 | status = f"SIZE {r.get('dims_ours')}!={r.get('dims_gt')}" |
| 309 | 328 | elif mae_pct > threshold_pct: |
| 310 | 329 | status = "FAIL" |
| 330 | elif a_pct > threshold_pct: | |
| 331 | status = "PASS (ALPHA DIFF)" | |
| 311 | 332 | else: |
| 312 | 333 | status = "PASS" |
| 313 | print(f" {label:<44s} | {mae_pct:6.2f}% | {mae:6.2f} | {rmse:6.2f} | {status}") | |
| 314 | ||
| 334 | print(f" {label:<44s} | {mae_pct:6.2f}% | {a_pct:6.2f}% | {mae:6.2f} | {rmse:6.2f} | {status}") |
scripts/gen_compatibility.py+110-40| ... | ... | @@ -17,8 +17,11 @@ from typing import Dict, List, Optional, Sequence, Set, Tuple |
| 17 | 17 | |
| 18 | 18 | REPO_ROOT = Path(__file__).resolve().parent.parent |
| 19 | 19 | EVAL_RS = REPO_ROOT / "crates" / "engine" / "src" / "eval" / "mod.rs" |
| 20 | EVAL_DIR_LABEL = "crates/engine/src/eval/" | |
| 21 | SCENE3D_DIR_LABEL = "crates/engine/src/scene3d/" | |
| 20 | 22 | SCENE3D_RS = REPO_ROOT / "crates" / "engine" / "src" / "scene3d" / "collect.rs" |
| 21 | 23 | COMP_RS = REPO_ROOT / "crates" / "model" / "src" / "comp.rs" |
| 24 | ADD_TOOL_RS = REPO_ROOT / "crates" / "app" / "src" / "add_tool.rs" | |
| 22 | 25 | PROBES_PY = REPO_ROOT / "scripts" / "fusion_probes.py" |
| 23 | 26 | DEFAULT_OUTPUT = REPO_ROOT / "compatibility.md" |
| 24 | 27 | |
| ... | ... | @@ -37,6 +40,16 @@ class ToolMeta: |
| 37 | 40 | aliases: Tuple[str, ...] = () |
| 38 | 41 | |
| 39 | 42 | |
| 43 | # Supported tools intentionally absent from the Add Tool launcher: created by other | |
| 44 | # tools or by grouping, or a duplicate spelling of a listed tool. | |
| 45 | ADD_TOOL_EXCLUDED: Set[str] = { | |
| 46 | "PolylineStroke", # created by Paint | |
| 47 | "Multistroke", # created by Paint | |
| 48 | "MacroOperator", # created by grouping | |
| 49 | "GroupOperator", # created by grouping | |
| 50 | "Fuse.Switch", # Switch covers it | |
| 51 | } | |
| 52 | ||
| 40 | 53 | CATEGORIES: Sequence[str] = ( |
| 41 | 54 | "Generators", |
| 42 | 55 | "Compositing & Blending", |
| ... | ... | @@ -52,7 +65,7 @@ CATEGORIES: Sequence[str] = ( |
| 52 | 65 | ) |
| 53 | 66 | |
| 54 | 67 | # Structured metadata for every supported Flow tool. |
| 55 | # Any tool discovered in eval.rs / scene3d.rs that is missing here will be | |
| 68 | # Any tool discovered in eval/ or scene3d/ that is missing here will be | |
| 56 | 69 | # flagged automatically so compatibility.md never drifts stale. |
| 57 | 70 | TOOL_METADATA: Sequence[ToolMeta] = ( |
| 58 | 71 | # Generators |
| ... | ... | @@ -190,7 +203,7 @@ TOOL_METADATA: Sequence[ToolMeta] = ( |
| 190 | 203 | ToolMeta("MacroOperator", "Time, Routing & Utility", "Suite comps", "0.0%", "Unpacks internal `Tools` subgraph and evaluates exported output seamlessly."), |
| 191 | 204 | ToolMeta("GroupOperator", "Time, Routing & Utility", "Suite comps", "0.0%", "Unpacks internal `Tools` subgraph and evaluates exported output seamlessly."), |
| 192 | 205 | ToolMeta("Custom", "Time, Routing & Utility", "Suite comps", "0.1%–0.6%", "Custom Tool shader evaluation (procedural wave/channel expressions + `UserControls` defaults)."), |
| 193 | ToolMeta("Note", "Time, Routing & Utility", "—", "N/A", "Non-rendering Flow sticky note; preserved losslessly on `.comp` roundtrip."), | |
| 206 | ToolMeta("Note", "Time, Routing & Utility", "—", "N/A", "Non-rendering Flow sticky note; preserved losslessly on `.comp` roundtrip.", aliases=("StickyNote",)), | |
| 194 | 207 | ToolMeta("Underlay", "Time, Routing & Utility", "—", "N/A", "Non-rendering Flow backdrop/group box; preserved losslessly on `.comp` roundtrip."), |
| 195 | 208 | ) |
| 196 | 209 | |
| ... | ... | @@ -231,7 +244,7 @@ UNSUPPORTED_NOTES: Sequence[UnsupportedMeta] = ( |
| 231 | 244 | |
| 232 | 245 | |
| 233 | 246 | def parse_eval_rs(path: Path) -> Set[str]: |
| 234 | """Extract all supported tool class names from eval_node_inner in eval.rs.""" | |
| 247 | """Extract all supported tool class names from eval_node_inner in eval/mod.rs.""" | |
| 235 | 248 | text = path.read_text(encoding="utf-8") |
| 236 | 249 | m = re.search(r"fn eval_node_inner\b.*?(?=\n fn |\n\})", text, re.S) |
| 237 | 250 | if not m: |
| ... | ... | @@ -250,24 +263,52 @@ def parse_eval_rs(path: Path) -> Set[str]: |
| 250 | 263 | return tools |
| 251 | 264 | |
| 252 | 265 | |
| 266 | def _top_level_match_arms(text: str, header: str) -> Set[str]: | |
| 267 | """String literals in the arm patterns of the first `match` whose header regex matches. | |
| 268 | ||
| 269 | Tracks brace depth instead of source indentation, so arms are found at any nesting. | |
| 270 | """ | |
| 271 | m = re.search(header, text, re.S) | |
| 272 | if not m: | |
| 273 | raise RuntimeError(f"Could not locate match header /{header}/") | |
| 274 | names: Set[str] = set() | |
| 275 | depth = 1 | |
| 276 | pattern = "" | |
| 277 | for line in text[m.end():].splitlines(): | |
| 278 | code = re.sub(r'"(?:[^"\\]|\\.)*"', '""', line) | |
| 279 | if depth == 1: | |
| 280 | pattern += line + "\n" | |
| 281 | if "=>" in line: | |
| 282 | names.update(re.findall(r'"([^"]+)"', pattern.split("=>", 1)[0])) | |
| 283 | pattern = "" | |
| 284 | depth += code.count("{") - code.count("}") | |
| 285 | if depth <= 0: | |
| 286 | break | |
| 287 | if depth > 1: | |
| 288 | pattern = "" | |
| 289 | return names | |
| 290 | ||
| 291 | ||
| 253 | 292 | def parse_scene3d_rs(path: Path) -> Set[str]: |
| 254 | """Extract all supported 3D tool class names from collect_scene & resolve_material in scene3d.rs.""" | |
| 293 | """Extract supported 3D tool class names from the scene collection and material-resolution matches.""" | |
| 294 | text = path.read_text(encoding="utf-8") | |
| 295 | return _top_level_match_arms(text, r"match node\.kind\.as_str\(\)\s*\{") | _top_level_match_arms( | |
| 296 | text, r"fn resolve_material_inner\b.*?match n\.kind\.as_str\(\)\s*\{" | |
| 297 | ) | |
| 298 | ||
| 299 | ||
| 300 | def parse_is_supported_tool(path: Path) -> Set[str]: | |
| 301 | """Return every class name accepted by `is_supported_tool` in comp.rs.""" | |
| 255 | 302 | text = path.read_text(encoding="utf-8") |
| 256 | m = re.search(r"match node\.kind\.as_str\(\)\s*\{(.*?)\n _ => \{\}", text, re.S) | |
| 303 | m = re.search(r"fn is_supported_tool\b.*?matches!\(\s*kind,(.*?)\n \)", text, re.S) | |
| 257 | 304 | if not m: |
| 258 | raise RuntimeError(f"Could not locate collect_scene match in {path}") | |
| 259 | tools: Set[str] = set() | |
| 260 | for line in m.group(1).splitlines(): | |
| 261 | if line.startswith(' "') and "=>" in line: | |
| 262 | lhs = line.split("=>", 1)[0] | |
| 263 | tools.update(re.findall(r'"([^"]+)"', lhs)) | |
| 264 | mm = re.search(r"match n\.kind\.as_str\(\)\s*\{(.*?)\n _ =>", text, re.S) | |
| 265 | if mm: | |
| 266 | for line in mm.group(1).splitlines(): | |
| 267 | if line.startswith(' "') and "=>" in line: | |
| 268 | lhs = line.split("=>", 1)[0] | |
| 269 | tools.update(re.findall(r'"([^"]+)"', lhs)) | |
| 270 | return tools | |
| 305 | raise RuntimeError(f"Could not locate is_supported_tool in {path}") | |
| 306 | return set(re.findall(r'"([^"]+)"', re.sub(r"//[^\n]*", "", m.group(1)))) | |
| 307 | ||
| 308 | ||
| 309 | def parse_add_tool_catalog(path: Path) -> Set[str]: | |
| 310 | """Return every `kind` listed in TOOL_CATALOG of add_tool.rs.""" | |
| 311 | return set(re.findall(r'ToolEntry\s*\{\s*kind:\s*"([^"]+)"', path.read_text(encoding="utf-8"))) | |
| 271 | 312 | |
| 272 | 313 | |
| 273 | 314 | def parse_comp_rs_modifiers(path: Path) -> Tuple[List[str], Set[str]]: |
| ... | ... | @@ -296,34 +337,45 @@ def parse_probe_suites(path: Path) -> Set[str]: |
| 296 | 337 | return set(re.findall(r'"([^"]+)"\s*:', m.group(1))) |
| 297 | 338 | |
| 298 | 339 | |
| 299 | TOOLS_START_RE = re.compile(r"(?m)^\tTools\s*=\s*(?:ordered\(\)\s*)?\{") | |
| 300 | TOP_TOOL_RE = re.compile( | |
| 301 | r'^\t\t(?:\["[^"]+"\]|[A-Za-z_][A-Za-z0-9_]*)\s*=\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\{' | |
| 340 | TOOL_RE = re.compile( | |
| 341 | r'^(\t+)(?:\["[^"]+"\]|[A-Za-z_][A-Za-z0-9_]*)\s*=\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\{' | |
| 302 | 342 | ) |
| 343 | TOOLS_BLOCK_RE = re.compile(r"^(\t+)Tools\s*=\s*(?:ordered\(\)\s*)?\{") | |
| 344 | ||
| 345 | ||
| 346 | def count_tool_classes(text: str) -> Counter[str]: | |
| 347 | """Count tool classes in every `Tools` block, including those nested in Macro/Group operators.""" | |
| 348 | counts: Counter[str] = Counter() | |
| 349 | block_indents: List[int] = [] # tab depth of each open Tools block | |
| 350 | for line in text.splitlines(): | |
| 351 | stripped = line.lstrip("\t") | |
| 352 | depth = len(line) - len(stripped) | |
| 353 | if block_indents and depth <= block_indents[-1] and stripped.startswith("}"): | |
| 354 | block_indents.pop() | |
| 355 | continue | |
| 356 | if block_indents and depth == block_indents[-1] + 1: | |
| 357 | tm = TOOL_RE.match(line) | |
| 358 | if tm: | |
| 359 | counts[tm.group(2)] += 1 | |
| 360 | continue | |
| 361 | if TOOLS_BLOCK_RE.match(line): | |
| 362 | block_indents.append(depth) | |
| 363 | return counts | |
| 303 | 364 | |
| 304 | 365 | |
| 305 | 366 | def scan_comp_corpus(root: Path) -> Optional[Tuple[int, Counter[str]]]: |
| 306 | """Lightweight top-level tool-class scanner over all *.comp files under root.""" | |
| 367 | """Tool-class counts over all *.comp files under root.""" | |
| 307 | 368 | if not root.exists(): |
| 308 | 369 | return None |
| 309 | counts: Counter[str] = Counter() | |
| 310 | 370 | comp_files = sorted(root.rglob("*.comp")) |
| 311 | 371 | if not comp_files: |
| 312 | 372 | return None |
| 373 | counts: Counter[str] = Counter() | |
| 313 | 374 | for path in comp_files: |
| 314 | 375 | try: |
| 315 | text = path.read_text(encoding="utf-8", errors="replace") | |
| 376 | counts += count_tool_classes(path.read_text(encoding="utf-8", errors="replace")) | |
| 316 | 377 | except OSError: |
| 317 | 378 | continue |
| 318 | m = TOOLS_START_RE.search(text) | |
| 319 | if not m: | |
| 320 | continue | |
| 321 | for line in text[m.end():].splitlines(): | |
| 322 | if line.startswith("\t}"): | |
| 323 | break | |
| 324 | tm = TOP_TOOL_RE.match(line) | |
| 325 | if tm: | |
| 326 | counts[tm.group(1)] += 1 | |
| 327 | 379 | return len(comp_files), counts |
| 328 | 380 | |
| 329 | 381 | |
| ... | ... | @@ -359,6 +411,8 @@ def build_markdown( |
| 359 | 411 | eval_tools: Set[str], |
| 360 | 412 | scene3d_tools: Set[str], |
| 361 | 413 | impl_modifiers: Set[str], |
| 414 | comp_supported: Set[str], | |
| 415 | catalog_kinds: Set[str], | |
| 362 | 416 | probe_suites: Set[str], |
| 363 | 417 | active_corpus: Optional[Tuple[int, Counter[str]]], |
| 364 | 418 | archive_corpus: Optional[Tuple[int, Counter[str]]], |
| ... | ... | @@ -384,7 +438,7 @@ def build_markdown( |
| 384 | 438 | meta_all_names.update(m.aliases) |
| 385 | 439 | non_render_tools = {"Note", "Underlay"} |
| 386 | 440 | |
| 387 | # Detect drift: tools in eval.rs / scene3d.rs not in TOOL_METADATA | |
| 441 | # Detect drift: tools in eval/ or scene3d/ not in TOOL_METADATA | |
| 388 | 442 | uncategorized = sorted(live_engine_tools - meta_all_names) |
| 389 | 443 | for name in uncategorized: |
| 390 | 444 | warnings.append(f"Uncategorized tool found in engine source: {name}") |
| ... | ... | @@ -392,7 +446,7 @@ def build_markdown( |
| 392 | 446 | # Detect stale metadata: tools in TOOL_METADATA no longer in engine source (excluding Note/Underlay) |
| 393 | 447 | stale = sorted((set(meta_by_name.keys()) - non_render_tools) - live_engine_tools) |
| 394 | 448 | for name in stale: |
| 395 | warnings.append(f"Stale tool in metadata not found in eval.rs/scene3d.rs: {name}") | |
| 449 | warnings.append(f"Stale tool in metadata not found in {EVAL_DIR_LABEL} or {SCENE3D_DIR_LABEL}: {name}") | |
| 396 | 450 | |
| 397 | 451 | # Detect uncategorized modifiers |
| 398 | 452 | known_mod_classes: Set[str] = set() |
| ... | ... | @@ -402,6 +456,20 @@ def build_markdown( |
| 402 | 456 | for name in uncategorized_mods: |
| 403 | 457 | warnings.append(f"Uncategorized modifier found in comp.rs: {name}") |
| 404 | 458 | |
| 459 | # is_supported_tool() must accept exactly the metadata classes (plus modifier classes). | |
| 460 | for name in sorted(comp_supported - meta_all_names - known_mod_classes): | |
| 461 | warnings.append(f"is_supported_tool accepts {name} but TOOL_METADATA has no entry") | |
| 462 | for name in sorted(((live_engine_tools | non_render_tools) & set(meta_by_name)) - comp_supported): | |
| 463 | warnings.append(f"is_supported_tool rejects {name} although the engine evaluates it") | |
| 464 | ||
| 465 | # Add Tool launcher must offer every user-creatable supported tool and nothing unsupported. | |
| 466 | for name in sorted(set(meta_by_name) - ADD_TOOL_EXCLUDED - catalog_kinds): | |
| 467 | warnings.append(f"add_tool.rs TOOL_CATALOG is missing {name}") | |
| 468 | for name in sorted(catalog_kinds - comp_supported): | |
| 469 | warnings.append(f"add_tool.rs TOOL_CATALOG lists {name} which is not supported") | |
| 470 | for name in sorted(catalog_kinds & ADD_TOOL_EXCLUDED): | |
| 471 | warnings.append(f"add_tool.rs TOOL_CATALOG lists {name} which ADD_TOOL_EXCLUDED omits") | |
| 472 | ||
| 405 | 473 | all_supported_tools = live_engine_tools | non_render_tools |
| 406 | 474 | all_supported_classes = all_supported_tools | impl_modifiers |
| 407 | 475 | |
| ... | ... | @@ -409,8 +477,8 @@ def build_markdown( |
| 409 | 477 | lines.append("# Fusion 21.1 Compatibility Matrix") |
| 410 | 478 | lines.append("") |
| 411 | 479 | lines.append( |
| 412 | "Auto-generated from live engine sources (`crates/engine/src/eval.rs`, " | |
| 413 | "`crates/engine/src/scene3d.rs`, `crates/model/src/comp.rs`) and real Fusion `.comp` corpora " | |
| 480 | f"Auto-generated from live engine sources (`{EVAL_DIR_LABEL}`, " | |
| 481 | f"`{SCENE3D_DIR_LABEL}`, `crates/model/src/comp.rs`) and real Fusion `.comp` corpora " | |
| 414 | 482 | "via `python3 scripts/gen_compatibility.py`." |
| 415 | 483 | ) |
| 416 | 484 | lines.append("") |
| ... | ... | @@ -427,7 +495,7 @@ def build_markdown( |
| 427 | 495 | lines.append("| --- | --- |") |
| 428 | 496 | lines.append( |
| 429 | 497 | f"| **Supported Flow Tools** | **{len(all_supported_tools)}** " |
| 430 | f"({len(eval_tools)} 2D/Fuse/utility in `eval.rs`, {len(scene3d_tools - eval_tools)} 3D scene nodes in `scene3d.rs`, 2 Flow annotations) |" | |
| 498 | f"({len(eval_tools)} 2D/Fuse/utility in `{EVAL_DIR_LABEL}`, {len(scene3d_tools - eval_tools)} 3D scene nodes in `{SCENE3D_DIR_LABEL}`, 2 Flow annotations) |" | |
| 431 | 499 | ) |
| 432 | 500 | lines.append( |
| 433 | 501 | f"| **Modifiers & Animation** | **{len(MODIFIER_METADATA)}** systems " |
| ... | ... | @@ -470,7 +538,7 @@ def build_markdown( |
| 470 | 538 | lines.append("## Uncategorized (New in Engine)") |
| 471 | 539 | lines.append("") |
| 472 | 540 | lines.append("> [!WARNING]") |
| 473 | lines.append("> The following tools were found in `eval.rs` / `scene3d.rs` but are not yet listed in `TOOL_METADATA` in `scripts/gen_compatibility.py`.") | |
| 541 | lines.append(f"> The following tools were found in `{EVAL_DIR_LABEL}` / `{SCENE3D_DIR_LABEL}` but are not yet listed in `TOOL_METADATA` in `scripts/gen_compatibility.py`.") | |
| 474 | 542 | lines.append("") |
| 475 | 543 | lines.append(f"| Tool | {usage_col} |") |
| 476 | 544 | lines.append("| --- | --- |") |
| ... | ... | @@ -551,7 +619,7 @@ def main() -> int: |
| 551 | 619 | parser.add_argument("-o", "--output", type=Path, default=DEFAULT_OUTPUT, help="Output markdown path.") |
| 552 | 620 | parser.add_argument("--active-dir", type=Path, default=ACTIVE_CORPUS_DIR, help="Active Fusion .comp directory.") |
| 553 | 621 | parser.add_argument("--archive-dir", type=Path, default=ARCHIVE_CORPUS_DIR, help="Archive Fusion .comp directory.") |
| 554 | parser.add_argument("--strict", action="store_true", help="Exit non-zero if uncategorized or stale tools are found.") | |
| 622 | parser.add_argument("--strict", action="store_true", help="Exit non-zero on any registry drift: engine vs TOOL_METADATA vs is_supported_tool vs add_tool.rs.") | |
| 555 | 623 | args = parser.parse_args() |
| 556 | 624 | |
| 557 | 625 | eval_tools = parse_eval_rs(EVAL_RS) |
| ... | ... | @@ -566,6 +634,8 @@ def main() -> int: |
| 566 | 634 | eval_tools=eval_tools, |
| 567 | 635 | scene3d_tools=scene3d_tools, |
| 568 | 636 | impl_modifiers=impl_modifiers, |
| 637 | comp_supported=parse_is_supported_tool(COMP_RS), | |
| 638 | catalog_kinds=parse_add_tool_catalog(ADD_TOOL_RS), | |
| 569 | 639 | probe_suites=probe_suites, |
| 570 | 640 | active_corpus=active_corpus, |
| 571 | 641 | archive_corpus=archive_corpus, |