fix(render): 合成器用源 nat_size 而非解码纹理尺寸 — 修预览左下角/抽搐 (#125)#129
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
真因(用户实测 + 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透传(与仿射同基准)。draw.nat_size而非tex.width/height。纹理经crop_uv0..1 采样,其分辨率与几何无关——既修 bug 又保留预览降采样性能。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。)