Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Merge branch 'fix/f6': community issue fixes

Claudee615b06256e4
diff --cc crates/gpu/src/tests.rs
index 0234f7934,3629d8ead..81cb98ad5
--- a/crates/gpu/src/tests.rs
+++ b/crates/gpu/src/tests.rs
@@@ -746,42 -746,34 +746,74 @@@ fn within_memory_returns_the_work_when_
assert_eq!((img.width, img.height), (64, 32));
}
+/// Precomp layers (not collapsed) render their nested comp resident on the GPU
+/// (`walk::draw_precomp`): match the CPU (nested blend modes, effects inside and outside,
+/// transforms, opacity, a blend mode on the precomp layer, half resolution,
+/// two instances at different times of the same nested comp).
+#[test]
+fn nested_precomps_render_resident() {
+ for depth in [BitDepth::Bpc8, BitDepth::Bpc32] {
+ let mut s = Scene::new(depth);
+ let inner = Comp::new(60, 40, FrameRate::FPS_30, Tick::from_seconds_f64(2.0));
+ let inner_id = s.p.add_item("Inner", Label::Sandstone, None, ItemKind::Comp(inner.clone().into()));
+ {
+ let mut ins = Scene { p: std::mem::take(&mut s.p), cid: inner_id, comp: inner };
+ let mut a = ins.footage(50, 30);
+ ins.effect(&mut a, "ec.blur.gaussian", &[("blurriness", n(3.0))]);
+ ins.push(a);
+ let mut b = ins.solid([0.2, 0.7, 0.4], 30, 20);
+ b.blend_mode = BlendMode::Difference;
+ set(&mut b, "transform/rotation", Value::Scalar(15.0));
+ ins.push(b);
+ s.p = ins.p;
+ }
+ let bg = s.footage(97, 61);
+ s.push(bg);
+ let mut pre = build::layer(&mut s.p, &s.comp, "Inner", LayerSource::Comp { item: inner_id }, (60, 40), None);
+ set(&mut pre, "transform/rotation", Value::Scalar(25.0));
+ set(&mut pre, "transform/opacity", Value::Scalar(80.0));
+ s.effect(&mut pre, "ec.color.levels", &[("gamma", n(1.3))]);
+ pre.blend_mode = BlendMode::Screen;
+ s.push(pre);
+ // A second instance, later in the nested comp's time.
+ let mut pre2 = build::layer(&mut s.p, &s.comp, "Inner 2", LayerSource::Comp { item: inner_id }, (60, 40), None);
+ set(&mut pre2, "transform/position", v3(70.0, 40.0));
+ pre2.start_time = Tick::from_seconds_f64(-0.5);
+ s.push(pre2);
+ check(&format!("nested precomps {depth:?}"), compare_at(&s, opts(), Tick::from_seconds_f64(0.2)), 0.0);
+ let half = RenderOpts { scale: 0.5, ..opts() };
+ check(&format!("nested precomps half {depth:?}"), compare_at(&s, half, Tick::from_seconds_f64(0.2)), 0.0);
+ }
+}
++
+ /// #613: an effect kernel the device's shader compiler rejects (FXC on DirectX 12 aborting on
+ /// `pointwise`) no longer turns the whole GPU compositor off: the context is built without it,
+ /// lists it, and the effects that need it render on the CPU, matching the CPU render.
+ #[test]
+ fn effects_whose_kernels_failed_render_on_the_cpu() {
+ if gpu().is_none() {
+ return;
+ }
+ let Ok(mut ctx) = pollster::block_on(crate::context::GpuContext::request()) else { return };
+ ctx.drop_kernel("pointwise");
+ ctx.drop_kernel("box_h");
+ let names: Vec<&str> = ctx.unavailable_kernels().iter().map(|(e, _)| *e).collect();
+ assert_eq!(names, ["pointwise", "box_h"]);
+ let g = Gpu::from_context(ctx);
+ for depth in [BitDepth::Bpc8, BitDepth::Bpc32] {
+ let mut s = Scene::new(depth);
+ let mut l = s.footage(80, 50);
+ s.effect(&mut l, "ec.color.exposure", &[("master/exposure", n(0.7))]);
+ s.effect(&mut l, "ec.color.tint", &[("black", c(0.1, 0.0, 0.3)), ("amount", n(80.0))]);
+ s.effect(&mut l, "ec.blur.gaussian", &[("blurriness", n(5.0))]);
+ s.effect(&mut l, "ec.channel.invert", &[("blend", n(50.0))]);
+ s.push(l);
+ let cpu = Renderer::new(&s.p, &Pattern, RenderOpts { backend: Backend::Cpu, ..opts() }).comp_frame_cpu(s.cid, Tick::ZERO);
+ let mut r = Renderer::new(&s.p, &Pattern, RenderOpts { backend: Backend::Gpu, ..opts() });
+ r.accel = Some(&g);
+ let img = g.render(&r, s.cid, Tick::ZERO).expect("the GPU renders the frame");
+ let mut d = diff(&cpu, &img, tolerance(depth));
+ d.quantized = depth != BitDepth::Bpc32;
+ check(&format!("missing kernels {depth:?}"), Some(d), 0.0);
+ }
+ }