Skip to content

test(render): pixel diff tests for wgpu compositor#211

Open
appergb wants to merge 1 commit into
mainfrom
test/render-pixel-diff
Open

test(render): pixel diff tests for wgpu compositor#211
appergb wants to merge 1 commit into
mainfrom
test/render-pixel-diff

Conversation

@appergb

@appergb appergb commented Jul 7, 2026

Copy link
Copy Markdown
Owner

背景

SPEC §6.2 要求 wgpu 合成器与上游 AVFoundation(CompositionBuilder.swift)做像素 diff —— 这是"命门验证"。CI 无法跑 AVFoundation 生成黄金参考,故采用 SPEC §6.3 的 自洽 + 已知点验证 策略。

新增

crates/opentake-render/tests/pixel_diff.rs(736 行,14 个测试)。自实现 PSNR/SSIM 工具,不加新依赖。

纯函数测试(无 GPU,CI 必跑)

测试 对拍点
affine_centered_half_canvas_matches_hand_computed 上游 L599-604,手算 [0.5,0,0,0.5,25,25]
affine_rotation_45_matches_compose_chain L605-614 compose 链
affine_flip_horizontal_with_smaller_source flip + nat≠render 符号/偏移
crop_to_uv_visible_insets_match_domain_fractions §3.4 inset→UV
compose_with_identity_is_noop CG concatenating
fade_envelope_smoothstep_endpoints_and_midpoint smoothstep(0.2)=0.104 vs linear 0.2
transform_keyframe_midframe_affine_equals_transform_at 逐帧求值 = clip.transform_at(f)
crop_keyframe_uv_varies_across_frames crop 关键帧随帧变化

GPU 集成测试(headless 自动 skip,本地 Metal 真跑)

测试 验收
quadrant_markers_land_in_authored_corners 四角标记图,捕捉 X/Y 翻转(只翻一次)
quadrant_round_trip_psnr_is_high 自洽 PSNR ≥50dB(超 §6.2 的 40dB 门槛)
half_opacity_two_track_blend_matches_hand_computed premult-over 手算 [~64,~128,0,255]
fade_midframe_renders_half_brightness fade 中帧亮度 ~128
text_overlay_visible_above_video cosmic-text 叠加在视频之上
ssim_identical_frames_score_near_one SSIM 工具自洽 ≥0.98

验收指标(SPEC §6.2 容差)

  • 几何:已知点 1e-9 容差(亚像素级)
  • 颜色:自洽 PSNR ≥50dB(门槛 40dB)
  • 文字:SSIM ≥0.98(自洽)

本地验证

cargo fmt --all --check                                        # OK
cargo clippy -p opentake-render --all-targets -- -D warnings   # 零告警
cargo test -p opentake-render                                  # 全绿

新增 14 + 既有 gpu_smoke(5)/gpu_text(1)/gpu_y_orientation/gpu_effects/gpu_downscaled_nat 全部通过。

工程纪律

  • 一 PR 一事:只加 tests/pixel_diff.rs,不改 src/
  • 不加新依赖(PSNR/SSIM 自实现,image 已是 dev-dep)
  • 不合并,留给主 agent 验收

Part of #7(PoC 像素 diff 框架部分)

…Foundation (#7)

PoC 场景 + 像素 diff 框架,验证 wgpu 与上游对齐
- 已知点 affine 单测(对拍 CompositionBuilder.affineTransform L599-614)
- 方向标记测试图(UV 翻转只一次)
- 双轨混合顺序 + fade 包络
- PSNR/SSIM 工具
@appergb appergb added the testing 测试相关变更 label Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing 测试相关变更

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant