Skip to content

fix(render): 合成器用源 nat_size 而非解码纹理尺寸 — 修预览左下角/抽搐 (#125)#129

Merged
appergb merged 1 commit into
mainfrom
fix/preview-composite-nat-size
Jun 24, 2026
Merged

fix(render): 合成器用源 nat_size 而非解码纹理尺寸 — 修预览左下角/抽搐 (#125)#129
appergb merged 1 commit into
mainfrom
fix/preview-composite-nat-size

Conversation

@appergb

@appergb appergb commented Jun 24, 2026

Copy link
Copy Markdown
Owner

真因(用户实测 + GPU 回归测试确认)

shader 的 quad 按 nat(源自然尺寸)缩放回源像素空间再套仿射(shader.wgsl 明注 nat = source natural size)。但 compositor.rs 把 uniform 的 nat 填成了解码纹理尺寸 tex.width/height,而非仿射所用的 ClipPlan.nat_size

预览按 preview_box 降采样解码(如源 1920 → 纹理 1280),于是 quad 只覆盖画布 tex/nat≈⅔ → 图层缩到左下角;不同 clip/帧纹理尺寸不同 → 落点跳变 = 乱抽搐。导出(#112)全分辨率解码 tex==nat 才正常,故导出对、预览错。

修复

  • LayerDraw 新增 nat_size 字段,从 ClipPlan.nat_size 透传(与仿射同基准)。
  • 合成器 uniform 的 nat 改用 draw.nat_size 而非 tex.width/height。纹理经 crop_uv 0..1 采样,其分辨率与几何无关——既修 bug 又保留预览降采样性能
  • 新增 GPU 回归测试 gpu_downscaled_nat.rs(4×4 纹理 / 16×16 源)断言全画幅 clip 铺满整帧;本机 GPU 实测通过,既有合成测试无回归。

注:PR #128 的 CSS 改动(<img objectFit:contain)是必要的(非 16:9 面板正确缩放),但不是真因。本 PR 是 #125 的真正修复。Refs #125(reopened)。

(关于'拖动不立即/一帧一帧':几何修复后帧将就地更新不再跳位;真正的即时 scrub 依赖流式播放引擎 #92/#100。)

…the decoded texture size

The shader scales its [0,1] quad by `nat` (source natural size) to recover
source-pixel space before applying the affine. The compositor was feeding
`tex.width/height` into that uniform instead of the nat_size the affine was
built with. In the preview the frame is decoded at a downscaled max_size, so the
texture is smaller than the source — the quad then covered only tex/nat of the
canvas and the layer rendered shrunk into the bottom-left corner, jittering as
the per-frame decoded size varied. Export decodes at full size (tex==nat) so it
was unaffected — which is why export looked right but preview did not.

Carry ClipPlan.nat_size through LayerDraw and use it for the uniform; the texture
is sampled via crop_uv 0..1 so its actual resolution is irrelevant to geometry.

Adds a GPU-gated regression test (4x4 texture, 16x16 source/canvas) asserting a
full-canvas clip fills the whole frame. Verified on real GPU; existing render
tests still pass. Real fix for #125 (PR #128's CSS change was necessary but not
sufficient). Refs #125
@appergb appergb merged commit d2262b6 into main Jun 24, 2026
2 checks passed
@appergb appergb deleted the fix/preview-composite-nat-size branch June 24, 2026 01:07
@appergb appergb restored the fix/preview-composite-nat-size branch June 24, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant