Skip to content

fix(renderer): pre-scale P010 UNORM samples before range expansion - #134

Closed
1824239290 wants to merge 1 commit into
AimesSoft:mainfrom
1824239290:split/p010-unorm-prescale
Closed

1824239290 wants to merge 1 commit into
AimesSoft:mainfrom
1824239290:split/p010-unorm-prescale

Conversation

@1824239290

Copy link
Copy Markdown
Contributor

概要

修复 P010 的 UNORM 采样预缩放缺失:三端视频 shader(WGSL / Metal MSL / D3D11 HLSL)在范围展开前统一补上 65535.0 / 65472.0 的反打包缩放。

背景

P010 将 10 位采样码以 code << 6 形式存入 16 位 UNORM 纹理。采样器按 16 位 UNORM 归一化得到 sample / 65535,而范围展开常数(64.0/1023.01023.0/876.0 等)假设输入是 sample / 1023。不补偿时每个采样读暗约 0.096%:黑位略微负值后被钳到 0,参考白落在 0.9989,对比度整体轻微压缩;全范围与有限范围 P010 都受影响。

改动

  • wgpu_video.wgsl / metal/apple.rs / d3d11.rsexpand_ycbcr_range:在范围展开前对 P010 采样乘 65535.0 / 65472.01023 × 64 正是 16 位容器中 10 位码的实际满幅)。
  • 新增跨端一致性测试 p010_unorm_prescale_is_present_across_video_shaders
  • 不依赖 Dolby Vision;对 HDR10 / SDR 的 P010 内容同样生效。

验证

P010 packs 10-bit codes as code << 6 in a 16-bit UNORM texture, so the
sampler returns sample/65535 while the range-expansion constants assume
sample/1023. Every P010 sample therefore reads about 0.096% darker than
intended: full black clamps slightly negative and reference white lands
at 0.9989, compressing contrast on all three backends for full-range
and limited-range P010 alike. Undo the packing scale in
expand_ycbcr_range (WGSL, MSL, HLSL) before any range conversion
applies.
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