EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
M13.9: gpu effect family scaffolding (fx_key, fx_stylize, fx_noise)
Brandon Thomas47f61debcb3b
diff --git a/crates/effects/src/lib.rs b/crates/effects/src/lib.rsindex 6f6716306..bc1cd5202 100644--- a/crates/effects/src/lib.rs+++ b/crates/effects/src/lib.rs@@ -806,6 +806,12 @@ pub const GPU_EFFECTS: &[&str] = &["ec.color.selectivecolor","ec.key.linearcolor","ec.keying.keylight",+ // effectcraft-gpu fx_key (keying, matte, channel)+ //+ // effectcraft-gpu fx_stylize (stylize, distort)+ //+ // effectcraft-gpu fx_noise (noise, blur, time)+ //];/// Effects whose output depends on [`EffectCtx::time`] directly (not only through animateddiff --git a/crates/gpu/src/context.rs b/crates/gpu/src/context.rsindex d6f388831..77f79be9d 100644--- a/crates/gpu/src/context.rs+++ b/crates/gpu/src/context.rs@@ -151,6 +151,9 @@ impl GpuContext {include_str!("shaders/fx_color.wgsl"),include_str!("shaders/fx_distort.wgsl"),include_str!("shaders/fx_generate.wgsl"),+ include_str!("shaders/fx_key.wgsl"),+ include_str!("shaders/fx_stylize.wgsl"),+ include_str!("shaders/fx_noise.wgsl"),].concat();let module =@@ -204,6 +207,9 @@ impl GpuContext {.chain(crate::fx_color::KERNELS).chain(crate::fx_distort::KERNELS).chain(crate::fx_generate::KERNELS)+ .chain(crate::fx_key::KERNELS)+ .chain(crate::fx_stylize::KERNELS)+ .chain(crate::fx_noise::KERNELS).map(|e| (e, &layout)).chain(EXT_ENTRIES.iter().map(|e| (e, &layout_ext))).map(|(e, layout)| {diff --git a/crates/gpu/src/effects.rs b/crates/gpu/src/effects.rsindex 3691ae17e..8169164a4 100644--- a/crates/gpu/src/effects.rs+++ b/crates/gpu/src/effects.rs@@ -121,6 +121,9 @@ fn apply(e: &mut Enc, id: &str, ctx: &EffectCtx, b: GBuf) -> Option<GBuf> {_ if crate::fx_color::IDS.contains(&id) => crate::fx_color::apply(e, id, ctx, b),_ if crate::fx_distort::IDS.contains(&id) => crate::fx_distort::apply(e, id, ctx, b),_ if crate::fx_generate::IDS.contains(&id) => crate::fx_generate::apply(e, id, ctx, b),+ _ if crate::fx_key::IDS.contains(&id) => crate::fx_key::apply(e, id, ctx, b),+ _ if crate::fx_stylize::IDS.contains(&id) => crate::fx_stylize::apply(e, id, ctx, b),+ _ if crate::fx_noise::IDS.contains(&id) => crate::fx_noise::apply(e, id, ctx, b),_ => pointwise(e, id, ctx, b),}}diff --git a/crates/gpu/src/fx_key.rs b/crates/gpu/src/fx_key.rsnew file mode 100644index 000000000..05625d4c3--- /dev/null+++ b/crates/gpu/src/fx_key.rs@@ -0,0 +1,19 @@+//! GPU effects, keying, matte and channel family (kernels in `shaders/fx_key.wgsl`, every entry point prefixed+//! `fxk_`): the CPU effects' exact steps with the pixel loops as compute kernels.++use effectcraft_effects::EffectCtx;++use crate::context::Enc;+use crate::effects::GBuf;++/// Compute entry points in `fx_key.wgsl`.+pub(crate) const KERNELS: &[&str] = &[];++/// Effect ids implemented here.+pub(crate) const IDS: &[&str] = &[];++/// Run effect `id` (one of [`IDS`]); `None` = this parameter combination runs on the CPU.+pub(crate) fn apply(e: &mut Enc, id: &str, ctx: &EffectCtx, b: GBuf) -> Option<GBuf> {+ let _ = (e, id, ctx, b);+ None+}diff --git a/crates/gpu/src/fx_noise.rs b/crates/gpu/src/fx_noise.rsnew file mode 100644index 000000000..55838838d--- /dev/null+++ b/crates/gpu/src/fx_noise.rs@@ -0,0 +1,19 @@+//! GPU effects, noise, blur and time family (kernels in `shaders/fx_noise.wgsl`, every entry point prefixed+//! `fxn_`): the CPU effects' exact steps with the pixel loops as compute kernels.++use effectcraft_effects::EffectCtx;++use crate::context::Enc;+use crate::effects::GBuf;++/// Compute entry points in `fx_noise.wgsl`.+pub(crate) const KERNELS: &[&str] = &[];++/// Effect ids implemented here.+pub(crate) const IDS: &[&str] = &[];++/// Run effect `id` (one of [`IDS`]); `None` = this parameter combination runs on the CPU.+pub(crate) fn apply(e: &mut Enc, id: &str, ctx: &EffectCtx, b: GBuf) -> Option<GBuf> {+ let _ = (e, id, ctx, b);+ None+}diff --git a/crates/gpu/src/fx_stylize.rs b/crates/gpu/src/fx_stylize.rsnew file mode 100644index 000000000..725b2eac2--- /dev/null+++ b/crates/gpu/src/fx_stylize.rs@@ -0,0 +1,19 @@+//! GPU effects, stylize and distort family (kernels in `shaders/fx_stylize.wgsl`, every entry point prefixed+//! `fxs_`): the CPU effects' exact steps with the pixel loops as compute kernels.++use effectcraft_effects::EffectCtx;++use crate::context::Enc;+use crate::effects::GBuf;++/// Compute entry points in `fx_stylize.wgsl`.+pub(crate) const KERNELS: &[&str] = &[];++/// Effect ids implemented here.+pub(crate) const IDS: &[&str] = &[];++/// Run effect `id` (one of [`IDS`]); `None` = this parameter combination runs on the CPU.+pub(crate) fn apply(e: &mut Enc, id: &str, ctx: &EffectCtx, b: GBuf) -> Option<GBuf> {+ let _ = (e, id, ctx, b);+ None+}diff --git a/crates/gpu/src/lib.rs b/crates/gpu/src/lib.rsindex bf47e3c58..63816e98a 100644--- a/crates/gpu/src/lib.rs+++ b/crates/gpu/src/lib.rs@@ -34,6 +34,9 @@ mod effects;mod fx_color;mod fx_distort;mod fx_generate;+mod fx_key;+mod fx_noise;+mod fx_stylize;mod ops;mod particles;mod walk;@@ -173,4 +176,10 @@ mod tests_fx_distort;#[cfg(test)]mod tests_fx_generate;#[cfg(test)]+mod tests_fx_key;+#[cfg(test)]+mod tests_fx_noise;+#[cfg(test)]+mod tests_fx_stylize;+#[cfg(test)]mod tests_particles;diff --git a/crates/gpu/src/shaders/fx_key.wgsl b/crates/gpu/src/shaders/fx_key.wgslnew file mode 100644index 000000000..4b251f3a2--- /dev/null+++ b/crates/gpu/src/shaders/fx_key.wgsl@@ -0,0 +1,3 @@+// GPU effects (keying, matte and channel family): see src/fx_key.rs. Each entry point mirrors the CPU effect in+// effectcraft-effects operation for operation. Every name here is prefixed `fxk_` (the+// family files share one module).diff --git a/crates/gpu/src/shaders/fx_noise.wgsl b/crates/gpu/src/shaders/fx_noise.wgslnew file mode 100644index 000000000..4fd5ac810--- /dev/null+++ b/crates/gpu/src/shaders/fx_noise.wgsl@@ -0,0 +1,3 @@+// GPU effects (noise, blur and time family): see src/fx_noise.rs. Each entry point mirrors the CPU effect in+// effectcraft-effects operation for operation. Every name here is prefixed `fxn_` (the+// family files share one module).diff --git a/crates/gpu/src/shaders/fx_stylize.wgsl b/crates/gpu/src/shaders/fx_stylize.wgslnew file mode 100644index 000000000..01d1c54d6--- /dev/null+++ b/crates/gpu/src/shaders/fx_stylize.wgsl@@ -0,0 +1,3 @@+// GPU effects (stylize and distort family): see src/fx_stylize.rs. Each entry point mirrors the CPU effect in+// effectcraft-effects operation for operation. Every name here is prefixed `fxs_` (the+// family files share one module).diff --git a/crates/gpu/src/tests_fx_key.rs b/crates/gpu/src/tests_fx_key.rsnew file mode 100644index 000000000..ae615fe78--- /dev/null+++ b/crates/gpu/src/tests_fx_key.rs@@ -0,0 +1,2 @@+//! GPU keying, matte and channel family effects vs the CPU effects (the oracle): direct on a buffer at full and half+//! resolution, as adjustment, and composited at 8 and 32 bpc.diff --git a/crates/gpu/src/tests_fx_noise.rs b/crates/gpu/src/tests_fx_noise.rsnew file mode 100644index 000000000..3b2b27437--- /dev/null+++ b/crates/gpu/src/tests_fx_noise.rs@@ -0,0 +1,2 @@+//! GPU noise, blur and time family effects vs the CPU effects (the oracle): direct on a buffer at full and half+//! resolution, as adjustment, and composited at 8 and 32 bpc.diff --git a/crates/gpu/src/tests_fx_stylize.rs b/crates/gpu/src/tests_fx_stylize.rsnew file mode 100644index 000000000..a11811aa5--- /dev/null+++ b/crates/gpu/src/tests_fx_stylize.rs@@ -0,0 +1,2 @@+//! GPU stylize and distort family effects vs the CPU effects (the oracle): direct on a buffer at full and half+//! resolution, as adjustment, and composited at 8 and 32 bpc.