Merge pull request #423 from cdinhoo/codex/effect-input-control-fixes

This commit is contained in:
Claude
2026-10-10 12:50:18 +00:00
12 changed files with 663 additions and 25 deletions
+7 -1
View File
@@ -216,6 +216,7 @@ fn composite_mode(m: u32) -> BlendMode {
fn point(e: &mut Enc, id: &str, ctx: &EffectCtx, b: GBuf) -> Option<GBuf> {
let pr = ctx.params;
let mut p = Params::default();
let mut original = None;
match id {
"ec.utility.cineon" => {
// utility::Cineon's offset and knee, in the CPU's f32.
@@ -246,6 +247,11 @@ fn point(e: &mut Enc, id: &str, ctx: &EffectCtx, b: GBuf) -> Option<GBuf> {
p.f[0] = pr.color("highlightColor");
}
"ec.channel.cccomposite" => {
if let Some(source) = ctx.env.host.and_then(|h| h.original()) {
let fitted = effectcraft_effects::util::fit_buffer(source, b.img.width, b.img.height, b.offset, b.scale);
original = Some(e.g.upload_image(&fitted)?);
}
p.u[1][0] = original.is_some() as u32;
let m = pr.e("compositeOriginal");
let mode = if m == 1 { BlendMode::Normal } else { composite_mode(m) };
p.u[0] = [6, (m == 1) as u32, mode_id(mode), pr.b("rgbOnly") as u32];
@@ -267,7 +273,7 @@ fn point(e: &mut Enc, id: &str, ctx: &EffectCtx, b: GBuf) -> Option<GBuf> {
}
_ => return None,
}
run(e, "fp2_point", &p, b, None, None)
run(e, "fp2_point", &p, b, original.as_ref(), None)
}
// ---------------------------------------------------------------- CC Block Load (stylize3)
+3 -1
View File
@@ -402,7 +402,9 @@ fn fp2_point(@builtin(global_invocation_id) gid: vec3<u32>) {
}
// u[0] = (_, composite original, mode, rgb only); f[0].x = opacity.
default: {
let orig = px * P.f[0].x;
var source = px;
if (P.u[1].x != 0u) { source = textureLoad(aux, p, 0); }
let orig = source * P.f[0].x;
if (P.u[0].y == 1u) {
o = blend_pixel(P.u[0].z, orig, px, 0.5);
} else {
+16
View File
@@ -103,3 +103,19 @@ fn adjustment_stacks_split_into_gpu_runs_and_cpu_steps() {
r.run_effects_on(&ctx, adj, true, &mut p);
assert_eq!((p.gpu, p.cpu), (3, 1));
}
#[test]
fn composite_reads_the_original_adjustment_input_on_gpu() {
for depth in [BitDepth::Bpc8, BitDepth::Bpc32] {
for mode in [0, 1, 2, 4, 15] {
for rgb in [false, true] {
let stack = vec![
("ec.channel.invert", vec![]),
("ec.channel.cccomposite", vec![("compositeOriginal", Value::Enum(mode)), ("opacity", n(65.0)), ("rgbOnly", Value::Bool(rgb))]),
];
let s = adjustment_scene(depth, &stack, true);
check(&format!("original adjustment {depth:?} mode {mode} rgb {rgb}"), compare_at(&s, RenderOpts { scale: 0.5, ..opts() }, Tick::ZERO), 0.0);
}
}
}
}