Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
refactor(effects): one effect at a time, no lanes
EtienneLescotcfb9de2226a2
diff --git a/crates/compositor/src/compositor_linux.rs b/crates/compositor/src/compositor_linux.rsindex 0b464ed83..dc7567373 100644--- a/crates/compositor/src/compositor_linux.rs+++ b/crates/compositor/src/compositor_linux.rs@@ -6948,9 +6948,9 @@ mod tests {}/// Un fragment d'effet de 1 s à 3 s, tel que l'app l'envoie.- fn fx(code: &str, target: &str, lane: u32) -> serde_json::Value {+ fn fx(code: &str, target: &str) -> serde_json::Value {serde_json::json!({- "clipIndex": 0, "startSec": 1.0, "endSec": 3.0, "target": target, "lane": lane,+ "clipIndex": 0, "startSec": 1.0, "endSec": 3.0, "target": target,"contract": 1, "code": code,"params": [{"name": "level", "type": "number"}, {"name": "tint", "type": "color"}],"values": {"level": 1.0, "tint": [0.0, 1.0, 0.0, 1.0]},@@ -6998,7 +6998,7 @@ mod tests {#[test]fn a_shader_effect_repaints_the_composed_frame_inside_its_region() {let Some(gpu) = gpu() else { return };- let comp = fx_compositor(&gpu, 320, 180, serde_json::json!([fx(INVERT, "image", 0)]));+ let comp = fx_compositor(&gpu, 320, 180, serde_json::json!([fx(INVERT, "image")]));assert_eq!(corner_at(&comp, &gpu, 0.5), [255, 0, 0], "avant la région : le fond rouge");assert_eq!(corner_at(&comp, &gpu, 2.0), [0, 255, 255], "dans la région : rouge inversé");assert_eq!(corner_at(&comp, &gpu, 3.5), [255, 0, 0], "après la région : le fond rouge");@@ -7011,7 +7011,7 @@ mod tests {let Some(gpu) = gpu() else { return };let comp = Compositor::new_sized(&gpu, 320, 180).expect("compositeur");comp.set_shader_fx_blocking(false);- let scene = shader_fx_scene(serde_json::json!([fx(INVERT, "image", 0)]));+ let scene = shader_fx_scene(serde_json::json!([fx(INVERT, "image")]));comp.set_live_params(live_params_from_scene(&scene));let start = std::time::Instant::now();comp.set_scene(Some(scene));@@ -7028,13 +7028,12 @@ mod tests {/// qui paniquerait sur une erreur de validation.#[test]fn a_broken_or_unknown_effect_leaves_the_frame_untouched() {- let broken = fx("fn effect(uv: vec2<f32>) -> vec4<f32> { nope }", "image", 0);+ let broken = fx("fn effect(uv: vec2<f32>) -> vec4<f32> { nope }", "image");let extra = fx("@group(0) @binding(4) var<uniform> extra: vec4<f32>;\nfn effect(uv: vec2<f32>) -> vec4<f32> { return extra; }","image",- 0,);- let mut future = fx(BLUE, "image", 0);+ let mut future = fx(BLUE, "image");future["contract"] = serde_json::json!(2);for effect in [broken, extra, future] {let Some(corner) = corner_under(serde_json::json!([effect])) else { return };@@ -7046,7 +7045,7 @@ mod tests {/// suit le nombre `level` dans le buffer, et se lit telle que l'app l'a écrite.#[test]fn a_color_parameter_reaches_the_shader() {- let Some(corner) = corner_under(serde_json::json!([fx(TINT, "image", 0)])) else { return };+ let Some(corner) = corner_under(serde_json::json!([fx(TINT, "image")])) else { return };assert_eq!(corner, [0, 255, 0]);}@@ -7057,7 +7056,7 @@ mod tests {fn a_hidden_cursor_still_hands_the_effect_its_pointer_and_clicks() {let Some(gpu) = gpu() else { return };const SEES: &str = "fn effect(uv: vec2<f32>) -> vec4<f32> { return vec4<f32>(ctx.cursor.z, ctx.clicks[0].w, 0.0, 1.0); }";- let comp = fx_compositor(&gpu, 320, 180, serde_json::json!([fx(SEES, "image", 0)]));+ let comp = fx_compositor(&gpu, 320, 180, serde_json::json!([fx(SEES, "image")]));comp.set_cursor(crate::cursor::CursorTrack::new_with_visibility(vec![(0.0, 0.5, 0.5), (4.0, 0.5, 0.5)],vec![1.5],@@ -7068,35 +7067,19 @@ mod tests {assert_eq!(corner_at(&comp, &gpu, 2.0), [255, 255, 0]);}- /// Les lanes s'appliquent dans l'ordre : bleu puis inversion donne jaune, l'inverse donne bleu.- #[test]- fn lanes_apply_in_order() {- let Some(blue_then_invert) =- corner_under(serde_json::json!([fx(INVERT, "image", 1), fx(BLUE, "image", 0)]))- else {- return;- };- assert_eq!(blue_then_invert, [255, 255, 0]);- let invert_then_blue =- corner_under(serde_json::json!([fx(INVERT, "image", 0), fx(BLUE, "image", 1)])).unwrap();- assert_eq!(invert_then_blue, [0, 0, 255]);- }-- /// `text` ne touche que le calque des textes, posé ensuite sur l'image ; `both` voit tout.- /// Sans annotation, le calque est transparent : un effet `text` qui le rend tel quel laisse- /// l'image intacte, un effet `text` opaque la recouvre.+ /// `text` ne touche que le calque des textes, posé ensuite sur l'image ; `image` et `both`+ /// repeignent l'image. Sans annotation, le calque est transparent : un effet `text` qui le+ /// rend tel quel laisse l'image intacte, un effet `text` opaque la recouvre.#[test]fn the_three_targets_keep_to_their_layer() {- let Some(image_only) = corner_under(serde_json::json!([fx(BLUE, "image", 0)])) else { return };+ let Some(image_only) = corner_under(serde_json::json!([fx(BLUE, "image")])) else { return };assert_eq!(image_only, [0, 0, 255]);- let text_untouched =- corner_under(serde_json::json!([fx(BLUE, "image", 0), fx(SAME, "text", 0)])).unwrap();- assert_eq!(text_untouched, [0, 0, 255], "un calque transparent ne change pas l'image");- let text_opaque =- corner_under(serde_json::json!([fx(BLUE, "image", 0), fx(TINT, "text", 0)])).unwrap();+ let text_untouched = corner_under(serde_json::json!([fx(SAME, "text")])).unwrap();+ assert_eq!(text_untouched, [255, 0, 0], "un calque transparent ne change pas l'image");+ let text_opaque = corner_under(serde_json::json!([fx(TINT, "text")])).unwrap();assert_eq!(text_opaque, [0, 255, 0], "le calque des textes, opaque, posé sur l'image");- let both = corner_under(serde_json::json!([fx(BLUE, "image", 0), fx(INVERT, "both", 0)])).unwrap();- assert_eq!(both, [255, 255, 0], "`both` voit l'image finale");+ let both = corner_under(serde_json::json!([fx(INVERT, "both")])).unwrap();+ assert_eq!(both, [0, 255, 255], "`both` repeint l'image finale");}/// Calibre les paliers de coût : le surcoût par frame d'un effet qui lit `frame()` N fois,@@ -7143,7 +7126,7 @@ mod tests {let code = reads_effect(reads);let report = crate::shader_fx::analyze(&code, &[]).expect("analyse").report;let with = (0..3)- .map(|_| per_frame(w, h, serde_json::json!([fx(&code, "image", 0)])))+ .map(|_| per_frame(w, h, serde_json::json!([fx(&code, "image")]))).fold(f64::MAX, f64::min);eprintln!("{w}x{h} : {reads:>3} lectures ({:>10}) : +{:.3} ms/frame",diff --git a/crates/compositor/src/compositor_macos.rs b/crates/compositor/src/compositor_macos.rsindex cef3da69b..822d1d417 100644--- a/crates/compositor/src/compositor_macos.rs+++ b/crates/compositor/src/compositor_macos.rs@@ -4802,9 +4802,9 @@ mod tests {}/// Un fragment d'effet de 1 s à 3 s, tel que l'app l'envoie.- fn fx(code: &str, target: &str, lane: u32) -> serde_json::Value {+ fn fx(code: &str, target: &str) -> serde_json::Value {serde_json::json!({- "clipIndex": 0, "startSec": 1.0, "endSec": 3.0, "target": target, "lane": lane,+ "clipIndex": 0, "startSec": 1.0, "endSec": 3.0, "target": target,"contract": 1, "code": code,"params": [{"name": "level", "type": "number"}, {"name": "tint", "type": "color"}],"values": {"level": 1.0, "tint": [0.0, 1.0, 0.0, 1.0]},@@ -4856,7 +4856,7 @@ mod tests {return;};let comp = super::Compositor::new_sized(&gpu, 320, 180).expect("compositeur");- comp.set_scene(Some(shader_fx_scene(serde_json::json!([fx(INVERT, "image", 0)]))));+ comp.set_scene(Some(shader_fx_scene(serde_json::json!([fx(INVERT, "image")]))));assert_eq!(corner_at(&comp, 0.5), [255, 0, 0], "avant la région : le fond rouge");assert_eq!(corner_at(&comp, 2.0), [0, 255, 255], "dans la région : rouge inversé");assert_eq!(corner_at(&comp, 3.5), [255, 0, 0], "après la région : le fond rouge");@@ -4872,7 +4872,7 @@ mod tests {};let comp = super::Compositor::new_sized(&gpu, 320, 180).expect("compositeur");comp.set_shader_fx_blocking(false);- comp.set_scene(Some(shader_fx_scene(serde_json::json!([fx(INVERT, "image", 0)]))));+ comp.set_scene(Some(shader_fx_scene(serde_json::json!([fx(INVERT, "image")]))));let start = std::time::Instant::now();while !comp.shader_fx_landed() {assert!(start.elapsed().as_secs() < 10, "la compilation n'a jamais abouti");@@ -4886,8 +4886,8 @@ mod tests {/// pas, la frame reste celle de la composition.#[test]fn a_broken_or_unknown_effect_leaves_the_frame_untouched() {- let broken = fx("fn effect(uv: vec2<f32>) -> vec4<f32> { nope }", "image", 0);- let mut future = fx(BLUE, "image", 0);+ let broken = fx("fn effect(uv: vec2<f32>) -> vec4<f32> { nope }", "image");+ let mut future = fx(BLUE, "image");future["contract"] = serde_json::json!(2);for effect in [broken, future] {let Some(corner) = corner_under(serde_json::json!([effect])) else { return };@@ -4899,7 +4899,7 @@ mod tests {/// suit le nombre `level` dans le buffer, et se lit telle que l'app l'a écrite.#[test]fn a_color_parameter_reaches_the_shader() {- let Some(corner) = corner_under(serde_json::json!([fx(TINT, "image", 0)])) else { return };+ let Some(corner) = corner_under(serde_json::json!([fx(TINT, "image")])) else { return };assert_eq!(corner, [0, 255, 0]);}@@ -4916,7 +4916,7 @@ mod tests {};const PLANE: &str = "fn effect(uv: vec2<f32>) -> vec4<f32> {\n let p = fx_to_footage(uv);\n return vec4<f32>(p, distance(fx_from_footage(p), uv) * 100.0, 1.0);\n}\n";for (rotation, projective) in [(None, false), (Some("left"), false), (Some("orbit"), true)] {- let mut json = shader_fx_json(serde_json::json!([fx(PLANE, "image", 0)]), serde_json::json!([]));+ let mut json = shader_fx_json(serde_json::json!([fx(PLANE, "image")]), serde_json::json!([]));json["clips"] = serde_json::json!([{"screenPath": "/s.mp4", "webcamPath": "", "sourceStartSec": 0,"sourceEndSec": 10, "webcamOffsetSec": 0, "hasAudio": false}]);json["layout"]["screenRect"] = serde_json::json!({"x": 0.1, "y": 0.1, "width": 0.8, "height": 0.8});@@ -4968,7 +4968,7 @@ mod tests {};const SEES: &str = "fn effect(uv: vec2<f32>) -> vec4<f32> { return vec4<f32>(ctx.cursor.z, ctx.clicks[0].w, 0.0, 1.0); }";let comp = super::Compositor::new_sized(&gpu, 320, 180).expect("compositeur");- comp.set_scene(Some(shader_fx_scene(serde_json::json!([fx(SEES, "image", 0)]))));+ comp.set_scene(Some(shader_fx_scene(serde_json::json!([fx(SEES, "image")]))));comp.set_cursor(crate::cursor::CursorTrack::new_with_visibility(vec![(0.0, 0.5, 0.5), (4.0, 0.5, 0.5)],vec![1.5],@@ -4979,35 +4979,19 @@ mod tests {assert_eq!(corner_at(&comp, 2.0), [255, 255, 0]);}- /// Les lanes s'appliquent dans l'ordre : bleu puis inversion donne jaune, l'inverse donne bleu.- #[test]- fn lanes_apply_in_order() {- let Some(blue_then_invert) =- corner_under(serde_json::json!([fx(INVERT, "image", 1), fx(BLUE, "image", 0)]))- else {- return;- };- assert_eq!(blue_then_invert, [255, 255, 0]);- let invert_then_blue =- corner_under(serde_json::json!([fx(INVERT, "image", 0), fx(BLUE, "image", 1)])).unwrap();- assert_eq!(invert_then_blue, [0, 0, 255]);- }-- /// `text` ne touche que le calque des textes, posé ensuite sur l'image ; `both` voit tout.- /// Sans annotation, le calque est transparent : un effet `text` qui le rend tel quel laisse- /// l'image intacte, un effet `text` opaque la recouvre.+ /// `text` ne touche que le calque des textes, posé ensuite sur l'image ; `image` et `both`+ /// repeignent l'image. Sans annotation, le calque est transparent : un effet `text` qui le+ /// rend tel quel laisse l'image intacte, un effet `text` opaque la recouvre.#[test]fn the_three_targets_keep_to_their_layer() {- let Some(image_only) = corner_under(serde_json::json!([fx(BLUE, "image", 0)])) else { return };+ let Some(image_only) = corner_under(serde_json::json!([fx(BLUE, "image")])) else { return };assert_eq!(image_only, [0, 0, 255]);- let text_untouched =- corner_under(serde_json::json!([fx(BLUE, "image", 0), fx(SAME, "text", 0)])).unwrap();- assert_eq!(text_untouched, [0, 0, 255], "un calque transparent ne change pas l'image");- let text_opaque =- corner_under(serde_json::json!([fx(BLUE, "image", 0), fx(TINT, "text", 0)])).unwrap();+ let text_untouched = corner_under(serde_json::json!([fx(SAME, "text")])).unwrap();+ assert_eq!(text_untouched, [255, 0, 0], "un calque transparent ne change pas l'image");+ let text_opaque = corner_under(serde_json::json!([fx(TINT, "text")])).unwrap();assert_eq!(text_opaque, [0, 255, 0], "le calque des textes, opaque, posé sur l'image");- let both = corner_under(serde_json::json!([fx(BLUE, "image", 0), fx(INVERT, "both", 0)])).unwrap();- assert_eq!(both, [255, 255, 0], "`both` voit l'image finale");+ let both = corner_under(serde_json::json!([fx(INVERT, "both")])).unwrap();+ assert_eq!(both, [0, 255, 255], "`both` repeint l'image finale");}/// Avec une vraie annotation : un effet `image` passe dessous sans la toucher, un effet `text`@@ -5038,11 +5022,11 @@ mod tests {let arrow_px = count(&bare, [255, 255, 255]);assert!(arrow_px > 500, "la flèche est dessinée : {arrow_px} px blancs");- let image = rgba_under(serde_json::json!([fx(BLUE, "image", 0)]));+ let image = rgba_under(serde_json::json!([fx(BLUE, "image")]));assert_eq!(count(&image, [255, 255, 255]), arrow_px, "l'effet `image` passe sous la flèche");assert_eq!([image[0], image[1], image[2]], [0, 0, 255]);- let text = rgba_under(serde_json::json!([fx(GREEN_TEXT, "text", 0)]));+ let text = rgba_under(serde_json::json!([fx(GREEN_TEXT, "text")]));assert_eq!(count(&text, [255, 255, 255]), 0, "la flèche est passée par l'effet `text`");assert_eq!(count(&text, [0, 255, 0]), arrow_px, "et elle seule est verte");assert_eq!([text[0], text[1], text[2]], [255, 0, 0], "l'image dessous est intacte");@@ -5090,7 +5074,7 @@ mod tests {let code = reads_effect(reads);let report = crate::shader_fx::analyze(&code, &[]).expect("analyse").report;let with = (0..5)- .map(|_| per_frame(w, h, serde_json::json!([fx(&code, "image", 0)])))+ .map(|_| per_frame(w, h, serde_json::json!([fx(&code, "image")]))).fold(f64::MAX, f64::min);eprintln!("{w}x{h} : {reads:>3} lectures ({:>10}) : +{:.3} ms/frame",diff --git a/crates/compositor/src/compositor_windows.rs b/crates/compositor/src/compositor_windows.rsindex d08204096..81ba78b74 100644--- a/crates/compositor/src/compositor_windows.rs+++ b/crates/compositor/src/compositor_windows.rs@@ -3897,9 +3897,9 @@ mod tests {}/// Un fragment d'effet de 1 s à 3 s, tel que l'app l'envoie.- fn fx(code: &str, target: &str, lane: u32) -> serde_json::Value {+ fn fx(code: &str, target: &str) -> serde_json::Value {serde_json::json!({- "clipIndex": 0, "startSec": 1.0, "endSec": 3.0, "target": target, "lane": lane,+ "clipIndex": 0, "startSec": 1.0, "endSec": 3.0, "target": target,"contract": 1, "code": code,"params": [{"name": "level", "type": "number"}, {"name": "tint", "type": "color"}],"values": {"level": 1.0, "tint": [0.0, 1.0, 0.0, 1.0]},@@ -3945,7 +3945,7 @@ mod tests {return;};let comp = Compositor::new_sized(&gpu, 320, 180).expect("compositeur");- comp.set_scene(Some(shader_fx_scene(serde_json::json!([fx(INVERT, "image", 0)]))));+ comp.set_scene(Some(shader_fx_scene(serde_json::json!([fx(INVERT, "image")]))));assert_eq!(corner_at(&comp, &gpu, 0.5), [255, 0, 0], "avant la région : le fond rouge");assert_eq!(corner_at(&comp, &gpu, 2.0), [0, 255, 255], "dans la région : rouge inversé");assert_eq!(corner_at(&comp, &gpu, 3.5), [255, 0, 0], "après la région : le fond rouge");@@ -3961,7 +3961,7 @@ mod tests {};let comp = Compositor::new_sized(&gpu, 320, 180).expect("compositeur");comp.set_shader_fx_blocking(false);- comp.set_scene(Some(shader_fx_scene(serde_json::json!([fx(INVERT, "image", 0)]))));+ comp.set_scene(Some(shader_fx_scene(serde_json::json!([fx(INVERT, "image")]))));let start = std::time::Instant::now();while !comp.shader_fx_landed() {assert!(start.elapsed().as_secs() < 10, "la compilation n'a jamais abouti");@@ -3975,8 +3975,8 @@ mod tests {/// pas, la frame reste celle de la composition.#[test]fn a_broken_or_unknown_effect_leaves_the_frame_untouched() {- let broken = fx("fn effect(uv: vec2<f32>) -> vec4<f32> { nope }", "image", 0);- let mut future = fx(BLUE, "image", 0);+ let broken = fx("fn effect(uv: vec2<f32>) -> vec4<f32> { nope }", "image");+ let mut future = fx(BLUE, "image");future["contract"] = serde_json::json!(2);for effect in [broken, future] {let Some(corner) = corner_under(serde_json::json!([effect])) else { return };@@ -3988,7 +3988,7 @@ mod tests {/// suit le nombre `level` dans le buffer, et se lit telle que l'app l'a écrite.#[test]fn a_color_parameter_reaches_the_shader() {- let Some(corner) = corner_under(serde_json::json!([fx(TINT, "image", 0)])) else { return };+ let Some(corner) = corner_under(serde_json::json!([fx(TINT, "image")])) else { return };assert_eq!(corner, [0, 255, 0]);}@@ -4004,7 +4004,7 @@ mod tests {};const PLANE: &str = "fn effect(uv: vec2<f32>) -> vec4<f32> {\n let p = fx_to_footage(uv);\n return vec4<f32>(p, distance(fx_from_footage(p), uv) * 100.0, 1.0);\n}\n";for (rotation, projective) in [(None, false), (Some("left"), false), (Some("orbit"), true)] {- let mut json = shader_fx_json(serde_json::json!([fx(PLANE, "image", 0)]));+ let mut json = shader_fx_json(serde_json::json!([fx(PLANE, "image")]));json["clips"] = serde_json::json!([{"screenPath": "/s.mp4", "webcamPath": "", "sourceStartSec": 0,"sourceEndSec": 10, "webcamOffsetSec": 0, "hasAudio": false}]);json["layout"]["screenRect"] = serde_json::json!({"x": 0.1, "y": 0.1, "width": 0.8, "height": 0.8});@@ -4056,7 +4056,7 @@ mod tests {};const SEES: &str = "fn effect(uv: vec2<f32>) -> vec4<f32> { return vec4<f32>(ctx.cursor.z, ctx.clicks[0].w, 0.0, 1.0); }";let comp = Compositor::new_sized(&gpu, 320, 180).expect("compositeur");- comp.set_scene(Some(shader_fx_scene(serde_json::json!([fx(SEES, "image", 0)]))));+ comp.set_scene(Some(shader_fx_scene(serde_json::json!([fx(SEES, "image")]))));comp.set_cursor(crate::cursor::CursorTrack::new_with_visibility(vec![(0.0, 0.5, 0.5), (4.0, 0.5, 0.5)],vec![1.5],@@ -4067,35 +4067,19 @@ mod tests {assert_eq!(corner_at(&comp, &gpu, 2.0), [255, 255, 0]);}- /// Les lanes s'appliquent dans l'ordre : bleu puis inversion donne jaune, l'inverse donne bleu.- #[test]- fn lanes_apply_in_order() {- let Some(blue_then_invert) =- corner_under(serde_json::json!([fx(INVERT, "image", 1), fx(BLUE, "image", 0)]))- else {- return;- };- assert_eq!(blue_then_invert, [255, 255, 0]);- let invert_then_blue =- corner_under(serde_json::json!([fx(INVERT, "image", 0), fx(BLUE, "image", 1)])).unwrap();- assert_eq!(invert_then_blue, [0, 0, 255]);- }-- /// `text` ne touche que le calque des textes, posé ensuite sur l'image ; `both` voit tout.- /// Sans annotation, le calque est transparent : un effet `text` qui le rend tel quel laisse- /// l'image intacte, un effet `text` opaque la recouvre.+ /// `text` ne touche que le calque des textes, posé ensuite sur l'image ; `image` et `both`+ /// repeignent l'image. Sans annotation, le calque est transparent : un effet `text` qui le+ /// rend tel quel laisse l'image intacte, un effet `text` opaque la recouvre.#[test]fn the_three_targets_keep_to_their_layer() {- let Some(image_only) = corner_under(serde_json::json!([fx(BLUE, "image", 0)])) else { return };+ let Some(image_only) = corner_under(serde_json::json!([fx(BLUE, "image")])) else { return };assert_eq!(image_only, [0, 0, 255]);- let text_untouched =- corner_under(serde_json::json!([fx(BLUE, "image", 0), fx(SAME, "text", 0)])).unwrap();- assert_eq!(text_untouched, [0, 0, 255], "un calque transparent ne change pas l'image");- let text_opaque =- corner_under(serde_json::json!([fx(BLUE, "image", 0), fx(TINT, "text", 0)])).unwrap();+ let text_untouched = corner_under(serde_json::json!([fx(SAME, "text")])).unwrap();+ assert_eq!(text_untouched, [255, 0, 0], "un calque transparent ne change pas l'image");+ let text_opaque = corner_under(serde_json::json!([fx(TINT, "text")])).unwrap();assert_eq!(text_opaque, [0, 255, 0], "le calque des textes, opaque, posé sur l'image");- let both = corner_under(serde_json::json!([fx(BLUE, "image", 0), fx(INVERT, "both", 0)])).unwrap();- assert_eq!(both, [255, 255, 0], "`both` voit l'image finale");+ let both = corner_under(serde_json::json!([fx(INVERT, "both")])).unwrap();+ assert_eq!(both, [0, 255, 255], "`both` repeint l'image finale");}/// Calibre les paliers de coût : le surcoût par frame d'un effet qui lit `frame()` N fois,@@ -4139,7 +4123,7 @@ mod tests {let code = reads_effect(reads);let report = crate::shader_fx::analyze(&code, &[]).expect("analyse").report;let with = (0..5)- .map(|_| per_frame(w, h, serde_json::json!([fx(&code, "image", 0)])))+ .map(|_| per_frame(w, h, serde_json::json!([fx(&code, "image")]))).fold(f64::MAX, f64::min);eprintln!("{w}x{h} : {reads:>3} lectures ({:>10}) : +{:.3} ms/frame",diff --git a/crates/compositor/src/scene.rs b/crates/compositor/src/scene.rsindex 7fea6bd7f..94dee1d59 100644--- a/crates/compositor/src/scene.rs+++ b/crates/compositor/src/scene.rs@@ -564,9 +564,6 @@ pub struct SceneShaderEffect {pub programme_end_sec: Option<f64>,#[serde(default)]pub target: ShaderEffectTarget,- /// Ordre d'application : la lane 0 d'abord, au plus près du contenu.- #[serde(default)]- pub lane: u32,/// Version du contrat. Une version que ce compositeur ne connaît pas ne se dessine pas.#[serde(default = "default_contract")]pub contract: u32,diff --git a/crates/compositor/src/shader_fx.rs b/crates/compositor/src/shader_fx.rsindex 4c2d95f34..d62f7cd17 100644--- a/crates/compositor/src/shader_fx.rs+++ b/crates/compositor/src/shader_fx.rs@@ -760,13 +760,11 @@ pub fn eviction_victim(entries: impl Iterator<Item = (u64, u64)>, scene: &[Sceneentries.filter(|(key, _)| !shown.contains(key)).min_by_key(|&(_, used)| used).map(|(key, _)| key)}-/// Les régions actives au temps source `t`, dans l'ordre où elles s'appliquent : par lane, puis-/// dans l'ordre de la scène.+/// Les régions actives au temps source `t`. Le document n'en tient qu'une à la fois ; une scène+/// écrite à la main qui en superpose les applique dans son ordre.pub fn active_effects(effects: &[SceneShaderEffect], t: f32) -> Vec<&SceneShaderEffect> {let t = t as f64;- let mut active: Vec<_> = effects.iter().filter(|e| t >= e.start_sec && t < e.end_sec).collect();- active.sort_by_key(|e| e.lane);- active+ effects.iter().filter(|e| t >= e.start_sec && t < e.end_sec).collect()}/// La boîte englobante (x, y, w, h) d'un quad, en uv de sortie : `ctx.footage` sous un tilt 3D.@@ -950,7 +948,6 @@ pub(crate) fn test_effect(code: &str, params: Vec<ShaderParamDecl>, values: &[(&programme_start_sec: None,programme_end_sec: None,target: ShaderEffectTarget::Image,- lane: 0,contract: CONTRACT,code: code.into(),params,@@ -1205,13 +1202,14 @@ mod tests {#[test]fn the_active_regions_and_their_progress() {let mut a = test_effect(VIGNETTE, vec![], &[]);- a.lane = 1;+ (a.start_sec, a.end_sec) = (3.0, 4.0);let b = test_effect(VIGNETTE, vec![], &[]);let effects = [a, b];assert!(active_effects(&effects, 0.5).is_empty());- let active = active_effects(&effects, 2.0);- assert_eq!(active.iter().map(|e| e.lane).collect::<Vec<_>>(), [0, 1], "par lane");- assert!(active_effects(&effects, 3.0).is_empty(), "fin exclusive");+ let during = active_effects(&effects, 2.0);+ assert!(during.len() == 1 && std::ptr::eq(during[0], &effects[1]));+ let after = active_effects(&effects, 3.0);+ assert!(after.len() == 1 && std::ptr::eq(after[0], &effects[0]), "fin exclusive");let ctx = context(&effects[1], 2.0, 10.0, [1920.0, 1080.0], &FxFrameInputs::default());assert_eq!(ctx.region, [0.5, 2.0, 1.0, 0.0], "fragment, temps source");diff --git a/crates/compositor/tests/render_frames_match_export.rs b/crates/compositor/tests/render_frames_match_export.rsindex 8e765fc32..40a805e49 100644--- a/crates/compositor/tests/render_frames_match_export.rs+++ b/crates/compositor/tests/render_frames_match_export.rs@@ -50,7 +50,7 @@ fn scene_json(source: &str) -> String {"cropByClip": [null, null],"output": {{"width":640,"height":360,"fps":null}},"shaderEffects": [{{- "clipIndex": 1, "startSec": 6.0, "endSec": 20.0, "target": "image", "lane": 0, "contract": 1,+ "clipIndex": 1, "startSec": 6.0, "endSec": 20.0, "target": "image", "contract": 1,"code": "fn effect(uv: vec2<f32>) -> vec4<f32> {{ let c = frame(uv); return vec4<f32>(c.rgb * (0.6 + 0.4 * sin(ctx.time * 3.0)), 1.0); }}","params": [], "values": {{}}}}]diff --git a/docs/shader-effects.md b/docs/shader-effects.mdindex 8bdfdc1e5..8a1dd6833 100644--- a/docs/shader-effects.md+++ b/docs/shader-effects.md@@ -93,7 +93,6 @@ export const shaderEffectRangeSchema = endGteStart(z.object({effectId: z.string().min(1),values: z.record(z.string(), shaderEffectValueSchema).default({}),target: z.enum(["image", "text", "both"]).default("image"),- lane: z.number().int().min(0).max(7).default(0),}), "endMs", "startMs");// documentSchemaShape@@ -115,7 +114,7 @@ shaderEffectRanges: z.array(shaderEffectRangeSchema).optional(),dernière région (`removeRegion`, `mapAllRegionCollections`). Le document ne garde pas de codemort.- **Les `max` du schéma sont des plafonds techniques, pas des budgets.** Ils protègent le document- (64 Ko de code, 32 paramètres, 8 lanes) et sont loin au-dessus de tout effet raisonnable. Ce que+ (64 Ko de code, 32 paramètres) et sont loin au-dessus de tout effet raisonnable. Ce quel'agent doit viser, ce sont les paliers de C.7.### B.3 Ancrée sur le clip, comme les autres régions@@ -140,13 +139,12 @@ ms brutes, sans ancre : elle restait en place pendant que les clips bougeaient.- **L'identité des pilules** (`regionIdentityKey`) compte tous les champs sauf la position et laprovenance. Deux régions contiguës du même effet, aux mêmes `values`, se fondent donc en unepilule, comme deux zooms identiques.-- **Les pistes.** Deux régions d'une même `lane` ne se chevauchent pas, avec la règle des autres- régions (`refuseIfBlocked`). Les lanes s'appliquent dans l'ordre : la lane 0 d'abord, au plus- près du contenu. C'est ce qui permet un ripple sur toute la vidéo ET un glitch- sur une coupe.-- **Après une édition de clip** qui fait se chevaucher deux régions d'une même lane, le rendu- applique les deux, dans l'ordre du tableau, et la piste les montre superposées. Pas de- réparation automatique : contrairement à l'audio, deux effets superposés ne cassent rien.+- **Un effet à la fois** (K.6). Deux régions d'effet ne se chevauchent pas : les outils refusent+ un chevauchement, avec la règle des autres régions (`refuseIfBlocked`). Pour combiner deux+ rendus au même instant, l'agent les écrit dans un seul shader.+- **Après une édition de clip** qui ferait se chevaucher deux régions, le rendu applique les+ deux, dans l'ordre du tableau. Pas de réparation automatique : deux effets superposés ne+ cassent rien.### B.4 Persistance@@ -170,7 +168,7 @@ ajoute à chaque fragment ce que le compositeur ne peut pas recalculer :"shaderEffects": [{"clipIndex": 0, "startSec": 1.0, "endSec": 5.0,"programmeStartSec": 1.0, "programmeEndSec": 5.0,- "target": "image", "lane": 0,+ "target": "image","contract": 1, "code": "fn effect(uv: vec2<f32>) -> vec4<f32> { … }","params": [ { "name": "strength", "type": "number" } ],"values": { "strength": 1.0 }@@ -363,8 +361,6 @@ refusé parce que la machine qui l'écrit est modeste.lectures y dominent aussi : sans les `sin`/`cos` du banc, 128 lectures coûtent encore 10,5 ms.- **Le Radeon 610M** des mesures Linux reste à mesurer. La description de l'outil donnera lespaliers en ms sur la RTX et sur le M1, pour que l'agent raisonne en temps et non en lectures.-- **Plusieurs effets au même instant s'additionnent.** Le retour d'un outil donne le palier de- l'effet, et le palier cumulé du moment le plus chargé de sa région.- **Rien n'est refusé au coût.** Le palier et sa recommandation reviennent à l'agent (E.3), quidécide, et ils restent lisibles dans le snapshot (E.2).@@ -397,11 +393,11 @@ Une région choisit sa cible (`target`). Sans demande explicite, c'est `image`.Les flous de confidentialité restent sûrs. L'effet ne voit que des pixels déjà floutés et ne peutrien y retrouver : il n'existe aucun chemin vers l'image d'avant le flou.-### D.2 Plusieurs effets à la fois+### D.2 Un effet à la fois-- **L'ordre.** Les régions actives à la frame s'appliquent par lane croissante, puis dans- l'ordre du tableau.-- **Le coût.** Chacune fait une copie du RT dans `ann_copy` et une passe plein cadre.+- **Le document n'en tient qu'un à un instant donné** (B.3). Une scène qui en superposerait les+ appliquerait dans l'ordre du tableau.+- **Le coût.** Un effet fait une copie du RT dans `ann_copy` et une passe plein cadre.- **Les cibles s'enchaînent dans l'ordre du dessin :** les effets `image`, puis les textes etleurs effets `text`, puis les effets `both`. Un effet ne voit que ce qui est dessiné avant lui.@@ -519,8 +515,8 @@ intégré les reçoit par le même tableau.| Outil | Arguments | Effet ||---|---|---|-| `addEffect` | `startSec`, `endSec` (secondes de règle), `effect` **ou** `effectId`, `values?`, `target?`, `lane?` | Pose une région. Avec `effect` (`name`, `description`, `code`, `params?`), crée d'abord la définition. Avec `effectId`, réutilise une définition du projet. |-| `setEffect` | `effectRegionId`, `startSec?`, `endSec?`, `values?`, `target?`, `lane?` | Change une région. Seuls les champs passés changent. |+| `addEffect` | `startSec`, `endSec` (secondes de règle), `effect` **ou** `effectId`, `values?`, `target?` | Pose une région. Avec `effect` (`name`, `description`, `code`, `params?`), crée d'abord la définition. Avec `effectId`, réutilise une définition du projet. |+| `setEffect` | `effectRegionId`, `startSec?`, `endSec?`, `values?`, `target?` | Change une région. Seuls les champs passés changent. || `setEffectDefinition` | `effectId`, `name?`, `description?`, `code?`, `params?` | Change une définition, donc toutes les régions qui l'utilisent. Un code neuf est compilé avant d'être accepté. Les `values` d'un paramètre retiré tombent, un paramètre nouveau prend son `default`. || `getEffect` | `effectId` | Lecture : la définition entière, code compris. || `removeModifier` | `id` | Retire une région d'effet, comme un zoom. |@@ -533,7 +529,7 @@ intégré les reçoit par le même tableau.retrait.- **Le placement suit les autres régions :** `anchorForAgent` / `landingOf`. Le modèle est`addCameraFullscreen`. Une étendue qui ne couvre aucun clip est refusée (`coversNoClip`), et- une région qui en heurterait une autre de la même lane aussi (`refuseIfBlocked`).+ une région qui en heurterait une autre aussi : un effet à la fois (`refuseIfBlocked`).### E.2 Ce que l'agent relit@@ -543,7 +539,7 @@ lecture :```json"effects": [{ "id": "fxr_…", "effectId": "fx_…", "name": "Ripple au clic",- "startSec": 0, "endSec": 6, "target": "image", "lane": 0, "values": { "strength": 1 } }+ "startSec": 0, "endSec": 6, "target": "image", "values": { "strength": 1 } }],"effectDefinitions": [{ "effectId": "fx_…", "name": "Ripple au clic",@@ -567,8 +563,8 @@ lecture :### E.3 Les retours- **Accepté :** l'id, l'étendue posée (`landingReport`, comme les autres régions : fragments,- bornes rognées), et le coût : le palier de l'effet, le palier cumulé du moment le plus chargé,- et la recommandation du palier quand la région la dépasse. Par exemple : « lourd sur 45 s :+ bornes rognées), et le coût : le palier de l'effet, et la recommandation du palier quand la région+ la dépasse. Par exemple : « lourd sur 45 s :pour une région longue, vise moyen ».- **Refusé à la compilation :** l'enveloppe `{ error }`, avec l'erreur de naga ou du compilateurdu backend, lignes et colonnes de SON code. Le document ne change pas.@@ -645,7 +641,8 @@ dit `validated: false`, et les checks lisent le code comme du texte.### F.1 Une piste « Effets » dans la timeline-- **Où.** Une rangée par lane utilisée, plus une rangée vide pour en ouvrir une nouvelle. Elles se placent sous la piste Full Camera, dans l'ordre des lanes de `V4Timeline.tsx`.+- **Où.** Une seule rangée « Effets », sous la piste Full Camera : les effets ne se chevauchent+ pas (K.6).- **La pilule** porte le nom de la définition. La glisser, l'étirer, la sélectionner et lasupprimer se font comme pour un zoom (`selectPill`, `startPillDrag`, `removeRegions`).- **L'annulation** passe par l'historique habituel (`saveDocument({ history: true })`). Une@@ -778,7 +775,7 @@ Le détail est dans| Niveau | Ce qu'il couvre ||---|---|-| Rust, `shader_fx.rs` | Prélude et struct générée ; packer de paramètres contre les offsets de naga ; borne littérale et plafond d'itérations ; estimation du coût et paliers (boucles imbriquées, fonctions dépliées) ; erreurs aux lignes de l'agent ; sélection des régions (lane, ordre, `underTrim`) ; `ctx.region` sur une pilule coupée. |+| Rust, `shader_fx.rs` | Prélude et struct générée ; packer de paramètres contre les offsets de naga ; borne littérale et plafond d'itérations ; estimation du coût et paliers (boucles imbriquées, fonctions dépliées) ; erreurs aux lignes de l'agent ; sélection des régions (fenêtre, `underTrim`) ; `ctx.region` sur une pilule coupée. || Rust, par backend | Une passe repeint la frame dans sa région et nulle part ailleurs ; les trois cibles (`text` laisse l'image intacte, `image` laisse les textes intacts) ; preview non bloquante puis `shader_fx_landed` ; effet cassé = frame intacte. Windows (fait), macOS (fait, sur le runner CI, avec en plus une vraie annotation entre une cible `image` et une cible `text`), Linux sur lavapipe. || Rust, `frame_geometry.rs` | `ctx.clicks`, `ctx.footage`, `ctx.camera` en uv de sortie, sous zoom et sous tilt. || TS, schéma | Parse, bornes des `values`, définition orpheline retirée, document ancien inchangé. |@@ -813,13 +810,17 @@ Le détail est dansindépendants de la machine. L'agent les connaît, avec leurs recommandations. Un budget lié àla machine aurait refusé des effets haut de gamme sur une machine modeste, alors que l'export,lui, les rend très bien.-3. **Pas de limites fermes non plus.** Paramètres, code et lanes ont des recommandations, et des+3. **Pas de limites fermes non plus.** Paramètres et code ont des recommandations, et desplafonds techniques loin au-dessus (B.2). Seule reste ferme la borne littérale des boucles,avec son plafond de 4 096 itérations par pixel : une protection contre le blocage du GPU, pasune limite de créativité.4. **Pas de bouton « ajouter un effet » en v1.** Les effets naissent des agents.5. **Trois cibles : `image`, `text`, `both`.** Sans demande explicite, l'effet vise `image`, sousles textes.+6. **Un effet à la fois** (décidé après les premières PR). Un effet est écrit sur mesure pour ce+ que l'utilisateur demande : deux rendus au même instant s'écrivent dans un seul shader, au lieu+ de s'empiler. Les lanes 0 à 7 des premières PR sont retirées du document, des outils et du+ compositeur, et la timeline n'a qu'une rangée d'effets.## L. Découpage en PR@@ -833,7 +834,7 @@ ailleurs (`legacyEditor`, sans ancre).référence.- `check_shader_effect` compile pour le backend et rend le palier.- `scene.rs` lit la nouvelle forme ; la passe Windows gère les trois cibles (calque de textes- à part pour `text`), `lane` et l'éviction LRU.+ à part pour `text`) et l'éviction LRU.2. **Modèle de données et DSL (TS).**- Schéma (B.2) et `RegionKind` dans tout le pipeline (B.3) ;- outils (E.1), snapshot (E.2), projection de scène (B.5) ;@@ -844,7 +845,7 @@ ailleurs (`legacyEditor`, sans ancre).4. **Passe Linux.** WGSL direct, bind group layout explicite, thread de fond, test lavapipe.5. **`getFrames` depuis le document.** Rendu de frames sans export quand celui-ci manque ou estpérimé (E.4).-6. **Interface.** Piste et lanes, inspecteur, copier-coller, i18n.+6. **Interface.** Piste, inspecteur, copier-coller, i18n.La PR 2 dépend de la 1. Les PR 3, 4 et 5 dépendent de la 1 et peuvent avancer en parallèle. LaPR 6 dépend de la 2.diff --git a/electron/ai-edition/agent-tools.test.ts b/electron/ai-edition/agent-tools.test.tsindex 764467566..3c72687b0 100644--- a/electron/ai-edition/agent-tools.test.ts+++ b/electron/ai-edition/agent-tools.test.ts@@ -3781,13 +3781,12 @@ describe("shader effects", () => {clipId: "clip_1",values: { level: 0.5 },target: "image",- lane: 0,});expect(JSON.parse(added.resultJson)).toMatchObject({effectRegionId: range.id,effectId: effect.id,validated: true,- cost: { tier: "light", busiestTier: "light" },+ cost: { tier: "light", frameReads: 4 },});expect(() => documentSchema.parse(doc)).not.toThrow();});@@ -3815,12 +3814,14 @@ describe("shader effects", () => {expect(reused.document?.shaderEffectRanges).toHaveLength(2);});- it("keeps one lane free of overlaps, and points to another lane", () => {+ it("runs one effect at a time, and says to combine looks in one shader", () => {const doc = add(fixtureDocument()).document as AxcutDocument;- const blocked = add(doc, { startSec: 4, endSec: 8 });+ const blocked = add(doc, { startSec: 4, endSec: 8, target: "text" });expect(blocked.ok).toBe(false);- expect(JSON.parse(blocked.resultJson).error).toMatch(/lane 0[\s\S]*another lane/);- expect(add(doc, { startSec: 4, endSec: 8, lane: 1 }).ok).toBe(true);+ expect(JSON.parse(blocked.resultJson).error).toMatch(+ /one effect runs at a time[\s\S]*one shader/,+ );+ expect(add(doc, { startSec: 6, endSec: 8 }).ok).toBe(true);});it("recommends a lighter tier when a heavy effect runs long, and never refuses it", () => {@@ -3861,16 +3862,13 @@ describe("shader effects", () => {});});- it("moves a region against its own lane only: another lane's effect does not shorten it", () => {- const below = add(fixtureDocument()).document as AxcutDocument;- const doc = add(below, { startSec: 8, endSec: 9, lane: 1 }).document as AxcutDocument;- const upper = doc.shaderEffectRanges?.find((r) => r.lane === 1);- const moved = run(doc, "setEffect", { effectRegionId: upper?.id, startSec: 4 });- expect(moved.ok).toBe(true);- expect(moved.document?.shaderEffectRanges?.find((r) => r.lane === 1)).toMatchObject({- startMs: 4000,- endMs: 9000,- });+ it("refuses to move an effect onto another one", () => {+ const first = add(fixtureDocument()).document as AxcutDocument;+ const doc = add(first, { startSec: 8, endSec: 9 }).document as AxcutDocument;+ const second = doc.shaderEffectRanges?.find((r) => r.startMs === 8000);+ const moved = run(doc, "setEffect", { effectRegionId: second?.id, startSec: 4 });+ expect(moved.ok).toBe(false);+ expect(JSON.parse(moved.resultJson).error).toMatch(/one effect runs at a time/);});it("changes the definition for every region, recompiles, and drops a removed parameter's values", () => {@@ -3893,7 +3891,7 @@ describe("shader effects", () => {const read = JSON.parse(run(doc, "getEffect", { effectId }).resultJson);expect(read).toMatchObject({code: CODE,- regions: [{ startSec: 2, endSec: 6, target: "image", lane: 0 }],+ regions: [{ startSec: 2, endSec: 6, target: "image" }],});const snapshot = JSON.parse(run(doc, "getCurrentDocument", {}).resultJson);expect(snapshot.effects).toEqual([diff --git a/electron/ai-edition/agent-tools.ts b/electron/ai-edition/agent-tools.tsindex ffa381069..8b26e8419 100644--- a/electron/ai-edition/agent-tools.ts+++ b/electron/ai-edition/agent-tools.ts@@ -57,13 +57,11 @@ import {shaderEffectValueSchema,} from "../../src/lib/ai-edition/schema";import {- busiestShaderEffectReads,findShaderEffect,SHADER_EFFECT_CONTRACT,type ShaderEffectCheck,type ShaderEffectCheckLookup,shaderEffectCostAdvice,- shaderEffectTierOf,storedShaderEffectValues,} from "../../src/lib/ai-edition/shaderEffects";import { getEditorSettings } from "../../src/lib/ai-edition/store/editorSettings";@@ -1006,7 +1004,6 @@ export const addCameraFullscreenArgs = z.object({});const effectTargetSchema = z.enum(["image", "text", "both"]);-const effectLaneSchema = z.number().int().min(0).max(7);const effectValuesSchema = z.record(z.string(), shaderEffectValueSchema);export const addEffectArgs = z.object({@@ -1023,7 +1020,6 @@ export const addEffectArgs = z.object({.optional(),values: effectValuesSchema.optional(),target: effectTargetSchema.optional(),- lane: effectLaneSchema.optional(),});export const setEffectArgs = z.object({@@ -1032,7 +1028,6 @@ export const setEffectArgs = z.object({endSec: secondsSchema.optional(),values: effectValuesSchema.optional(),target: effectTargetSchema.optional(),- lane: effectLaneSchema.optional(),});export const setEffectDefinitionArgs = z.object({@@ -1483,7 +1478,6 @@ export function documentSnapshotForModel(startSec: roundSec(r.startMs),endSec: roundSec(r.endMs),target: r.target,- lane: r.lane,values: r.values,})),effectDefinitions: (document.shaderEffects ?? []).map((e) => ({@@ -1593,42 +1587,33 @@ export function shaderEffectCheckLookup(: null;}-/** Two effects of one lane cannot overlap: the refusal names what is in the way, and the way out. */-function effectLaneBlocked(+/** One effect at a time: the refusal names the one in the way, and the way out. */+function effectBlocked(ranges: AxcutShaderEffectRange[],- lane: number,startMs: number,endMs: number,except: ReadonlySet<string> = new Set(),): string | null {- const wall = coalesceRegionsForRuler(- ranges.filter((r) => r.lane === lane && !except.has(r.id)),- ).find((pill) => pill.start * 1000 < endMs && pill.end * 1000 > startMs);+ const wall = coalesceRegionsForRuler(ranges.filter((r) => !except.has(r.id))).find(+ (pill) => pill.start * 1000 < endMs && pill.end * 1000 > startMs,+ );if (!wall) return null;return (`${formatSec(startMs / 1000)} – ${formatSec(endMs / 1000)} would run into effect ${wall.ids[0]} ` +- `at ${formatSec(wall.start)} – ${formatSec(wall.end)} on lane ${lane}, and two effects of one lane ` +- "cannot overlap. Put it on another lane (0–7, applied in order, lane 0 first) or pick a span clear of it."+ `at ${formatSec(wall.start)} – ${formatSec(wall.end)}, and one effect runs at a time. To combine ` ++ "two looks, write them in one shader (setEffectDefinition); otherwise pick a span clear of it.");}-/** What an effect costs where it was placed: its tier, the busiest moment it shares with the- * other effects, and a recommendation when its tier runs longer than it is meant to. */-function effectCostReport(- document: AxcutDocument,- definition: AxcutShaderEffect,- startSec: number,- endSec: number,-) {+/** What an effect costs: its tier, and a recommendation when the tier runs longer than it is+ * meant to. */+function effectCostReport(definition: AxcutShaderEffect, startSec: number, endSec: number) {if (!definition.cost) return { cost: null };- const busiest = busiestShaderEffectReads(document, startSec * 1000, endSec * 1000);const advice = shaderEffectCostAdvice(definition.cost.tier, endSec - startSec);return {cost: {tier: definition.cost.tier,frameReads: definition.cost.frameReads,- busiestTier: shaderEffectTierOf(busiest),- busiestFrameReads: busiest,...(advice ? { advice } : {}),},};@@ -3378,7 +3363,7 @@ export function executeAgentTool(case "addEffect": {const parsed = addEffectArgs.safeParse(args);if (!parsed.success) return failure(parsed.error.message);- const { effectId, effect, values = {}, target = "image", lane = 0 } = parsed.data;+ const { effectId, effect, values = {}, target = "image" } = parsed.data;if ((effectId === undefined) === (effect === undefined)) {return failure("Pass either `effect` to write a new effect, or `effectId` to reuse one of this project's (getCurrentDocument lists them under effectDefinitions), not both.",@@ -3407,7 +3392,7 @@ export function executeAgentTool(}const startMs = toMs(Math.min(parsed.data.startSec, parsed.data.endSec));const endMs = toMs(Math.max(parsed.data.startSec, parsed.data.endSec));- const blocked = effectLaneBlocked(document.shaderEffectRanges ?? [], lane, startMs, endMs);+ const blocked = effectBlocked(document.shaderEffectRanges ?? [], startMs, endMs);if (blocked) return failure(`The effect was NOT placed: ${blocked}`);const region = {id: createId("fxr"),@@ -3416,7 +3401,6 @@ export function executeAgentTool(effectId: definition.id,values: storedShaderEffectValues(definition, values),target,- lane,};const placed = anchorForAgent(region, document, "fxr");const landing = landingOf(placed, document);@@ -3436,7 +3420,7 @@ export function executeAgentTool(effectId: definition.id,...landingReport(landing, startMs / 1000, endMs / 1000),...(created ? { validated: check !== null } : {}),- ...effectCostReport(next, definition, landing.startSec, landing.endSec),+ ...effectCostReport(definition, landing.startSec, landing.endSec),}),summary:`effect "${definition.name}" ${formatSec(landing.startSec)} – ${formatSec(landing.endSec)}` +@@ -3455,7 +3439,6 @@ export function executeAgentTool(const pillIds = new Set(resolvePillIds(prev, existing.id));const pill = coalesceRegionsForRuler(prev).find((p) => p.ids.includes(existing.id));const { values, target } = parsed.data;- const lane = parsed.data.lane ?? existing.lane;const patched = prev.map((r) =>pillIds.has(r.id)? {@@ -3465,7 +3448,6 @@ export function executeAgentTool(? r.values: storedShaderEffectValues(definition, { ...r.values, ...values }),target: target ?? r.target,- lane,}: r,);@@ -3476,23 +3458,13 @@ export function executeAgentTool(parsed.data.startSec,parsed.data.endSec,);- const blocked = effectLaneBlocked(patched, lane, startMs, endMs, pillIds);+ const blocked = effectBlocked(patched, startMs, endMs, pillIds);if (blocked) return failure(`The effect was NOT changed: ${blocked}`);const moved = parsed.data.startSec !== undefined || parsed.data.endSec !== undefined;- // Clamped against its own lane only, the one `effectLaneBlocked` checked: effects of other- // lanes stack with it and must not shorten it.const rebuilt = moved- ? [- ...patched.filter((r) => r.lane !== lane),- ...replacePillSpan(- patched.filter((r) => r.lane === lane),- existing.id,- startMs,- endMs,- document.timeline.clips,- () => createId("fxr"),- ),- ]+ ? replacePillSpan(patched, existing.id, startMs, endMs, document.timeline.clips, () =>+ createId("fxr"),+ ): patched;const landing = landingAfterPillEdit(prev, rebuilt, pillIds, document);if (!landing.anchored) return coversNoClip("effect", startMs / 1000, endMs / 1000, document);@@ -3504,7 +3476,7 @@ export function executeAgentTool(effectRegionId: landing.ids[0] ?? existing.id,effectId: definition.id,...landingReport(landing, startMs / 1000, endMs / 1000),- ...effectCostReport(next, definition, landing.startSec, landing.endSec),+ ...effectCostReport(definition, landing.startSec, landing.endSec),}),summary:`updated effect "${definition.name}" ${formatSec(landing.startSec)} – ${formatSec(landing.endSec)}` +@@ -3575,7 +3547,6 @@ export function executeAgentTool(startSec: roundSec(r.startMs),endSec: roundSec(r.endMs),target: r.target,- lane: r.lane,values: r.values,}));return {diff --git a/electron/ai-edition/deep-agent/service.ts b/electron/ai-edition/deep-agent/service.tsindex 88b7333d0..69e0b85a8 100644--- a/electron/ai-edition/deep-agent/service.ts+++ b/electron/ai-edition/deep-agent/service.ts@@ -265,9 +265,9 @@ export const TOOL_DESCRIPTIONS: Record<string, string> = {addCameraFullscreen:"Add a camera-fullscreen region over a span of the edited timeline (virtual seconds): the webcam fills the frame for that span. This only does something when the footage under that span comes from an asset with a linked webcam — check assets[].hasCameraTrack (or hasAnyCamera) in getCurrentDocument first. On footage with no camera the call is refused rather than storing a region that would render nothing; say so instead of retrying.",addEffect:- "Write a visual effect as a shader and pose it over a span of the edited timeline (virtual seconds), or pose one of this project's effects again (effectId). Use it for a look the settings do not offer. `effect.code` is WGSL that defines `fn effect(uv: vec2<f32>) -> vec4<f32>`, called for every pixel; uv is 0..1 with (0,0) top-left. Available inside it: `frame(uv)` samples the composed picture; `params.<name>` reads each declared parameter; `ctx.time` is programme seconds; `ctx.region.x` goes 0 to 1 across the region (y its length in s, z seconds since it began); `ctx.resolution` and `ctx.aspect`; `ctx.cursor` (xy in uv, z = 1 when on screen); `ctx.clicks[0..3]`, the last four clicks, newest first (xy in uv where it happened, z seconds since, w = 1 when the slot holds one); `ctx.footage` and `ctx.camera`, the recording's and the webcam's rects (x, y, w, h in uv; camera zero-sized when absent) — all already placed through zoom and layout; `fx_to_footage(uv)` and `fx_from_footage(p)` map between output uv and the recording's own surface (0..1 across the recording) through the warp the compositor draws it with, zoom, layout and 3D camera included, and `ctx.footage_aspect` is its width over height: the effect works in whichever of the two spaces fits it; `fx_px(n)`, n pixels of a 1080p frame as a fraction of the height; `fx_hash(vec2<u32>)`, a random number in [0,1) identical on every GPU. Rules: the effect is a pure function of those inputs (no state between frames), so the preview and the export show the same pixels; reason in uv or fx_px, never raw pixels; every loop is a `for` with literal bounds (`for (var i = 0; i < 16; i++)`), at most 4096 iterations per pixel — the one hard rule. `params` declares up to 8 (recommended) parameters, each `{type: number|toggle|color|point, name, label, default}` (number also `min`, `max`); declare one only when moving it visibly changes the effect over its whole range. `target`: `image` (default: the picture under the annotations and captions), `text` (the annotations and captions alone, premultiplied alpha), `both` (everything); use text or both only when asked. Effects of one `lane` (0–7) cannot overlap; lanes apply in order, lane 0 first. The result gives the cost tier, in frame() reads per pixel, with what a 1080p frame pays on a fast discrete GPU (RTX 4070 Ti) and on an integrated one (Apple M1): light ≤ 8, up to 0.06 ms and 1.3 ms; medium ≤ 32, 0.14 ms and 4.3 ms; heavy ≤ 128, 0.54 ms and 16 ms; very heavy beyond, 2 ms and 49 ms at 512 reads. It also gives a recommendation when the tier runs long: light anywhere, medium up to a minute, heavy up to 10 s, very heavy a few seconds. It is a recommendation, never a refusal. Code that does not compile is refused with the compiler's error at the line of your code: fix it and call again. Check the result with getFrames.",+ "Write a visual effect as a shader and pose it over a span of the edited timeline (virtual seconds), or pose one of this project's effects again (effectId). Use it for a look the settings do not offer. `effect.code` is WGSL that defines `fn effect(uv: vec2<f32>) -> vec4<f32>`, called for every pixel; uv is 0..1 with (0,0) top-left. Available inside it: `frame(uv)` samples the composed picture; `params.<name>` reads each declared parameter; `ctx.time` is programme seconds; `ctx.region.x` goes 0 to 1 across the region (y its length in s, z seconds since it began); `ctx.resolution` and `ctx.aspect`; `ctx.cursor` (xy in uv, z = 1 when on screen); `ctx.clicks[0..3]`, the last four clicks, newest first (xy in uv where it happened, z seconds since, w = 1 when the slot holds one); `ctx.footage` and `ctx.camera`, the recording's and the webcam's rects (x, y, w, h in uv; camera zero-sized when absent) — all already placed through zoom and layout; `fx_to_footage(uv)` and `fx_from_footage(p)` map between output uv and the recording's own surface (0..1 across the recording) through the warp the compositor draws it with, zoom, layout and 3D camera included, and `ctx.footage_aspect` is its width over height: the effect works in whichever of the two spaces fits it; `fx_px(n)`, n pixels of a 1080p frame as a fraction of the height; `fx_hash(vec2<u32>)`, a random number in [0,1) identical on every GPU. Rules: the effect is a pure function of those inputs (no state between frames), so the preview and the export show the same pixels; reason in uv or fx_px, never raw pixels; every loop is a `for` with literal bounds (`for (var i = 0; i < 16; i++)`), at most 4096 iterations per pixel — the one hard rule. `params` declares up to 8 (recommended) parameters, each `{type: number|toggle|color|point, name, label, default}` (number also `min`, `max`); declare one only when moving it visibly changes the effect over its whole range. `target`: `image` (default: the picture under the annotations and captions), `text` (the annotations and captions alone, premultiplied alpha), `both` (everything); use text or both only when asked. One effect runs at a time: to combine two looks, write them in one shader. The result gives the cost tier, in frame() reads per pixel, with what a 1080p frame pays on a fast discrete GPU (RTX 4070 Ti) and on an integrated one (Apple M1): light ≤ 8, up to 0.06 ms and 1.3 ms; medium ≤ 32, 0.14 ms and 4.3 ms; heavy ≤ 128, 0.54 ms and 16 ms; very heavy beyond, 2 ms and 49 ms at 512 reads. It also gives a recommendation when the tier runs long: light anywhere, medium up to a minute, heavy up to 10 s, very heavy a few seconds. It is a recommendation, never a refusal. Code that does not compile is refused with the compiler's error at the line of your code: fix it and call again. Check the result with getFrames.",setEffect:- "Move, resize or re-tune an effect region by id (virtual seconds): its span, its parameter `values`, its `target` or its `lane`. Only the fields you pass change; a value equal to the default is dropped. Refused if the new span runs into another effect of the same lane.",+ "Move, resize or re-tune an effect region by id (virtual seconds): its span, its parameter `values`, or its `target`. Only the fields you pass change; a value equal to the default is dropped. Refused if the new span runs into another effect: one runs at a time.",setEffectDefinition:"Change an effect itself by effectId — its name, description, WGSL `code` or `params` — and with it every region that uses it. New code is compiled first and refused with the compiler's error if it does not compile. A removed parameter's values drop; the bounds re-clamp the others. Read the current code with getEffect before rewriting it.",getEffect:diff --git a/electron/mcp/effects-contract.ts b/electron/mcp/effects-contract.tsindex 96c24d764..832e3d16e 100644--- a/electron/mcp/effects-contract.ts+++ b/electron/mcp/effects-contract.ts@@ -78,15 +78,17 @@ changes the effect over its whole range: each one becomes a control in the edito\`frame(uv).a\` as alpha. For the target text, frame() is the text layer in premultiplied alpha,transparent outside the text, and the effect must return premultiplied alpha.-## Targets and lanes+## Targets- **image** (default): the picture under the annotations and captions; the text stays readable.- **text**: the annotations and captions alone, drawn over the untouched picture afterwards.- **both**: everything, captions included.-Use text or both only when the request asks for them. Effects of one lane (0–7) cannot overlap;-lanes apply in order, lane 0 first, so a ripple across the whole video and a glitch on a cut go on-two lanes.+Use text or both only when the request asks for them.++**One effect at a time.** Two effects cannot overlap in time. To combine two looks at the same+moment, write them in one shader: an effect is written for what the user asked, not stacked from+parts.## Costdiff --git a/src/lib/ai-edition/schema/index.test.ts b/src/lib/ai-edition/schema/index.test.tsindex 977f16ba5..5178c5490 100644--- a/src/lib/ai-edition/schema/index.test.ts+++ b/src/lib/ai-edition/schema/index.test.ts@@ -1265,7 +1265,7 @@ describe("shader effects (docs/shader-effects.md)", () => {});expect(shaderEffectRangeSchema.parse({ id: "r", startMs: 0, endMs: 1000, effectId: "fx" }),- ).toMatchObject({ values: {}, target: "image", lane: 0 });+ ).toMatchObject({ values: {}, target: "image" });});it("refuses a parameter declared twice, or a default out of its bounds", () => {diff --git a/src/lib/ai-edition/schema/index.ts b/src/lib/ai-edition/schema/index.tsindex 96b2eff94..c3422b597 100644--- a/src/lib/ai-edition/schema/index.ts+++ b/src/lib/ai-edition/schema/index.ts@@ -628,8 +628,6 @@ export const shaderEffectRangeSchema = endGteStart(values: z.record(z.string(), shaderEffectValueSchema).default({}),// What the effect transforms: the picture under the texts, the texts alone, or both.target: z.enum(["image", "text", "both"]).default("image"),- // Application order, lane 0 first, closest to the content. No overlap within a lane.- lane: z.number().int().min(0).max(7).default(0),}),"endMs","startMs",diff --git a/src/lib/ai-edition/shaderEffects.ts b/src/lib/ai-edition/shaderEffects.tsindex 6d0f29515..d9592198d 100644--- a/src/lib/ai-edition/shaderEffects.ts+++ b/src/lib/ai-edition/shaderEffects.ts@@ -2,7 +2,6 @@ import type {AxcutDocument,AxcutShaderEffect,AxcutShaderEffectParam,- AxcutShaderEffectRange,AxcutShaderEffectValue,} from "./schema";@@ -152,26 +151,3 @@ export function shaderEffectCostAdvice(tier: ShaderEffectTier, spanSec: number):tier === "very-heavy" ? "heavy or lighter" : tier === "heavy" ? "medium or light" : "light";return `${tier} over ${spanSec.toFixed(1)} s: this tier is meant for at most ${TIER_SPAN_SEC[tier]} s; for a region this long, aim ${lighter}. It is a recommendation, not a limit.`;}--/** The `frame()` reads of every effect running at the busiest moment of `[startMs, endMs]`. */-export function busiestShaderEffectReads(- document: AxcutDocument,- startMs: number,- endMs: number,-): number {- const ranges = (document.shaderEffectRanges ?? []).filter(- (r) => r.startMs < endMs && r.endMs > startMs,- );- const reads = (range: AxcutShaderEffectRange) =>- findShaderEffect(document, range.effectId)?.cost?.frameReads ?? 0;- // The load only changes at a region edge, so the busiest moment is one of the starts.- let busiest = 0;- for (const at of [startMs, ...ranges.map((r) => r.startMs)]) {- if (at < startMs || at >= endMs) continue;- const load = ranges- .filter((r) => r.startMs <= at && r.endMs > at)- .reduce((sum, r) => sum + reads(r), 0);- busiest = Math.max(busiest, load);- }- return busiest;-}diff --git a/src/lib/ai-edition/store/useTimeline.test.ts b/src/lib/ai-edition/store/useTimeline.test.tsindex cc12709c1..09564eb76 100644--- a/src/lib/ai-edition/store/useTimeline.test.ts+++ b/src/lib/ai-edition/store/useTimeline.test.ts@@ -779,7 +779,6 @@ describe("useTimeline.clearTimeline", () => {effectId: "fx_1",values: {},target: "image",- lane: 0,},],},diff --git a/src/native/sceneDescription.test.ts b/src/native/sceneDescription.test.tsindex 773df2c5e..567fe925e 100644--- a/src/native/sceneDescription.test.ts+++ b/src/native/sceneDescription.test.ts@@ -3003,7 +3003,6 @@ describe("buildSceneDescription.shaderEffects", () => {effectId: "fx1",values: { tint: "#ff0000", on: true },target: "text",- lane: 2,},],});@@ -3017,7 +3016,6 @@ describe("buildSceneDescription.shaderEffects", () => {programmeStartSec: 1,programmeEndSec: 4,target: "text",- lane: 2,contract: 1,code,params: [@@ -3040,7 +3038,6 @@ describe("buildSceneDescription.shaderEffects", () => {effectId: "fx_gone",values: {},target: "image",- lane: 0,},],});diff --git a/src/native/sceneDescription.ts b/src/native/sceneDescription.tsindex ae1cdbe4c..71e920b38 100644--- a/src/native/sceneDescription.ts+++ b/src/native/sceneDescription.ts@@ -136,7 +136,6 @@ export interface SceneShaderEffect {programmeStartSec: number;programmeEndSec: number;target: "image" | "text" | "both";- lane: number;contract: number;code: string;params: Array<{ name: string; type: "number" | "toggle" | "color" | "point" }>;@@ -1184,7 +1183,6 @@ export function buildSceneDescription(programmeStartSec: region.programmeStartSec ?? region.startMs / 1000,programmeEndSec: region.programmeEndSec ?? region.endMs / 1000,target: region.target,- lane: region.lane,contract: effect.contract,code: effect.code,params: effect.params.map(({ name, type }) => ({ name, type })),diff --git a/technical-documentation/architecture/ai-agent.md b/technical-documentation/architecture/ai-agent.mdindex 5a90259ef..b09493e13 100644--- a/technical-documentation/architecture/ai-agent.md+++ b/technical-documentation/architecture/ai-agent.md@@ -64,8 +64,8 @@ The model never free-writes the project document. It can only call the fixed set| `setAnnotation` | Moves, resizes, retypes or restyles an annotation. A type change goes through `convertAnnotationKind` with the footage under each fragment (`annotationFootageRect`), as the inspector's type switch does; `figureData` / `blurData` merge only the keys sent. Arguments of another kind (width on a text, blurData on an arrow) are refused. | The corresponding clip-anchored `annotations` fragments. || `addCameraFullscreen` | Adds a camera-fullscreen region over virtual timeline time; refused when no clip under the span comes from an asset with a linked `cameraTrack`, since such a region can only render nothing. | `legacyEditor.cameraFullscreenRegions`. || `setCameraFullscreen` | Moves or resizes a camera-fullscreen pill, under the same camera requirement as `addCameraFullscreen`. | The corresponding `legacyEditor.cameraFullscreenRegions` fragments. |-| `addEffect` | Writes a shader effect (WGSL, [docs/shader-effects.md](../../docs/shader-effects.md)) and poses it over virtual timeline time, or poses one of the project's effects again by `effectId`. The compositor checks the code first (`checkShaderEffect`); code that does not compile is refused with the error at the agent's line. The result gives the cost tier and, when the tier runs long, a recommendation, never a refusal. Two effects of one lane cannot overlap. | `shaderEffects` (a new definition) and `shaderEffectRanges`. |-| `setEffect` | Moves, re-tunes (`values`), retargets or changes the lane of an effect pill. | The pill's `shaderEffectRanges` fragments. |+| `addEffect` | Writes a shader effect (WGSL, [docs/shader-effects.md](../../docs/shader-effects.md)) and poses it over virtual timeline time, or poses one of the project's effects again by `effectId`. The compositor checks the code first (`checkShaderEffect`); code that does not compile is refused with the error at the agent's line. The result gives the cost tier and, when the tier runs long, a recommendation, never a refusal. One effect runs at a time: two cannot overlap. | `shaderEffects` (a new definition) and `shaderEffectRanges`. |+| `setEffect` | Moves, re-tunes (`values`) or retargets an effect pill. | The pill's `shaderEffectRanges` fragments. || `setEffectDefinition` | Changes an effect's name, description, code or parameters, and so every region using it; new code is checked first. A removed parameter's values drop. | The `shaderEffects` entry and its regions' `values`. || `getEffect` | Reads one effect in full, code included; `getCurrentDocument` lists effects without their code. | Read only. || `removeTrim` | Deletes a trim so its source span plays and exports again. | `timeline.trimRanges`. |diff --git a/technical-documentation/architecture/document-model.md b/technical-documentation/architecture/document-model.mdindex b063fa41d..6cdec83d3 100644--- a/technical-documentation/architecture/document-model.md+++ b/technical-documentation/architecture/document-model.md@@ -28,7 +28,7 @@ and anything unknown is rejected by the `z.literal(axcutSchemaVersion)` check in| `annotations[]` | `AxcutAnnotationRegion[]` | Text/image/figure/blur overlays, anchored to a clip (`clipId?`). || `zoomRanges[]` | `AxcutZoomRegion[]` | Zoom-in effects, depth 1–6, anchored to a clip (`clipId?`). || `shaderEffects[]?` | `AxcutShaderEffect[]` | Agent-written shader effects: WGSL `code`, `name`, `description`, the contract version, declared `params`, and the compositor's cached `cost`. Optional: absent on a document without effects. A definition no region uses is dropped by the edit that removed its last region. See [docs/shader-effects.md](../../docs/shader-effects.md). |-| `shaderEffectRanges[]?` | `AxcutShaderEffectRange[]` | Where each effect applies: clip-anchored regions like the zooms, with the parameter `values` that differ from the defaults, a `target` (`image`, `text`, `both`) and a `lane`. Optional, like `shaderEffects`. |+| `shaderEffectRanges[]?` | `AxcutShaderEffectRange[]` | Where each effect applies: clip-anchored regions like the zooms, with the parameter `values` that differ from the defaults, a `target` (`image`, `text`, `both`). One effect at a time: regions do not overlap. Optional, like `shaderEffects`. || `audioTracks[]` | `AxcutAudioTrack[]` | Imported audio (voiceover / BGM / SFX, issue #350) mixed over the programme. NOT clip-anchored — addressed in RAW/document timeline seconds (`timelineStartSec`), with `trimStartSec`/`trimEndSec` windowing the source and `gainDb` its level. Added from the timeline toolbar; the referenced asset has `kind: "audio"`. || `legacyEditor` | OpenScreen v2 `ProjectEditorState` passthrough | Appearance/cursor settings not yet first-class in the AI-edition schema. || `agent` | `{ baseIntent?, pendingQuestions[], suggestions[], lastAppliedOperations[], lastReasoningSummary? }` | LLM agent state. |diff --git a/technical-documentation/architecture/native-compositor.md b/technical-documentation/architecture/native-compositor.mdindex a59becc09..ebc6e2176 100644--- a/technical-documentation/architecture/native-compositor.md+++ b/technical-documentation/architecture/native-compositor.md@@ -208,8 +208,8 @@ backend-specific.its effect. The live view (`set_shader_fx_blocking(false)`) skips the effect until it lands, thenrecomposes the paused frame (`shader_fx_landed`).- **Targets.** `image` effects run before the annotations and captions. `text` effects run on a- transparent text layer, which is then drawn over the image. `both` effects run last. Within a- target, effects apply by lane, then in scene order. Each pass copies its destination into+ transparent text layer, which is then drawn over the image. `both` effects run last. The document holds+ one effect at a time; a hand-written scene that overlaps several applies them in its order. Each pass copies its destination into`ann_copy` and repaints it with blending off. On Metal every pass is encoded in the frame'scommand buffer: a blit into `ann_copy`, then a render pass that loads its target (an effect may`discard`). `draw_annotations` takes the target it opens its pass on, which is how the text layer