hdr工作面适配 - #24
Open
konodiodaaaaa1 wants to merge 12 commits into
Open
Conversation
… shoulder, NaN guard Fixes three live-verified color faults on the DLSSNR HDR routes: 1. Yellow highlight leak on the SDR R8 route: MapSdrToHdr multiplied the SDR white point twice when restoring saturated whites, pushing them to (peak/80)*(sdrWhite/80)=20.25 canonical (1620 nit on a 360-nit display). Restore now maps saturated whites to peak/sdrWhite in the normalized domain before the single white-point scale. 2. NaN speckles on the bounded FP16 route: BuildShoulder divided by (peak-1)==0 when the monitor reports MaxLuminance below the SDR white (observed 80 nit vs 360 nit). The curve now degrades to the plain identity; FrameSourceBase raises the reported peak to the SDR white with a visible warning. 3. Residual tint with non-default controls: the PreserveHdrRange branch re-derived luma after applying the directional multiplier, leaking lightness into chroma when saturation/shadow/reflection controls were combined. Rewritten as a strict luma/chroma decomposition that stays linear in the FP16 domain. The SDR-compatible routes now use a replicate contract (identity below the SDR white point, saturate above) so captured SDR frames reach the backend bit-exact; the bounded FP16 route uses an anchored Reinhard shoulder with linear tail (target 2.5) and an algebraically exact inverse. mode 2 clamps out-of-gamut negatives before the model; mode 3 keeps the full range. DLSSNR resolution scaling and residual reconstruction are re-enabled on the HDR path with PreserveHdrRange. Also: SDR-white measurement failure logging, DLSSNR boundary log carries curve parameters, DLSS SR IsHDR creation flag, XeSSFG canonical-FP16 terminal marker, FG terminal selection, signed-snippet strength ranges, mechanical tests for the curve family and degenerate cases, fxc-validated HLSL, and the design/upstream-handoff documents.
…ale selector The DLSSNR model's training contract is sRGB-encoded input (what the U8 route has always fed it). Feeding linear scRGB left mid-tones squeezed into the bottom of the model's input distribution, observed live as a washed-out, hazy image. The bounded FP16 route now encodes the normalized color with an extended sRGB OETF: identical to the standard curve on [0,1] (bit-exact match with the U8 path for SDR content) and the same power law continued above 1 for HDR headroom - monotone, exactly invertible, no gamut clipping. Verified there is no public community alternative; this is the most lossless encoding available for a model whose contract is sRGB. The experimentalHdrScale parameter and its 1/2/4.5 selector tiers are removed everywhere (effect source, settings parsing, protocol struct, routes, renderer wiring, status log): the normalization is now fully derived from frame metadata. The DLSSNR route is a single fixed experimental-fp16 BoundedHDR route. HDR-off isolation re-audited: every boundary (capture processor, effect drawer adapters, route selection, native factory, XeSS/NVOF/RTX-Video branches, presenter formats, compiler macros) is gated on IsHdrCompatibilityEnabled and returns the stock 0.6.6 behavior when the switch is off.
The local build machine had hardened E:/D: SDK paths directly into Magpie.vcxproj, Magpie.Core.vcxproj and WinUI.targets (CppWinRT union include, CppWinRTPath, MagpieWindowsKitsPath SDK import, WinUI SDK bin lookup). These are machine-specific and do not belong in the PR; the same overrides live in the untracked BuildOptions.props.user on the build machine. All three files are restored to the upstream experimental versions so the PR diff contains functional changes only.
Author
|
@SAOG0721 R2 状态更新,说明一下 DLSSNR 的回退结论。 经过实机日志驱动的多轮修复(黄色高光泄露、NaN 斑点、残差参数偏色均已修复),最终确认社区 DLSSNR DLL 的 Feature 18 模型输入契约是 sRGB 编码,与 U8 路径一致;线性 scRGB 直入会导致模型分布在中间调失配(画面灰蒙蒙)。目前 DLSSNR 在 HDR 模式下已回退为"扩展 sRGB 编码的 SDR 域处理"([0,1] 与 U8 路径逐位一致,>1 延拓幂律), 其余 HDR 兼容能力不受影响并已实机验证:DLSS SR、DLSSFG、XeSSFG 原生无损直通,FSR/XeSS SR/RTX Video/光流的 HDR 分支保留;HDR 开关关闭时已逐边界复查与官方 0.6.6 完全等效(capture、effect、native、presenter、compiler 宏全部 gate,无任何残留 HDR 处理)。 另外把之前混入的构建机本地 SDK 路径(vcxproj/WinUI.targets)还原成了上游原版,现在 PR diff 只含功能性变更,无文件删除。测试构建在 fork 的 v0.6.6-hdr-r1 release,欢迎实机验证。 |
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.
关联关系
这次 PR 的定位
这是一条完整的 HDR 工作面适配分支。实现以本地 0.6.5 已经完成的效果、native backend、DLSSNR 残差、Frame Guidance、FG 发布和参数会话为基础,加入官方 0.6.6 的会话生命周期、NGX 异常保护、捕获关闭保护、实时参数队列、inputRevision history 管理、窗口 owner 和 overlay 状态恢复。
HDR 适配采用显式全局开关:
关闭 HDR compatibility 时,HDR boundary 清空,HDR-only 参数进入 inactive/default,HDR capture pool、normalization、HDR compiler variant、HDR presenter 和 HDR terminal 均退出处理链。外部显示器或系统处于 HDR 状态时,关闭这个选项仍然选择线上 U8/LDR 路由;本地 0.6.5 的 DLSSNR residual、Frame Guidance、ZeroMV、FG failure recovery 和原有参数行为保持原逻辑。
Canonical FP16 与 route boundary
inter-effect canonical storage 为 DXGI_FORMAT_R16G16B16A16_FLOAT,并由 HdrFrameMetadata 与 ColorDescription 携带 transfer、primaries、range、reference white、SDR white、display peak、scene/display referred、pre-exposure 和 HDR metadata。
每个效果通过结构化 HdrFormatRoute 描述 input/output format、transfer、range、alpha mode、evidence level、HDR-native、adapter profile、HDR/SDR 默认值和 normalization scale。route 选择使用结构化字段,effect 名称只用于 catalog 分组和诊断。
已落地的 adapter profile:
Native backend 适配
DLSSNR
保留本地 DLSSNR 的颜色、depth、motion、exposure、残差、输入分辨率和 history 逻辑。HDR 状态使用 canonical FP16 -> bounded HDR normalization -> DLSSNR color/depth/motion/exposure -> inverse normalization -> canonical FP16。
inputRevision 由 Renderer 传入;上游实时参数或输入 route 变化时刷新 history,避免旧静帧缓存与新输入混合。所有 NGX create/evaluate/release/shutdown、参数访问和 signed snippet 调用统一进入 NgxRuntimeGuard。
DLSS SR / DLSS FG
DLSS SR 使用 route-compatible float 输入和既有 guidance contract。DLSSFG 增加 _dlssFgNormalizedInput、_dlssFgCanonicalGenerated 和 _dlssFgHdrNormalizationScale,在 evaluate 前后完成 bounded/canonical 转换,并在 publication 前检查 canonical FP16 descriptor。原有 CPU Fence、D3D11/D3D12 共享资源、history reset、一次重建和当前会话禁用策略继续保留。
XeSS SR / XeSSFG
XeSS SR 的 HDR FP16 初始化和 SDR U8 初始化分开;XESS_INIT_FLAG_LDR_INPUT_COLOR 只用于 SDR 路由,HDR 浮点输入保留自己的 contract。XeSSZeroMVUpscaler 继续作为独立的线上 ZeroMV backend。
XeSSFG 作为 presentation terminal 使用 canonical FP16 -> Rec.709 to Rec.2020 -> PQ/BT.2100 -> R10G10B10A2_UNORM -> DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020 -> XeSSFG proxy swap chain。backbuffer、HUD-less、UI surface 和 proxy swap chain 使用同一 HDR10 contract;HDR off 恢复线上 LDR terminal。
FSR2/FSR3/FSR4、RTX Video、光流
FSR2/3/4 保留本地 ZeroMV、motion、depth、exposure、reactive/transparency mask 和 FG/optical-flow 辅助资源,HDR 只在 boundary 增加 canonical/route conversion。RTX Video 使用显式 normalized-D3D/U8 bridge,inputScale 按实际 float/U8 输入选择。AMD OF 与 NVOF 在 HDR 状态从 canonical frame 做 provider-local conversion,SDR 状态优先线上 B8G8R8A8/U8 contract。
PassThrough 和普通 shader
PassThrough 分为 REFERENCE_HDR_HLSL 与 REFERENCE_LDR_HLSL。Effect compiler 的 MP_HDR_SATURATE、MP_HDR_ALPHA、MP_HDR_COMPATIBILITY 只注入 HDR variant。Group A 效果使用结构化 R8 SDR fallback;CAS 额外保留条件 FP16/linear route 和独立编译 gate。alpha 由 route 显式声明 Preserve、ForceOpaque 或 Premultiplied,publication 和 overlay 边界保持一致。
官方 0.6.6 流程合入
本地 9c2309a 保留官方 0.6.6 的核心设计:
官方 0.6.6 的用户可见设计和 HDR boundary 是两层职责:0.6.6 负责会话与资源生命周期,HDR 层负责 canonical FP16、色彩 metadata、格式适配和 terminal presentation。
配置与回退重点
重点审查入口:
HDR off 的强制合同:
验证
已在 E:\Magpie-0.6.5-build 完成 Release x64 全量重建,版本为 0.6.6-hdr-fp16compat。
R2 更新(2026-09-08):实机颜色修复轮
重要状态说明:DLSSNR 的 HDR 直通探索已回退。 实机日志与数值验证确认社区 DLL 的 Feature 18 模型输入契约是 sRGB 编码(U8 路径一直如此),线性 scRGB 直入导致中间调挤压在模型分布低端(灰蒙蒙、不通透),此前还出现过三处已修复的颜色故障(饱和白双重白点乘法 → 黄色高光泄露;显示器 MaxLuminance 低于 SDR 白时曲线系数 NaN → 黄色斑点;残差参数在 HDR 域的亮度/色度泄漏 → 非默认参数偏色)。当前版本 DLSSNR 在 HDR 模式下的 FP16 实验路径使用扩展 sRGB OETF([0,1] 与 U8 契约逐位一致,>1 延拓同一幂律),
experimentalHdrScale选择器已移除;SDR 模式完全回到线上行为。DLSSNR 的结论是:模型本身不支持直接 HDR 值域,HDR 模式下实际上是带编码的 SDR 域处理。其余 HDR 兼容能力保持并已实机验证:DLSS SR、DLSSFG、XeSSFG 走 DirectFP16/terminal 路由原生无损;FSR 系、XeSS SR、RTX Video、光流的 HDR 分支保留。HDR 兼容开关关闭时已逐边界复查,与官方 0.6.6 完全等效(capture/effect/native/presenter/compiler 宏全部 gate)。
本轮同时把构建机硬编码的 SDK 路径从 Magpie.vcxproj、Magpie.Core.vcxproj、WinUI.targets 还原为上游原版(机器特定覆盖已移回未跟踪的 BuildOptions.props.user),PR diff 现在只含功能性变更,无文件删除,与上游文档保持一致。
实机构建与验证:fork release v0.6.6-hdr-r1(含 r1+r2 修复,SHA-256 见 release 页)。
Review focus
请按下面顺序审阅:
本 PR 提交源码、资源和已构建版本相关变更;详细交接稿留在本地工作树,作为本 PR 描述和后续上游审阅的依据,文件本身保持未加入本次推送。