fix(renderer): pre-scale P010 UNORM samples before range expansion - #134
Closed
1824239290 wants to merge 1 commit into
Closed
1824239290 wants to merge 1 commit into
1824239290 wants to merge 1 commit into
Conversation
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.
1824239290
force-pushed
the
split/p010-unorm-prescale
branch
from
September 7, 2026 07:17
1fe5107 to
2ef5311
Compare
This was referenced Sep 10, 2026
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.
概要
修复 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.0、1023.0/876.0等)假设输入是sample / 1023。不补偿时每个采样读暗约 0.096%:黑位略微负值后被钳到 0,参考白落在 0.9989,对比度整体轻微压缩;全范围与有限范围 P010 都受影响。改动
wgpu_video.wgsl/metal/apple.rs/d3d11.rs的expand_ycbcr_range:在范围展开前对 P010 采样乘65535.0 / 65472.0(1023 × 64正是 16 位容器中 10 位码的实际满幅)。p010_unorm_prescale_is_present_across_video_shaders。验证