From 47f61debcb3b324033a843a04cd26d2f59fbdcea Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sat, 3 Oct 2026 07:51:33 -0400 Subject: [PATCH] M13.9: gpu effect family scaffolding (fx_key, fx_stylize, fx_noise) Co-Authored-By: Claude Opus 5.5 --- crates/effects/src/lib.rs | 6 ++++++ crates/gpu/src/context.rs | 6 ++++++ crates/gpu/src/effects.rs | 3 +++ crates/gpu/src/fx_key.rs | 19 +++++++++++++++++++ crates/gpu/src/fx_noise.rs | 19 +++++++++++++++++++ crates/gpu/src/fx_stylize.rs | 19 +++++++++++++++++++ crates/gpu/src/lib.rs | 9 +++++++++ crates/gpu/src/shaders/fx_key.wgsl | 3 +++ crates/gpu/src/shaders/fx_noise.wgsl | 3 +++ crates/gpu/src/shaders/fx_stylize.wgsl | 3 +++ crates/gpu/src/tests_fx_key.rs | 2 ++ crates/gpu/src/tests_fx_noise.rs | 2 ++ crates/gpu/src/tests_fx_stylize.rs | 2 ++ 13 files changed, 96 insertions(+) create mode 100644 crates/gpu/src/fx_key.rs create mode 100644 crates/gpu/src/fx_noise.rs create mode 100644 crates/gpu/src/fx_stylize.rs create mode 100644 crates/gpu/src/shaders/fx_key.wgsl create mode 100644 crates/gpu/src/shaders/fx_noise.wgsl create mode 100644 crates/gpu/src/shaders/fx_stylize.wgsl create mode 100644 crates/gpu/src/tests_fx_key.rs create mode 100644 crates/gpu/src/tests_fx_noise.rs create mode 100644 crates/gpu/src/tests_fx_stylize.rs diff --git a/crates/effects/src/lib.rs b/crates/effects/src/lib.rs index 6f671630..bc1cd520 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 animated diff --git a/crates/gpu/src/context.rs b/crates/gpu/src/context.rs index d6f38883..77f79be9 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.rs index 3691ae17..8169164a 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 { _ 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.rs new file mode 100644 index 00000000..05625d4c --- /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 { + let _ = (e, id, ctx, b); + None +} diff --git a/crates/gpu/src/fx_noise.rs b/crates/gpu/src/fx_noise.rs new file mode 100644 index 00000000..55838838 --- /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 { + let _ = (e, id, ctx, b); + None +} diff --git a/crates/gpu/src/fx_stylize.rs b/crates/gpu/src/fx_stylize.rs new file mode 100644 index 00000000..725b2eac --- /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 { + let _ = (e, id, ctx, b); + None +} diff --git a/crates/gpu/src/lib.rs b/crates/gpu/src/lib.rs index bf47e3c5..63816e98 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.wgsl new file mode 100644 index 00000000..4b251f3a --- /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.wgsl new file mode 100644 index 00000000..4fd5ac81 --- /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.wgsl new file mode 100644 index 00000000..01d1c54d --- /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.rs new file mode 100644 index 00000000..ae615fe7 --- /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.rs new file mode 100644 index 00000000..3b2b2743 --- /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.rs new file mode 100644 index 00000000..a11811aa --- /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.