Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.
C++
feat(sr): add a supersample shrink option and fix the SR card summary
Veyra Goal Agent82acac61da7a
diff --git a/AGENTS.md b/AGENTS.mdindex 0d9ecc76..3ceb6517 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -1,5 +1,7 @@# Veyra Agent 工作规则+> **2026-10-28后续(用户选择)**:同分支新增“超分后缩回到”超采样选项:单次RTX视频超分到目标尺寸,再线性光精确缩回`srOutput`,NR/补帧/显示按缩回尺寸运行;双重开启时不用、保留选择。复用`srOutput`字段与`SrResolve`,导出协议14,超采样图同双重图走WDDM预算准入。读`docs/SR_SUPERSAMPLE_2026-10-28.md`及`reports/claude-sr-supersample-20261028/FINAL.json`。用户随后要求直接合并:双重超分、复查修正与超采样已合入本地main(未push/Release),活动树切回main,其余限制同下条。+> **2026-10-28最新用户纠偏(覆盖下面同日早期两条)**:当前分支`codex/dual-sr-20261028`,实施真正的“基础SR→降低第一次AI结果→第二次SR”;双重开关位于基础超分下,展开独立第二设置,默认关闭。普通8K保持原规则,撤回强制4K参数修正/拦截;新双重图按WDDM预算拒绝不足的分配,不偷偷缩小尺寸。当前双重仅RTX视频超分,两次真实Evaluate;本机SDK共享Feature,不宣称两个独立SDK实例。实际验证与限制读`docs/DUAL_SR_PLAN_2026-10-28.md`及`reports/dual-sr-20261028/FINAL.json`。不重跑原8K最终输出+NR+VFG危险组合,根因未证实;不改真实配置、不合并main、不push/Release。> 2026-10-28后续:用户报告接手测试版在1080p先降/8K最终输出时整机卡住重启。当前修复分支`codex/sr-stage-freeze-20261028`,依据`docs/SR_STAGE_FREEZE_2026-10-28.md`;原存档同时开NR与VFG 2X,不得再无防护重跑原组合。当前将三段式SR的NR/FG最终输出限制到4K,保留8K内部超分;这不是底层驱动挂死已根治的证明。真实用户会话仅只读及保全,不直接修改;私有副本验证。无合并main/push/Release授权。diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.mdindex 478145d6..7051b08d 100644--- a/docs/CURRENT_STATUS.md+++ b/docs/CURRENT_STATUS.md@@ -10,7 +10,9 @@## 本轮整理结果与开发入口-**2026-10-28当前开发分支:**`codex/dual-sr-20261028`。按用户最新纠偏完成“基础超分→降低第一次AI结果→第二次超分”;基础下方开关展开第二次设置,列表/节点一致,当前双重支持RTX视频超分。普通8K保持原规则,撤回先前4K限制;新双重图按WDDM预算准入,不改用户请求尺寸。GPU实测每帧两次Evaluate、第二输入确来自第一次结果,普通8K和实际导出通过,保存/界面/翻译回归见[当前交付记录](DUAL_SR_PLAN_2026-10-28.md)。尚未合入main或发布,正式版仍2.1.1;独立`claude/capture-fps-audio-20261027`未混入。+**2026-10-28(已合入本地main):**施工分支`codex/dual-sr-20261028`。按用户最新纠偏完成“基础超分→降低第一次AI结果→第二次超分”;基础下方开关展开第二次设置,列表/节点一致,当前双重支持RTX视频超分。普通8K保持原规则,撤回先前4K限制;新双重图按WDDM预算准入,不改用户请求尺寸。GPU实测每帧两次Evaluate、第二输入确来自第一次结果,普通8K和实际导出通过,保存/界面/翻译回归见[当前交付记录](DUAL_SR_PLAN_2026-10-28.md)。用户2026-10-28要求后已合入本地main,未push、未发布,正式版仍2.1.1;独立`claude/capture-fps-audio-20261027`未混入。++同分支随后按用户选择新增“超分后缩回到”超采样选项(单次RTX视频超分到更高尺寸,线性光精确缩回,后续效果按缩回尺寸运行;双重开启时不用),随同上述改动合入本地main,见[超采样选项](SR_SUPERSAMPLE_2026-10-28.md)。此前单层接手和4K防护现为历史:[接手记录](SR_STAGE_HANDOFF_2026-10-28.md)、[原卡死诊断](SR_STAGE_FREEZE_2026-10-28.md)。原8K最终输出+NR+VFG整机卡死的具体根因未证明,本轮未重跑该危险组合;短测和预算准入不能冒充驱动挂死已根治。diff --git a/docs/DUAL_SR_PLAN_2026-10-28.md b/docs/DUAL_SR_PLAN_2026-10-28.mdindex 3b121e61..11bcacbe 100644--- a/docs/DUAL_SR_PLAN_2026-10-28.md+++ b/docs/DUAL_SR_PLAN_2026-10-28.md@@ -51,7 +51,7 @@ ResolutionPlan、固定链计划、实际GPU纹理、状态尺寸、导出共享新增4K双重SR+NR+VFG 2X文件组合短测约12秒,三个效果实际激活,保持两次SR及请求的4K输出;末段本机读数显存4054MiB、WDDM预算11175MiB,累计处理275源帧。此为RTX5070/1080p30合成文件的软件读数,不是原危险8K组合或真实采集验收。-复验曾遇到旧测试断言仍要求已退休的`srOutput`触发重建,已改为检验其不干预处理;重复运行复用了上次故意损坏的预设/旁路文件,导致旧格式用例失败,runner改用每次唯一TEMP和fixture路径后全通过。失败JSON/日志保留为`cpu-recheck-before.*`,不掩盖失败。旧`sr-stage-ui.qml`/`sr-stage-safety-ui.*`和GPU `stage*`模式保留供历史追溯,当前双重验收使用`dual-sr-ui.qml`及GPU `dual`模式。+复验曾遇到旧测试断言仍要求已退休的`srOutput`触发重建,已改为检验其不干预处理;重复运行复用了上次故意损坏的预设/旁路文件,导致旧格式用例失败,runner改用每次唯一TEMP和fixture路径后全通过。失败JSON/日志保留为`cpu-recheck-before.*`,不掩盖失败。旧`sr-stage-ui.qml`/`sr-stage-safety-ui.*`、`sr-stage-ab.py`和GPU `stage*`模式按退休的单层语义断言,已在复查后删除(Git历史可查);当前验收工具见文末“复查修正”。验收原始回执在 `E:/项目/Veyra/reports/dual-sr-20261028`,GUI回执在 `reports/codex-dual-sr-20261028`;日志对应 `logs/`。第一次SDK创建失败保留,未用后续成功覆盖。真实界面截图 `tests/codex-dual-sr-20261028/dual-controls.png`。@@ -60,3 +60,47 @@ ResolutionPlan、固定链计划、实际GPU纹理、状态尺寸、导出共享交互测试入口在 `E:/项目/Veyra/tests/dual-sr-20261028/启动双重超分测试.cmd`,使用独立interactive-profile,关闭自动恢复/预热,不修改原配置。避免直接打开共享运行目录时自动恢复用户此前的高负载会话。未做长时动态画质、所有显卡/驱动、实卡输入或原8K NR/VFG组合验收;不承诺双重超分必然提升画质或没有任何缺陷。++## 复查修正(Claude,2026-10-28)++用户要求复查上面的交付后在本分支修正两处遗留,未提交。++- 卡片摘要:列表超分卡片仍按退休的单层字段拼接,只要是RTX视频超分就把保留的`srPrescale`显示成“1080p→4K”(双重关闭时也显示),并在退休的`srOutput`非零时显示“→片源尺寸/xK”,却不显示第二目标和质量。现改为仅在双重开启且为RTX视频超分时显示“基础目标→降低尺寸→第二目标 · 质量 基础/第二”,如“RTX 视频超分 · 4K→1080p→2K · 质量 1/2”;关闭后为“RTX 视频超分 · 4K · 质量 1”。删除不再使用的“片源尺寸”词条。+- 测试工具:删除上述退休的GPU `stage`/`stage-boundaries`/`stage-capabilities`/`stage-image`模式和三个旧脚本。`veyra_sr_quality_tests`保留`dual`,新增:++| 模式 | 检查 |+|---|---|+| `dual-restore` | SDR输入输出透明;HDR 2560×1440→基础4K→1080p→第二4K,两次恢复都对各自基础满足恢复钳位界:\|输出−双线性(基础)\| ≤ 0.5×203/80+0.05;第二次的基础是第一次线性结果的面积平均 |+| `dual-boundaries` | 4K源→基础4K→720p→第二2K(输出小于源)、同组合原生NR先行;2K源→基础4K→75%(2880×1620)非整数降低与CPU面积平均一致 |+| `dual-capabilities` | 质量1–4 × 1080p源第二5K/6K/7K/8K,加720p降低与21:9,共24组,每组两次实际Evaluate |+| `sr-image` | 单张图片走真实处理图,供A/B:`<dir> sr-image <输入.png> <名称> <质量0..4> <目标> <降低\|off> <第二目标> <第二质量> [video\|still\|capture]` |++`scripts/acceptance/dual-sr-ab.py`替代旧A/B:用原生4K参考图生成软4K、原生2K、原生1080p三种源,比较单次与双重的PSNR/SSIM、梯度锐度、SR阶段中位GPU时间,并输出1:1裁切;双重用例强制核对每帧两次Evaluate。`dual-sr-ui.qml`增加三项卡片摘要断言,`sr-stage-ui.py`把截图路径传入夹具。++验证:`build.py`重编产品/i18n/测试目标,`stage_app.py`以新文件替换运行目录EXE/QML,产品EXE与测试EXE在构建与运行目录逐SHA一致。GPU `dual`、`dual-restore`(第一次1.2771、第二次1.2718,界1.319)、`dual-boundaries`(非整数降低最大差1LSB)、`dual-capabilities` 24/24均退出0;EffectChain、PresetLibrary、RepairPreset通过;QtQuick 117/0/1跳过;i18n 0失败,`extract.py --check`缺失0(2690条)。真实界面16项断言全部通过、无QML错误,截图`tests/claude-codex-review-20261028/dual-controls.png`。日志`logs/claude-codex-review-20261028/`。++图片A/B(`reports/claude-codex-review-20261028/ab/gta-t780|gta-t95/`,GTA VI原生4K两帧,全部质量4,PSNR/SSIM以原4K为参考):++| 源 | 方式 | t780 PSNR / SSIM / ms | t95 PSNR / SSIM / ms |+|---|---|---|---|+| 原生1080p | 双三次(无AI) | 45.82 / 0.9932 / – | 49.72 / 0.9919 / – |+| 原生1080p | 单次→4K | 43.38 / 0.9759 / 6.4 | 44.33 / 0.9721 / 6.2 |+| 原生1080p | 双重4K→1080p→4K | 41.13 / 0.9673 / 13.4 | 41.80 / 0.9564 / 12.7 |+| 原生1080p | 双重4K→1440p→4K | 42.43 / 0.9729 / 18.4 | 43.28 / 0.9653 / 17.5 |+| 原生2K | 双三次(无AI) | 48.63 / 0.9957 / – | 51.86 / 0.9941 / – |+| 原生2K | 单次→4K | 44.76 / 0.9805 / 12.6 | 45.74 / 0.9781 / 12.6 |+| 原生2K | 双重4K→1080p→4K | 42.04 / 0.9701 / 21.4 | 42.93 / 0.9632 / 20.1 |+| 原生2K | 双重4K→1440p→4K | 42.79 / 0.9741 / 23.0 | 43.68 / 0.9684 / 25.9 |+| 原生2K | 双重8K→1440p→4K | 42.88 / 0.9738 / 24.3 | 43.61 / 0.9679 / 27.0 |+| 软4K | 不超分(输入) | 41.65 / 0.9780 / – | 43.85 / 0.9744 / – |+| 软4K | 单次原尺寸 | 40.91 / 0.9706 / 28.1 | 42.77 / 0.9664 / 27.9 |+| 软4K | 双重4K→1080p→4K | 40.71 / 0.9640 / 32.6 | 42.23 / 0.9619 / 35.1 |+| 软4K | 双重4K→1440p→4K | 40.12 / 0.9658 / 37.1 | 41.90 / 0.9616 / 40.1 |++两帧所有组里,双重的PSNR/SSIM都低于单次。所有RTX输出的梯度锐度都高于参考;双重除原生1080p t780的1440p一例(0.00968,单次0.00973)外又高于单次(同组参考0.00736、双重1080p 0.01006)。SR阶段GPU时间为单次的约1.2–2.9倍。放大裁切中差异细微:双重1080p的路牌、窗框边缘更硬、暗边更明显,文字并未比单次更清楚;双重1440p与单次接近。PSNR/SSIM偏向不锐化的结果(不超分或双三次高于所有RTX输出),只表示与原图的保真度,不是主观画质结论;仅两帧、一款游戏、单机RTX 5070。完整数据在同目录`ab.json`。++追加对比(同目录`extra.json`,同源同参考,质量4):第二次前只缩到75%/90%时更接近单次但仍更低(原生1080p t780 42.68/43.02,单次43.38),第二次接近4K原尺寸修复,SR阶段20.6–36.9ms。先超到8K再在线性光精确面积缩回4K,四组都高于单次(原生1080p t780 44.03/0.9799、t95 45.06/0.9766;原生2K t780 45.23/0.9835、t95 46.28/0.9809),锐度更接近参考,SR阶段只多1–3ms;用浮点USM锐化回单次的锐度后略低于单次。把单次用浮点USM锐化到双重1080p的同等锐度,四组PSNR/SSIM都高于双重(如原生1080p t780 42.72/0.9743对41.13/0.9673)。即在这些素材上,双重近似一次高开销锐化;“超分到更高再缩回”是测过的唯一同时提高保真的做法,也就是被双重取代的单层“再缩到”,其`SrResolve`路径仍在代码中。PIL的UnsharpMask在100%以下按整数丢弃小差值,首轮据此的匹配结果已作废,改用浮点USM。++未修:当前计划中SR输出总等于工作尺寸,EnhanceGraph的`SrResolve`再缩路径不会执行但未删;EnhanceGraph尺寸日志(`three-step prescale=`)和EffectChain/EnhanceGraph部分注释仍沿用旧三段式说法。普通8K+NR+VFG按用户指令不加防护,原危险组合未重跑。++后续:用户随后选择把“超分到更高再缩回”做成选项,`SrResolve`重新启用、日志与注释已改,见[超采样选项](SR_SUPERSAMPLE_2026-10-28.md)。diff --git a/docs/README.md b/docs/README.mdindex b553b573..8930e263 100644--- a/docs/README.md+++ b/docs/README.md@@ -9,6 +9,6 @@5. [分支与工作树归档](BRANCH_ARCHIVE.md):保留项、已退休分支tip与恢复方法。6. [2.1.1用户更新说明](RELEASE_NOTES_2.1.1.md) 与 [对应源码/构建](BUILD_2.1.1.md)。7. [界面代码与职责边界](ARCHITECTURE.md):桥接模块与QML组件从哪里找。-8. [当前双重超分施工](DUAL_SR_PLAN_2026-10-28.md):基础SR→降低AI结果→第二次SR;覆盖同日早期单层方案与4K限制。+8. [当前双重超分施工](DUAL_SR_PLAN_2026-10-28.md):基础SR→降低AI结果→第二次SR;覆盖同日早期单层方案与4K限制。随后新增[超采样选项](SR_SUPERSAMPLE_2026-10-28.md):单次RTX视频超分到更高尺寸后精确缩回。历史方案、排查和发行过程集中在[历史索引](history/INDEX.md)。旧路径对照[PATH_MAP.json](history/PATH_MAP.json);这些历史文件中的“当前/未合并/未发布”按原日期解释。diff --git a/docs/SR_STAGE_REPORT_2026-10-28.md b/docs/SR_STAGE_REPORT_2026-10-28.mdindex 2f7d6aab..a572d3cf 100644--- a/docs/SR_STAGE_REPORT_2026-10-28.md+++ b/docs/SR_STAGE_REPORT_2026-10-28.md@@ -92,7 +92,7 @@ GPU 测试(合成画面,读回只在测试中):## 6. 未验证与边界-- 未用户本人的原生 4K 原图跑参照对比(附件被压成 2000×1125);拿到原图路径后可用`scripts/acceptance/sr-stage-ab.py --mode native`直接跑。+- 未用户本人的原生 4K 原图跑参照对比(附件被压成 2000×1125);拿到原图路径后可用`scripts/acceptance/sr-stage-ab.py --mode native`直接跑(该脚本已随单层模式退休,双重超分对比见`scripts/acceptance/dual-sr-ab.py`)。- 未实测显存峰值,第 3.4 节方案中的数字是纹理尺寸计算值。- 未与 main 构建做逐像素对比;关闭时代码路径只多了描述符槽位,由原有单步回归测试覆盖。- 未上采集卡实测(会占用设备,需要用户同意);未测 5K–7K 目标、1080p→8K 以外的 4x 以上倍率(6x 等)。本机 VSR 在 3x/4x 输出 8K 均正常。diff --git a/docs/SR_SUPERSAMPLE_2026-10-28.md b/docs/SR_SUPERSAMPLE_2026-10-28.mdnew file mode 100644index 00000000..809ac10a--- /dev/null+++ b/docs/SR_SUPERSAMPLE_2026-10-28.md@@ -0,0 +1,66 @@+# 超采样选项:超分后缩回(2026-10-28)++## 用户合同++用户看过双重超分复查的图片A/B后,选择把“先超到更高分辨率,再精确缩回输出尺寸”做成基础超分的选项。在施工树`codex/dual-sr-20261028`完成,用户随后要求直接合并到本地main(提交与合并哈希见FINAL回执);未push、未Release,不改真实配置、SDK、模型、驱动,Lecram暂停。双重超分保留,默认关闭。++依据见[双重超分复查](DUAL_SR_PLAN_2026-10-28.md)的“复查修正”和“追加对比”:在两帧GTA VI原生4K上,双重超分所有组都不如单次;先超到8K再缩回4K四组都比单次更接近原图,只多约1–3ms。++## 行为++- 列表与节点共用`SrStageEditor`,在“质量”下新增“超分后缩回到”:不缩回 / 片源尺寸 / 2K / 4K / 5K / 6K / 7K,默认不缩回。“目标尺寸”此时是超采样的中间尺寸。+- 只在单次RTX视频超分(质量1–4、NVIDIA)生效。双重开启时该行禁用但保留选择,关闭双重后恢复;DLSS SR、FSR、其他显卡保持原单次路径。+- 链路:源 → RTX视频超分到目标尺寸 → 线性光精确面积缩回(HDR先按纹素恢复再平均)→ 降噪、补帧、调色、显示都按缩回后的尺寸运行,不在8K上跑。+- 超分没有放大或缩回尺寸不小于超分结果时不缩回,实际尺寸下方说明原因。运行中显示`1920x1080 → 7680x4320 → 3840x2160`;卡片摘要如“RTX 视频超分 · 8K→4K · 质量 1”。+- 图片、视频文件、采集与导出共用同一尺寸合同。++## 实现++- 字段沿用`srOutput`。PresetStore v33+、PresetLibrary v16+、ChainSession v11+已保存它,无格式升级;旧单层预设里设过“再缩到”的,现在按超采样生效。+- `runningSrOutput`恢复返回`srOutput`(仅上述条件);`activeVideoSettings`只在单次RTX视频超分时保留它,所以双重开启或其他后端下修改它不重建图;执行计划同样传入。GPU复用原有的`SrResolve`缩回pass。+- 导出worker共享布局不变,但该字段语义变了,协议13→14,避免旧worker静默忽略缩回。+- 显存:超采样图与双重图一样走WDDM预算准入,纹理估算加上超分结果RGBA8,SDK预留(RTX 256MiB、NR启用1GiB、VFG每工作像素128B),再留可用预算20%;不足则拒绝事务,不改请求尺寸。普通单次路径保持原规则。预留是保守估算,不是SDK峰值测量。+- 日志改为`supersample evaluate=WxH output=WxH`与`dual reduce=…`,不再写“three-step”;相关注释同步。++## 验证++构建:`py -3.11 -I -B E:/项目/Veyra/tmp/claude-sr-stage-20261028/build/build.py`,MSVC/Ninja并发2;10个产品/测试目标134.0秒,改提示文字后3个目标2.0秒,均退出0。新出现的警告只有EnhanceGraph.cpp既有的C4189(`st`/`dSize`),早先重编该文件时同样出现。`stage_app.py`以新文件替换运行目录EXE/QML。++检查脚本`tmp/claude-sr-supersample-20261028/checks.py cpu|qml|gpu|export`,回执在`reports/claude-sr-supersample-20261028/`,日志在`logs/`同名目录:++| 检查 | 结果 |+|---|---|+| EffectChain | 453项通过,含13项超采样:1080p→8K→4K,NR与补帧在4K,导出/图片同尺寸,回到片源尺寸,非整数2K,未放大时不缩回并报告,双重忽略保留值,DLSS SR/FSR/其他显卡不生效,只在单次RTX视频超分时重建 |+| PresetLibrary / RepairPreset | 552项通过;v33/v34字段往返通过 |+| GPU `supersample` | SDR缩回与同图8K结果的CPU面积平均最大差1LSB;HDR最大差0.031、超差0;回到2560×1440片源;1080p→4K→2K;双重时两次超分并忽略保留值。q2 2K→8K超分阶段5.57ms,带缩回5.43ms |+| GPU `dual`/`dual-restore`/`dual-boundaries`/`dual-capabilities` | 全部通过,24/24 |+| 实际导出 | `sr-supersample` 3840×2160、`sr-supersample-2k` 2560×1440、`dual-sr` 2560×1440,H.264/NVENC各4源帧4编码帧(ffprobe);worker日志`supersample evaluate=7680x4320 output=3840x2160` |+| QtQuick / 翻译 | 117通过、0失败、1既有跳过;i18n 0失败,`extract.py --check`缺失0(2698条) |+| 真实界面 | 21项断言通过、无QML错误:列表超采样8K→4K、关闭回到8K、双重开启时禁用、节点有同样控件;最后超采样8K→4K+NR+VFG 2X约12秒,三效果实际运行,显存4029MiB/WDDM预算11175MiB,超分P95 2.82ms(质量1) |++截图:`tests/claude-sr-supersample-20261028/dual-controls-supersample.png`(超采样)与`dual-controls.png`(双重)。界面测试的切换顺序先设缩回、再关双重、最后改8K,任何一步都没有8K最终输出叠加NR/VFG。++## 图片A/B(产品图内,质量4)++`scripts/acceptance/sr-ab.py --mode native`,GTA VI原生4K两帧;PSNR/SSIM以原4K为参考,耗时为超分阶段中位数:++| 源 | 方式 | t780 PSNR / SSIM / ms | t95 PSNR / SSIM / ms |+|---|---|---|---|+| 原生1080p | 单次→4K | 43.38 / 0.9759 / 6.7 | 44.33 / 0.9721 / 6.6 |+| 原生1080p | 超采样8K→4K | **44.21 / 0.9799** / 7.9 | **45.27 / 0.9769** / 7.9 |+| 原生1080p | 双重4K→1080p→4K | 41.13 / 0.9673 / 13.5 | 41.80 / 0.9564 / 13.5 |+| 原生2K | 单次→4K | 44.76 / 0.9805 / 11.7 | 45.74 / 0.9781 / 11.7 |+| 原生2K | 超采样8K→4K | **45.40 / 0.9835** / 12.9 | **46.52 / 0.9812** / 13.1 |+| 原生2K | 双重4K→1080p→4K | 42.04 / 0.9701 / 18.6 | 42.93 / 0.9632 / 18.7 |+| 软4K | 不超分(输入) | 41.65 / 0.9780 / – | 43.85 / 0.9744 / – |+| 软4K | 单次原尺寸 | 40.91 / 0.9706 / 25.8 | 42.77 / 0.9664 / 26.1 |+| 软4K | 超采样8K→4K | 41.33 / 0.9729 / 26.4 | 43.53 / 0.9717 / 26.5 |++超采样在两帧所有组都高于单次,锐度更接近参考(原生1080p t780:参考0.00736、单次0.00973、超采样0.00865),放大看路牌边缘的暗边比单次少、明显少于双重。它比单次略软;之前用浮点锐化把它拉回单次的锐度后,数值略低于单次,所以它是“更自然、更接近原图”的选项,不是“更锐”。软4K上不超分仍得分最高,PSNR/SSIM只代表保真度,不是主观结论。完整数据与裁切在`reports/claude-sr-supersample-20261028/ab/`。++## 未做与限制++- 未做长时播放、实卡采集、其他显卡/驱动验收;超采样+NR+VFG只有约12秒短测(1080p30文件、质量1)。+- 原8K最终输出+NR+VFG危险组合未重跑,整机卡死根因仍未证实。+- 已合入本地main,未push/Release;双重超分是否撤掉由用户决定。`SrResolve`现已重新使用,不再是死代码。+- 仅两帧、一款游戏、单机RTX 5070。diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 561cd9e5..48a91214 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -77,3 +77,47 @@ UI真实运行核对列表与节点的展开/关闭、两次参数独立、第交付沿用tests/claude-sr-stage-20261028/app;独立interactive-profile入口tests/dual-sr-20261028/启动双重超分测试.cmd,禁自动恢复/预热,不改原设置。AGENTS(活动树与E盘共享)、CURRENT_STATUS、文档索引及旧报告已标记最新纠偏。详细合同、命令与边界见docs/DUAL_SR_PLAN_2026-10-28.md,最终摘要/保护检查在reports/dual-sr-20261028/FINAL.json。未复测原8K最终输出+NR+VFG危险组合,不宣称整机卡死具体根因已证实或驱动挂死根治。当前双重仅RTX视频超分,未扩为所有显卡/模型/实卡/长时画质验收。不复制新完整运行包,仅复用现有运行目录;新增小型测试、日志和证据实际逻辑字节见FINAL,未测本轮净物理占用/回收。正式2.1.1资产、SDK/模型/DLL/驱动不改,不合并main、不push/Release,Lecram暂停。++## 2026-10-28 双重超分复查与修正(Claude)++用户先要求检查Codex接手完成的情况,再要求在本分支修复超分卡片摘要,并删除或改写失效的旧stage测试和A/B工具。仍在`codex/dual-sr-20261028`(HEAD `e61e497`)工作区,未提交;不合并main、不push/Release。++复查:同一构建目录的产品EXE与FINAL记录SHA一致;CPU三组、GPU `dual`、真实界面13项复现通过。发现两处遗留:列表超分卡片摘要仍按退休单层字段拼接,RTX超分时总把保留的降低尺寸显示为“1080p→4K”(双重关闭时也显示),且缺第二目标/质量;旧GPU `stage*`模式、`sr-stage-ab.py`、`sr-stage-ui.qml`、`sr-stage-safety-ui.*`仍按退休的先降/再缩语义。++修正:ProPage摘要仅在双重开启且为RTX视频超分时显示“基础目标→降低尺寸→第二目标 · 质量 基础/第二”,删除“片源尺寸”词条。SrQualityTests删除`stage`/`stage-boundaries`/`stage-capabilities`/`stage-image`,保留`dual`,新增`dual-restore`、`dual-boundaries`、`dual-capabilities`、`sr-image`;`scripts/acceptance/dual-sr-ab.py`替代旧A/B;`dual-sr-ui.qml`加三项摘要断言和截图参数,`sr-stage-ui.py`传截图路径、默认媒体改为nr-1080p30.mp4。`sr-image`名称改为UTF-8输出(原宽字符逐字截断,有C4244警告);旧实施报告的脚本提示加退休说明,DUAL_SR_PLAN补“复查修正”节。++命令:`py -3.11 -I -B E:/项目/Veyra/tmp/claude-sr-stage-20261028/build/build.py <目标>`(并发2)重编veyra_qml_ui、i18n与测试目标,最后一次veyra_sr_quality_tests 5.4秒、0警告;`stage_app.py`以新文件替换运行目录。`tmp/claude-codex-review-20261028/run_tests.py`跑CPU/QtQuick/i18n,`gpu_final.py`用最终测试EXE重跑四个GPU模式;UI `py -3.11 -X utf8 -B -I scripts/acceptance/sr-stage-ui.py --task claude-codex-review-20261028`;A/B `py -3.11 -X utf8 -B -I scripts/acceptance/dual-sr-ab.py --mode native --image tests/claude-sr-stage-20261028/media/gta-4k-t780.png --tag gta-t780`(t95同)。++结果:产品EXE `542ad0b9…`、测试EXE `c00a86c9…`在构建与运行目录逐SHA一致。GPU `dual`、`dual-restore`(第一次1.2771、第二次1.2718,界1.319)、`dual-boundaries`(非整数降低最大差1LSB)、`dual-capabilities` 24/24全部退出0;EffectChain/PresetLibrary/RepairPreset通过;QtQuick 117/0/1跳过;i18n 0失败,`extract.py --check`缺失0(2690条)。真实界面16项断言通过、无QML错误,截图`tests/claude-codex-review-20261028/dual-controls.png`完整显示“RTX 视频超分 · 4K→1080p→2K · 质量 1/2”。ASCII与中文名称的`sr-image`各一次通过,A/B工具改动后冒烟通过。++过程失败:最初的HDR峰值判据不成立(恢复本就按钳位放大差值),改为对各自基础的恢复钳位界;摘要首版在窄面板被截断为“质量 1,…”,改为“质量 1/2”并去掉多出的词条;A/B裁切在组间同名覆盖,改加组前缀。均在最终结果前修正。++A/B(GTA VI原生4K两帧,全部质量4,完整表见DUAL_SR_PLAN“复查修正”):两帧所有组双重的PSNR/SSIM都低于单次,如原生1080p t780单次43.38/0.9759/6.4ms、双重4K→1080p→4K 41.13/0.9673/13.4ms;梯度锐度除一例外高于单次,SR阶段GPU时间约1.2–2.9倍;放大裁切差异细微,双重1080p边缘更硬、暗边更明显。PSNR/SSIM只代表与原图的保真度(不超分/双三次高于所有RTX输出),不是主观画质结论。++追加对比(用户问双重是否有效、是否因中间分辨率过低):`tmp/claude-codex-review-20261028/ab_extra.py`在同一运行目录用`sr-image`补跑75%/90%降低与单次超到8K,CPU线性光2×面积缩回4K;`ab_extra2.py`用浮点USM(高斯σ1)按梯度锐度匹配。结果写入`reports/claude-codex-review-20261028/ab/gta-t780|gta-t95/extra.json`:缩得越少越接近单次但都未超过,90%时SR阶段26.8–36.9ms;8K再缩回四组均高于单次、SR阶段只多1–3ms;单次锐化到双重同等锐度时四组都比双重保真。首轮用PIL UnsharpMask,100%以下整数截断小差值、匹配失效,结果作废后改浮点实现。++产物:回执`reports/claude-codex-review-20261028`(tests.json、gpu-final.json、sr-stage-ui.json、ab/、FINAL.json),日志`logs/`同名,A/B与GPU工作图`tests/`同名,任务脚本`tmp/`同名;收尾删除冒烟输出与测试缓存79,646,121字节,其余实际字节见FINAL。运行目录`tests/claude-sr-stage-20261028/app`的EXE/QML已是本次版本。++未做:未提交;`SrResolve`不会执行的再缩路径、尺寸日志`three-step prescale=`及旧注释未改;未重跑原8K最终输出+NR+VFG;未做视频动态、主观或多显卡画质评测。真实配置、SDK/模型/驱动、正式2.1.1资产未改,Lecram暂停。++## 2026-10-28 超采样选项“超分后缩回到”(Claude)++用户看过双重超分A/B后选择“做成选项”:先用RTX视频超分到更高尺寸,再精确缩回输出尺寸。仍在`codex/dual-sr-20261028`工作区,未提交;不合并main、不push/Release,不改真实配置/SDK/模型/驱动,Lecram暂停。++实现:`runningSrOutput`在单次RTX视频超分(NVIDIA、双重关闭)时恢复返回`srOutput`,执行计划与`activeVideoSettings`同步,GPU复用`SrResolve`线性光面积缩回,后续NR/补帧/显示按缩回尺寸运行。超采样图与双重图同样走WDDM预算+SDK预留+20%余量准入,纹理估算加超分结果RGBA8。列表/节点`SrStageEditor`新增“超分后缩回到”(不缩回/片源尺寸/2K–7K),双重开启时禁用并保留;实际尺寸与未生效原因移到编辑器底部,卡片摘要显示“8K→4K”。开启双重不再清空缩回选择。字段无格式升级(v33/16/11起已保存);导出协议13→14。日志改为`supersample evaluate=… output=…`/`dual reduce=…`,三段式注释同步更新。++测试:EffectChain新增13项超采样检查,改写“双重关闭忽略再缩”旧断言;GPU新增`supersample`模式(SDR/HDR对同图8K结果的CPU面积平均、回到片源尺寸、非整数2K、双重忽略保留值);`sr-image`增加缩回参数,A/B工具改名`scripts/acceptance/sr-ab.py`并加超采样用例;导出模式改为`sr-supersample`/`sr-supersample-2k`并核对worker日志;界面夹具加超采样步骤与截图,最后跑超采样+NR+VFG。++命令:`py -3.11 -I -B E:/项目/Veyra/tmp/claude-sr-stage-20261028/build/build.py <10个目标>` 134.0秒、改提示后3目标2.0秒,均退出0(新警告仅EnhanceGraph.cpp既有C4189);`stage_app.py`;`py -3.11 -X utf8 -I -B E:/项目/Veyra/tmp/claude-sr-supersample-20261028/checks.py cpu|qml|gpu|export`;`py -3.11 -X utf8 -B -I scripts/acceptance/sr-stage-ui.py --task claude-sr-supersample-20261028`;`py -3.11 -X utf8 -B -I scripts/acceptance/sr-ab.py --mode native --image tests/claude-sr-stage-20261028/media/gta-4k-t780.png --tag gta-t780`(t95同)。++结果:EffectChain 453、PresetLibrary 552通过,RepairPreset退出0;GPU `supersample` SDR最大差1LSB、HDR最大差0.031超差0,`dual`/`dual-restore`/`dual-boundaries`/`dual-capabilities`(24/24)通过;导出3840×2160、2560×1440、2560×1440各4帧(ffprobe);QtQuick 117/0/1跳过,i18n 0失败、缺失0(2698条);界面21项断言、无QML错误,超采样8K→4K+NR+VFG约12秒显存4029MiB/预算11175MiB。产品图内A/B两帧所有组超采样都高于单次(原生1080p t780 44.21/0.9799对43.38/0.9759,原生2K t95 46.52/0.9812对45.74/0.9781),超分阶段多约1.2ms。++过程失败:首轮界面截图显示“目标尺寸”说明换行6行,缩短两条提示并补翻译后重编复测;`checks.py`首版按项目FFmpeg目录找ffprobe不存在,改用PATH中已安装的ffprobe(同先前runner)。均在最终结果前修正。++未做:未提交;无长时播放、实卡、其他显卡验收,超采样+NR+VFG仅约12秒短测;原8K最终输出+NR+VFG未重跑。双重超分保留、默认关闭,是否撤掉待用户决定。详细见docs/SR_SUPERSAMPLE_2026-10-28.md,回执reports/claude-sr-supersample-20261028/FINAL.json。++## 2026-10-28 合入本地main(Claude)++用户明确要求“直接合并到Main即可”,覆盖此前各段“不合并main”。在`codex/dual-sr-20261028`把复查修正与超采样选项提交为一个提交,再以合并提交并入本地`main`(原`7b0b64b`,是该分支祖先,无分叉),沿用以往“Merge … for local integration”的做法;仓库没有启用的git钩子。活动树随后切回`main`,内容与已测试的工作区一致,无需重编。++并入内容:claude/sr-stage-20261028(cf84762)、codex/sr-stage-freeze-20261028(67d0294)、codex/dual-sr-20261028(e61e497)及本次提交。独立`claude/capture-fps-audio-20261027`未并入;施工分支保留未删。未push、未Release,正式版仍2.1.1,运行目录与真实配置不变。提交与合并哈希、合并后检查见reports/claude-sr-supersample-20261028/FINAL.json。diff --git a/i18n/catalog.json b/i18n/catalog.jsonindex 896a3a38..e5546a92 100644--- a/i18n/catalog.json+++ b/i18n/catalog.json@@ -2744,6 +2744,13 @@"en": "Don't wait","ja": "待たない"},+ {+ "zh": "不缩回",+ "src": "qml/SrStageEditor.qml",+ "zh-TW": "不縮回",+ "en": "No shrink",+ "ja": "縮小しない"+ },{"zh": "不补偿","src": "qml/ProDisplayPanel.qml",@@ -3808,13 +3815,6 @@"en": "Choose a resolution first, then a frame rate and pixel format supported at that resolution.","ja": "先に解像度を選択し、その解像度で対応するフレームレートとピクセル形式を選択してください。"},- {- "zh": "先降到 / 再缩到目前仅 RTX 视频超分支持",- "src": "src/ui/bridge/Enhancement.cpp",- "zh-TW": "先降到 / 再縮到目前僅 RTX 影片超解析支援",- "en": "Shrink first / Fit after are available with RTX Video Super Resolution only for now",- "ja": "先に縮小 / 後で縮小は現在 RTX ビデオ超解像のみ対応しています"- },{"zh": "光流","src": "qml/NodePage.qml",@@ -5041,6 +5041,20 @@"en": "Double super resolution","ja": "2段階超解像"},+ {+ "zh": "双重超分开启时不使用;关闭双重超分后恢复。",+ "src": "qml/SrStageEditor.qml",+ "zh-TW": "雙重超解析開啟時不使用;關閉雙重超解析後恢復。",+ "en": "Not used while double SR is on; it returns when double SR is turned off.",+ "ja": "2段階超解像がオンの間は使用されません。オフにすると戻ります。"+ },+ {+ "zh": "双重超分目前仅 RTX 视频超分支持",+ "src": "src/ui/bridge/Enhancement.cpp",+ "zh-TW": "雙重超解析目前僅 RTX 影片超解析支援",+ "en": "Double SR is currently supported by RTX Video SR only",+ "ja": "2段階超解像は現在RTX Video SRのみ対応しています"+ },{"zh": "双重超分目前使用 RTX 视频超分","src": "qml/SrStageEditor.qml",@@ -5840,11 +5854,11 @@"ja": "基本設定"},{- "zh": "基础超分的输出尺寸;关闭双重超分时保持原有单次超分。",+ "zh": "基础超分的尺寸;设置缩回时为中间尺寸。","src": "qml/SrStageEditor.qml",- "zh-TW": "基礎超分的輸出尺寸;關閉雙重超分時保持原有單次超分。",- "en": "Base SR output size. With Double SR off, the original single-pass behavior is preserved.",- "ja": "基本超解像の出力サイズです。2段階超解像をオフにすると、従来の1回の処理を維持します。"+ "zh-TW": "基礎超解析的尺寸;設定縮回時為中間尺寸。",+ "en": "Base SR size; with a shrink set, this is the intermediate size.",+ "ja": "基本超解像のサイズです。縮小先を設定すると中間サイズになります。"},{"zh": "填充裁切",@@ -15619,6 +15633,34 @@"en": "SR 4K · NR 1 layer · FG 2X","ja": "超解像 4K · NR 1 層 · フレーム生成 2X"},+ {+ "zh": "超分后缩回到",+ "src": "qml/SrStageEditor.qml",+ "zh-TW": "超解析後縮回到",+ "en": "Shrink after SR to",+ "ja": "超解像後の縮小先"+ },+ {+ "zh": "超分后缩回未生效:超分须先放大画面,且缩回尺寸要小于超分结果。",+ "src": "src/ui/bridge/Status.cpp",+ "zh-TW": "超解析後縮回未生效:超解析須先放大畫面,且縮回尺寸要小於超解析結果。",+ "en": "Shrink after SR was not applied: SR must enlarge the picture, and the shrink size must be smaller than the SR result.",+ "ja": "超解像後の縮小は未適用です。超解像で拡大し、縮小先は超解像の結果より小さくする必要があります。"+ },+ {+ "zh": "超分后缩回目前仅 RTX 视频超分支持",+ "src": "src/ui/bridge/Enhancement.cpp",+ "zh-TW": "超解析後縮回目前僅 RTX 影片超解析支援",+ "en": "Shrink after SR is currently supported by RTX Video SR only",+ "ja": "超解像後の縮小は現在RTX Video SRのみ対応しています"+ },+ {+ "zh": "超分后缩回目前使用 RTX 视频超分",+ "src": "qml/SrStageEditor.qml",+ "zh-TW": "超解析後縮回目前使用 RTX 影片超解析",+ "en": "Shrink after SR currently uses RTX Video SR",+ "ja": "超解像後の縮小は現在RTX Video SRを使用します"+ },{"zh": "超分算法","src": "qml/NodePage.qml",@@ -15647,6 +15689,13 @@"en": "Brightness beyond the cap needs compression; use the sample reading to check hard clipping","ja": "上限を超える輝度は圧縮が必要です。実際のクリップはサンプル値で確認してください。"},+ {+ "zh": "超采样:先超到目标尺寸再精确缩回,更自然、略软;显存更高,降噪和补帧按缩回后尺寸运行。",+ "src": "qml/SrStageEditor.qml",+ "zh-TW": "超取樣:先超到目標尺寸再精確縮回,更自然、略軟;顯示記憶體更高,降噪和補幀按縮回後尺寸執行。",+ "en": "Supersampling: SR to the target, then an exact shrink. More natural, slightly softer; more video memory. NR and frame generation run at the shrunk size.",+ "ja": "スーパーサンプリング:目標サイズまで超解像して正確に縮小します。より自然で少し柔らかく、ビデオメモリ使用量が増えます。ノイズ除去とフレーム生成は縮小後のサイズで実行します。"+ },{"zh": "越小越敏感,越大稳得越多","src": "qml/ProPage.qml",diff --git a/include/veyra/engine/EnhancementSettings.h b/include/veyra/engine/EnhancementSettings.hindex 4f4d47f3..3c2e16c0 100644--- a/include/veyra/engine/EnhancementSettings.h+++ b/include/veyra/engine/EnhancementSettings.h@@ -343,7 +343,8 @@ struct EnhancementSettings {uint32_t dlssSrModel=0; // DLSS SR only; see kDlssSrModelCount// Base SR uses srTarget; the optional second SR has its own target/quality.// srPrescale now lowers the first AI result only when dualSrEnabled.- // srOutput is retained for reading the older experimental presets.+ // srOutput shrinks a single RTX Video SR result (supersampling); double SR+ // ignores it.pipeline::SrPrescale srPrescale=pipeline::SrPrescale::Off;pipeline::SrOutput srOutput=pipeline::SrOutput::Target;bool dualSrEnabled=false;@@ -431,10 +432,11 @@ struct EnhancementSettings {if(!sr){active.srTarget=defaults.srTarget;active.videoSrQuality=defaults.videoSrQuality;active.srMotion=defaults.srMotion;}if(!sr||videoSrQuality!=0)active.dlssSrModel=defaults.dlssSrModel;if(!sr||!srStageBackend(videoSrQuality)||!dualSrEnabled){- active.srPrescale=defaults.srPrescale;active.srOutput=defaults.srOutput;+ active.srPrescale=defaults.srPrescale;active.dualSrEnabled=false;active.dualSrTarget=defaults.dualSrTarget;active.dualSrQuality=defaults.dualSrQuality;}- active.srOutput=defaults.srOutput; // retired post-fit never changes the running graph+ // The supersample shrink belongs to a single RTX Video SR pass.+ if(!sr||!srStageBackend(videoSrQuality)||dualSrEnabled)active.srOutput=defaults.srOutput;if(multiplier<=1){active.frameGenerationBackend=defaults.frameGenerationBackend;active.vfgQuality=defaults.vfgQuality;active.fgMotion=defaults.fgMotion;active.fgStrictAdmission=defaults.fgStrictAdmission;diff --git a/include/veyra/engine/GraphDescription.h b/include/veyra/engine/GraphDescription.hindex ef637e78..39ac5045 100644--- a/include/veyra/engine/GraphDescription.h+++ b/include/veyra/engine/GraphDescription.h@@ -70,8 +70,11 @@ struct StageRequest {inline pipeline::SrPrescale runningSrPrescale(const EnhancementSettings& s,bool nvidiaAdapter){return nvidiaAdapter&&srStageBackend(s.videoSrQuality)&&s.dualSrEnabled?s.srPrescale:pipeline::SrPrescale::Off;}+// Supersampling (user 2026-10-28): one RTX Video SR pass evaluates at its target+// and the result is area-shrunk into srOutput before every later effect. Double+// SR has its own second target, so the shrink is inactive there.inline pipeline::SrOutput runningSrOutput(const EnhancementSettings& s,bool nvidiaAdapter){- (void)s;(void)nvidiaAdapter;return pipeline::SrOutput::Target;+ return nvidiaAdapter&&srStageBackend(s.videoSrQuality)&&!s.dualSrEnabled?s.srOutput:pipeline::SrOutput::Target;}// Fills the stage, size and parameter fields of `desc` from `settings`.@@ -190,7 +193,7 @@ inline pipeline::ResolutionPlan describeStages(const StageRequest& request,constChainExecutionPlan execution;const auto validation=compileChainExecutionPlan(chain,{{request.width,request.height},settings.srTarget,request.stillImage,request.exportJob,boundedAmd,desc.dualSr?srPrescale:pipeline::SrPrescale::Off,- pipeline::SrOutput::Target,desc.dualSr,settings.dualSrTarget},execution);+ desc.dualSr?pipeline::SrOutput::Target:srOutput,desc.dualSr,settings.dualSrTarget},execution);if(!validation.accepted){desc.fixedExecutionPlanError=validation.message;return plan;}if(request.nodeOrder){// Node order owns the first NR stage, even for an ordinary resize ordiff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.hindex 4da5b6be..3aa0757d 100644--- a/include/veyra/pipeline/EnhanceGraph.h+++ b/include/veyra/pipeline/EnhanceGraph.h@@ -841,7 +841,7 @@ private:size_t rgbPitch_=0;ComPtr<ID3D12Resource> workRgba_;ComPtr<ID3D12Resource> videoSrInput_,videoSrOutput_;- ComPtr<ID3D12Resource> srPrescaled_; // linear SR input after the three-step prescale+ ComPtr<ID3D12Resource> srPrescaled_; // linear second-SR input: the double SR reduction of the first resultComPtr<ID3D12Resource> firstSrInput_,firstSrOutput_,firstSrLinear_;ComPtr<ID3D12Resource> videoHdrInput_,videoHdrOutput_;ComPtr<ID3D12Resource> residualRgba_,nrFlow_,baseFlow_;@@ -902,7 +902,7 @@ private:ComputePass amdHdrEncodePass_, amdHdrRestorePass_;float toneMapPeakNits_=0; // latched per graph/source; never varies with frame brightnessComputePass rgbPass_,hdrVideoSrPass_;- ComputePass srPrescalePass_,srResolvePass_; // three-step SR area shrink before / after RTX Video SR+ ComputePass srPrescalePass_,srResolvePass_; // area shrinks: double SR reduction / supersample shrink after RTX Video SRComputePass firstSrRestorePass_;ComputePass downsamplePass_,residualPass_,stackProtectionPass_,flowAdaptPass_;ComputePass flowRefinePass_,flowFillPass_,fgFlowAdaptPass_,flowClaimPass_;diff --git a/qml/Veyra/ProPage.qml b/qml/Veyra/ProPage.qmlindex d5fbca58..eef7a9c3 100644--- a/qml/Veyra/ProPage.qml+++ b/qml/Veyra/ProPage.qml@@ -1318,12 +1318,16 @@ VPage {title: qsTr("超分辨率")switchAvailable: Support.available(veyra, "sr")summary: !switchAvailable ? Support.reason(veyra, "sr") : (veyra.srEnabled ? (veyra.srBackendChoices?.find(o => o.id === String(veyra.videoSrQuality === 0 || veyra.videoSrQuality === 5 ? veyra.videoSrQuality : 4))?.label || qsTr("RTX 视频超分")) : qsTr("已关闭"))- + " · " + (srStageShown && veyra.srPrescale > 0 ? (veyra.srPrescale >= 150 ? (veyra.srPrescale - 100) + "%" : ["", "720p", "900p", "1080p", "1440p"][veyra.srPrescale]) + "→" : "")- + veyra.srTargetLabel- + (srStageShown && veyra.srOutput > 0 ? "→" + (veyra.srOutput === 1 ? qsTr("片源尺寸") : ["", "", "2K", "4K", "5K", "6K", "7K"][veyra.srOutput]) : "")- + (veyra.videoSrQuality > 0 ? qsTr(" · 质量 ") + veyra.videoSrQuality : "")- // Three-step SR shows in the summary only where it runs (RTX Video SR).- readonly property bool srStageShown: veyra.videoSrQuality >= 1 && veyra.videoSrQuality <= 4+ + " · " + veyra.srTargetLabel+ + (supersampleShown ? "→" + (veyra.srOutput === 1 ? qsTr("片源尺寸") : ["", "", "2K", "4K", "5K", "6K", "7K"][veyra.srOutput]) : "")+ + (dualShown ? "→" + (veyra.srPrescale >= 150 ? (veyra.srPrescale - 100) + "%" : ["", "720p", "900p", "1080p", "1440p"][veyra.srPrescale]) + "→" + ["", "2K", "4K", "8K", "5K", "6K", "7K"][veyra.dualSrTargetIndex] : "")+ + (veyra.videoSrQuality > 0 ? qsTr(" · 质量 ") + veyra.videoSrQuality + (dualShown ? "/" + veyra.dualSrQuality : "") : "")+ // Base target, then the supersample shrink, or the double SR reduction+ // and second target while double SR is on (RTX Video SR). Each kept+ // value is hidden while its mode is off.+ readonly property bool rtxVideoSr: veyra.videoSrQuality >= 1 && veyra.videoSrQuality <= 4+ readonly property bool supersampleShown: !veyra.dualSrEnabled && veyra.srOutput > 0 && rtxVideoSr+ readonly property bool dualShown: veyra.dualSrEnabled && veyra.srPrescale > 0 && rtxVideoSron: veyra.srEnabledopen: trueonToggled: on => veyra.srEnabled = ondiff --git a/qml/Veyra/SrStageEditor.qml b/qml/Veyra/SrStageEditor.qmlindex 652c30bc..a86d04fc 100644--- a/qml/Veyra/SrStageEditor.qml+++ b/qml/Veyra/SrStageEditor.qml@@ -11,7 +11,7 @@ ColumnLayout {readonly property var targets: [{id:"1",label:"2K"},{id:"2",label:"4K"},{id:"4",label:"5K"},{id:"5",label:"6K"},{id:"6",label:"7K"},{id:"3",label:"8K"}]VRow {label: qsTr("目标尺寸")- hint: qsTr("基础超分的输出尺寸;关闭双重超分时保持原有单次超分。")+ hint: qsTr("基础超分的尺寸;设置缩回时为中间尺寸。")VSeg { objectName: editor.namePrefix+"-sr-target"; options: editor.targets; current: String(veyra.srTargetIndex); onPicked: id => veyra.srTargetIndex=Number(id) }}VRow {@@ -24,6 +24,21 @@ ColumnLayout {enabled: editor.supported; opacity: enabled ? 1 : 0.4VSeg { objectName:editor.namePrefix+"-sr-quality"; options:[{id:"1",label:"1"},{id:"2",label:"2"},{id:"3",label:"3"},{id:"4",label:"4"}]; current:String(veyra.videoSrQuality); onPicked:id=>veyra.videoSrQuality=Number(id) }}+ // Supersampling: a single RTX Video SR pass at the target, shrunk into this size.+ VRow {+ label: qsTr("超分后缩回到")+ hint: !editor.supported ? qsTr("超分后缩回目前使用 RTX 视频超分")+ : veyra.dualSrEnabled ? qsTr("双重超分开启时不使用;关闭双重超分后恢复。")+ : qsTr("超采样:先超到目标尺寸再精确缩回,更自然、略软;显存更高,降噪和补帧按缩回后尺寸运行。")+ enabled: editor.supported && !veyra.dualSrEnabled+ opacity: enabled ? 1 : 0.4+ VSelect {+ objectName: editor.namePrefix+"-sr-output"+ options: [{id:"0",label:qsTr("不缩回")},{id:"1",label:qsTr("片源尺寸")},{id:"2",label:"2K"},{id:"3",label:"4K"},{id:"4",label:"5K"},{id:"5",label:"6K"},{id:"6",label:"7K"}]+ value: options.find(o=>o.id===String(veyra.srOutput))?.label||qsTr("不缩回")+ onPicked: id => veyra.srOutput=Number(id)+ }+ }VRow {label: qsTr("双重超分")hint: editor.supported ? qsTr("先完成基础超分,再将结果降低分辨率并执行第二次超分;两次执行独立,会增加耗时和显存。") : qsTr("双重超分目前使用 RTX 视频超分")@@ -67,7 +82,8 @@ ColumnLayout {hint: qsTr("RTX 视频超分,独立于基础超分质量")VSeg { objectName: editor.namePrefix+"-dual-sr-quality"; options:[{id:"1",label:"1"},{id:"2",label:"2"},{id:"3",label:"3"},{id:"4",label:"4"}]; current:String(veyra.dualSrQuality); onPicked:id=>veyra.dualSrQuality=Number(id) }}- Text { text: veyra.srStageSummary; color: Theme.t2; font.family: Theme.fontUi; font.pixelSize:11; wrapMode:Text.WordWrap; Layout.fillWidth:true }- Text { text: veyra.srStageNote; visible:text.length>0; color:Theme.t2; font.pixelSize:11; wrapMode:Text.WordWrap; Layout.fillWidth:true }}+ // Running sizes of double SR or supersampling, and why a choice did not apply.+ Text { text: veyra.srStageSummary; visible:text.length>0; color: Theme.t2; font.family: Theme.fontUi; font.pixelSize:11; wrapMode:Text.WordWrap; Layout.fillWidth:true }+ Text { text: veyra.srStageNote; visible:text.length>0; color:Theme.t2; font.pixelSize:11; wrapMode:Text.WordWrap; Layout.fillWidth:true }}diff --git a/scripts/acceptance/dual-sr-ui.qml b/scripts/acceptance/dual-sr-ui.qmlindex 9287fd35..85a5d513 100644--- a/scripts/acceptance/dual-sr-ui.qml+++ b/scripts/acceptance/dual-sr-ui.qml@@ -2,6 +2,7 @@ import QtQuickItem {id: testproperty string media: ""+ property string shot: "" // screenshot path from the runner; empty skips itproperty bool saved: falsefunction find(name) {let hit=null@@ -17,7 +18,7 @@ Item {function check(ok,label){if(!ok)throw new Error(label);veyra.logUi("sr-stage-test","PASS "+label)}function settled(){return ticks>=7&&veyra.running&&!veyra.applying}onTriggered:{try{- ++ticks;if(++total>200)throw new Error("bounded dual test step="+step)+ ++ticks;if(++total>260)throw new Error("bounded SR stage test step="+step)if(step===0){if(ticks<4)returnveyra.muted=true;veyra.nrEnabled=false;veyra.fgEnabled=false@@ -26,8 +27,27 @@ Item {}if(step===1){if(!settled())return- check(veyra.srTargetIndex===3&&veyra.outputSummary==="7680x4320","ordinary 8K remains an actual 8K output")+ check(veyra.srTargetIndex===3&&veyra.outputSummary==="7680x4320"&&veyra.srStageSummary==="","ordinary 8K remains an actual 8K output")check(!find("list-dual-sr-panel").visible,"second-pass settings start collapsed")+ find("list-sr-output").picked("3");next(11);return+ }+ if(step===11){+ if(!settled())return+ check(veyra.srOutput===3&&veyra.outputSummary==="3840x2160"&&veyra.srStageSummary==="1920x1080 → 7680x4320 → 3840x2160",+ "supersample evaluates 8K and outputs the 4K shrink: "+veyra.srStageSummary)+ check(find("list-sr").summary.indexOf("8K→4K")>=0,"the card summary shows the supersample shrink: "+find("list-sr").summary)+ test.saved=false+ if(test.shot.length>0)test.parent.parent.grabToImage(r=>{r.saveToFile(test.shot.replace(/\.png$/,"-supersample.png"));test.saved=true})+ else test.saved=true+ next(115);return+ }+ if(step===115){+ if(!test.saved||ticks<3)return+ find("list-sr-output").picked("0");next(12);return+ }+ if(step===12){+ if(!settled())return+ check(veyra.outputSummary==="7680x4320"&&veyra.srStageSummary===""&&find("list-sr").summary.indexOf("→")<0,"no shrink returns to the ordinary 8K output")veyra.srTargetIndex=2;next(2);return}if(step===2){@@ -38,13 +58,17 @@ Item {if(!settled())returncheck(veyra.dualSrEnabled&&find("list-dual-sr-panel").visible,"Double SR control expands the second-pass settings")check(veyra.srTargetIndex===2&&veyra.srStageSummary==="1920x1080 → 3840x2160 → 1920x1080 → 3840x2160","first SR then reduce then second SR in the running plan")+ check(find("list-sr").summary.indexOf("4K→1080p→4K")>=0,"the card summary shows base 4K, then 1080p, then the second 4K: "+find("list-sr").summary)+ check(!find("list-sr-output").enabled,"the supersample shrink is unavailable while double SR is on")find("list-dual-sr-quality").picked("2");find("list-dual-sr-target").picked("1");next(4);return}if(step===4){if(!settled())returncheck(veyra.srTargetIndex===2&&veyra.videoSrQuality===1&&veyra.dualSrTargetIndex===1&&veyra.dualSrQuality===2,"second controls do not change base target or quality")check(veyra.outputSummary==="2560x1440","second target owns the final output")- test.parent.parent.grabToImage(r=>{r.saveToFile("E:/项目/Veyra/tests/codex-dual-sr-20261028/dual-controls.png");test.saved=true})+ check(find("list-sr").summary.indexOf("4K→1080p→2K")>=0&&find("list-sr").summary.indexOf("质量 1/2")>=0,"the card summary follows the second target and quality: "+find("list-sr").summary)+ if(test.shot.length>0)test.parent.parent.grabToImage(r=>{r.saveToFile(test.shot);test.saved=true})+ else test.saved=truenext(45);return}if(step===45){@@ -54,12 +78,15 @@ Item {if(step===5){if(!settled())returncheck(!find("list-dual-sr-panel").visible&&veyra.outputSummary==="3840x2160"&&veyra.srStageSummary==="","disable collapses controls and restores base-only output")+ // The reduction stays saved for turning double SR back on, but must not show.+ check(veyra.srPrescale===3&&find("list-sr").summary.indexOf("1080p")<0&&find("list-sr").summary.indexOf("/")<0,+ "the card summary drops the kept reduction while double SR is off: "+find("list-sr").summary)veyra.nodeMode=1;check(veyra.addEffect("sr")>=0,"add base SR to an empty node graph");veyra.navigate("node")veyra.videoSrQuality=1;veyra.srTargetIndex=2;next(6);return}if(step===6){if(!settled())return- check(find("node-dual-sr-toggle")&&!find("node-dual-sr-panel").visible,"node editor has the same collapsed control")+ check(find("node-dual-sr-toggle")&&find("node-sr-output")&&!find("node-dual-sr-panel").visible,"node editor has the same supersample and collapsed double SR controls")find("node-dual-sr-toggle").toggled(true);veyra.srPrescale=3;find("node-dual-sr-target").picked("3");next(7);return}if(step===7){@@ -75,6 +102,13 @@ Item {if(ticks<24||!settled())returncheck(veyra.srActive&&veyra.nrActive&&veyra.fgActive&&veyra.fgBackendName==="vfg","bounded 4K two-pass SR with NR and VFG actually runs")check(veyra.outputSummary==="3840x2160"&&veyra.srStageSummary==="1920x1080 → 3840x2160 → 1920x1080 → 3840x2160","combined graph retains both SR operations and the requested 4K output")+ // Shrink first, then double SR off, then the 8K target: no step ever has an 8K final output with NR/VFG.+ veyra.srOutput=3;veyra.dualSrEnabled=false;veyra.srTargetIndex=3;next(9);return+ }+ if(step===9){+ if(ticks<24||!settled())return+ check(veyra.srActive&&veyra.nrActive&&veyra.fgActive&&veyra.outputSummary==="3840x2160"&&veyra.srStageSummary==="1920x1080 → 7680x4320 → 3840x2160",+ "supersample 8K -> 4K with NR and VFG runs everything after SR at 4K")veyra.logUi("sr-stage-test","SR_STAGE_UI_PASS");console.log("SR_STAGE_UI_PASS");Qt.quit()}}catch(e){veyra.logUi("sr-stage-test","SR_STAGE_UI_FAIL "+e.message);console.log("SR_STAGE_UI_FAIL "+e.message);Qt.quit()}}diff --git a/scripts/acceptance/sr-ab.py b/scripts/acceptance/sr-ab.pynew file mode 100644index 00000000..153861b7--- /dev/null+++ b/scripts/acceptance/sr-ab.py@@ -0,0 +1,133 @@+"""RTX Video SR picture A/B: one SR pass, supersampling (SR to 8K, then an exact area+shrink to 4K) and double SR (base SR -> reduce -> second SR).++Every picture goes through the real graph (veyra_sr_quality_tests sr-image in the+shared staged copy, video-file semantics: a 4K source at a 4K target gets the+existing native-size restore). Lossless PNG in and out; RTX Video SR quality 4 for+every pass.++ --mode blurry --image X no reference: X is scaled to 3840x2160 (bicubic) as a soft+ 4K; sharpness proxy only.+ --mode native --image X X is a native 3840x2160 reference. Three sources are made+ from it (soft 4K: area 1920x1080, JPEG q70, bicubic back to+ 4K; native 2K: Lanczos 2560x1440; native 1080p: Lanczos+ 1920x1080) and every 4K result is compared with the reference+ (PSNR / SSIM on luma, gradient sharpness proxy).+Crops (100 %) of the busiest regions go side by side into one PNG per group.+usage: py -3.11 -X utf8 -B -I scripts/acceptance/sr-ab.py --mode blurry|native --image PATH [--tag NAME] [--task NAME]+"""+from pathlib import Path+import argparse, io, json, os, subprocess+import numpy as np+from PIL import Image, ImageDraw++ap = argparse.ArgumentParser(); ap.add_argument('--mode', choices=['blurry', 'native'], required=True)+ap.add_argument('--image', required=True); ap.add_argument('--tag', default=''); ap.add_argument('--task', default='claude-sr-supersample-20261028')+args = ap.parse_args()+assert args.task.startswith(('codex-', 'claude-')) and '/' not in args.task and '\\' not in args.task and '..' not in args.task+B = Path('E:/项目/Veyra'); T = args.task; tag = args.tag or args.mode+A = B/'tests/claude-sr-stage-20261028/app'; TMP = B/'tmp'/T/'ab'+OUT = B/'reports'/T/'ab'/tag; WORK = B/'tests'/T/'ab'/tag+for p in (OUT, WORK, TMP): p.mkdir(parents=True, exist_ok=True)+env = {k: v for k, v in os.environ.items() if not k.upper().startswith(('VEYRA_', 'QT_', 'QSG_', 'QML_'))}+env.update(TEMP=str(TMP), TMP=str(TMP))+# (name, base quality 0..4, base target, supersample shrink or 'off', reduction or 'off', second target)+SINGLE = ('single-4k', 4, '4k', 'off', 'off', '4k')+SUPERSAMPLE = ('ss-8k-4k', 4, '8k', '4k', 'off', '4k')+DUAL_1080 = ('dual-4k-1080-4k', 4, '4k', 'off', '1080', '4k')+DUAL_1440 = ('dual-4k-1440-4k', 4, '4k', 'off', '1440', '4k')+++def render(src, name, quality, target, shrink, reduce, second):+ """One picture through the graph; returns (array, GPU ms of the SR stage, sizes)."""+ run = subprocess.run([str(A/'veyra_sr_quality_tests.exe'), str(WORK/'gpu'), 'sr-image', str(src), name, str(quality), target, shrink, reduce, second, '4', 'video'],+ cwd=A, env=env, capture_output=True, text=True, encoding='utf-8', errors='replace', timeout=120)+ line = next((l for l in run.stdout.splitlines() if l.startswith('SR_IMAGE')), '')+ assert run.returncode == 0 and 'passed=1' in line, (name, run.returncode, line, run.stdout[-500:])+ fields = dict(kv.split('=', 1) for kv in line.split()[1:])+ if reduce != 'off': assert fields['first'] != '0x0' and int(fields['evaluations']) == 12, ('double SR did not run twice', name, line)+ if shrink != 'off': assert fields['srOutput'] != fields['output'] and int(fields['evaluations']) == 6, ('supersample did not shrink one pass', name, line)+ return np.asarray(Image.open(WORK/'gpu'/(name + '.png')).convert('RGB')), float(fields['srMs']), fields+++def luma(a):+ a = a.astype(np.float64) / 255.0+ return 0.2126 * a[..., 0] + 0.7152 * a[..., 1] + 0.0722 * a[..., 2]+++def psnr(a, b):+ mse = np.mean((luma(a) - luma(b)) ** 2)+ return float('inf') if mse == 0 else 10 * np.log10(1.0 / mse)+++def box(x, r=4):+ # Mean over (2r+1)^2 windows via an integral image (SSIM's local statistics).+ c = np.pad(x, r + 1, mode='edge').cumsum(0).cumsum(1); n = 2 * r + 1+ return (c[n:, n:] - c[:-n, n:] - c[n:, :-n] + c[:-n, :-n])[:x.shape[0], :x.shape[1]] / (n * n)+++def ssim(a, b):+ x, y = luma(a), luma(b); c1, c2 = 0.01 ** 2, 0.03 ** 2+ mx, my = box(x), box(y); vx, vy, cxy = box(x * x) - mx * mx, box(y * y) - my * my, box(x * y) - mx * my+ return float(np.mean(((2 * mx * my + c1) * (2 * cxy + c2)) / ((mx * mx + my * my + c1) * (vx + vy + c2))))+++def sharpness(a):+ # Mean luma gradient magnitude (no-reference detail proxy; noise and halos raise it too).+ y = luma(a); return float(np.mean(np.hypot(np.diff(y, axis=1)[:-1], np.diff(y, axis=0)[:, :-1])))+++def crops(images, labels, prefix, reference=None, size=480, count=3):+ """The `count` busiest non-overlapping windows of the first image, all images side by side."""+ base = luma(images[0]); g = np.hypot(*np.gradient(base)); h, w = base.shape; picks = []+ energy = box(g, size // 2)+ for _ in range(count):+ y, x = np.unravel_index(np.argmax(energy), energy.shape)+ y0, x0 = int(np.clip(y - size // 2, 0, h - size)), int(np.clip(x - size // 2, 0, w - size))+ picks.append((x0, y0)); energy[max(0, y0 - size):y0 + 2 * size, max(0, x0 - size):x0 + 2 * size] = -1+ out = []+ for i, (x0, y0) in enumerate(picks):+ tiles = ([(reference, 'reference')] if reference is not None else []) + list(zip(images, labels))+ sheet = Image.new('RGB', (size * len(tiles), size + 24), (24, 24, 24)); draw = ImageDraw.Draw(sheet)+ for k, (img, label) in enumerate(tiles):+ sheet.paste(Image.fromarray(img[y0:y0 + size, x0:x0 + size]), (k * size, 24)); draw.text((k * size + 6, 5), label, fill=(240, 240, 240))+ path = OUT/f'{prefix}-{i + 1}-x{x0}-y{y0}.png'; sheet.save(path); out.append(str(path))+ return out+++def group(name, src, cases, reference=None, upscale=False):+ images, labels = [], []+ if upscale:+ up = np.asarray(Image.open(src).resize((3840, 2160), Image.BICUBIC))+ entry = dict(sharpness=sharpness(up))+ if reference is not None: entry.update(psnr=psnr(up, reference), ssim=ssim(up, reference))+ report['cases'][name + '/bicubic'] = entry; images.append(up); labels.append('bicubic')+ for case, quality, target, shrink, reduce, second in cases:+ img, ms, fields = render(src, f'{name}-{case}', quality, target, shrink, reduce, second)+ assert img.shape == (2160, 3840, 3), (case, img.shape)+ entry = dict(srMs=ms, first=fields['first'], srInput=fields['srInput'], srOutput=fields['srOutput'], output=fields['output'],+ evaluations=int(fields['evaluations']), sharpness=sharpness(img))+ if reference is not None: entry.update(psnr=psnr(img, reference), ssim=ssim(img, reference))+ report['cases'][name + '/' + case] = entry; images.append(img); labels.append(f'{case} {ms:.1f} ms' if ms > 0 else case)+ report['crops'][name] = crops(images, labels, name, reference)+++source = Image.open(args.image).convert('RGB')+report = dict(mode=args.mode, image=str(args.image), imageSize=list(source.size), quality=4, cases={}, crops={})+if args.mode == 'blurry':+ soft = source.resize((3840, 2160), Image.BICUBIC) if source.size != (3840, 2160) else source+ soft.save(WORK/'soft-4k.png')+ group('soft-4k', WORK/'soft-4k.png', [('input', 0, '4k', 'off', 'off', '4k'), SINGLE, SUPERSAMPLE, DUAL_1080])+else:+ assert source.size == (3840, 2160), 'native mode needs a 3840x2160 reference'+ ref = np.asarray(source)+ buf = io.BytesIO(); source.resize((1920, 1080), Image.BOX).save(buf, 'JPEG', quality=70)+ Image.open(io.BytesIO(buf.getvalue())).convert('RGB').resize((3840, 2160), Image.BICUBIC).save(WORK/'soft-4k.png')+ source.resize((2560, 1440), Image.LANCZOS).save(WORK/'native-2k.png')+ source.resize((1920, 1080), Image.LANCZOS).save(WORK/'native-1080p.png')+ group('soft-4k', WORK/'soft-4k.png', [('input', 0, '4k', 'off', 'off', '4k'), SINGLE, SUPERSAMPLE, DUAL_1080], ref)+ group('native-2k', WORK/'native-2k.png', [SINGLE, SUPERSAMPLE, DUAL_1080, DUAL_1440], ref, upscale=True)+ group('native-1080p', WORK/'native-1080p.png', [SINGLE, SUPERSAMPLE, DUAL_1080, DUAL_1440], ref, upscale=True)+ report['referenceSharpness'] = sharpness(ref)+(OUT/'ab.json').write_text(json.dumps(report, ensure_ascii=False, indent=1), 'utf8')+print(json.dumps(report, ensure_ascii=False, indent=1))diff --git a/scripts/acceptance/sr-stage-ab.py b/scripts/acceptance/sr-stage-ab.pydeleted file mode 100644index 0e7bb2e7..00000000--- a/scripts/acceptance/sr-stage-ab.py+++ /dev/null@@ -1,131 +0,0 @@-"""Three-step SR picture A/B with RTX Video SR (claude-sr-stage-20261028).--Every picture goes through the real graph (veyra_sr_quality_tests stage-image in the-task's staged copy, video-file semantics: a 4K source at a 4K target gets the existing-native-size restore). Lossless PNG in and out.-- --mode blurry --image X no reference: X is scaled to 3840x2160 (bicubic) as a soft- 4K, then single step vs three-step. Sharpness proxy only.- --mode native --image X X is a native 3840x2160 reference. Two degraded sources are- made from it (soft 4K: area 1920x1080, JPEG q70, bicubic back- to 4K; native 2K: Lanczos 2560x1440) and every result is- compared with the reference (PSNR / SSIM on luma).-Crops (100 %) of the busiest regions go side by side into one PNG per region.-usage: py -3.11 -X utf8 -B -I scripts/acceptance/sr-stage-ab.py --mode blurry|native --image PATH [--tag NAME]-"""-from pathlib import Path-import argparse, io, json, os, re, subprocess-import numpy as np-from PIL import Image, ImageDraw--B = Path('E:/项目/Veyra'); T = 'claude-sr-stage-20261028'-A = B/'tests'/T/'app'; TMP = B/'tmp'/T/'ab'-ap = argparse.ArgumentParser(); ap.add_argument('--mode', choices=['blurry', 'native'], required=True)-ap.add_argument('--image', required=True); ap.add_argument('--tag', default='')-args = ap.parse_args()-tag = args.tag or args.mode-OUT = B/'reports'/T/'ab'/tag; WORK = B/'tests'/T/'ab'/tag-for p in (OUT, WORK, TMP): p.mkdir(parents=True, exist_ok=True)-env = {k: v for k, v in os.environ.items() if not k.upper().startswith(('VEYRA_', 'QT_', 'QSG_', 'QML_'))}-env.update(TEMP=str(TMP), TMP=str(TMP))---def render(src, name, quality, prescale='off', target='4k', output='target'):- """One picture through the graph; returns (array, gpu ms of the SR stage, sizes)."""- run = subprocess.run([str(A/'veyra_sr_quality_tests.exe'), str(WORK/'gpu'), 'stage-image', str(src), name, str(quality), prescale, target, output, 'video'],- cwd=A, env=env, capture_output=True, text=True, timeout=120)- line = next((l for l in run.stdout.splitlines() if l.startswith('STAGE_IMAGE')), '')- assert run.returncode == 0 and 'passed=1' in line, (name, run.returncode, line, run.stdout[-500:])- fields = dict(kv.split('=', 1) for kv in line.split()[1:])- return np.asarray(Image.open(WORK/'gpu'/(name + '.png')).convert('RGB')), float(fields['srMs']), fields---def luma(a):- a = a.astype(np.float64) / 255.0- return 0.2126 * a[..., 0] + 0.7152 * a[..., 1] + 0.0722 * a[..., 2]---def psnr(a, b):- mse = np.mean((luma(a) - luma(b)) ** 2)- return float('inf') if mse == 0 else 10 * np.log10(1.0 / mse)---def box(x, r=4):- # Mean over (2r+1)^2 windows via an integral image (SSIM's local statistics).- c = np.pad(x, r + 1, mode='edge').cumsum(0).cumsum(1); n = 2 * r + 1- return (c[n:, n:] - c[:-n, n:] - c[n:, :-n] + c[:-n, :-n])[:x.shape[0], :x.shape[1]] / (n * n)---def ssim(a, b):- x, y = luma(a), luma(b); c1, c2 = 0.01 ** 2, 0.03 ** 2- mx, my = box(x), box(y); vx, vy, cxy = box(x * x) - mx * mx, box(y * y) - my * my, box(x * y) - mx * my- return float(np.mean(((2 * mx * my + c1) * (2 * cxy + c2)) / ((mx * mx + my * my + c1) * (vx + vy + c2))))---def sharpness(a):- # Mean luma gradient magnitude (no-reference detail proxy; noise and halos raise it too).- y = luma(a); return float(np.mean(np.hypot(np.diff(y, axis=1)[:-1], np.diff(y, axis=0)[:, :-1])))---def crops(images, labels, reference=None, size=480, count=3, prefix='crop'):- """The `count` busiest non-overlapping windows of the first image, all images side by side."""- base = luma(images[0]); g = np.hypot(*np.gradient(base)); h, w = base.shape; picks = []- energy = box(g, size // 2)- for _ in range(count):- y, x = np.unravel_index(np.argmax(energy), energy.shape)- y0, x0 = int(np.clip(y - size // 2, 0, h - size)), int(np.clip(x - size // 2, 0, w - size))- picks.append((x0, y0)); energy[max(0, y0 - size):y0 + 2 * size, max(0, x0 - size):x0 + 2 * size] = -1- out = []- for i, (x0, y0) in enumerate(picks):- tiles = [(reference, 'reference')] if reference is not None else []- tiles += list(zip(images, labels))- sheet = Image.new('RGB', (size * len(tiles), size + 24), (24, 24, 24)); draw = ImageDraw.Draw(sheet)- for k, (img, label) in enumerate(tiles):- sheet.paste(Image.fromarray(img[y0:y0 + size, x0:x0 + size]), (k * size, 24)); draw.text((k * size + 6, 5), label, fill=(240, 240, 240))- path = OUT/f'{prefix}-{i + 1}-x{x0}-y{y0}.png'; sheet.save(path); out.append(str(path))- return out---source = Image.open(args.image).convert('RGB')-report = dict(mode=args.mode, image=str(args.image), imageSize=list(source.size), cases={})-if args.mode == 'blurry':- soft = source.resize((3840, 2160), Image.BICUBIC) if source.size != (3840, 2160) else source- soft_path = WORK/'soft-4k.png'; soft.save(soft_path)- cases = [('input', 0, 'off', '4k', 'target'), ('vsr4-native', 4, 'off', '4k', 'target'),- ('vsr4-1440-4k', 4, '1440', '4k', 'target'), ('vsr4-1080-4k', 4, '1080', '4k', 'target'),- ('vsr4-1080-8k-4k', 4, '1080', '8k', '4k'), ('vsr2-1080-4k', 2, '1080', '4k', 'target')]- images, labels = [], []- for name, q, pre, tgt, outp in cases:- img, ms, fields = render(soft_path, name, q, pre, tgt, outp)- report['cases'][name] = dict(srMs=ms, srInput=fields['srInput'], srOutput=fields['srOutput'], output=fields['output'], sharpness=sharpness(img))- images.append(img); labels.append(f'{name} {ms:.1f} ms' if ms > 0 else name)- report['crops'] = crops(images, labels)-else:- assert source.size == (3840, 2160), 'native mode needs a 3840x2160 reference'- ref = np.asarray(source)- buf = io.BytesIO(); source.resize((1920, 1080), Image.BOX).save(buf, 'JPEG', quality=70)- soft = Image.open(io.BytesIO(buf.getvalue())).convert('RGB').resize((3840, 2160), Image.BICUBIC)- soft_path = WORK/'soft-4k.png'; soft.save(soft_path)- qhd_path = WORK/'native-2k.png'; source.resize((2560, 1440), Image.LANCZOS).save(qhd_path)- groups = {'soft-4k': (soft_path, [('input', 0, 'off', '4k', 'target'), ('vsr4-native', 4, 'off', '4k', 'target'),- ('vsr4-1440-4k', 4, '1440', '4k', 'target'), ('vsr4-1080-4k', 4, '1080', '4k', 'target'),- ('vsr4-1080-8k-4k', 4, '1080', '8k', '4k')]),- 'native-2k': (qhd_path, [('vsr4-2k-4k', 4, 'off', '4k', 'target'), ('vsr4-2k-8k-4k', 4, 'off', '8k', '4k'),- ('vsr4-1080-4k', 4, '1080', '4k', 'target')])}- report['crops'] = {}- for group, (src, cases) in groups.items():- images, labels = [], []- if group == 'native-2k':- up = np.asarray(Image.open(src).resize((3840, 2160), Image.BICUBIC))- report['cases'][group + '/bicubic'] = dict(psnr=psnr(up, ref), ssim=ssim(up, ref), sharpness=sharpness(up))- images.append(up); labels.append('bicubic')- for name, q, pre, tgt, outp in cases:- img, ms, fields = render(src, f'{group}-{name}', q, pre, tgt, outp)- assert img.shape == ref.shape, (name, img.shape)- report['cases'][group + '/' + name] = dict(srMs=ms, srInput=fields['srInput'], srOutput=fields['srOutput'], output=fields['output'],- psnr=psnr(img, ref), ssim=ssim(img, ref), sharpness=sharpness(img))- images.append(img); labels.append(f'{name} {ms:.1f} ms' if ms > 0 else name)- report['crops'][group] = crops(images, labels, reference=ref, prefix=group)- report['referenceSharpness'] = sharpness(ref)-(OUT/'ab.json').write_text(json.dumps(report, ensure_ascii=False, indent=1), 'utf8')-print(json.dumps(report, ensure_ascii=False, indent=1))diff --git a/scripts/acceptance/sr-stage-safety-ui.py b/scripts/acceptance/sr-stage-safety-ui.pydeleted file mode 100644index 93e8a04f..00000000--- a/scripts/acceptance/sr-stage-safety-ui.py+++ /dev/null@@ -1,28 +0,0 @@-"""One bounded file-only regression using a copy of the reported settings."""-import hashlib,json,os,shutil,subprocess-from pathlib import Path-B=Path('E:/项目/Veyra');R=Path(__file__).resolve().parents[2];T='sr-stage-freeze-20261028'-A=B/'tests/claude-sr-stage-20261028/app';P=B/'tests'/T/'profile';L=B/'logs'/T;TMP=B/'tmp'/T;OUT=B/'reports'/T-for p in (P,L,TMP,OUT):p.mkdir(parents=True,exist_ok=True)-user=A/'runtime_local/user-data-2.0.0'-before={p.name:hashlib.sha256(p.read_bytes()).hexdigest() for p in user.glob('chain-session*')}-for name in before:shutil.copyfile(user/name,P/name)-(P/'qml-preferences.v1.json').write_text(json.dumps({'language':'zh-CN','autoResume':False,'prewarmEnhancement':False}),encoding='utf-8')-media=B/'tests/nr-manual-scale-20261024/media/nr-4k30.mp4'-src=(R/'qml/Veyra/Main.qml').read_bytes();text=src.decode('utf-8');idx=text.rfind('}')-loader='\nLoader {source: '+json.dumps((R/'scripts/acceptance/sr-stage-safety-ui.qml').as_uri())+'; onLoaded: item.media='+json.dumps(media.as_posix())+'}\n'-def replace(path,data):- staged=path.with_name(path.name+'.safety-new');staged.write_bytes(data);os.replace(staged,path)-replace(A/'qml/Veyra/Main.qml',(text[:idx]+loader+text[idx:]).encode('utf-8'))-env={k:v for k,v in os.environ.items() if not k.upper().startswith(('VEYRA_','QT_','QSG_','QML_'))}-env.update(TEMP=str(TMP),TMP=str(TMP),APPDATA=str(P/'AppData'),LOCALAPPDATA=str(P/'LocalAppData'),CUDA_CACHE_PATH=str(TMP/'cuda'),QML_DISABLE_DISK_CACHE='1',QT_FORCE_STDERR_LOGGING='1',VEYRA_LOG_FILE=str(L/'engine.log'))-try:- with (L/'console.log').open('wb') as f:rc=subprocess.run([str(A/'veyra_qml_ui.exe'),'--page','pro','--data-dir',str(P),'--exit-after','60000'],cwd=A,env=env,stdout=f,stderr=subprocess.STDOUT,timeout=75).returncode-finally:replace(A/'qml/Veyra/Main.qml',src)-console=(L/'console.log').read_text(encoding='utf-8',errors='replace');engine=(L/'engine.log').read_text(encoding='utf-8',errors='replace')-errors=[l for l in console.splitlines() if any(x in l for x in ('ReferenceError:','TypeError:','Binding loop detected','is not a type','SyntaxError:'))]-unchanged=all(hashlib.sha256((user/n).read_bytes()).hexdigest()==h for n,h in before.items())-result={'exit':rc,'passed':rc==0 and 'SR_SAFETY_UI_PASS' in console and 'SR_SAFETY_UI_FAIL' not in console and not errors and unchanged,'qmlErrors':errors,'userSettingsUnchanged':unchanged,'unsafeWorkExtentObserved':'base=7680x4320' in engine,'steps':[l for l in engine.splitlines() if '[sr-safety-test]' in l or '[sr-stage-safety]' in l],'log':str(L/'engine.log')}-result['passed']=result['passed'] and not result['unsafeWorkExtentObserved']-(OUT/'safe-ui.json').write_text(json.dumps(result,ensure_ascii=False,indent=2),encoding='utf-8');print(json.dumps(result,ensure_ascii=False,indent=2))-raise SystemExit(0 if result['passed'] else 1)diff --git a/scripts/acceptance/sr-stage-safety-ui.qml b/scripts/acceptance/sr-stage-safety-ui.qmldeleted file mode 100644index 579c174d..00000000--- a/scripts/acceptance/sr-stage-safety-ui.qml+++ /dev/null@@ -1,35 +0,0 @@-// Private-profile regression for the 2026-10-28 freeze; never opens a device.-import QtQuick-Item {- id: test- property string media: ""- Timer {- interval: 500; running: test.media.length > 0; repeat: true- property int ticks: 0- property int step: 0- property int played: 0- function check(ok,label) { if (!ok) throw new Error(label); veyra.logUi("sr-safety-test","PASS " + label) }- onTriggered: { try {- if (++ticks > 100) throw new Error("bounded safety test step=" + step)- if (step === 0) {- if (ticks < 4) return- check(veyra.srTargetIndex === 3 && veyra.srPrescale === 3, "restore preserves internal 1080p to 8K")- check(veyra.srOutput === 3, "restore bounds final output before any source opens")- check(veyra.nrEnabled && veyra.fgEnabled, "restore retains NR and frame-generation selections")- // Attempt to undo the output fit while the other stages are on.- veyra.srOutput = 0- check(veyra.srOutput === 3, "unsafe output edit is bounded atomically")- veyra.muted = true- veyra.openPath(test.media); step = 1; return- }- if (step === 1) {- if (!veyra.running || veyra.applying) return- if (++played < 24) return- check(veyra.outputSummary === "3840x2160", "running output stays 4K")- check(veyra.srStageSummary === "3840x2160 → 1920x1080 → 7680x4320 → 3840x2160", "SR evaluates 8K and fits before the downstream stages")- check(veyra.srActive && veyra.nrActive && veyra.fgActive, "SR, NR and frame generation all actually active")- veyra.logUi("sr-safety-test","SR_SAFETY_UI_PASS"); console.log("SR_SAFETY_UI_PASS"); Qt.quit()- }- } catch(e) { veyra.logUi("sr-safety-test","SR_SAFETY_UI_FAIL " + e.message); console.log("SR_SAFETY_UI_FAIL " + e.message); Qt.quit() } }- }-}diff --git a/scripts/acceptance/sr-stage-ui.py b/scripts/acceptance/sr-stage-ui.pyindex 8568bc25..67232c30 100644--- a/scripts/acceptance/sr-stage-ui.py+++ b/scripts/acceptance/sr-stage-ui.py@@ -1,16 +1,17 @@-"""Double SR rows in the real app (shared claude-sr-stage-20261028 staging).+"""Supersample and double SR rows in the real app (shared claude-sr-stage-20261028 staging).Runs this tree's build in the task's staged copy (tmp stage_app.py: hard links to the2.1.1 portable donor, this build's EXE / shaders / QML), on a private profile, playing a-4K file with RTX Video SR while sr-stage-ui.qml drives the list SR card. Main.qml gets the-test Loader only inside that copy.-usage: py -3.11 -X utf8 -B -I scripts/acceptance/sr-stage-ui.py [media]+1080p file with RTX Video SR while the fixture (dual-sr-ui.qml) drives the list and node SR+controls. Main.qml gets the test Loader only inside that copy; the fixture's screenshot+goes to tests/<task>/dual-controls.png.+usage: py -3.11 -X utf8 -B -I scripts/acceptance/sr-stage-ui.py [media] [--task NAME] [--fixture FILE]"""from pathlib import Pathimport argparse, json, os, shutil, subprocess, sysparser=argparse.ArgumentParser()-parser.add_argument('media',nargs='?',default='E:/项目/Veyra/tests/nr-manual-scale-20261024/media/nr-4k30.mp4')+parser.add_argument('media',nargs='?',default='E:/项目/Veyra/tests/nr-manual-scale-20261024/media/nr-1080p30.mp4')parser.add_argument('--task',default='claude-sr-stage-20261028')parser.add_argument('--fixture',default='dual-sr-ui.qml')args=parser.parse_args()@@ -34,8 +35,10 @@ P.mkdir(parents=True)main_src = R/'qml/Veyra/Main.qml'; main = main_src.read_text('utf8'); pos = main.rfind('}')fixture=(R/'scripts/acceptance'/args.fixture).resolve()assert fixture.is_relative_to((R/'scripts/acceptance').resolve()) and fixture.is_file()+SHOT = B/'tests'/T/'dual-controls.png'; SHOT.parent.mkdir(parents=True, exist_ok=True)loader = ('\nLoader { anchors.fill: parent; source: ' + json.dumps(fixture.as_uri()) +- '; onLoaded: item.media=' + json.dumps(MEDIA.as_posix()) + ' }\n')+ '; onLoaded: { if (item.shot !== undefined) item.shot=' + json.dumps(SHOT.as_posix()) ++ '; item.media=' + json.dumps(MEDIA.as_posix()) + ' } }\n')replace(A/'qml/Veyra/Main.qml', (main[:pos] + loader + main[pos:]).encode('utf8'))env = {k: v for k, v in os.environ.items() if not k.upper().startswith(('VEYRA_', 'QT_', 'QSG_', 'QML_'))}log_file = L/'engine.log'; console = L/'console.log'diff --git a/scripts/acceptance/sr-stage-ui.qml b/scripts/acceptance/sr-stage-ui.qmldeleted file mode 100644index 855e2476..00000000--- a/scripts/acceptance/sr-stage-ui.qml+++ /dev/null@@ -1,101 +0,0 @@-// Loaded only into a private staging copy, never the user's running package.-// claude-sr-stage-20261028: the three-step SR rows of the list SR card, driven-// through the controls themselves while a 4K file plays with RTX Video SR.-import QtQuick-Item {- id: test- property string media: ""- function find(name) {- let hit = null- const walk = item => { if (hit) return; if (item.objectName === name) { hit = item; return } for (const c of item.children) walk(c) }- walk(test.parent.parent) // the Loader's parent: the window's content item- return hit- }- Timer {- interval: 500; running: test.media.length > 0; repeat: true- property int step: 0- property int ticks: 0- property int total: 0- function check(ok, label) { if (!ok) throw new Error(label); veyra.logUi("sr-stage-test", "PASS " + label) }- function next(n) { step = n; ticks = 0 }- function settled() { return ticks >= 6 && !veyra.applying && veyra.running }- onTriggered: { try {- ++ticks; ++total; if (total > 400) throw new Error("bounded step=" + step)- if (step === 0) {- if (ticks < 4) return- veyra.muted = true; veyra.fgEnabled = false; veyra.nrEnabled = false- veyra.srEnabled = true; veyra.videoSrQuality = 3; veyra.srTargetIndex = 2- veyra.openPath(test.media); next(1); return- }- if (step === 1) {- if (!settled()) return- check(veyra.srActive, "RTX Video SR restores the 4K file at its size: " + veyra.statusText)- check(veyra.srStageSummary === "", "single step shows no three-step sizes")- const prescale = find("list-sr-prescale"), output = find("list-sr-output")- check(prescale && output && prescale.enabled && output.enabled, "the list SR card has both rows, enabled for RTX Video SR")- prescale.picked("3"); next(2); return // 1080p, through the control- }- if (step === 2) {- if (!settled()) return- check(veyra.srPrescale === 3, "the prescale control sets 1080p")- check(veyra.srActive && veyra.srStageSummary === "3840x2160 → 1920x1080 → 3840x2160", "running sizes " + veyra.srStageSummary)- find("list-sr-target").picked("3"); next(3); return // 8K- }- if (step === 3) {- if (!settled()) return- find("list-sr-output").picked("3"); next(4); return // fit 4K- }- if (step === 4) {- if (!settled()) return- check(veyra.srOutput === 3, "the output control sets 4K")- check(veyra.srStageSummary === "3840x2160 → 1920x1080 → 7680x4320 → 3840x2160", "running sizes " + veyra.srStageSummary)- check(veyra.outputSummary === "3840x2160", "the chain output stays 4K: " + veyra.outputSummary)- find("list-sr-prescale").picked("manual"); next(5); return- }- if (step === 5) {- if (!settled()) return- check(veyra.srPrescale === 175 && find("list-sr-prescale-percent-row").visible, "manual prescale starts at 75 %")- check(veyra.srStageSummary === "3840x2160 → 2880x1620 → 7680x4320 → 3840x2160", "running sizes " + veyra.srStageSummary)- // A 2K target after a 1440p prescale cannot enlarge: reported, not applied.- find("list-sr-output").picked("0"); veyra.srTargetIndex = 1; veyra.srPrescale = 4; next(6); return- }- if (step === 6) {- if (!settled()) return- check(veyra.srStageNote.indexOf("先降到未生效") === 0, "an ineffective prescale is reported: " + veyra.srStageNote)- check(find("list-sr-prescale").options.find(o => o.id === "4").disabled === true, "1440p is marked unavailable for a 2K target")- veyra.videoSrQuality = 5; next(7); return // AMD FSR- }- if (step === 7) {- if (!settled()) return- check(!find("list-sr-prescale").enabled && !find("list-sr-output").enabled, "another SR backend disables both rows")- const before = veyra.srPrescale; veyra.srPrescale = 3- check(veyra.srPrescale === before, "the bridge refuses a prescale edit for another backend")- veyra.videoSrQuality = 3; veyra.srTargetIndex = 2; veyra.srPrescale = 0; next(8); return- }- if (step === 8) {- if (!settled()) return- check(veyra.srStageSummary === "" && veyra.srStageNote === "", "prescale off restores the single step")- veyra.nodeMode = 1- check(veyra.addEffect("sr") >= 0, "add an SR node to the initially empty node graph")- veyra.navigate("node"); next(9); return- }- if (step === 9) {- if (!settled()) return- veyra.nrEnabled = false; veyra.srEnabled = true- veyra.videoSrQuality = 3; veyra.srTargetIndex = 2- const prescale = find("node-sr-prescale"), output = find("node-sr-output")- if (!prescale || !output) return- check(prescale.enabled && output.enabled, "node SR editor exposes both enabled rows")- prescale.picked("3"); output.picked("0"); next(10); return- }- if (step === 10) {- if (!settled()) return- check(veyra.nodeMode === 1 && veyra.srActive && veyra.srPrescale === 3,- "node editor applies the prescale through its control")- check(veyra.srStageSummary === "3840x2160 → 1920x1080 → 3840x2160",- "node editor running sizes " + veyra.srStageSummary)- veyra.logUi("sr-stage-test", "SR_STAGE_UI_PASS"); console.log("SR_STAGE_UI_PASS"); Qt.quit(); return- }- } catch (e) { veyra.logUi("sr-stage-test", "SR_STAGE_UI_FAIL " + e.message); console.log("SR_STAGE_UI_FAIL " + e.message); Qt.quit() } }- }-}diff --git a/src/engine/EffectChain.cpp b/src/engine/EffectChain.cppindex b76116cd..2a79cea1 100644--- a/src/engine/EffectChain.cpp+++ b/src/engine/EffectChain.cpp@@ -536,8 +536,8 @@ ChainValidation compileChainExecutionPlan(const EffectChain& chain, const ChainEif (node.enabled && node.type == EffectType::NrEnhance) nrFirst = node.nr.lowLatencyPairing;}nrFirst = nrFirst && !request.stillImage && !request.exportJob;- // SR processing is its evaluated size; a three-step output fit can make- // the step output smaller than that.+ // SR processing is its evaluated size; a supersample shrink makes the step+ // output smaller than that.const auto resolved = pipeline::ResolutionPlan::make(request.source,true,pipeline::NrSizePolicy::Native,true,0,request.srTarget,false,0,request.srPrescale,request.srOutput,request.dualSrEnabled,request.dualSrTarget);const pipeline::SrStageExtents srStage{resolved.srInput,resolved.srOutput,resolved.base};@@ -732,7 +732,7 @@ bool requiresGraphRebuild(const EnhancementSettings& savedPrevious, const Enhancif ((previous.nrHoldStrength > 0.0f) != (next.nrHoldStrength > 0.0f)) return true;if (previous.nrPolicy != next.nrPolicy) return true;if (previous.srTarget != next.srTarget) return true;- // Three-step SR changes what SR reads and writes.+ // The double SR reduction and the supersample shrink change what SR reads and writes.if (previous.srPrescale != next.srPrescale || previous.srOutput != next.srOutput) return true;if(previous.dualSrEnabled!=next.dualSrEnabled||previous.dualSrTarget!=next.dualSrTarget||previous.dualSrQuality!=next.dualSrQuality)return true;// A different DLSS SR model (render preset) needs a new SR feature.diff --git a/src/engine/ExportJobManager.cpp b/src/engine/ExportJobManager.cppindex c5157814..2bd823c9 100644--- a/src/engine/ExportJobManager.cpp+++ b/src/engine/ExportJobManager.cpp@@ -32,7 +32,9 @@ struct Shared {// instead of reading a mismatched layout.// 10: 32-node chain with anti-aliasing; 11: beauty payloads and face detection.// 12: SR prescale/output fields change the shared settings layout.- static constexpr DWORD kVersion=13; // independent second SR parameters+ // 13: independent second SR parameters. 14: srOutput (the supersample+ // shrink) is honoured again; a version 13 worker would silently ignore it.+ static constexpr DWORD kVersion=14;DWORD signature=magic,version=kVersion,bytes=sizeof(Shared);EnhancementSettings settings;EffectChain chain;diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cppindex a7cba5c5..e76a7315 100644--- a/src/pipeline/EnhanceGraph.cpp+++ b/src/pipeline/EnhanceGraph.cpp@@ -580,8 +580,8 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)if(!Extent{srcW_,srcH_}.valid()||!Extent{workW_,workH_}.valid()){veyra::log::error("resolution","source/output exceeds D3D12 texture dimensions or is empty");return false;}- // NR before SR still reads the source. Three-step SR can now produce a- // smaller work texture, so its output is not the bound for that NR input.+ // NR before SR still reads the source. Double SR or a supersample shrink can+ // produce a smaller work texture, so its output is not the bound for that NR input.const auto nrFull=desc_.nrFullExtent(0);if(!Extent{nrW_,nrH_}.valid()||nrW_>nrFull.width||nrH_>nrFull.height){veyra::log::error("resolution",std::format("invalid NR extent {}x{} for stage input {}x{}",nrW_,nrH_,nrFull.width,nrFull.height));return false;@@ -595,10 +595,11 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)veyra::log::error("dual-sr","invalid independent SR stages or missing reduction");return false;}if(srPrescaleActive()||srResolveActive()){- // Three-step SR: shrink, enlarge with RTX Video SR, fit into the work extent.+ // Staged SR: double SR reduces before its second pass; supersampling+ // enlarges with RTX Video SR and then shrinks into the work extent.if(!Extent{srInW_,srInH_}.valid()||!Extent{srOutW_,srOutH_}.valid()||srInW_>(desc.dualSr?desc.firstSrWidth:srcW_)||srInH_>(desc.dualSr?desc.firstSrHeight:srcH_)||- srOutW_<workW_||srOutH_<workH_||srOutW_<=srInW_||srOutH_<=srInH_){veyra::log::error("resolution","invalid three-step SR extent");return false;}- if(!desc.enableSr||!engine::srStageBackend(desc.videoSrQuality)){veyra::log::error("resolution","three-step SR runs on RTX Video SR only");return false;}+ srOutW_<workW_||srOutH_<workH_||srOutW_<=srInW_||srOutH_<=srInH_){veyra::log::error("resolution","invalid staged SR extent");return false;}+ if(!desc.enableSr||!engine::srStageBackend(desc.videoSrQuality)){veyra::log::error("resolution","staged SR runs on RTX Video SR only");return false;}}diagnostics::DiagnosticEvent initDiagnostic;initDiagnostic.stage="initialize";initDiagnostic.identity={epoch_+1,desc.settingsRevision,0};initDiagnostic.resolution.source={srcW_,srcH_};initDiagnostic.resolution.base=initDiagnostic.resolution.fg=initDiagnostic.resolution.output={workW_,workH_};initDiagnostic.resolution.nr={nrW_,nrH_};initDiagnostic.resolution.flow={nvofW_,nvofH_};initDiagnostic.flowApplied=std::to_string(unsigned(desc.flowQuality));initDiagnostic.runtimeHash="unverified-user-replaceable";Logger::diagnosticContext(initDiagnostic);veyra::log::info("resolution",std::format("source={}x{} base={}x{} nr={}x{} flow={}x{} fg={}x{} output={}x{}",srcW_,srcH_,workW_,workH_,nrW_,nrH_,nvofW_,nvofH_,workW_,workH_,workW_,workH_));@@ -648,7 +649,10 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)const uint64_t vfgSharedBytes=vfg?uint64_t((workW_*4u+255u)&~255u)*workH_*(2u+2u*(desc_.fgMultiplier-1u)):0;const unsigned generatedTextures=fgEnabled_?(fsrEnabled()?2u:vfg?2u*(desc_.fgMultiplier-1u):10u):0;const uint64_t dualBytes=desc_.dualSr?uint64_t(desc_.firstSrWidth)*desc_.firstSrHeight*12u+uint64_t(srcW_)*srcH_*4u:0;- const uint64_t estimate=dualBytes+uint64_t(workW_)*workH_*(76u+4u*generatedTextures)+vfgSharedBytes+ // Supersampling keeps the larger RGBA8 SR result beside the work textures.+ const uint64_t supersampleBytes=!desc_.dualSr&&srResolveActive()?uint64_t(srOutW_)*srOutH_*4u:0;+ const bool stagedSr=desc_.dualSr||supersampleBytes>0;+ const uint64_t estimate=dualBytes+supersampleBytes+uint64_t(workW_)*workH_*(76u+4u*generatedTextures)+vfgSharedBytes+nrTextureBytes+fullLayerBytes+uint64_t(srcW_)*srcH_*(32u+(desc_.protectionBeforeSr()?8u:0u))+temporalBytes+tailColorBytes+interProtectionBytes+(flowRefine_?uint64_t(nvofW_)*nvofH_*(flowConsistency_?13u:flowClaims_?18u:12u)+uint64_t(workW_)*workH_*4u:0);@@ -657,14 +661,15 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)// Keep measured WDDM headroom for SDK-owned allocations. There is no// resolution cap or silent resize: reject the transaction when its// conservative reservation cannot fit, preserving the previous graph.- // The new reservation belongs to the new two-pass graph. Keep the- // existing single-pass admission policy, including ordinary 8K.- const uint64_t sdkReserve=desc_.dualSr?((nrEnabled_?(1024ull<<20):0)++ // The new reservation belongs to the staged graphs (double SR and the+ // supersample shrink). Keep the existing single-pass admission policy,+ // including ordinary 8K.+ const uint64_t sdkReserve=stagedSr?((nrEnabled_?(1024ull<<20):0)+(vfg?uint64_t(workW_)*workH_*128u:0)+(256ull<<20)):0;const uint64_t required=estimate+sdkReserve;const uint64_t available=budget>usage?budget-usage:0;- veyra::log::info("memory",std::format("admission textures={}MiB sdkReserve={}MiB available={}MiB headroom={}%",estimate>>20,sdkReserve>>20,available>>20,desc_.dualSr?20:0));- if(usage>=budget||required>(desc_.dualSr?available*4/5:available)){veyra::log::error("memory","insufficient adapter budget for requested graph and SDK reservation; dimensions unchanged");return false;}+ veyra::log::info("memory",std::format("admission textures={}MiB sdkReserve={}MiB available={}MiB headroom={}%",estimate>>20,sdkReserve>>20,available>>20,stagedSr?20:0));+ if(usage>=budget||required>(stagedSr?available*4/5:available)){veyra::log::error("memory","insufficient adapter budget for requested graph and SDK reservation; dimensions unchanged");return false;}}Status st = Status::Ok;@@ -1534,7 +1539,8 @@ bool EnhanceGraph::initNgxFeatures()if (list == nullptr) { failedBackend_=engine::FailedBackend::Infrastructure; return false; }failedBackend_=engine::FailedBackend::Sr;if(desc_.videoSrQuality){videoSrBackend_=std::make_unique<ngx::VideoSrBackend>();if(!videoSrBackend_->create(*coreHost_,list,desc_.dualSr?srInW_:0,desc_.dualSr?srInH_:0,desc_.dualSr?srOutW_:0,desc_.dualSr?srOutH_:0))return false;veyra::log::info("video-sr",std::format("selected quality={} input={}x{} output={}x{}{}",desc_.videoSrQuality,srcW_,srcH_,workW_,workH_,- srPrescaleActive()||srResolveActive()?std::format(" three-step prescale={}x{} evaluate={}x{}",srInW_,srInH_,srOutW_,srOutH_):std::string()));+ desc_.dualSr?std::format(" dual reduce={}x{} evaluate={}x{}",srInW_,srInH_,srOutW_,srOutH_):+ srResolveActive()?std::format(" supersample evaluate={}x{} output={}x{}",srOutW_,srOutH_,workW_,workH_):std::string()));if(desc_.dualSr){firstVideoSrBackend_=std::make_unique<ngx::VideoSrBackend>();if(!firstVideoSrBackend_->create(*coreHost_,list,srcW_,srcH_,desc_.firstSrWidth,desc_.firstSrHeight)){if(!firstVideoSrBackend_->duplicateCreation())return false;firstVideoSrBackend_.reset();@@ -2624,7 +2630,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Framelist->Dispatch((desc_.firstSrWidth+15)/16,(desc_.firstSrHeight+15)/16,1);tracker_.uavBarrier(list,firstSrLinear_.Get());tracker_.transition(list,firstSrLinear_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);++metrics_.srEvaluateCount;}- // Three-step SR shrinks the resolved SR input first (exact area, linear light).+ // Double SR reduces the first AI result before the second pass (exact area, linear light).const bool prescaled=srPrescaled_!=nullptr;if(prescaled){tracker_.transition(list,desc_.dualSr?firstSrLinear_.Get():srStageInput(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);diff --git a/src/ui/bridge/Enhancement.cpp b/src/ui/bridge/Enhancement.cppindex 9f524c01..a41b143a 100644--- a/src/ui/bridge/Enhancement.cpp+++ b/src/ui/bridge/Enhancement.cpp@@ -45,7 +45,8 @@ void QmlPlayerBridge::setDualSrEnabled(bool enabled){auto s=settings();if(s.dualSrEnabled==enabled)return;if(enabled&&!engine::srStageBackend(s.videoSrQuality))return;s.dualSrEnabled=enabled;- if(enabled){if(s.srPrescale==pipeline::SrPrescale::Off)s.srPrescale=pipeline::SrPrescale::P1080;s.srOutput=pipeline::SrOutput::Target;}+ // A kept supersample shrink is inactive under double SR and returns when it is off.+ if(enabled&&s.srPrescale==pipeline::SrPrescale::Off)s.srPrescale=pipeline::SrPrescale::P1080;if(impl_->commit(s))emit settingsChanged();}int QmlPlayerBridge::dualSrTargetIndex() const {@@ -59,13 +60,14 @@ void QmlPlayerBridge::setDualSrTargetIndex(int index){int QmlPlayerBridge::dualSrQuality() const {return int(settings().dualSrQuality);}void QmlPlayerBridge::setDualSrQuality(int quality){if(quality<1||quality>4)return;auto s=settings();s.dualSrQuality=uint32_t(quality);if(impl_->commit(s))emit settingsChanged();}int QmlPlayerBridge::srOutput() const { return int(settings().srOutput); }-// Three-step SR runs on RTX Video SR only; other backends keep the single step.+// Double SR and the supersample shrink run on RTX Video SR only; other backends+// keep the single step.void QmlPlayerBridge::setSrPrescale(int value) {const auto want = pipeline::SrPrescale(uint32_t(value));if (value < 0 || !pipeline::validSrPrescale(want)) return;auto s = settings();if (s.srPrescale == want) return;- if (!engine::srStageBackend(s.videoSrQuality)) { emit notice(tr("先降到 / 再缩到目前仅 RTX 视频超分支持"), true); return; }+ if (!engine::srStageBackend(s.videoSrQuality)) { emit notice(tr("双重超分目前仅 RTX 视频超分支持"), true); return; }s.srPrescale = want;if (impl_->commit(s)) emit settingsChanged();}@@ -74,7 +76,7 @@ void QmlPlayerBridge::setSrOutput(int value) {if (value < 0 || !pipeline::validSrOutput(want)) return;auto s = settings();if (s.srOutput == want) return;- if (!engine::srStageBackend(s.videoSrQuality)) { emit notice(tr("先降到 / 再缩到目前仅 RTX 视频超分支持"), true); return; }+ if (!engine::srStageBackend(s.videoSrQuality)) { emit notice(tr("超分后缩回目前仅 RTX 视频超分支持"), true); return; }s.srOutput = want;if (impl_->commit(s)) emit settingsChanged();}diff --git a/src/ui/bridge/Status.cpp b/src/ui/bridge/Status.cppindex 92b056f9..615c0f36 100644--- a/src/ui/bridge/Status.cpp+++ b/src/ui/bridge/Status.cpp@@ -12,16 +12,17 @@ QString QmlPlayerBridge::outputSummary() const {if (!s.running || !plan.output.valid() || plan.settingsRevision != s.applied.revision) return {};return QStringLiteral("%1x%2").arg(plan.output.width).arg(plan.output.height);}-// Three-step SR as the running plan has it: source -> shrunk input -> SR-// result -> output. Empty for single-step SR.+// Staged SR as the running plan has it. Double SR: source -> first result ->+// reduction -> second result; supersampling: source -> SR result -> shrunk+// output. Empty for single-step SR.QString QmlPlayerBridge::srStageSummary() const {const auto& s = impl_->snapshot;const auto& plan = s.metrics.resolution;if (!s.running || !plan.output.valid() || plan.settingsRevision != s.applied.revision || !plan.srApplied) return {};- if (!plan.dualSrApplied) return {};+ if (!plan.dualSrApplied && plan.base == plan.srOutput) return {};const auto size = [](pipeline::Extent e) { return QStringLiteral("%1x%2").arg(e.width).arg(e.height); };- QStringList parts{size(plan.source),size(plan.firstSrOutput)};- parts << size(plan.srInput);+ QStringList parts{size(plan.source)};+ if (plan.dualSrApplied) parts << size(plan.firstSrOutput) << size(plan.srInput);parts << size(plan.srOutput);if (plan.base != plan.srOutput) parts << size(plan.base);return parts.join(QStringLiteral(" → "));@@ -32,6 +33,7 @@ QString QmlPlayerBridge::srStageNote() const {if (!s.running || !plan.output.valid() || plan.settingsRevision != s.applied.revision) return {};QStringList notes;if (plan.srPrescaleIneffective) notes << tr("第二次超分未执行:再次降低后的尺寸须小于基础超分结果及第二次目标。");+ if (plan.srOutputIneffective) notes << tr("超分后缩回未生效:超分须先放大画面,且缩回尺寸要小于超分结果。");return notes.join(QStringLiteral(";"));}diff --git a/tests/integration/ExportWorkflowTests.cpp b/tests/integration/ExportWorkflowTests.cppindex a999d705..197ee62a 100644--- a/tests/integration/ExportWorkflowTests.cpp+++ b/tests/integration/ExportWorkflowTests.cpp@@ -37,7 +37,8 @@ int wmain(int argc,wchar_t** argv){const bool hevc=mode.find(L"hevc")!=std::wstring::npos;const bool fsr=mode.find(L"fsr-")==0;const bool rejectXess=mode==L"reject-xess";- const bool srStage=mode==L"sr-stage-fit"||mode==L"sr-stage-prescale";+ // Supersampling: 1080p -> 8K -> 4K, or 1080p -> 4K -> a non-integer 2K shrink.+ const bool srStage=mode==L"sr-supersample"||mode==L"sr-supersample-2k";const bool dualSr=mode==L"dual-sr";if(dualSr){settings.sr=true;settings.videoSrQuality=1;settings.srMotion=MotionSource::Zero;@@ -48,9 +49,9 @@ int wmain(int argc,wchar_t** argv){}if(srStage){settings.sr=true;settings.videoSrQuality=1;settings.srMotion=MotionSource::Zero;- settings.srPrescale=veyra::pipeline::SrPrescale::P1080;- settings.srTarget=mode==L"sr-stage-fit"?veyra::pipeline::SrTarget::Uhd8K:veyra::pipeline::SrTarget::Uhd4K;- settings.srOutput=mode==L"sr-stage-fit"?veyra::pipeline::SrOutput::Uhd4K:veyra::pipeline::SrOutput::Qhd;+ settings.srPrescale=veyra::pipeline::SrPrescale::P1080; // kept for double SR, unused here+ settings.srTarget=mode==L"sr-supersample"?veyra::pipeline::SrTarget::Uhd8K:veyra::pipeline::SrTarget::Uhd4K;+ settings.srOutput=mode==L"sr-supersample"?veyra::pipeline::SrOutput::Uhd4K:veyra::pipeline::SrOutput::Qhd;media.audio.policy=media.subtitles.policy=ExportTrackPolicy::None;}if(fsr||rejectXess){@@ -199,13 +200,14 @@ int wmain(int argc,wchar_t** argv){std::wcout<<L"DUAL_SR_EXPORT source=4 encoded=4 frozenAndEvaluated=1\n";}if(srStage){- require(s.encoded==4&&s.sourceFrames==4,"SR stage export lost source frames");+ require(s.encoded==4&&s.sourceFrames==4,"supersample export lost source frames");require(s.frozen.srPrescale==settings.srPrescale&&s.frozen.srOutput==settings.srOutput&&s.frozen.srTarget==settings.srTarget,- "SR stage fields lost crossing the worker protocol");+ "supersample fields lost crossing the worker protocol");std::ifstream log(s.workerLog);const std::string text((std::istreambuf_iterator<char>(log)),{});- const auto evaluated=mode==L"sr-stage-fit"?"evaluate=7680x4320":"evaluate=3840x2160";- require(text.find(evaluated)!=std::string::npos,"SR stage was not evaluated at the requested dimensions");- std::wcout<<L"SR_STAGE_EXPORT encoded="<<s.encoded<<L" frozenAndEvaluated=1\n";+ const auto evaluated=mode==L"sr-supersample"?"supersample evaluate=7680x4320 output=3840x2160":"supersample evaluate=3840x2160 output=2560x1440";+ require(text.find(evaluated)!=std::string::npos&&text.find("dual reduce=")==std::string::npos,+ "supersample was not evaluated and shrunk at the requested dimensions");+ std::wcout<<L"SUPERSAMPLE_EXPORT encoded="<<s.encoded<<L" frozenAndEvaluated=1\n";}if(rejectXess){require(s.message.find(L"XeSS")!=std::wstring::npos&&s.message.find(L"FSR")!=std::wstring::npos,"XeSS rejection lost its backend-specific reason");diff --git a/tests/integration/SrQualityTests.cpp b/tests/integration/SrQualityTests.cppindex 69b6bcdd..357e1995 100644--- a/tests/integration/SrQualityTests.cpp+++ b/tests/integration/SrQualityTests.cpp@@ -92,11 +92,12 @@ static int referenceTest(const std::filesystem::path& directory,const std::wstri}-// ---- three-step SR (2026-10-28) -----------------------------------------------// Real RTX Video SR with the prescale and the output fit: sizes and SDK-// evaluations, the shrink against a CPU area average of the graph's own encoded-// input, and the fit against a CPU area average of the same graph run at the SR-// size (SDR and HDR). Readbacks are restricted to this test.+// ---- double RTX Video SR and supersampling (2026-10-28) ------------------------+// Base SR, an exact area reduction of the first AI result, then a second SR with+// real SDK evaluations: sizes, the reduction against a CPU area average of the+// graph's own first result, and both HDR restores against the bases they must+// use. Supersampling: one pass shrunk into the output, against a CPU area average+// of the same graph's larger result. Readbacks are restricted to this test.namespace stage {using namespace veyra;// Copy a texture in a known state to the CPU and restore that state.@@ -172,14 +173,14 @@ Frame hdrFrame(const sink::RgbaImage& img){}return f;}-struct Run{bool ok=false;sink::RgbaImage output,srInput,firstLinear;double srMs=-1;uint64_t evaluations=0;pipeline::Extent srIn{},srOut{},work{};bool enabled=false;};+struct Run{bool ok=false;sink::RgbaImage output,srInput,firstLinear;double srMs=-1;uint64_t evaluations=0;pipeline::Extent srIn{},srOut{},work{},first{};bool enabled=false;};Run run(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing& ring,const AVFrame* frame,bool hdr,const engine::EnhancementSettings& settings,bool readSrInput,bool still=false,bool uncompressed=false,unsigned frames=6,bool readFirst=false){engine::StageRequest request;request.width=unsigned(frame->width);request.height=unsigned(frame->height);request.sr=settings.sr;request.stillImage=still;request.uncompressedSource=uncompressed;request.nr=settings.nr;pipeline::EnhanceGraphDesc desc;engine::describeStages(request,settings,desc);desc.rgbInput=!hdr;desc.hdrInput=hdr;desc.hdrOutput=hdr;desc.outputDitherStep=0;desc.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();- Run r;r.srIn={desc.srInputWidth,desc.srInputHeight};r.srOut={desc.srOutputWidth,desc.srOutputHeight};r.work={desc.workWidth,desc.workHeight};+ Run r;r.srIn={desc.srInputWidth,desc.srInputHeight};r.srOut={desc.srOutputWidth,desc.srOutputHeight};r.work={desc.workWidth,desc.workHeight};r.first={desc.firstSrWidth,desc.firstSrHeight};if(!desc.fixedExecutionPlanError.empty()){std::cout<<"plan error: "<<desc.fixedExecutionPlanError<<std::endl;return r;}pipeline::EnhanceGraph graph(ctx,ring);if(!graph.initialize(desc)||!graph.createViews()){graph.shutdown();return r;}@@ -197,9 +198,14 @@ Run run(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing& ring,const AVFrame* fif(!ms.empty()){std::sort(ms.begin(),ms.end());r.srMs=ms[ms.size()/2];}r.ok=ok;out={};ring.drainQueue();graph.shutdown();return r;}-engine::EnhancementSettings vsr(unsigned quality,pipeline::SrTarget target,pipeline::SrPrescale prescale=pipeline::SrPrescale::Off,pipeline::SrOutput output=pipeline::SrOutput::Target){+engine::EnhancementSettings vsr(unsigned quality,pipeline::SrTarget target){engine::EnhancementSettings s;s.nr=false;s.sr=quality!=0;s.multiplier=1;s.videoSrQuality=quality?quality:engine::kDefaultVideoSrQuality;- s.srTarget=target;s.srPrescale=prescale;s.srOutput=output;s.srMotion=engine::MotionSource::Zero;s.hdrOutputMode=engine::HdrOutputMode::ScRgb;+ s.srTarget=target;s.srMotion=engine::MotionSource::Zero;s.hdrOutputMode=engine::HdrOutputMode::ScRgb;+ return s;+}+// Base SR to `target`, its result reduced to `reduce`, then a second SR to `second`.+engine::EnhancementSettings twoPass(unsigned quality,pipeline::SrTarget target,pipeline::SrPrescale reduce,pipeline::SrTarget second,unsigned secondQuality){+ auto s=vsr(quality,target);s.dualSrEnabled=true;s.srPrescale=reduce;s.dualSrTarget=second;s.dualSrQuality=secondQuality;return s;}// CPU area average of an image by an integer factor, SDR (sRGB) or scRGB FP16.@@ -212,94 +218,70 @@ std::vector<double> shrink(const sink::RgbaImage& img,unsigned factor,bool hdr){}return out;}-int test(const std::filesystem::path& directory){+// CPU exact area resample to linear RGB with NrDownsample's weights; fp16 reads+// linear/scRGB FP16 texels, otherwise sRGB bytes.+std::vector<double> area(const sink::RgbaImage& img,unsigned w,unsigned h,bool fp16){+ std::vector<double> out(size_t(w)*h*3);const double sx=double(img.width)/w,sy=double(img.height)/h;+ for(unsigned y=0;y<h;++y)for(unsigned x=0;x<w;++x){+ const double x0=x*sx,x1=(x+1)*sx,y0=y*sy,y1=(y+1)*sy;double sum[3]{},weights=0;+ for(unsigned j=unsigned(y0);j<unsigned(std::ceil(y1))&&j<img.height;++j)for(unsigned i=unsigned(x0);i<unsigned(std::ceil(x1))&&i<img.width;++i){+ const double weight=(std::min(x1,i+1.0)-std::max(x0,double(i)))*(std::min(y1,j+1.0)-std::max(y0,double(j)));+ if(weight<=0)continue;weights+=weight;+ for(unsigned c=0;c<3;++c){const size_t p=(size_t(j)*img.width+i)*4+c;sum[c]+=weight*(fp16?half(img,p):decode(img.pixels[p]));}+ }+ for(unsigned c=0;c<3;++c)out[(size_t(y)*w+x)*3+c]=sum[c]/weights;+ }+ return out;+}+std::vector<double> linear(const sink::RgbaImage& img){+ std::vector<double> out(size_t(img.width)*img.height*3);+ for(size_t p=0;p<size_t(img.width)*img.height;++p)for(unsigned c=0;c<3;++c)out[p*3+c]=half(img,p*4+c);+ return out;+}+// HdrVideoSrRestore's bilinear base sample for output pixel (x,y) of a W x H output.+double bilinear(const std::vector<double>& img,unsigned w,unsigned h,unsigned W,unsigned H,unsigned x,unsigned y,unsigned c){+ const double px=(x+0.5)*double(w)/W-0.5,py=(y+0.5)*double(h)/H-0.5;const int qx=int(std::floor(px)),qy=int(std::floor(py));+ const double fx=px-qx,fy=py-qy;double v=0;+ for(int j=0;j<2;++j)for(int i=0;i<2;++i){const int sx=std::clamp(qx+i,0,int(w)-1),sy=std::clamp(qy+j,0,int(h)-1);+ v+=img[(size_t(sy)*w+sx)*3+c]*(i?fx:1-fx)*(j?fy:1-fy);}+ return v;+}+// SDR input/output transparency (the A/B baseline) and both HDR restores of+// double SR. HdrRestore returns its base plus a delta clamped to +-0.5*203/80,+// so every output lies within that bound of the base it sampled: the first+// restore must sample the source, the second the area reduction of the first+// AI result. A full-size base would break the bound on the thin 1000-nit lines.+int restore(const std::filesystem::path& directory){std::filesystem::create_directories(directory);Logger::instance().openFile((directory/L"engine.log").wstring());gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status status;if(!ctx.initialize({},status)||!ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),4,status))return 2;bool ok=true;const auto check=[&](bool pass,const std::string& label){std::cout<<(pass?"PASS ":"FAIL ")<<label<<std::endl;ok=ok&&pass;};- using pipeline::SrTarget;using pipeline::SrPrescale;using pipeline::SrOutput;using pipeline::Extent;- const auto uhd=pattern(3840,2160),qhd=pattern(2560,1440);- const auto uhdSdr=sdrFrame(uhd),qhdSdr=sdrFrame(qhd),uhdHdr=hdrFrame(uhd),qhdHdr=hdrFrame(qhd);- if(!uhdSdr||!qhdSdr||!uhdHdr||!qhdHdr)return 2;- // 1. Without SR the input/output conversion is transparent (the A/B baseline).+ using pipeline::SrTarget;using pipeline::SrPrescale;{- const auto off=run(ctx,ring,uhdSdr.get(),false,vsr(0,SrTarget::Uhd4K),false);+ const auto uhd=pattern(3840,2160);const auto frame=sdrFrame(uhd);if(!frame)return 2;+ const auto off=run(ctx,ring,frame.get(),false,vsr(0,SrTarget::Uhd4K),false);int worst=0;for(size_t i=0;off.ok&&i<uhd.pixels.size();++i)if(i%4!=3)worst=std::max(worst,std::abs(int(off.output.pixels[i])-int(uhd.pixels[i])));check(off.ok&&off.output.width==3840&&worst<=1,"SDR input/output conversion is transparent (max "+std::to_string(worst)+")");}- // 2. SDR prescale: 4K -> 1080p -> RTX Video SR 4K.- for(const unsigned quality:{1u,4u}){- const auto native=run(ctx,ring,uhdSdr.get(),false,vsr(quality,SrTarget::Uhd4K),true);- const auto shrunk=run(ctx,ring,uhdSdr.get(),false,vsr(quality,SrTarget::Uhd4K,SrPrescale::P1080),true);- check(native.ok&&native.enabled&&native.srInput.width==3840&&native.evaluations==6,"SDR q"+std::to_string(quality)+" single step: 4K native restore runs RTX Video SR");- check(shrunk.ok&&shrunk.enabled&&shrunk.srIn==Extent{1920,1080}&&shrunk.srOut==Extent{3840,2160}&&shrunk.srInput.width==1920&&- shrunk.srInput.height==1080&&shrunk.output.width==3840&&shrunk.output.height==2160&&shrunk.evaluations==6,- "SDR q"+std::to_string(quality)+" prescale: SR reads 1920x1080 and writes 3840x2160");- if(native.ok&&shrunk.ok&&native.srInput.width==3840&&shrunk.srInput.width==1920){- const auto reference=shrink(native.srInput,2,false);int worst=0;size_t over=0,count=0;- for(size_t p=0;p<size_t(1920)*1080;++p)for(unsigned c=0;c<3;++c){- const int d=std::abs(int(shrunk.srInput.pixels[p*4+c])-int(std::lround(encode(reference[p*3+c]))));worst=std::max(worst,d);over+=d>1;++count;}- check(worst<=2&&over*1000<count,"SDR q"+std::to_string(quality)+" prescale equals the area average in linear light (max "+std::to_string(worst)+", >1: "+std::to_string(over)+")");- }- std::cout<<"STAGE_TIMING case=sdr-4k q="<<quality<<" nativeSrMs="<<native.srMs<<" prescale1080SrMs="<<shrunk.srMs<<std::endl;- }- // 3. SDR fit: 2K -> RTX Video SR 8K -> 4K equals the area average of the 8K run.- {- const auto full=run(ctx,ring,qhdSdr.get(),false,vsr(2,SrTarget::Uhd8K),false);- const auto fit=run(ctx,ring,qhdSdr.get(),false,vsr(2,SrTarget::Uhd8K,SrPrescale::Off,SrOutput::Uhd4K),false);- check(full.ok&&full.output.width==7680&&fit.ok&&fit.enabled&&fit.srOut==Extent{7680,4320}&&fit.work==Extent{3840,2160}&&- fit.output.width==3840&&fit.output.height==2160&&fit.evaluations==6,"SDR fit: SR writes 7680x4320, the chain runs at 3840x2160");- if(full.ok&&fit.ok&&full.output.width==7680&&fit.output.width==3840){- const auto reference=shrink(full.output,2,false);int worst=0;size_t over=0,count=0;- for(size_t p=0;p<size_t(3840)*2160;++p)for(unsigned c=0;c<3;++c){- const int d=std::abs(int(fit.output.pixels[p*4+c])-int(std::lround(encode(reference[p*3+c]))));worst=std::max(worst,d);over+=d>1;++count;}- check(worst<=2&&over*200<count,"SDR fit equals the area average of the 8K result (max "+std::to_string(worst)+", >1: "+std::to_string(over)+")");- }- std::cout<<"STAGE_TIMING case=sdr-2k-8k q=2 fullSrMs="<<full.srMs<<" fitSrMs="<<fit.srMs<<std::endl;- }- // 4. HDR fit (proxy + restore per SR texel, then the average), scRGB output.- {- const auto full=run(ctx,ring,qhdHdr.get(),true,vsr(2,SrTarget::Uhd8K),false);- const auto fit=run(ctx,ring,qhdHdr.get(),true,vsr(2,SrTarget::Uhd8K,SrPrescale::Off,SrOutput::Uhd4K),false);- check(full.ok&&fit.ok&&fit.enabled&&fit.output.width==3840&&full.output.width==7680,"HDR fit: 8K SR result fitted to 3840x2160");- if(full.ok&&fit.ok&&full.output.width==7680&&fit.output.width==3840){- const auto reference=shrink(full.output,2,true);size_t over=0,count=0,bad=0;double worst=0,peak=0;- for(size_t p=0;p<size_t(3840)*2160;++p)for(unsigned c=0;c<3;++c){- const double v=half(fit.output,p*4+c),r=reference[p*3+c];if(!std::isfinite(v)){++bad;continue;}- const double d=std::abs(v-r);worst=std::max(worst,d);peak=std::max(peak,v);over+=d>0.003+0.003*std::abs(r);++count;}- check(!bad&&over*1000<count,"HDR fit equals the area average of the 8K restore (worst "+std::to_string(worst)+", over "+std::to_string(over)+", peak "+std::to_string(peak)+")");+ const auto hdr=hdrFrame(pattern(2560,1440));if(!hdr)return 2;+ const auto source=run(ctx,ring,hdr.get(),true,vsr(0,SrTarget::Uhd4K),false);+ const auto two=run(ctx,ring,hdr.get(),true,twoPass(2,SrTarget::Uhd4K,SrPrescale::P1080,SrTarget::Uhd4K,2),false,false,false,3,true);+ check(source.ok&&source.output.width==2560&&two.ok&&two.evaluations==6&&two.firstLinear.width==3840&&two.output.width==3840,+ "HDR double SR: 2560x1440 -> base 3840x2160 -> 1920x1080 -> second 3840x2160");+ if(source.ok&&two.ok&&source.output.width==2560&&two.firstLinear.width==3840&&two.output.width==3840){+ const auto base=linear(source.output),reduced=area(two.firstLinear,1920,1080,true);+ const double bound=0.5*203.0/80.0+0.05;double first=0,second=0;size_t bad=0;+ for(unsigned y=0;y<2160;++y)for(unsigned x=0;x<3840;++x)for(unsigned c=0;c<3;++c){+ const size_t i=(size_t(y)*3840+x)*4+c;const double f=half(two.firstLinear,i),o=half(two.output,i);+ if(!std::isfinite(f)||!std::isfinite(o)){++bad;continue;}+ first=std::max(first,std::abs(f-bilinear(base,2560,1440,3840,2160,x,y,c)));+ second=std::max(second,std::abs(o-bilinear(reduced,1920,1080,3840,2160,x,y,c)));}+ check(!bad&&first<=bound,"HDR first restore uses the source base ("+std::to_string(first)+")");+ check(!bad&&second<=bound,"HDR second restore uses the reduced first result ("+std::to_string(second)+")");}- // 5. HDR prescale. HdrRestore returns base + a delta clamped to +-0.5*203/80, so- // every output channel lies within that bound of the base it sampled. The- // single step must stay near the full linear input; the prescale near the- // bilinear-sampled area average of it (a full-size base would fail on the- // thin 1000-nit lines).- {- const auto linear=run(ctx,ring,uhdHdr.get(),true,vsr(0,SrTarget::Uhd4K),false);- const auto native=run(ctx,ring,uhdHdr.get(),true,vsr(2,SrTarget::Uhd4K),false);- const auto shrunk=run(ctx,ring,uhdHdr.get(),true,vsr(2,SrTarget::Uhd4K,SrPrescale::P1080),false);- check(linear.ok&&native.ok&&shrunk.ok&&shrunk.enabled&&shrunk.srIn==Extent{1920,1080}&&shrunk.output.width==3840,"HDR prescale: SR reads 1920x1080");- if(linear.ok&&native.ok&&shrunk.ok&&linear.output.width==3840&&native.output.width==3840&&shrunk.output.width==3840){- const auto base=shrink(linear.output,2,true);- const auto sample=[&](unsigned x,unsigned y,unsigned c){- const double px=(x+0.5)*0.5-0.5,py=(y+0.5)*0.5-0.5;const int qx=int(std::floor(px)),qy=int(std::floor(py));- const double fx=px-qx,fy=py-qy;double v=0;- for(int j=0;j<2;++j)for(int i=0;i<2;++i){const int sx=std::clamp(qx+i,0,1919),sy=std::clamp(qy+j,0,1079);- v+=base[(size_t(sy)*1920+sx)*3+c]*(i?fx:1-fx)*(j?fy:1-fy);}- return v;};- const double bound=0.5*203.0/80.0+0.05;double worstNative=0,worstShrunk=0,a=0,b=0;size_t bad=0;- for(unsigned y=0;y<2160;++y)for(unsigned x=0;x<3840;++x)for(unsigned c=0;c<3;++c){- const size_t i=(size_t(y)*3840+x)*4+c;const double n=half(native.output,i),s=half(shrunk.output,i);- if(!std::isfinite(n)||!std::isfinite(s)){++bad;continue;}- worstNative=std::max(worstNative,std::abs(n-half(linear.output,i)));worstShrunk=std::max(worstShrunk,std::abs(s-sample(x,y,c)));a+=n;b+=s;}- check(!bad&&worstNative<=bound,"HDR single step stays within the restore clamp of the full base ("+std::to_string(worstNative)+")");- check(!bad&&worstShrunk<=bound,"HDR prescale restores from the shrunk base ("+std::to_string(worstShrunk)+")");- check(std::abs(b/a-1)<0.03,"HDR prescale keeps the mean brightness (ratio "+std::to_string(b/a)+")");- }- }- ring.shutdown();ctx.shutdown();std::cout<<"STAGE_RESULT passed="<<ok<<std::endl;return ok?0:1;+ ring.shutdown();ctx.shutdown();std::cout<<"DUAL_RESTORE passed="<<ok<<std::endl;return ok?0:1;}int dual(const std::filesystem::path& directory){std::filesystem::create_directories(directory);Logger::instance().openFile((directory/L"engine.log").wstring());@@ -327,58 +309,118 @@ int dual(const std::filesystem::path& directory){const auto h=run(ctx,ring,hdr.get(),true,s,false,false,false,2,true);bool finite=h.ok;for(size_t i=0;finite&&i<h.output.pixels.size()/2;++i)finite=std::isfinite(half(h.output,i));check(finite&&h.evaluations==4&&h.firstLinear.width==3840,"HDR restores the first result before the second reduction and evaluation");- s.dualSrEnabled=false;s.srTarget=pipeline::SrTarget::Uhd8K;s.srOutput=pipeline::SrOutput::Uhd4K;+ s.dualSrEnabled=false;s.srTarget=pipeline::SrTarget::Uhd8K;s.srOutput=pipeline::SrOutput::Target;const auto normal=run(ctx,ring,sdr.get(),false,s,false,false,false,2);- check(normal.ok&&normal.evaluations==2&&normal.output.width==7680,"dual OFF preserves normal 8K output and ignores retired pre/post fields");+ check(normal.ok&&normal.evaluations==2&&normal.output.width==7680,"dual OFF preserves normal 8K output and ignores the kept reduction");ring.shutdown();ctx.shutdown();std::cout<<"DUAL_SR_RESULT passed="<<ok<<std::endl;return ok?0:1;}+// A final output smaller than the source, also with native NR first at the+// source size, and a non-integer reduction of the first AI result.int boundaries(const std::filesystem::path& directory){std::filesystem::create_directories(directory);Logger::instance().openFile((directory/L"engine.log").wstring());gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status status;if(!ctx.initialize({},status)||!ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),4,status))return 2;bool ok=true;- const auto check=[&](bool pass,const char* label){std::cout<<(pass?"PASS ":"FAIL ")<<label<<std::endl;ok=ok&&pass;};- using pipeline::SrTarget;using pipeline::SrPrescale;using pipeline::SrOutput;using pipeline::Extent;- const auto frame=sdrFrame(pattern(3840,2160));if(!frame)return 2;- auto settings=vsr(1,SrTarget::Qhd,SrPrescale::P1080);- const auto down=run(ctx,ring,frame.get(),false,settings,false);- check(down.ok&&down.enabled&&down.work==Extent{2560,1440}&&down.evaluations==6,- "4K -> 1080p -> 2K runs with a chain output smaller than the source");+ const auto check=[&](bool pass,const std::string& label){std::cout<<(pass?"PASS ":"FAIL ")<<label<<std::endl;ok=ok&&pass;};+ using pipeline::SrTarget;using pipeline::SrPrescale;using pipeline::Extent;+ const auto uhd=sdrFrame(pattern(3840,2160)),qhd=sdrFrame(pattern(2560,1440));if(!uhd||!qhd)return 2;+ auto settings=twoPass(1,SrTarget::Uhd4K,SrPrescale::P720,SrTarget::Qhd,1);+ const auto down=run(ctx,ring,uhd.get(),false,settings,false,false,false,3);+ check(down.ok&&down.enabled&&down.srIn==Extent{1280,720}&&down.work==Extent{2560,1440}&&down.evaluations==6,+ "4K -> base 4K -> 720p -> second 2K: the final output may be smaller than the source");settings.nr=true;settings.lowLatency=true;settings.nrPolicy=pipeline::NrSizePolicy::Native;settings.nrTemporal=false;settings.nrMotion=engine::MotionSource::Zero;- const auto nrFirst=run(ctx,ring,frame.get(),false,settings,false);+ const auto nrFirst=run(ctx,ring,uhd.get(),false,settings,false,false,false,3);check(nrFirst.ok&&nrFirst.enabled&&nrFirst.work==Extent{2560,1440}&&nrFirst.evaluations==6,- "native NR at source 4K -> prescale 1080p -> VSR 2K retains the source NR extent");- settings.nr=false;settings.lowLatency=false;settings.srPrescale=SrPrescale::P720;- settings.srTarget=SrTarget::Uhd4K;settings.srOutput=SrOutput::Qhd;- const auto fit=run(ctx,ring,frame.get(),false,settings,false);- check(fit.ok&&fit.enabled&&fit.srIn==Extent{1280,720}&&fit.srOut==Extent{3840,2160}&&fit.work==Extent{2560,1440},- "4K -> 720p -> VSR 4K -> 2K supports a non-integer area resolve");- ring.shutdown();ctx.shutdown();std::cout<<"STAGE_BOUNDARIES passed="<<ok<<std::endl;return ok?0:1;+ "native NR first at the 4K source still runs with a 2K double SR output");+ const auto manual=run(ctx,ring,qhd.get(),false,twoPass(1,SrTarget::Uhd4K,pipeline::srPrescaleForPercent(75),SrTarget::Uhd4K,1),true,false,false,3,true);+ check(manual.ok&&manual.srIn==Extent{2880,1620}&&manual.firstLinear.width==3840&&manual.work==Extent{3840,2160}&&manual.evaluations==6,+ "75 % of the 4K first result is 2880x1620");+ if(manual.ok&&manual.srInput.width==2880&&manual.firstLinear.width==3840){+ const auto expected=area(manual.firstLinear,2880,1620,true);int worst=0;size_t over=0;+ for(size_t p=0;p<size_t(2880)*1620;++p)for(unsigned c=0;c<3;++c){+ const int d=std::abs(int(manual.srInput.pixels[p*4+c])-int(std::lround(encode(expected[p*3+c]))));worst=std::max(worst,d);over+=d>1;}+ check(worst<=2&&over*1000<size_t(2880)*1620*3,"the non-integer reduction equals the exact area average (max "+std::to_string(worst)+", >1: "+std::to_string(over)+")");+ }+ ring.shutdown();ctx.shutdown();std::cout<<"DUAL_BOUNDARIES passed="<<ok<<std::endl;return ok?0:1;}+// Every RTX Video SR quality with each larger second target, a 720p reduction+// and a 21:9 source, through real SDK evaluations of both passes.int capabilities(const std::filesystem::path& directory){std::filesystem::create_directories(directory);Logger::instance().openFile((directory/L"engine.log").wstring());gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status status;if(!ctx.initialize({},status)||!ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),4,status))return 2;- using pipeline::SrTarget;using pipeline::SrPrescale;using pipeline::SrOutput;using pipeline::Extent;- const auto frame=sdrFrame(pattern(3840,2160)),wide=sdrFrame(pattern(3840,1600));if(!frame||!wide)return 2;+ using pipeline::SrTarget;using pipeline::SrPrescale;using pipeline::Extent;+ const auto fhd=sdrFrame(pattern(1920,1080)),wide=sdrFrame(pattern(3840,1600));if(!fhd||!wide)return 2;bool ok=true;unsigned cases=0;for(unsigned quality=1;quality<=4;++quality){for(auto target:{SrTarget::Uhd5K,SrTarget::Uhd6K,SrTarget::Uhd7K,SrTarget::Uhd8K}){- const auto result=run(ctx,ring,frame.get(),false,vsr(quality,target,SrPrescale::P1080,SrOutput::Uhd4K),false,false,false,2);- const bool passed=result.ok&&result.srIn==Extent{1920,1080}&&result.srOut==pipeline::srTargetExtent(target)&&- result.work==Extent{3840,2160}&&result.evaluations==2;- std::cout<<"STAGE_CAPABILITY q="<<quality<<" target="<<uint32_t(target)<<" passed="<<passed<<std::endl;ok=ok&&passed;++cases;+ const auto result=run(ctx,ring,fhd.get(),false,twoPass(quality,SrTarget::Uhd4K,SrPrescale::P1080,target,quality),false,false,false,2);+ const bool passed=result.ok&&result.first==Extent{3840,2160}&&result.srIn==Extent{1920,1080}&&+ result.srOut==pipeline::srTargetExtent(target)&&result.work==pipeline::srTargetExtent(target)&&result.evaluations==4;+ std::cout<<"DUAL_CAPABILITY q="<<quality<<" second="<<uint32_t(target)<<" passed="<<passed<<std::endl;ok=ok&&passed;++cases;}for(bool isWide:{false,true}){- const auto result=run(ctx,ring,isWide?wide.get():frame.get(),false,vsr(quality,SrTarget::Uhd4K,isWide?SrPrescale::P1080:SrPrescale::P720),false,false,false,2);- const bool passed=result.ok&&result.evaluations==2&&result.work==(isWide?Extent{3840,1600}:Extent{3840,2160});- std::cout<<"STAGE_CAPABILITY q="<<quality<<" wide="<<isWide<<" scale="<<(isWide?2:3)<<" passed="<<passed<<std::endl;ok=ok&&passed;++cases;+ const auto result=run(ctx,ring,isWide?wide.get():fhd.get(),false,+ twoPass(quality,SrTarget::Uhd4K,isWide?SrPrescale::P1080:SrPrescale::P720,SrTarget::Uhd4K,quality),false,false,false,2);+ const bool passed=result.ok&&result.evaluations==4&&result.srIn==(isWide?Extent{1920,800}:Extent{1280,720})&&+ result.work==(isWide?Extent{3840,1600}:Extent{3840,2160});+ std::cout<<"DUAL_CAPABILITY q="<<quality<<" wide="<<isWide<<" passed="<<passed<<std::endl;ok=ok&&passed;++cases;}}- ring.shutdown();ctx.shutdown();std::cout<<"STAGE_CAPABILITIES cases="<<cases<<" passed="<<ok<<std::endl;return ok?0:1;+ ring.shutdown();ctx.shutdown();std::cout<<"DUAL_CAPABILITIES cases="<<cases<<" passed="<<ok<<std::endl;return ok?0:1;+}+// Supersampling: one RTX Video SR pass at 8K shrunk to 4K equals the CPU area+// average of the same graph's 8K result (SDR in sRGB; HDR after the per-texel+// restore), the exact source size and a non-integer 2K shrink run, and double+// SR ignores a kept shrink.+int supersample(const std::filesystem::path& directory){+ std::filesystem::create_directories(directory);Logger::instance().openFile((directory/L"engine.log").wstring());+ gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status status;+ if(!ctx.initialize({},status)||!ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),4,status))return 2;+ bool ok=true;+ const auto check=[&](bool pass,const std::string& label){std::cout<<(pass?"PASS ":"FAIL ")<<label<<std::endl;ok=ok&&pass;};+ using pipeline::SrTarget;using pipeline::SrOutput;using pipeline::Extent;+ const auto qhd=pattern(2560,1440);const auto qhdSdr=sdrFrame(qhd),qhdHdr=hdrFrame(qhd),hd=sdrFrame(pattern(1920,1080));+ if(!qhdSdr||!qhdHdr||!hd)return 2;+ const auto shrunk=[](unsigned quality,SrTarget target,SrOutput output){auto s=vsr(quality,target);s.srOutput=output;return s;};+ {+ const auto full=run(ctx,ring,qhdSdr.get(),false,vsr(2,SrTarget::Uhd8K),false);+ const auto fit=run(ctx,ring,qhdSdr.get(),false,shrunk(2,SrTarget::Uhd8K,SrOutput::Uhd4K),false);+ check(full.ok&&full.output.width==7680&&fit.ok&&fit.enabled&&fit.srOut==Extent{7680,4320}&&fit.work==Extent{3840,2160}&&+ fit.output.width==3840&&fit.output.height==2160&&fit.evaluations==6,"SDR: SR writes 7680x4320 once per frame, the chain runs at 3840x2160");+ if(full.ok&&fit.ok&&full.output.width==7680&&fit.output.width==3840){+ const auto reference=shrink(full.output,2,false);int worst=0;size_t over=0,count=0;+ for(size_t p=0;p<size_t(3840)*2160;++p)for(unsigned c=0;c<3;++c){+ const int d=std::abs(int(fit.output.pixels[p*4+c])-int(std::lround(encode(reference[p*3+c]))));worst=std::max(worst,d);over+=d>1;++count;}+ check(worst<=2&&over*200<count,"SDR shrink equals the area average of the 8K result (max "+std::to_string(worst)+", >1: "+std::to_string(over)+")");+ }+ std::cout<<"SUPERSAMPLE_TIMING case=sdr-2k-8k-4k q=2 fullSrMs="<<full.srMs<<" shrinkSrMs="<<fit.srMs<<std::endl;+ }+ {+ const auto full=run(ctx,ring,qhdHdr.get(),true,vsr(2,SrTarget::Uhd8K),false);+ const auto fit=run(ctx,ring,qhdHdr.get(),true,shrunk(2,SrTarget::Uhd8K,SrOutput::Uhd4K),false);+ check(full.ok&&fit.ok&&fit.enabled&&fit.output.width==3840&&full.output.width==7680,"HDR: the 8K SR result is shrunk to 3840x2160");+ if(full.ok&&fit.ok&&full.output.width==7680&&fit.output.width==3840){+ const auto reference=shrink(full.output,2,true);size_t over=0,count=0,bad=0;double worst=0,peak=0;+ for(size_t p=0;p<size_t(3840)*2160;++p)for(unsigned c=0;c<3;++c){+ const double v=half(fit.output,p*4+c),r=reference[p*3+c];if(!std::isfinite(v)){++bad;continue;}+ const double d=std::abs(v-r);worst=std::max(worst,d);peak=std::max(peak,v);over+=d>0.003+0.003*std::abs(r);++count;}+ check(!bad&&over*1000<count,"HDR shrink equals the area average of the 8K restore (worst "+std::to_string(worst)+", over "+std::to_string(over)+", peak "+std::to_string(peak)+")");+ }+ }+ {+ const auto back=run(ctx,ring,qhdSdr.get(),false,shrunk(4,SrTarget::Uhd8K,SrOutput::Source),false,false,false,2);+ check(back.ok&&back.srOut==Extent{7680,4320}&&back.output.width==2560&&back.output.height==1440&&back.evaluations==2,"2K -> 8K -> back to the exact 2560x1440 source");+ const auto twoK=run(ctx,ring,hd.get(),false,shrunk(4,SrTarget::Uhd4K,SrOutput::Qhd),false,false,false,2);+ check(twoK.ok&&twoK.srOut==Extent{3840,2160}&&twoK.output.width==2560&&twoK.output.height==1440,"1080p -> 4K -> a non-integer 2K shrink");+ auto dual=twoPass(2,SrTarget::Uhd8K,pipeline::SrPrescale::P1080,SrTarget::Uhd4K,2);dual.srOutput=SrOutput::Qhd;+ const auto both=run(ctx,ring,hd.get(),false,dual,false,false,false,2);+ check(both.ok&&both.evaluations==4&&both.output.width==3840,"double SR runs both passes and ignores a kept shrink");+ }+ ring.shutdown();ctx.shutdown();std::cout<<"SUPERSAMPLE_RESULT passed="<<ok<<std::endl;return ok?0:1;}-pipeline::SrPrescale prescaleArg(std::wstring_view v){+pipeline::SrPrescale reduceArg(std::wstring_view v){if(v==L"720")return pipeline::SrPrescale::P720;if(v==L"900")return pipeline::SrPrescale::P900;if(v==L"1080")return pipeline::SrPrescale::P1080;if(v==L"1440")return pipeline::SrPrescale::P1440;if(v.ends_with(L"%"))return pipeline::srPrescaleForPercent(unsigned(std::stoi(std::wstring(v.substr(0,v.size()-1)))));@@ -388,23 +430,30 @@ pipeline::SrTarget targetArg(std::wstring_view v){if(v==L"2k")return pipeline::SrTarget::Qhd;if(v==L"5k")return pipeline::SrTarget::Uhd5K;if(v==L"6k")return pipeline::SrTarget::Uhd6K;if(v==L"7k")return pipeline::SrTarget::Uhd7K;if(v==L"8k")return pipeline::SrTarget::Uhd8K;return pipeline::SrTarget::Uhd4K;}-pipeline::SrOutput outputArg(std::wstring_view v){+pipeline::SrOutput shrinkArg(std::wstring_view v){if(v==L"source")return pipeline::SrOutput::Source;if(v==L"2k")return pipeline::SrOutput::Qhd;if(v==L"4k")return pipeline::SrOutput::Uhd4K;- if(v==L"5k")return pipeline::SrOutput::Uhd5K;if(v==L"6k")return pipeline::SrOutput::Uhd6K;if(v==L"7k")return pipeline::SrOutput::Uhd7K;return pipeline::SrOutput::Target;+ if(v==L"5k")return pipeline::SrOutput::Uhd5K;if(v==L"6k")return pipeline::SrOutput::Uhd6K;if(v==L"7k")return pipeline::SrOutput::Uhd7K;+ return pipeline::SrOutput::Target;}-// One A/B picture: <dir> stage-image <input.png> <name> <quality 0..4> <prescale> <target> <output> [video|still|capture]-int image(const std::filesystem::path& directory,const std::wstring& input,const std::wstring& name,unsigned quality,- std::wstring_view prescale,std::wstring_view target,std::wstring_view output,std::wstring_view mode){+// One A/B picture: <dir> sr-image <input.png> <name> <quality 0..4> <target> <shrink off|source|2k..7k>+// <reduce off|720|900|1080|1440|NN%> <second-target> <second-quality> [video|still|capture]+// Quality 0 leaves SR off; a shrink supersamples one pass; reduce "off" keeps a single pass.+int image(const std::filesystem::path& directory,const std::wstring& input,const std::wstring& name,unsigned quality,std::wstring_view target,+ std::wstring_view shrinkTo,std::wstring_view reduce,std::wstring_view second,unsigned secondQuality,std::wstring_view mode){std::filesystem::create_directories(directory);Logger::instance().openFile((directory/(name+L".log")).wstring());sink::RgbaImage source;if(!sink::loadImage(input,source))return 2;gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status status;if(!ctx.initialize({},status)||!ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),4,status))return 2;const auto frame=sdrFrame(source);if(!frame)return 2;- const auto r=run(ctx,ring,frame.get(),false,vsr(quality,targetArg(target),prescaleArg(prescale),outputArg(output)),false,mode==L"still",mode==L"capture");+ auto settings=quality&&reduce!=L"off"?twoPass(quality,targetArg(target),reduceArg(reduce),targetArg(second),secondQuality):vsr(quality,targetArg(target));+ settings.srOutput=shrinkArg(shrinkTo);+ const auto r=run(ctx,ring,frame.get(),false,settings,false,mode==L"still",mode==L"capture");std::error_code ec;std::filesystem::remove(directory/(name+L".png"),ec); // saveImage never replaces a fileconst bool saved=r.ok&&sink::saveImage((directory/(name+L".png")).wstring(),r.output,false);- std::cout<<"STAGE_IMAGE name="<<std::string(name.begin(),name.end())<<" source="<<source.width<<'x'<<source.height<<" srInput="<<r.srIn.width<<'x'<<r.srIn.height<<" srOutput="<<r.srOut.width<<'x'<<r.srOut.height- <<" output="<<r.output.width<<'x'<<r.output.height<<" srActive="<<r.enabled<<" evaluations="<<r.evaluations<<" srMs="<<r.srMs<<" passed="<<saved<<std::endl;+ char label[1024]{};WideCharToMultiByte(CP_UTF8,0,name.c_str(),-1,label,sizeof(label),nullptr,nullptr);+ std::cout<<"SR_IMAGE name="<<label<<" source="<<source.width<<'x'<<source.height<<" first="<<r.first.width<<'x'<<r.first.height+ <<" srInput="<<r.srIn.width<<'x'<<r.srIn.height<<" srOutput="<<r.srOut.width<<'x'<<r.srOut.height<<" output="<<r.output.width<<'x'<<r.output.height+ <<" srActive="<<r.enabled<<" evaluations="<<r.evaluations<<" srMs="<<r.srMs<<" passed="<<saved<<std::endl;ring.shutdown();ctx.shutdown();return saved?0:1;}}@@ -414,12 +463,13 @@ int wmain(int argc,wchar_t** argv){if(argc<2)return 2;const HRESULT com=CoInitializeEx(nullptr,COINIT_MULTITHREADED);if(FAILED(com))return 2;- if(argc==3&&std::wstring_view(argv[2])==L"stage"){const int result=stage::test(argv[1]);CoUninitialize();return result;}if(argc==3&&std::wstring_view(argv[2])==L"dual"){const int result=stage::dual(argv[1]);CoUninitialize();return result;}- if(argc==3&&std::wstring_view(argv[2])==L"stage-boundaries"){const int result=stage::boundaries(argv[1]);CoUninitialize();return result;}- if(argc==3&&std::wstring_view(argv[2])==L"stage-capabilities"){const int result=stage::capabilities(argv[1]);CoUninitialize();return result;}- if(argc>=9&&std::wstring_view(argv[2])==L"stage-image"){- const int result=stage::image(argv[1],argv[3],argv[4],unsigned(std::stoi(argv[5])),argv[6],argv[7],argv[8],argc>9?argv[9]:L"video");+ if(argc==3&&std::wstring_view(argv[2])==L"dual-restore"){const int result=stage::restore(argv[1]);CoUninitialize();return result;}+ if(argc==3&&std::wstring_view(argv[2])==L"dual-boundaries"){const int result=stage::boundaries(argv[1]);CoUninitialize();return result;}+ if(argc==3&&std::wstring_view(argv[2])==L"dual-capabilities"){const int result=stage::capabilities(argv[1]);CoUninitialize();return result;}+ if(argc==3&&std::wstring_view(argv[2])==L"supersample"){const int result=stage::supersample(argv[1]);CoUninitialize();return result;}+ if(argc>=11&&std::wstring_view(argv[2])==L"sr-image"){+ const int result=stage::image(argv[1],argv[3],argv[4],unsigned(std::stoi(argv[5])),argv[6],argv[7],argv[8],argv[9],unsigned(std::stoi(argv[10])),argc>11?argv[11]:L"video");CoUninitialize();return result;}if(argc>5&&(std::wstring_view(argv[2])==L"reference"||std::wstring_view(argv[2])==L"models")){diff --git a/tests/unit/EffectChainTests.cpp b/tests/unit/EffectChainTests.cppindex 5d9b4d2b..0810a420 100644--- a/tests/unit/EffectChainTests.cpp+++ b/tests/unit/EffectChainTests.cpp@@ -1507,7 +1507,10 @@ static void testThreeStepSr(){check(off.activeVideoSettings().srPrescale==SrPrescale::Off&&dlss.activeVideoSettings().srPrescale==SrPrescale::Off,"three-step SR: SR off and other backends normalize the fields");auto before=s;before.srPrescale=SrPrescale::Off;auto output=s;output.srOutput=SrOutput::Qhd;- check(requiresGraphRebuild(before,s)&&!requiresGraphRebuild(s,output),"double SR: reduction rebuilds, retired post-fit does not change the graph");+ check(requiresGraphRebuild(before,s)&&!requiresGraphRebuild(s,output),"double SR: reduction rebuilds, the kept shrink is inactive under double SR");+ auto single=s;single.dualSrEnabled=false;auto shrunk=single;shrunk.srOutput=SrOutput::Uhd4K;+ check(requiresGraphRebuild(single,shrunk)&&shrunk.activeVideoSettings().srOutput==SrOutput::Uhd4K&&+ output.activeVideoSettings().srOutput==SrOutput::Target,"supersample: the shrink rebuilds a single RTX Video SR pass only");auto dlssBefore=before;dlssBefore.videoSrQuality=0;check(!requiresGraphRebuild(dlssBefore,dlss),"three-step SR: inactive edits do not rebuild the graph");EnhancementSettings restored;ChainGlobalSettings::capture(output).apply(restored);@@ -1517,6 +1520,47 @@ static void testThreeStepSr(){}}+// Supersampling (2026-10-28): one RTX Video SR pass evaluates at its target and is+// shrunk before every later effect, so NR and FG never run at the larger size.+static void testSupersampleSr(){+ using namespace veyra;using pipeline::Extent;using pipeline::SrOutput;using pipeline::SrTarget;+ EnhancementSettings s;s.sr=true;s.nr=true;s.lowLatency=false;s.nrPolicy=pipeline::NrSizePolicy::Native;+ s.videoSrQuality=4;s.srTarget=SrTarget::Uhd8K;s.srOutput=SrOutput::Uhd4K;s.multiplier=2;+ StageRequest r;r.width=1920;r.height=1080;r.sr=true;r.nr=true;r.fg=true;r.nvidiaAdapter=true;+ pipeline::EnhanceGraphDesc d;auto p=describeStages(r,s,d);+ check(d.enableSr&&!d.dualSr&&d.srInputWidth==1920&&d.srOutputWidth==7680&&d.srOutputHeight==4320&&d.workWidth==3840&&d.workHeight==2160&&+ d.validateFixedExecutionPlan().empty(),"supersample: 1080p evaluates 8K and the chain continues at 4K");+ bool layers=!d.nrLayersExtent.empty();for(const auto e:d.nrLayersExtent)layers=layers&&e==Extent{3840,2160};+ check(d.enableNr&&d.nrWidth==3840&&d.nrHeight==2160&&layers&&p.fg==Extent{3840,2160}&&p.output==Extent{3840,2160},+ "supersample: NR and FG run at the shrunk 4K, never at 8K");+ for(const bool exporting:{true,false}){+ auto q=r;q.exportJob=exporting;q.stillImage=!exporting;q.fg=false;describeStages(q,s,d);+ check(d.srOutputWidth==7680&&d.workWidth==3840&&d.validateFixedExecutionPlan().empty(),+ exporting?"supersample: exports use the same sizes":"supersample: still images use the same sizes");+ }+ {+ auto source=s;source.srOutput=SrOutput::Source;auto q=r;q.width=2560;q.height=1440;p=describeStages(q,source,d);+ check(d.srOutputWidth==7680&&d.workWidth==2560&&d.workHeight==1440,"supersample: 2K -> 8K -> back to the exact source size");+ auto qhd=s;qhd.srTarget=SrTarget::Uhd4K;qhd.srOutput=SrOutput::Qhd;describeStages(r,qhd,d);+ check(d.srOutputWidth==3840&&d.workWidth==2560&&d.workHeight==1440&&d.validateFixedExecutionPlan().empty(),+ "supersample: 1080p -> 4K -> a non-integer 2K shrink");+ auto none=s;none.srTarget=SrTarget::Uhd4K;none.srOutput=SrOutput::Qhd;auto q4k=r;q4k.width=3840;q4k.height=2160;+ p=describeStages(q4k,none,d);+ check(p.srOutputIneffective&&d.workWidth==3840&&d.srOutputWidth==3840,"supersample: no enlargement leaves the shrink unapplied and reported");+ }+ {+ auto dual=s;dual.dualSrEnabled=true;dual.srPrescale=pipeline::SrPrescale::P1080;dual.dualSrTarget=SrTarget::Uhd4K;describeStages(r,dual,d);+ check(d.dualSr&&d.firstSrWidth==7680&&d.srOutputWidth==3840&&d.workWidth==3840,"supersample: double SR keeps its own second target and ignores the shrink");+ for(const unsigned backend:{0u,kVideoSrFsr}){+ auto other=s;other.videoSrQuality=backend;describeStages(r,other,d);+ check(d.workWidth==7680&&d.srOutputWidth==7680&&other.activeVideoSettings().srOutput==SrOutput::Target,+ "supersample: DLSS SR and FSR keep their single step");+ }+ auto amd=r;amd.nvidiaAdapter=false;describeStages(amd,s,d);+ check(d.srOutputWidth==d.workWidth,"supersample: other adapters keep the single step");+ }+}+int main() {{using namespace veyra;using namespace veyra::engine;@@ -1591,13 +1635,19 @@ int main() {testBeautySettingsChain();testWideChains();testThreeStepSr();+ testSupersampleSr();{using namespace veyra;using pipeline::SrTarget;using pipeline::SrPrescale;using pipeline::SrOutput;EnhancementSettings s;s.sr=true;s.nr=false;s.videoSrQuality=2;s.srTarget=SrTarget::Uhd8K;s.srPrescale=SrPrescale::P1080;s.srOutput=SrOutput::Uhd4K;StageRequest r;r.width=2560;r.height=1440;r.sr=true;pipeline::EnhanceGraphDesc d;auto p=describeStages(r,s,d);- check(!d.dualSr&&d.workWidth==7680&&d.srInputWidth==2560,"dual off restores ordinary 8K and ignores retired pre/post fields");+ check(!d.dualSr&&d.srInputWidth==2560&&d.srOutputWidth==7680&&d.workWidth==3840&&d.validateFixedExecutionPlan().empty(),+ "dual off: the kept reduction is unused and the 4K shrink supersamples the 8K pass");+ {+ auto plain=s;plain.srOutput=SrOutput::Target;pipeline::EnhanceGraphDesc o;describeStages(r,plain,o);+ check(!o.dualSr&&o.workWidth==7680&&o.srOutputWidth==7680,"dual off without a shrink keeps ordinary 8K");+ }s.dualSrEnabled=true;s.dualSrTarget=SrTarget::Uhd4K;s.dualSrQuality=1;p=describeStages(r,s,d);check(d.dualSr&&d.firstSrWidth==7680&&d.srInputWidth==1920&&d.srOutputWidth==3840&&d.workWidth==3840&&d.dualSrQuality==1&&d.videoSrQuality==2&&d.validateFixedExecutionPlan().empty(),