Skip to content

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++

Add RTX Video SR families and mixed dual SR stages

Veyra Goal Agentba00ce310e49
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fa5e9ee8..c1c00916 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -384,6 +384,7 @@ add_library(veyra_pipeline STATIC
src/pipeline/LmxxfNrBackend.cpp
src/pipeline/Rdna3NrBackend.cpp
src/pipeline/VfgBackend.cpp
+ src/pipeline/VfxSrBackend.cpp
)
veyra_apply_warnings(veyra_pipeline)
# FFmpeg/NVOF headers are third-party: /WX stays off for this target.
@@ -1457,6 +1458,10 @@ add_executable(veyra_sr_reconstruction_tests tests/integration/SrReconstructionT
target_compile_features(veyra_vfg_export_probe PRIVATE cxx_std_20)
target_compile_options(veyra_vfg_export_probe PRIVATE /utf-8)
target_link_libraries(veyra_vfg_export_probe PRIVATE veyra_engine)
+ add_executable(veyra_video_ai_export_probe tests/integration/VideoAiExportProbe.cpp)
+ target_compile_features(veyra_video_ai_export_probe PRIVATE cxx_std_20)
+ target_compile_options(veyra_video_ai_export_probe PRIVATE /utf-8)
+ target_link_libraries(veyra_video_ai_export_probe PRIVATE veyra_engine)
add_executable(veyra_preset_library_tests tests/unit/PresetLibraryTests.cpp src/engine/PresetLibrary.cpp src/engine/EffectChain.cpp)
target_link_options(veyra_preset_library_tests PRIVATE /STACK:33554432) # Preset apply recurses over 21 KB ChainConfiguration frames; the default 1 MB stack is too close to the edge.
add_executable(veyra_hdr_tuning_tests tests/unit/HdrOutputTuningTests.cpp src/engine/PresetLibrary.cpp src/engine/EffectChain.cpp)
@@ -1474,6 +1479,13 @@ target_link_options(veyra_hdr_tuning_tests PRIVATE /STACK:33554432)
target_compile_definitions(veyra_vfg_settings_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)
target_include_directories(veyra_vfg_settings_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(veyra_vfg_settings_tests PRIVATE veyra_base)
+ add_executable(veyra_video_ai_settings_tests tests/unit/VideoAiSettingsTests.cpp src/engine/PresetLibrary.cpp src/engine/PresetStore.cpp src/engine/EffectChain.cpp)
+ target_compile_features(veyra_video_ai_settings_tests PRIVATE cxx_std_20)
+ target_compile_options(veyra_video_ai_settings_tests PRIVATE /utf-8)
+ target_compile_definitions(veyra_video_ai_settings_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)
+ target_include_directories(veyra_video_ai_settings_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
+ target_link_libraries(veyra_video_ai_settings_tests PRIVATE veyra_base)
+ target_link_options(veyra_video_ai_settings_tests PRIVATE /STACK:33554432)
add_executable(veyra_effect_availability_tests tests/unit/EffectAvailabilityTests.cpp)
target_compile_features(veyra_effect_availability_tests PRIVATE cxx_std_20)
target_include_directories(veyra_effect_availability_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.md
index a67732e2..2d2989a4 100644
--- a/docs/CURRENT_STATUS.md
+++ b/docs/CURRENT_STATUS.md
@@ -1,5 +1,7 @@
# 当前项目状态
+**2026-11-05 RTX 视频超分三个版本与双重超分(未合并)**:分支 `claude/vsr-rife-20261105`(基于 main `8eda262`)把超分整理为标准 / 高码率 / 流媒体加档位,双重超分和超采样适配三个版本;RIFE 已按用户要求删除。本机 RTX 5070 导出、实际界面与回归测试通过;未提交、未合并 main、未打包或发布。详见[记录](RTX_VIDEO_SR_FAMILIES_2026-11-05.md),回执 `E:/项目/Veyra/reports/claude-vsr-rife-20261105/FINAL.json`。
+
**2026-11-05 补帧延迟预算实验终止**:用户决定按失败方向删除;独立分支和测试入口已移除,未进入main/正式包。活动树回main,产品代码保持fedd7fc,仅记录终止结论。停止研究,不再把“预读生效”当作性能收益。详见[终止记录](FG_LATENCY_BUDGET_RETIRED_2026-11-05.md)。
**当前正式版2.1.2(2026-11-02)**:用户授权公开发行,main和v2.1.2/v2.1.2-sources已推送;发行准备899590f,程序构建358be8c(EXE33d8e615…),使用Claude最新去重包的原程序字节。两显卡包及源码已发布,服务端摘要、匿名下载、Latest与两张二维码核验通过。[完整更新](RELEASE_NOTES_2.1.2.md) · [构建/源码](BUILD_2.1.2.md) · [发行记录](RELEASE_2.1.2_EXECUTION_2026-11-02.md)。正式产物releases/codex-release-2.1.2-20261102,FINAL回执reports/codex-release-2.1.2-20261102。
diff --git a/docs/RTX_VIDEO_SR_FAMILIES_2026-11-05.md b/docs/RTX_VIDEO_SR_FAMILIES_2026-11-05.md
new file mode 100644
index 00000000..ca1b07a1
--- /dev/null
+++ b/docs/RTX_VIDEO_SR_FAMILIES_2026-11-05.md
@@ -0,0 +1,153 @@
+# RTX 视频超分三个版本(标准 / 高码率 / 流媒体)与双重超分(2026-11-05,Claude)
+
+## 用户要求与当前状态
+
+- **第一轮**:“把Video Super Resolution和RIFE 都加到软件里,开新的分支来做”。
+- **第二轮(当前范围)**:
+ - “RIFE整个删掉,因为此前已经接入了30系的VFG补丁”;
+ - RTX 新的视频超分整合为“高码率就高码率、流媒体就流媒体,然后在里面选择档位”;
+ - 原来的 1234 档位改成低中高超高;
+ - 双重超分适配到高码率和流媒体。
+
+| 项目 | 内容 |
+|---|---|
+| 分支 | `claude/vsr-rife-20261105`,基于 main `8eda262`,独立工作树 `worktrees/claude-vsr-rife-20261105`;分支名保留第一轮的写法 |
+| 状态 | **未提交、未合并 main、未 push、未发布、未打包** |
+| 回执 | `E:/项目/Veyra/reports/claude-vsr-rife-20261105/FINAL.json` |
+| 手动测试入口 | `E:/项目/Veyra/tests/claude-vsr-rife-20261105/启动RTX视频超分测试.cmd`(私有配置、日志、临时目录;运行目录是私有的 `tests/claude-vsr-rife-20261105/app`) |
+
+- **前置调研**:`E:/项目/Veyra/reports/claude-video-sr-fi-survey-20261105/FINDINGS.md`。
+- **Codex 的共用施工树和共享运行目录** `tests/claude-sr-stage-20261028/app` 都没动。
+
+## 为什么删掉 RIFE
+
+- **用户实测**:4K 30 fps 下 RIFE 2X 每对帧预计 35–40 ms,超过 33 ms 预算,部分帧对被拒绝。
+- **本机补测**:导出串行、每个源帧多出的时间如下。
+
+ | 补帧 | 1080p | 4K |
+ |---|---|---|
+ | VFG 中 | +2.2 ms | +6.6 ms |
+ | VFG 高 | +15.1 ms | +13.2 ms |
+ | RIFE | +9.0 ms | +32.1 ms |
+
+- **画质**:对 60 fps 真值,RIFE 25.08 dB,VFG 中 25.36 dB,RIFE 不占优。
+- **适用面**:RIFE 原本只对没有 VFG 的 30 系有意义;30 系 VFG 兼容由 Codex 在 `codex/vfg-ampere-20261102`(`edad6e9`)上完成。**它不在 main,也不在本分支**;两边都改了 `EffectAvailability.h`、`Hardware.cpp`、`i18n/catalog.json`,合并时要注意(`ampere` 字段和“GeForce RTX 30”判断已与该分支写成一样)。
+- **代码处理**:RIFE 的全部代码已删除:worker、协议、后端、着色器、`PairFrameGenerator` 接口、补帧后端值 5、界面、节点、预设和翻译。补帧相关文件全部回到 main 原样,VfgBackend 也未改动。
+- **下载和依赖保留在本机,没有删除**(约 1.6 GB):
+ - `downloads/claude-vsr-rife-20261105`(1.1 GB);
+ - `deps/claude-vsr-rife-20261105`(241 MB);
+ - `build/claude-vsr-rife-20261105/bench`(247 MB,基准程序)。
+
+ 是否删除由用户决定。测试程序里的 RIFE 运行组件(343 MB 副本)已删除。
+
+## 用户能看到的变化
+
+- **“超分算法”下拉**改为:DLSS SR、RTX 视频超分 · 标准、RTX 视频超分 · 高码率、RTX 视频超分 · 流媒体、FSR。
+- **“档位”**(原“质量 1/2/3/4”)改为“低 / 中 / 高 / 超高”。
+ - 流媒体只有中和超高两档:SDK 只有 21 和 23 两个模式。
+ - 在三个版本之间切换时保留档位;从流媒体以外切到流媒体时,低/中对应中,高/超高对应超高。
+- **双重超分**三个版本都能开。
+ - 第二次超分有自己的“第二次超分算法”(三个版本可选,可与基础不同)和“第二次超分档位”。
+ - 任意组合都能跑,例如流媒体先清理压缩痕迹,再用高码率保留细节。
+- **“超分后缩回到”**(超采样)三个版本也都能用。
+- **卡片摘要**示例:“RTX 视频超分 · 流媒体 · 4K→1080p→4K · 中 / 高码率 超高”。
+- **高码率和流媒体只做放大**:片源已经达到目标尺寸时不运行,超分区下方会提示“同尺寸修复请用标准”。只有标准版本会做同尺寸修复。
+- **可用性**:标准需要 RTX;高码率需要 RTX 加 Video Effects 运行组件;流媒体还要求 RTX 30 及更新。
+
+## 设计
+
+- **存储值不变**,沿用 SDK 编号:标准 1–4,高码率 16–19,流媒体 21/23,DLSS 0,FSR 5。
+ - 新增 `VideoSrFamily` 及 `videoSrFamily / videoSrTier / videoSrQualityFor / rtxVideoSr / ngxVideoSr`。
+ - 原 `srStageBackend` 只表示标准,改名 `ngxVideoSr`。双重、超采样、先降的判断改用 `rtxVideoSr`(三个版本)。
+- **界面桥接**新增 `srAlgorithmOf / srTierOf / srQualityFor / srTierChoices / srQualityLabel`。
+ - 算法 id:`rtx` / `rtx-hb` / `rtx-st`,DLSS 和 FSR 仍用数字。
+ - 列表、节点和保存预设的摘要共用这些函数。
+- **每一次超分各自选运行库**:
+ - 最终一次用 `dualSrQuality`(双重时)或 `videoSrQuality`;第一次(仅双重)用 `videoSrQuality`。
+ - 标准走 NGX;高码率和流媒体各自是一个 `VfxSrBackend` 实例。
+ - 只有用到标准时才创建 NGX。
+ - 两个 NGX 实例共用创建键时,沿用原来的复用规则。
+- **Video Effects 交接**:拷入 → 提交 → 队列信号 → CUDA 运行 → 队列等待 → 在同一槽的下一个命令列表拷出,图的队列上没有 CPU 等待。
+ - CUDA 流必须是阻塞流:VideoSuperRes 有一部分工作排在旧式默认流上;非阻塞流会读到旧输入、输出错帧。第一轮已修复,见下。
+- **双重时第一次为 Video Effects 但不放大**(片源已达到基础目标):第一次结果直接复制片源。日志记为 `firstRuntime=copy`。
+- **显存准入**:
+ - 计入 Video Effects 每次超分的共享输入、输出缓冲;
+ - 双重或超采样时,每个已加载模型预留 256 MiB(NGX 共用一份,每个 Video Effects 实例一份)。这是估算,不是测得的 SDK 峰值。
+- **设置可用性检查**也覆盖第二次超分的版本。
+
+## 持久化
+
+- **设置预设**(PresetStore):基础或第二次超分用到 16–23 时写 v35,否则保持原版本(标准双重仍是 v34)。
+- **预设库**(v18)和**模式会话**(v13):用到 16–23 时写到 `.video-ai` 附属文件,旧文件字节不变,旧版本读到的仍是旧文件。
+- **导出 worker 协议未改**:新值不改变字段布局。
+
+## 依赖(不进 Git)
+
+- **运行库**:高码率和流媒体需要 `runtime/nvidia-vfg` 里的 `nvVFXVideoSuperRes.dll` 和 `nvngx_vsr.dll` 1.8.3.0,来自 `deps/vfg-python-20261003/nvvfx/libs`(`nvidia-vfx` 0.2.0.0,SDK 1.3.0,也是现有 VFG 运行库的来源)。
+- **与原有标准超分的关系**:实验区 `runtime/experimental/nvngx_vsr.dll` 1.6.0.0 供标准(NGX)使用,两者互不影响。
+- **打包清单尚未加入这两个文件**(42 KB 和 56.4 MB)。
+
+## 验证(本机 RTX 5070,compute 12.0,2026-11-05)
+
+素材:项目内只有合成测试图,所以用仓库里的真实游戏截图做了一个平移视频,放在 `tests/claude-vsr-rife-20261105/media`(720p 和 540p,另有 60 fps 真值)。
+
+### 导出探针 `veyra_video_ai_export_probe`(每组 60 帧)
+
+- **结果**:全部 ok,输出帧数与尺寸正确。
+- **检查方法**:输出逐帧对齐源帧(灰度 320×180 MAE,看是否与相邻帧更像)。
+
+| 组合 | 实际运行库 | 输出 | 与源帧偏差 | 错位帧 |
+|---|---|---|---|---|
+| 标准 超高,720p→1440p | NGX | 2560×1440 | 2.38 | 0 |
+| 高码率 超高,720p→1440p | Video Effects | 2560×1440 | 2.28 | 0 |
+| 流媒体 超高,720p→1440p | Video Effects | 2560×1440 | 5.13 | 0 |
+| 双重:高码率 超高 → 1080p → 流媒体 超高 | VFX + VFX | 3840×2160 | 4.26 | 0 |
+| 双重:标准 超高 → 1080p → 高码率 超高 | NGX + VFX | 3840×2160 | 2.32 | 0 |
+| 双重:高码率 超高 → 1080p → 标准 超高 | VFX + NGX | 3840×2160 | 2.31 | 0 |
+| 双重:标准 → 标准(回归) | NGX + NGX | 3840×2160 | 2.41 | 0 |
+| 超采样:高码率 中,4K 再缩回 1440p | Video Effects | 2560×1440 | 2.21 | 0 |
+| 双重:4K 片源,高码率 → 1080p → 流媒体 中 | 复制 + VFX | 3840×2160 | 3.42 | 0 |
+
+### 各模式耗时(1080p→4K,串行导出每帧总时间;解码和编码相同,只看差值)
+
+| 版本 | 低 | 中 | 高 | 超高 |
+|---|---|---|---|---|
+| 标准 | 7.1 ms | 7.3 ms | 7.3 ms | 8.6 ms |
+| 高码率 | 6.9 ms | 6.9 ms | 8.1 ms | 12.2 ms |
+| 流媒体 | — | 7.3 ms | — | 12.4 ms |
+
+- 画面对比:`reports/claude-vsr-rife-20261105/sr-modes-labeled*.png`。
+- 高码率保留细纹理;流媒体清理最强,可能放大细纹;标准介于两者之间。
+- 测试素材是拍显示器的照片,带细竖纹,实际片源请以用户自己的为准。
+
+### 实际界面
+
+- **新夹具 `scripts/acceptance/sr-families-ui.qml`**:私有运行脚本 `tmp/claude-vsr-rife-20261105/ui_runner.py`,与 `sr-stage-ui.py` 相同的 Loader 注入,但用本任务的私有测试程序。
+ - 覆盖:
+ - 标准 → 高码率保留档位 → 中 → 流媒体(只剩中/超高);
+ - 开双重 → 第二次换高码率 → 改低 → 基础换回标准;
+ - 卡片摘要。
+ - 结果:15 项检查全部通过,无错误、无 QML 报错。
+ - 截图:`tests/claude-vsr-rife-20261105/sr-families-ui.png`。
+ - 日志里实际出现了“流媒体+标准”“流媒体+高码率”“标准+高码率”三种双重组合。
+- **原有回归夹具 `dual-sr-ui.qml`**(只把摘要断言改成新格式):1080p 片源,21 项检查全部通过。覆盖普通 8K、8K→4K 超采样、双重、节点双重 8K,以及 4K 双重 + NR + VFG。
+
+### 单元与回归测试
+
+| 测试 | 结果 |
+|---|---|
+| 新 `veyra_video_ai_settings_tests` | 240 / 0(档位映射、校验、双重/超采样的实际计划、三种存储与旧文件保护) |
+| VFG 设置 | 683 / 0 |
+| 效果可用性 | 72 / 0 |
+| 效果链、预设库、NR 模型设置、UI 合同 | 通过 |
+| 翻译 | 0 失败;`extract.py --check` 缺失 0 |
+| QtQuick | 132 / 0 / 1 |
+| 补帧设置集成(两种模式) | 各 16 / 0 |
+
+## 未验证 / 已知限制
+
+- **硬件**:只在本机 RTX 5070 上测过;20/30/40 系、笔记本、多显卡都没测。
+- **HDR/PQ 内容**:经 Video Effects 超分的效果未验证(走现有 RGBA8 代理)。
+- **同尺寸修复**:高码率和流媒体不做(SDK 的放大模式),只有标准做。
+- **打包与授权**:打包清单未加入新运行库;再分发按现有 VFG 运行库的同一来源处理,发布前需要核对。
+- **显存预留**:是估算,不是测得的 SDK 峰值。
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 39677b85..977248d2 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -2,6 +2,16 @@
完整旧日志:[截至本轮整理前的记录](history/worklog/WORKLOG_before_maintenance_2026-10-27.md)。当前状态见[CURRENT_STATUS](CURRENT_STATUS.md),历史授权见[历史索引](history/INDEX.md)。
+## 2026-11-05 RTX 视频超分三个版本与双重超分(Claude,未提交)
+
+分支 `claude/vsr-rife-20261105`(基于 main `8eda262`,独立工作树),未提交、未合并、不 push/Release。记录见 [RTX_VIDEO_SR_FAMILIES_2026-11-05](RTX_VIDEO_SR_FAMILIES_2026-11-05.md)。
+
+- 第一轮加入了 Video Effects VideoSuperRes 和 RIFE。用户实测 RIFE 在 4K 比 VFG 高档贵得多(本机 4K 每源帧 +32 ms,VFG 高 +13 ms,中 +7 ms),且 30 系 VFG 兼容已在 `codex/vfg-ampere-20261102`,按用户要求整个删除 RIFE,补帧代码回到 main 原样。
+- 超分算法改为 RTX 视频超分 · 标准 / 高码率 / 流媒体,各自选档位(低中高超高,流媒体只有中和超高),原 1234 改为低中高超高。
+- 双重超分和超采样适配三个版本,第二次超分可选不同版本;每次超分各自走 NGX 或 Video Effects,第一次不放大时直接复制。VideoSuperRes 必须用阻塞 CUDA 流(第一轮发现并修复的错帧)。
+- 验证:导出 9 组(含四种双重运行库组合)全部逐帧对齐;实际界面新夹具 15 项、原双重夹具 21 项通过;新单测 240/0,VFG 设置 683/0,QtQuick 132/0/1,补帧集成两种模式通过。
+- 未做:打包清单、其他显卡、HDR 内容;RIFE 下载与依赖约 1.6 GB 仍在本机,待用户决定是否删除。
+
## 2026-10-27 屏幕捕获帧率、采集对白与后续方向(Claude)
用户要求:屏幕捕获60帧只有55(日志67)、采集对白很轻(日志68)、后续方向只调研。分支claude/capture-fps-audio-20261027从main 7b0b64b;用户Veyra运行中,未停止、未占采集卡;不push/Release。报告[CAPTURE_FPS_AUDIO_REPORT_2026-10-27](CAPTURE_FPS_AUDIO_REPORT_2026-10-27.md),证据reports/claude-capture-fps-audio-20261027。
diff --git a/i18n/catalog.json b/i18n/catalog.json
index 4e064f13..880f61fe 100644
--- a/i18n/catalog.json
+++ b/i18n/catalog.json
@@ -294,13 +294,6 @@
"en": " · Range candidate (verified on connection)",
"ja": " · 範囲内の候補(接続時に検証)"
},
- {
- "zh": " · 质量 ",
- "src": "qml/ProPage.qml",
- "zh-TW": " · 品質 ",
- "en": " · quality ",
- "ja": " · 品質 "
- },
{
"zh": " · 还原",
"src": "qml/ColourPanel.qml",
@@ -1947,11 +1940,25 @@
"ja": "RTX ビデオ超解像"
},
{
- "zh": "RTX 视频超分,独立于基础超分质量",
- "src": "qml/SrStageEditor.qml",
- "zh-TW": "RTX 視訊超分,獨立於基礎超分品質",
- "en": "RTX Video SR, independent of the base SR quality",
- "ja": "RTX Video SR。基本超解像とは独立した品質設定"
+ "zh": "RTX 视频超分 · 标准",
+ "src": "src/ui/bridge/Hardware.cpp",
+ "zh-TW": "RTX 影片超解析 · 標準",
+ "en": "RTX Video SR · Standard",
+ "ja": "RTX 超解像 · 標準"
+ },
+ {
+ "zh": "RTX 视频超分 · 流媒体",
+ "src": "src/ui/bridge/Hardware.cpp",
+ "zh-TW": "RTX 影片超解析 · 流媒體",
+ "en": "RTX Video SR · Streaming",
+ "ja": "RTX 超解像 · ストリーミング"
+ },
+ {
+ "zh": "RTX 视频超分 · 高码率",
+ "src": "src/ui/bridge/Hardware.cpp",
+ "zh-TW": "RTX 影片超解析 · 高位元率",
+ "en": "RTX Video SR · High bitrate",
+ "ja": "RTX 超解像 · 高ビットレート"
},
{
"zh": "RX 7000 / 9000 · AMD NR(实验)",
@@ -11251,6 +11258,13 @@
"en": "Format and picture",
"ja": "フォーマットと映像"
},
+ {
+ "zh": "档位",
+ "src": "qml/SrStageEditor.qml",
+ "zh-TW": "檔位",
+ "en": "Tier",
+ "ja": "段階"
+ },
{
"zh": "检查",
"src": "qml/SettingsPage.qml",
@@ -12133,6 +12147,13 @@
"en": "Magenta",
"ja": "マゼンタ"
},
+ {
+ "zh": "流媒体",
+ "src": "src/ui/bridge/Enhancement.cpp",
+ "zh-TW": "流媒體",
+ "en": "Streaming",
+ "ja": "ストリーミング"
+ },
{
"zh": "流畅",
"src": "src/engine/PresetLibrary.cpp",
@@ -12525,6 +12546,13 @@
"en": "Status: %1",
"ja": "状態:%1"
},
+ {
+ "zh": "独立于基础超分,可以换成另一种 RTX 视频超分。",
+ "src": "qml/SrStageEditor.qml",
+ "zh-TW": "獨立於基礎超解析,可以換成另一種 RTX 影片超解析。",
+ "en": "Independent of the base SR; it can use another RTX Video Super Resolution model.",
+ "ja": "基本の超解像とは独立しており、別の RTX ビデオ超解像を選べます。"
+ },
{
"zh": "独立采集音频配置失败;BMD 原生视频继续运行",
"src": "src/source/CaptureCardSource.cpp",
@@ -13240,11 +13268,18 @@
"ja": "2回目の超解像は未実行です。縮小後の入力は、基本結果と2回目の目標より小さくする必要があります。"
},
{
- "zh": "第二次超分质量",
+ "zh": "第二次超分档位",
"src": "qml/SrStageEditor.qml",
- "zh-TW": "第二次超分品質",
- "en": "Second SR quality",
- "ja": "2回目の超解像品質"
+ "zh-TW": "第二次超解析檔位",
+ "en": "Second SR tier",
+ "ja": "2回目の超解像段階"
+ },
+ {
+ "zh": "第二次超分算法",
+ "src": "qml/SrStageEditor.qml",
+ "zh-TW": "第二次超解析算法",
+ "en": "Second SR algorithm",
+ "ja": "2回目のアップスケーリング方式"
},
{
"zh": "等待 PS5 登录 PIN 超时,请重新连接。",
@@ -15836,6 +15871,13 @@
"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": "src/ui/bridge/Enhancement.cpp",
+ "zh-TW": "超高",
+ "en": "Ultra",
+ "ja": "超高"
+ },
{
"zh": "越小越敏感,越大稳得越多",
"src": "qml/ProPage.qml",
@@ -15857,6 +15899,13 @@
"en": "Higher is smoother but ghosts more on motion",
"ja": "高いほど滑らかですが、動きの残像も増えます"
},
+ {
+ "zh": "越高越清晰、越耗时;流媒体只有中和超高两档。",
+ "src": "qml/SrStageEditor.qml",
+ "zh-TW": "越高越清晰、越耗時;流媒體只有中和超高兩檔。",
+ "en": "Higher tiers are sharper and take longer; Streaming has only Medium and Ultra.",
+ "ja": "段階が高いほど鮮明になり、処理時間も増えます。ストリーミングは中と超高の2段階のみです。"
+ },
{
"zh": "越高越稳,过高会显得发闷",
"src": "qml/ProPage.qml",
@@ -17593,6 +17642,13 @@
"en": "Requires AMD RX 9000",
"ja": "AMD RX 9000 が必要です"
},
+ {
+ "zh": "需要 NVIDIA RTX 30 及更新显卡",
+ "src": "src/ui/bridge/Hardware.cpp",
+ "zh-TW": "需要 NVIDIA RTX 30 或更新的顯示卡",
+ "en": "Requires an NVIDIA RTX 30-series or newer GPU",
+ "ja": "NVIDIA RTX 30 シリーズ以降の GPU が必要です"
+ },
{
"zh": "需要 NVIDIA RTX 40 / 50(Ada / Blackwell)",
"src": "src/ui/bridge/Hardware.cpp",
@@ -18699,6 +18755,20 @@
"en": "high latency · needs CPU unpacking",
"ja": "高遅延 · CPU での展開が必要"
},
+ {
+ "zh": "高码率",
+ "src": "src/ui/bridge/Enhancement.cpp",
+ "zh-TW": "高位元率",
+ "en": "High bitrate",
+ "ja": "高ビットレート"
+ },
+ {
+ "zh": "高码率和流媒体只做放大:片源已达到目标尺寸,所以没有运行;同尺寸修复请用标准。",
+ "src": "src/ui/bridge/Status.cpp",
+ "zh-TW": "高位元率和流媒體只做放大:片源已達到目標尺寸,所以沒有執行;同尺寸修復請用標準。",
+ "en": "High bitrate and Streaming only upscale. The source already reaches the target size, so they did not run; use Standard to restore at the same size.",
+ "ja": "高ビットレートとストリーミングは拡大専用です。ソースがすでに目標サイズのため実行されませんでした。同じサイズでの修復には標準を使ってください。"
+ },
{
"zh": "高级设置:技术参数",
"src": "qml/ProDisplayPanel.qml",
diff --git a/include/veyra/engine/EnhancementSettings.h b/include/veyra/engine/EnhancementSettings.h
index 28587f43..b732bc24 100644
--- a/include/veyra/engine/EnhancementSettings.h
+++ b/include/veyra/engine/EnhancementSettings.h
@@ -75,8 +75,31 @@ inline constexpr uint32_t kVideoSrFsr=5;
// Fresh SR selections use RTX Video SR high; explicit saved selections retain
// their numeric IDs. The UI seeds FSR separately on AMD/Intel adapters.
inline constexpr uint32_t kDefaultVideoSrQuality=4;
-// Three-step SR (prescale / SR / output fit) runs on RTX Video SR only so far.
-constexpr bool srStageBackend(uint32_t videoSrQuality){return videoSrQuality>=1&&videoSrQuality<=4;}
+// RTX Video SR comes in three model families, each chosen by tier (1 low,
+// 2 medium, 3 high, 4 ultra). Stored values keep the SDK numbers:
+// - standard 1..4: RTX Video SDK through NGX, trained on compressed video;
+// - high bitrate 16..19 and streaming 21/23 (medium/ultra only, Ampere or
+// newer): NVIDIA Video Effects VideoSuperRes. High bitrate skips the
+// compression clean-up to keep clean detail; streaming cleans hardest.
+// Every family runs double SR and the supersample shrink. Only the standard
+// family restores a source already at the target size.
+enum class VideoSrFamily : uint32_t { Standard = 0, HighBitrate = 1, Streaming = 2 };
+inline constexpr uint32_t kVideoSrFamilyCount=3;
+constexpr bool ngxVideoSr(uint32_t q){return q>=1&&q<=4;}
+constexpr bool vfxVideoSr(uint32_t q){return (q>=16&&q<=19)||q==21||q==23;}
+constexpr bool vfxVideoSrNeedsAmpere(uint32_t q){return q==21||q==23;}
+constexpr bool rtxVideoSr(uint32_t q){return ngxVideoSr(q)||vfxVideoSr(q);}
+constexpr bool validVideoSrQuality(uint32_t q){return q<=kVideoSrFsr||vfxVideoSr(q);}
+inline constexpr uint32_t kVfxVideoSrQualities[]={16,17,18,19,21,23};
+constexpr VideoSrFamily videoSrFamily(uint32_t q){
+ return q>=16&&q<=19?VideoSrFamily::HighBitrate:q==21||q==23?VideoSrFamily::Streaming:VideoSrFamily::Standard;
+}
+constexpr uint32_t videoSrTier(uint32_t q){return q>=16&&q<=19?q-15:q==21?2u:q==23?4u:q;}
+// Streaming has no low or high tier: low and medium give medium, high and ultra give ultra.
+constexpr uint32_t videoSrQualityFor(VideoSrFamily family,uint32_t tier){
+ tier=tier<1?1u:tier>4?4u:tier;
+ return family==VideoSrFamily::HighBitrate?15u+tier:family==VideoSrFamily::Streaming?(tier<=2?21u:23u):tier;
+}
// DLSS SR model (videoSrQuality 0 only): 0 = DLSS 4 transformer (preset K,
// what DLSS SR always used here), 1 = DLSS 4.5 second-generation transformer
// (preset M), 2 = DLSS 4.5 Ultra Performance model (preset L). Both 4.5
@@ -339,7 +362,7 @@ struct EnhancementSettings {
HdrMetadataSettings hdrMetadata;
bool useHdrPreview(bool hdrInput,bool hdrDisplayActive)const{return (hdrInput||videoHdr.enabled)&&hdrDisplayActive&&!forceSdrPreview;}
pipeline::SrTarget srTarget=pipeline::SrTarget::Uhd4K;
- uint32_t videoSrQuality=kDefaultVideoSrQuality; // 0 DLSS SR; 1–4 RTX Video SR
+ uint32_t videoSrQuality=kDefaultVideoSrQuality; // 0 DLSS SR; 5 FSR; RTX Video SR family/tier values (videoSrFamily)
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.
@@ -349,7 +372,7 @@ struct EnhancementSettings {
pipeline::SrOutput srOutput=pipeline::SrOutput::Target;
bool dualSrEnabled=false;
pipeline::SrTarget dualSrTarget=pipeline::SrTarget::Uhd4K;
- uint32_t dualSrQuality=4;
+ uint32_t dualSrQuality=4; // any RTX Video SR value, independent of the base family
uint32_t multiplier=1;
FrameGenerationBackend frameGenerationBackend=FrameGenerationBackend::Dlss;
// NvVFX Mode: Low=0, Medium=1 (default), High=2; mixed tiers 3-5, see vfgPrimaryMode().
@@ -435,12 +458,12 @@ struct EnhancementSettings {
if(!nr||!protection.enabled)active.protection=defaults.protection;
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){
+ if(!sr||!rtxVideoSr(videoSrQuality)||!dualSrEnabled){
active.srPrescale=defaults.srPrescale;
active.dualSrEnabled=false;active.dualSrTarget=defaults.dualSrTarget;active.dualSrQuality=defaults.dualSrQuality;
}
// The supersample shrink belongs to a single RTX Video SR pass.
- if(!sr||!srStageBackend(videoSrQuality)||dualSrEnabled)active.srOutput=defaults.srOutput;
+ if(!sr||!rtxVideoSr(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;
@@ -578,12 +601,12 @@ struct EnhancementSettings {
// The AMD 3.1.x provider delivers one generated frame per present; the
// probe measured the same count for 2/3/4 requested frames.
if(fsrFrameGeneration(frameGenerationBackend)&&multiplier>2)return "AMD FSR frame generation supports up to 2X";
- if(videoSrQuality>kVideoSrFsr)return "invalid video SR quality";
+ if(!validVideoSrQuality(videoSrQuality))return "invalid video SR quality";
if(dlssSrModel>=kDlssSrModelCount)return "invalid DLSS SR model";
if(!pipeline::validSrTarget(srTarget))return "invalid SR target";
if(!pipeline::validSrPrescale(srPrescale))return "invalid SR prescale";
if(!pipeline::validSrOutput(srOutput))return "invalid SR output";
- if(!pipeline::validSrTarget(dualSrTarget)||dualSrQuality<1||dualSrQuality>4)return "invalid second SR target or quality";
+ if(!pipeline::validSrTarget(dualSrTarget)||!rtxVideoSr(dualSrQuality))return "invalid second SR target or quality";
if(opticalFlowBackend!=OpticalFlowBackend::Nvidia&&opticalFlowBackend!=OpticalFlowBackend::AmdFidelityFx&&opticalFlowBackend!=OpticalFlowBackend::GpuDis)return "invalid optical flow backend";
if(multiplier<1||multiplier>(frameGenerationBackend==FrameGenerationBackend::Vfg?8u:6u))return "unsupported multiplier";
// 0 = auto quality; explicit values are capped at 300 Mbps so a typo
diff --git a/include/veyra/engine/GraphDescription.h b/include/veyra/engine/GraphDescription.h
index 71fdfb40..031a5c25 100644
--- a/include/veyra/engine/GraphDescription.h
+++ b/include/veyra/engine/GraphDescription.h
@@ -65,16 +65,16 @@ struct StageRequest {
const ChainRuntimeOrder* nodeOrder=nullptr; // paired with this settings transaction
};
-// Double SR runs on RTX Video SR (NVIDIA) only; every other backend keeps
-// its existing single pass, regardless of saved second-pass fields.
+// Double SR runs on RTX Video SR (NVIDIA, every model family) only; every other
+// backend keeps its existing single pass, regardless of saved second-pass fields.
inline pipeline::SrPrescale runningSrPrescale(const EnhancementSettings& s,bool nvidiaAdapter){
- return nvidiaAdapter&&srStageBackend(s.videoSrQuality)&&s.dualSrEnabled?s.srPrescale:pipeline::SrPrescale::Off;
+ return nvidiaAdapter&&rtxVideoSr(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){
- return nvidiaAdapter&&srStageBackend(s.videoSrQuality)&&!s.dualSrEnabled?s.srOutput:pipeline::SrOutput::Target;
+ return nvidiaAdapter&&rtxVideoSr(s.videoSrQuality)&&!s.dualSrEnabled?s.srOutput:pipeline::SrOutput::Target;
}
// Fills the stage, size and parameter fields of `desc` from `settings`.
@@ -126,7 +126,7 @@ inline pipeline::ResolutionPlan describeStages(const StageRequest& request,const
boundedAmd?pipeline::NrSizePolicy::Realtime:policy,
(request.stillImage||request.exportJob)&&!boundedAmd,settings.revision,settings.srTarget,lowLatency,
request.amdNr&&currentNrRuntime(settings.nrRuntime)==NrRuntime::LmxxfAmd?1080u:0u,srPrescale,srOutput,
- settings.dualSrEnabled&&request.nvidiaAdapter&&srStageBackend(settings.videoSrQuality),settings.dualSrTarget);
+ settings.dualSrEnabled&&request.nvidiaAdapter&&rtxVideoSr(settings.videoSrQuality),settings.dualSrTarget);
if(request.exportJob&&!request.stillImage)
plan.nr=exportNrProcessingExtent(plan.base,settings.nrRuntime,policy);
desc.sourceWidth=request.width;desc.sourceHeight=request.height;
@@ -137,12 +137,13 @@ inline pipeline::ResolutionPlan describeStages(const StageRequest& request,const
desc.firstSrWidth=plan.firstSrOutput.width;desc.firstSrHeight=plan.firstSrOutput.height;
desc.nrWidth=plan.nr.width;desc.nrHeight=plan.nr.height;
desc.flowWidth=plan.flow.width;desc.flowHeight=plan.flow.height;
- // RTX Video SR can restore compressed video at its original resolution.
+ // Standard RTX Video SR can restore compressed video at its original resolution
+ // (the Video Effects families only enlarge).
// ResolutionPlan::srApplied describes enlargement, not SDK execution. Raw capture has
// no compression artifacts: there a source already at the target skips SR as in 2.0.6
// (5090 field log 57: 4K->4K VSR cost ~8.7 ms a frame and pushed 60 fps over budget).
const bool nativeVideoRestore=request.sr&&!request.stillImage&&!request.uncompressedSource&&request.nvidiaAdapter&&
- settings.videoSrQuality>=1&&settings.videoSrQuality<=4;
+ ngxVideoSr(settings.videoSrQuality);
desc.enableSr=(plan.srApplied||nativeVideoRestore)&&(request.nvidiaAdapter||settings.videoSrQuality==kVideoSrFsr);
desc.enableNr=request.nr&&(request.nvidiaAdapter||request.amdNr)&&(!settings.nrLayerCount||settings.activeNrLayerCount()>0);
desc.nrBeforeSr=!request.stillImage&&!request.exportJob&&lowLatency&&desc.enableNr&&desc.enableSr;
diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.h
index 56ea5a4e..c792017e 100644
--- a/include/veyra/pipeline/EnhanceGraph.h
+++ b/include/veyra/pipeline/EnhanceGraph.h
@@ -49,7 +49,7 @@ struct SwsContext;
struct NVSDK_NGX_Parameter;
struct NVSDK_NGX_Handle;
namespace veyra::guidance { class AmdOpticalFlow; class GpuDisOpticalFlow; }
-namespace veyra::pipeline { class VfgBackend; }
+namespace veyra::pipeline { class VfgBackend; class VfxSrBackend; }
namespace veyra::gfx {
class D3D12DeviceContext;
@@ -1039,6 +1039,10 @@ private:
std::unique_ptr<guidance::GpuDisOpticalFlow> gpuDis_;
std::unique_ptr<ngx::VideoSrBackend> videoSrBackend_;
std::unique_ptr<ngx::VideoSrBackend> firstVideoSrBackend_;
+ // Video Effects VideoSuperRes (high bitrate / streaming families): the final
+ // pass and, under double SR, the first pass when that family is chosen there.
+ std::unique_ptr<VfxSrBackend> vfxSrBackend_;
+ std::unique_ptr<VfxSrBackend> firstVfxSrBackend_;
std::unique_ptr<ngx::TrueHdrBackend> videoHdrBackend_;
std::unique_ptr<ngx::DlssFgBackend> fgBackend_;
std::unique_ptr<gfx::FsrFgPresenter> fsrFgBackend_;
diff --git a/include/veyra/pipeline/VfxSrBackend.h b/include/veyra/pipeline/VfxSrBackend.h
new file mode 100644
index 00000000..e63179c7
--- /dev/null
+++ b/include/veyra/pipeline/VfxSrBackend.h
@@ -0,0 +1,35 @@
+#pragma once
+#include <d3d12.h>
+#include <memory>
+#include <string>
+
+namespace veyra::gfx { class D3D12DeviceContext; }
+
+namespace veyra::pipeline {
+// NVIDIA Video Effects "VideoSuperRes" (SDK 1.3) on the graph's RGBA8 SR
+// textures, for the modes the RTX Video SDK path does not offer (high bitrate,
+// streaming). It shares the VFG runtime directory and CUDA interop: the graph
+// records copyIn(), submits, calls run() (queue signal -> CUDA wait, run,
+// signal -> queue wait; no CPU wait) and records copyOut() in a new list.
+class VfxSrBackend {
+public:
+ VfxSrBackend();
+ ~VfxSrBackend();
+ VfxSrBackend(const VfxSrBackend&)=delete;
+ VfxSrBackend& operator=(const VfxSrBackend&)=delete;
+ static bool runtimeAvailable(const std::wstring& runtimeRoot);
+ bool initialize(gfx::D3D12DeviceContext&,const std::wstring& runtimeRoot,unsigned inputWidth,unsigned inputHeight,
+ unsigned outputWidth,unsigned outputHeight,unsigned qualityLevel);
+ bool created() const;
+ // The texture is RGBA8 in COPY_SOURCE.
+ bool copyIn(ID3D12GraphicsCommandList*,ID3D12Resource* texture);
+ // Call after the list holding copyIn() was submitted on this queue.
+ bool run(ID3D12CommandQueue*);
+ // The texture is RGBA8 in COPY_DEST.
+ bool copyOut(ID3D12GraphicsCommandList*,ID3D12Resource* texture);
+ void shutdown();
+private:
+ struct Impl;
+ std::unique_ptr<Impl> impl_;
+};
+}
diff --git a/include/veyra/ui/EffectAvailability.h b/include/veyra/ui/EffectAvailability.h
index 32ce34c8..ff1b7a96 100644
--- a/include/veyra/ui/EffectAvailability.h
+++ b/include/veyra/ui/EffectAvailability.h
@@ -5,12 +5,13 @@
namespace veyra::ui {
// Hardware gates are independent of packaging and runtime initialization. A
// qualifying adapter still needs the component files and a successful backend.
-enum class HardwareEffect { Nvidia, NvidiaNr50, NvidiaNrSf, Vfg, AmdNr, Fsr4, CrossVendor };
+enum class HardwareEffect { Nvidia, NvidiaNr50, NvidiaNrSf, Vfg, AmdNr, Fsr4, CrossVendor, NvidiaAmpere };
struct EffectGpu {
uint32_t vendor = 0;
bool rtx = false, blackwell = false, ada = false, rx9000 = false;
uint32_t deviceId = 0;
bool rx7000 = false;
+ bool ampere = false;
};
constexpr bool hardwareSupports(HardwareEffect effect, EffectGpu gpu) {
switch (effect) {
@@ -18,6 +19,7 @@ constexpr bool hardwareSupports(HardwareEffect effect, EffectGpu gpu) {
case HardwareEffect::NvidiaNr50: return gpu.vendor == 0x10DE && gpu.blackwell;
case HardwareEffect::NvidiaNrSf: return gpu.vendor == 0x10DE && gpu.rtx;
case HardwareEffect::Vfg: return gpu.vendor == 0x10DE && (gpu.ada || gpu.blackwell);
+ case HardwareEffect::NvidiaAmpere: return gpu.vendor == 0x10DE && (gpu.ampere || gpu.ada || gpu.blackwell);
case HardwareEffect::AmdNr: return gpu.vendor == 0x1002 && (gpu.rx9000 || gpu.rx7000);
case HardwareEffect::Fsr4: return gpu.vendor == 0x1002 && gpu.rx9000;
case HardwareEffect::CrossVendor: return gpu.vendor == 0x10DE || gpu.vendor == 0x1002 || gpu.vendor == 0x8086;
diff --git a/include/veyra/ui/QmlPlayerBridge.h b/include/veyra/ui/QmlPlayerBridge.h
index db6e1497..b13dc51c 100644
--- a/include/veyra/ui/QmlPlayerBridge.h
+++ b/include/veyra/ui/QmlPlayerBridge.h
@@ -626,6 +626,12 @@ public:
QVariantMap effectCapabilities() const;
QVariantList nrRuntimeChoices() const;
QVariantList srBackendChoices() const;
+ // RTX Video SR family / tier helpers for the SR lists (see Enhancement.cpp).
+ Q_INVOKABLE QString srAlgorithmOf(int quality) const;
+ Q_INVOKABLE int srTierOf(int quality) const;
+ Q_INVOKABLE int srQualityFor(const QString& algorithm,int tier) const;
+ Q_INVOKABLE QVariantList srTierChoices(int quality) const;
+ Q_INVOKABLE QString srQualityLabel(int quality,bool withFamily) const;
Q_INVOKABLE QVariantMap effectAvailability(const QString& id) const;
// `engine` must outlive the bridge. `dataDirectory` holds ui-session.v1 and
// the preset library; empty means the default user data directory.
diff --git a/qml/Veyra/NodePage.qml b/qml/Veyra/NodePage.qml
index e5604797..cb29cfa6 100644
--- a/qml/Veyra/NodePage.qml
+++ b/qml/Veyra/NodePage.qml
@@ -1512,9 +1512,10 @@ VPage {
label: qsTr("超分算法")
VSelect {
objectName: "node-sr-backend"
+ implicitWidth: 210 // the RTX Video SR family names need more than the default 150
options: veyra.srBackendChoices || []
- value: options.find(o => o.id === String(veyra.videoSrQuality === 0 || veyra.videoSrQuality === 5 ? veyra.videoSrQuality : 4))?.label || ""
- onPicked: id => veyra.videoSrQuality = Number(id)
+ value: options.find(o => o.id === veyra.srAlgorithmOf(veyra.videoSrQuality))?.label || ""
+ onPicked: id => veyra.videoSrQuality = veyra.srQualityFor(id, veyra.srTierOf(veyra.videoSrQuality))
}
}
VRow {
diff --git a/qml/Veyra/ProPage.qml b/qml/Veyra/ProPage.qml
index 6296b20f..8a6107b9 100644
--- a/qml/Veyra/ProPage.qml
+++ b/qml/Veyra/ProPage.qml
@@ -1317,15 +1317,15 @@ VPage {
hue: "#4F7BFF"
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("已关闭"))
+ summary: !switchAvailable ? Support.reason(veyra, "sr") : (veyra.srEnabled ? (veyra.srBackendChoices?.find(o => o.id === veyra.srAlgorithmOf(veyra.videoSrQuality))?.label || qsTr("RTX 视频超分")) : qsTr("已关闭"))
+ " · " + 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 : "") : "")
+ + (rtxVideoSr ? " · " + veyra.srQualityLabel(veyra.videoSrQuality, false) + (dualShown ? " / " + veyra.srQualityLabel(veyra.dualSrQuality, true) : "") : "")
// 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
+ // and second target while double SR is on (RTX Video SR), then the tier
+ // (and the second family and tier). Each kept value is hidden while its mode is off.
+ readonly property bool rtxVideoSr: veyra.srAlgorithmOf(veyra.videoSrQuality).startsWith("rtx")
readonly property bool supersampleShown: !veyra.dualSrEnabled && veyra.srOutput > 0 && rtxVideoSr
readonly property bool dualShown: veyra.dualSrEnabled && veyra.srPrescale > 0 && rtxVideoSr
on: veyra.srEnabled
@@ -1336,9 +1336,11 @@ VPage {
label: qsTr("超分算法")
VSelect {
objectName: "list-sr-backend"
+ implicitWidth: 210 // the RTX Video SR family names need more than the default 150
options: veyra.srBackendChoices || []
- value: options.find(o => o.id === String(veyra.videoSrQuality === 0 || veyra.videoSrQuality === 5 ? veyra.videoSrQuality : 4))?.label || ""
- onPicked: id => veyra.videoSrQuality = Number(id)
+ value: options.find(o => o.id === veyra.srAlgorithmOf(veyra.videoSrQuality))?.label || ""
+ // Switching between RTX families keeps the tier.
+ onPicked: id => veyra.videoSrQuality = veyra.srQualityFor(id, veyra.srTierOf(veyra.videoSrQuality))
}
}
VRow {
diff --git a/qml/Veyra/SavePresetDialog.qml b/qml/Veyra/SavePresetDialog.qml
index e1aa4856..4720d40d 100644
--- a/qml/Veyra/SavePresetDialog.qml
+++ b/qml/Veyra/SavePresetDialog.qml
@@ -16,7 +16,7 @@ DialogLayer {
// node, with the parameters that matter.
function nodeSummary(n) {
switch (n.type) {
- case "sr": return veyra.srTargetLabel + (veyra.videoSrQuality > 0 ? qsTr(" · 质量 ") + veyra.videoSrQuality : "")
+ case "sr": return veyra.srTargetLabel + (veyra.srQualityLabel(veyra.videoSrQuality, true) ? " · " + veyra.srQualityLabel(veyra.videoSrQuality, true) : "")
case "nr": { const l = veyra.nrLayers.find(x => x.index === n.index); return l ? qsTr("强度 ") + l.intensity.toFixed(2) : "NR" }
case "video-hdr": return qsTr("峰值 ") + (veyra.videoHdrParams.peakNits || 1000) + " nits"
case "protection": return veyra.protectionRegions.length + qsTr(" / 4 个区域")
diff --git a/qml/Veyra/SrStageEditor.qml b/qml/Veyra/SrStageEditor.qml
index a86d04fc..0acdf515 100644
--- a/qml/Veyra/SrStageEditor.qml
+++ b/qml/Veyra/SrStageEditor.qml
@@ -6,7 +6,9 @@ ColumnLayout {
id: editor
property string namePrefix: "list"
spacing: 6
- readonly property bool supported: veyra.videoSrQuality >= 1 && veyra.videoSrQuality <= 4 && Support.available(veyra,"sr")
+ // Any RTX Video SR family (standard / high bitrate / streaming) runs the stages below.
+ readonly property bool supported: veyra.srAlgorithmOf(veyra.videoSrQuality).startsWith("rtx") && Support.available(veyra,"sr")
+ readonly property var rtxFamilies: (veyra.srBackendChoices || []).filter(o => o.id.startsWith("rtx"))
readonly property bool manual: veyra.srPrescale >= 150 && veyra.srPrescale <= 190
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 {
@@ -20,9 +22,15 @@ ColumnLayout {
VSeg { options:[{id:"0",label:qsTr("零运动")},{id:"1",label:qsTr("光流")}]; current:String(veyra.srMotionSource); onPicked:id=>veyra.srMotionSource=Number(id) }
}
VRow {
- label: qsTr("质量")
+ label: qsTr("档位")
+ hint: qsTr("越高越清晰、越耗时;流媒体只有中和超高两档。")
enabled: editor.supported; opacity: enabled ? 1 : 0.4
- VSeg { 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) }
+ VSeg {
+ objectName: editor.namePrefix+"-sr-quality"
+ options: veyra.srTierChoices(veyra.videoSrQuality)
+ current: String(veyra.srTierOf(veyra.videoSrQuality))
+ onPicked: id => veyra.videoSrQuality = veyra.srQualityFor(veyra.srAlgorithmOf(veyra.videoSrQuality), Number(id))
+ }
}
// Supersampling: a single RTX Video SR pass at the target, shrunk into this size.
VRow {
@@ -78,9 +86,24 @@ ColumnLayout {
VSeg { objectName: editor.namePrefix+"-dual-sr-target"; options: editor.targets; current: String(veyra.dualSrTargetIndex); onPicked: id=>veyra.dualSrTargetIndex=Number(id) }
}
VRow {
- label: qsTr("第二次超分质量")
- 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) }
+ label: qsTr("第二次超分算法")
+ hint: qsTr("独立于基础超分,可以换成另一种 RTX 视频超分。")
+ VSelect {
+ objectName: editor.namePrefix+"-dual-sr-algorithm"
+ implicitWidth: 210
+ options: editor.rtxFamilies
+ value: options.find(o => o.id === veyra.srAlgorithmOf(veyra.dualSrQuality))?.label || ""
+ onPicked: id => veyra.dualSrQuality = veyra.srQualityFor(id, veyra.srTierOf(veyra.dualSrQuality))
+ }
+ }
+ VRow {
+ label: qsTr("第二次超分档位")
+ VSeg {
+ objectName: editor.namePrefix+"-dual-sr-quality"
+ options: veyra.srTierChoices(veyra.dualSrQuality)
+ current: String(veyra.srTierOf(veyra.dualSrQuality))
+ onPicked: id => veyra.dualSrQuality = veyra.srQualityFor(veyra.srAlgorithmOf(veyra.dualSrQuality), Number(id))
+ }
}
}
// Running sizes of double SR or supersampling, and why a choice did not apply.
diff --git a/scripts/acceptance/dual-sr-ui.qml b/scripts/acceptance/dual-sr-ui.qml
index 85a5d513..2552d505 100644
--- a/scripts/acceptance/dual-sr-ui.qml
+++ b/scripts/acceptance/dual-sr-ui.qml
@@ -66,7 +66,7 @@ Item {
if(!settled())return
check(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")
- 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)
+ check(find("list-sr").summary.indexOf("4K→1080p→2K")>=0&&find("list-sr").summary.indexOf("低 / 标准 中")>=0,"the card summary follows the second target, family and tier: "+find("list-sr").summary)
if(test.shot.length>0)test.parent.parent.grabToImage(r=>{r.saveToFile(test.shot);test.saved=true})
else test.saved=true
next(45);return
diff --git a/scripts/acceptance/sr-families-ui.qml b/scripts/acceptance/sr-families-ui.qml
new file mode 100644
index 00000000..7e05e0ef
--- /dev/null
+++ b/scripts/acceptance/sr-families-ui.qml
@@ -0,0 +1,94 @@
+import QtQuick
+// RTX Video SR families in the real list page: algorithm (standard / high bitrate /
+// streaming) and tier selection, double SR with a second family, and the card summary.
+// Runner: the same Loader injection as sr-stage-ui.py; expects a 720p clip of 30 s or more.
+Item {
+ id: test
+ property string media: ""
+ property string shot: "" // screenshot path from the runner; empty skips it
+ property bool saved: false
+ 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);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 next(n){step=n;ticks=0}
+ 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}
+ function ids(list){return (list||[]).map(o=>o.id).join(",")}
+ function labels(list){return (list||[]).map(o=>o.label).join("")}
+ onTriggered:{try{
+ ++ticks;if(++total>220)throw new Error("bounded SR family test step="+step)
+ if(step===0){
+ if(ticks<4)return
+ veyra.muted=true;veyra.nrEnabled=false;veyra.fgEnabled=false
+ veyra.srEnabled=true;veyra.videoSrQuality=4;veyra.dualSrEnabled=false;veyra.srOutput=0;veyra.srTargetIndex=2
+ veyra.openPath(test.media);next(1);return
+ }
+ if(step===1){
+ if(!settled())return
+ const backend=find("list-sr-backend"),tiers=find("list-sr-quality")
+ check(backend!==null&&tiers!==null,"list SR algorithm and tier controls exist")
+ check(ids(backend.options)==="0,rtx,rtx-hb,rtx-st,5","algorithms: DLSS, three RTX Video SR families, FSR ("+ids(backend.options)+")")
+ check(backend.value===backend.options[1].label&&tiers.current==="4"&&labels(tiers.options)==="低中高超高","standard family at ultra with four named tiers")
+ check(find("list-sr").summary.indexOf(backend.options[1].label)>=0&&find("list-sr").summary.indexOf(" · 超高")>=0,
+ "card summary names the family and tier: "+find("list-sr").summary)
+ backend.picked("rtx-hb");next(2);return
+ }
+ if(step===2){
+ if(!settled())return
+ check(veyra.videoSrQuality===19&&veyra.srActive&&veyra.outputSummary==="3840x2160","high bitrate keeps the ultra tier and runs 720p -> 4K")
+ find("list-sr-quality").picked("2");next(3);return
+ }
+ if(step===3){
+ if(!settled())return
+ check(veyra.videoSrQuality===17&&veyra.srActive,"high bitrate medium tier")
+ find("list-sr-backend").picked("rtx-st");next(4);return
+ }
+ if(step===4){
+ if(!settled())return
+ const tiers=find("list-sr-quality")
+ check(veyra.videoSrQuality===21&&labels(tiers.options)==="中超高"&&tiers.current==="2"&&veyra.srActive,"streaming offers medium and ultra, keeps medium and runs")
+ find("list-dual-sr-toggle").toggled(true);next(5);return
+ }
+ if(step===5){
+ if(!settled())return
+ check(veyra.dualSrEnabled&&find("list-dual-sr-panel").visible,"double SR opens on the streaming family")
+ check(veyra.srStageSummary==="1280x720 → 3840x2160 → 1920x1080 → 3840x2160","streaming base, reduction, second pass: "+veyra.srStageSummary)
+ const algo=find("list-dual-sr-algorithm")
+ check(algo!==null&&ids(algo.options)==="rtx,rtx-hb,rtx-st","second pass offers the three RTX Video SR families")
+ algo.picked("rtx-hb");next(6);return
+ }
+ if(step===6){
+ if(!settled())return
+ check(veyra.videoSrQuality===21&&veyra.dualSrQuality===19,"the second family changes only the second pass")
+ check(veyra.srActive&&veyra.srStageSummary==="1280x720 → 3840x2160 → 1920x1080 → 3840x2160","streaming + high bitrate double SR runs")
+ check(find("list-sr").summary.indexOf("中 / 高码率 超高")>=0,"card summary shows both passes: "+find("list-sr").summary)
+ test.saved=false
+ if(test.shot.length>0)test.parent.parent.grabToImage(r=>{r.saveToFile(test.shot);test.saved=true})
+ else test.saved=true
+ next(7);return
+ }
+ if(step===7){
+ if(!test.saved||ticks<3)return
+ find("list-dual-sr-quality").picked("1");next(8);return
+ }
+ if(step===8){
+ if(!settled())return
+ check(veyra.dualSrQuality===16&&veyra.videoSrQuality===21&&veyra.srActive,"second pass low tier, base unchanged")
+ find("list-sr-backend").picked("rtx");next(9);return
+ }
+ if(step===9){
+ if(!settled())return
+ check(veyra.videoSrQuality===2&&veyra.dualSrEnabled&&veyra.dualSrQuality===16&&veyra.srActive,
+ "back to the standard family at the same tier; the high bitrate second pass stays")
+ 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/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index c7f1d664..b764d476 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -2867,7 +2867,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
for(size_t stage=0;stage<measured.gpu.size();++stage){const auto& sample=measured.gpu[stage];if(sample.state==diagnostics::SampleState::Measured&&sample.milliseconds&&sample.end&&sample.end!=lastGpuSampleEnd[stage]){gpuStageTimes[stage].add(*sample.milliseconds);lastGpuSampleEnd[stage]=sample.end;}}
- measured.resolution=pipeline::ResolutionPlan::make({width,height},options.sr,options.snapshot().nrPolicy,isImage,options.settings.revision,options.settings.srTarget,options.settings.lowLatency&&options.nr,0,runningSrPrescale(options.settings,ctx.adapter().isNvidia),runningSrOutput(options.settings,ctx.adapter().isNvidia),options.settings.dualSrEnabled&&ctx.adapter().isNvidia&&srStageBackend(options.settings.videoSrQuality),options.settings.dualSrTarget);measured.decodeCpuMs=decodeMs;measured.submitCpuMs=std::chrono::duration<double,std::milli>(processDone-processStart).count();measured.gpuWaitCpuMs=gpuWaitMs;measured.deadlineWaitCpuMs=frameWaitMs;measured.presentCpuMs=framePresentMs;measured.queueWatermark=out.batch.count;
+ measured.resolution=pipeline::ResolutionPlan::make({width,height},options.sr,options.snapshot().nrPolicy,isImage,options.settings.revision,options.settings.srTarget,options.settings.lowLatency&&options.nr,0,runningSrPrescale(options.settings,ctx.adapter().isNvidia),runningSrOutput(options.settings,ctx.adapter().isNvidia),options.settings.dualSrEnabled&&ctx.adapter().isNvidia&&rtxVideoSr(options.settings.videoSrQuality),options.settings.dualSrTarget);measured.decodeCpuMs=decodeMs;measured.submitCpuMs=std::chrono::duration<double,std::milli>(processDone-processStart).count();measured.gpuWaitCpuMs=gpuWaitMs;measured.deadlineWaitCpuMs=frameWaitMs;measured.presentCpuMs=framePresentMs;measured.queueWatermark=out.batch.count;
LiveStats completed;if(liveScheduler)completed=liveStats;
uint64_t skipped=0;{std::lock_guard lock(mutex_);skipped=snapshot_.captureRateSkipped-rateSkippedBase;}
frameFlow->update([&](auto& m){m.counters.captureReceived=captureStats.received-captureFlowBase.received;m.counters.mailboxOverwritten=captureStats.dropped-captureFlowBase.dropped;m.counters.sourceSkippedBeforeGraph=skipped;m.slotReuseWaitCount=slotWaitCount;m.slotReuseWaitMs=slotWaitMilliseconds;m.counters.commandSlotsInFlight=slotsInFlight;m.counters.commandSlotHighWater=std::max(m.counters.commandSlotHighWater,slotsInFlight);});
diff --git a/src/engine/PresetLibrary.cpp b/src/engine/PresetLibrary.cpp
index 8e0daa45..60d035ac 100644
--- a/src/engine/PresetLibrary.cpp
+++ b/src/engine/PresetLibrary.cpp
@@ -98,6 +98,7 @@ void PresetLibrary::addBuiltins() {
bool PresetLibrary::load() {
error_.clear();
addBuiltins();
+ const auto directVideoAi=std::filesystem::path(path_).concat(L".video-ai");
const auto directDual=std::filesystem::path(path_).concat(L".dual-sr");
const auto directSrStage=std::filesystem::path(path_).concat(L".sr-stage");
const auto directBeauty=std::filesystem::path(path_).concat(L".beauty");
@@ -144,6 +145,8 @@ bool PresetLibrary::load() {
else if(std::filesystem::exists(srStagePath))path_=srStagePath;
const auto dualPath=std::filesystem::path(path_).concat(L".dual-sr");
if(std::filesystem::exists(directDual))path_=directDual;else if(std::filesystem::exists(dualPath))path_=dualPath;
+ const auto videoAiPath=std::filesystem::path(path_).concat(L".video-ai");
+ if(std::filesystem::exists(directVideoAi))path_=directVideoAi;else if(std::filesystem::exists(videoAiPath))path_=videoAiPath;
if (!std::filesystem::exists(path_)) return true;
std::error_code ec;
const auto size = std::filesystem::file_size(path_, ec);
@@ -240,6 +243,8 @@ bool PresetLibrary::save() {
// Opting into a new model must leave the older build's library intact.
// v14 (anti-aliasing nodes, chains past 16 nodes) and v15 (beauty nodes) get their own files too.
// v16 (three-step SR) as well.
+ if(data.starts_with("VEYRA_PRESET_LIBRARY 18")&&!path_.wstring().ends_with(L".video-ai"))path_=std::filesystem::path(path_).concat(L".video-ai");
+ if(!path_.wstring().ends_with(L".video-ai")){
if(data.starts_with("VEYRA_PRESET_LIBRARY 17")&&!path_.wstring().ends_with(L".dual-sr"))path_=std::filesystem::path(path_).concat(L".dual-sr");
if(!path_.wstring().ends_with(L".dual-sr")){
if(data.starts_with("VEYRA_PRESET_LIBRARY 16")&&!path_.wstring().ends_with(L".sr-stage"))path_=std::filesystem::path(path_).concat(L".sr-stage");
@@ -273,6 +278,7 @@ bool PresetLibrary::save() {
}
}
}
+ }
std::error_code ec;
std::filesystem::create_directories(path_.parent_path(), ec);
const auto temporary = std::filesystem::path(path_).concat(L".tmp");
@@ -730,7 +736,11 @@ std::string PresetLibrary::encodeEntries(const std::vector<PresetEntry>& entries
});
const auto dualOf=[](const ChainGlobalSettings& g){return g.dualSrEnabled||g.dualSrTarget!=pipeline::SrTarget::Uhd4K||g.dualSrQuality!=4;};
const bool dual=std::any_of(entries_.begin(),entries_.end(),[&](const auto& e){return (e.globals&&dualOf(*e.globals))||(e.nodeConfiguration&&(dualOf(*e.nodeConfiguration)||(e.nodeConfiguration->editor&&e.nodeConfiguration->editor->globals&&dualOf(*e.nodeConfiguration->editor->globals))));});
- const int version=std::max(minimumVersion, dual?17:srStage?16:beauty?15:effects?14:nrModel?13:dlss?12:tuning?11:flow?10:correctionExtended?9:correction?8:vfg?7:rendering?6:globals?5:editor?4:layerSizes?3:multi?2:1);
+ // RTX Video SR high bitrate / streaming values (16..23, base or second pass)
+ // are rejected by older readers: own version and file.
+ const auto videoAiOf=[](const ChainGlobalSettings& g){return vfxVideoSr(g.videoSrQuality)||vfxVideoSr(g.dualSrQuality);};
+ const bool videoAi=std::any_of(entries_.begin(),entries_.end(),[&](const auto& e){return (e.globals&&videoAiOf(*e.globals))||(e.nodeConfiguration&&(videoAiOf(*e.nodeConfiguration)||(e.nodeConfiguration->editor&&e.nodeConfiguration->editor->globals&&videoAiOf(*e.nodeConfiguration->editor->globals))));});
+ const int version=std::max(minimumVersion, videoAi?18:dual?17:srStage?16:beauty?15:effects?14:nrModel?13:dlss?12:tuning?11:flow?10:correctionExtended?9:correction?8:vfg?7:rendering?6:globals?5:editor?4:layerSizes?3:multi?2:1);
o << "VEYRA_PRESET_LIBRARY " << version << '\n' << std::quoted(utf8(defaultName_)) << ' ' << entries_.size() << '\n';
for (const auto& e : entries_) {
o << std::quoted(utf8(e.name)) << ' ' << std::quoted(utf8(e.note)) << ' '
@@ -804,7 +814,7 @@ bool PresetLibrary::parse(const std::string& data, std::vector<PresetEntry>& out
std::string magic, quoted;
int version = 0;
size_t count = 0;
- const int allowedVersion=maxVersion>0?std::min(maxVersion,17):17;
+ const int allowedVersion=maxVersion>0?std::min(maxVersion,18):18;
if (!(in >> magic >> version) || magic != "VEYRA_PRESET_LIBRARY" || version < 1 || version > allowedVersion) { error = L"预设库格式或版本不支持"; return false; }
if (!(in >> std::quoted(quoted) >> count) || count > 64) { error = L"预设库条目数非法"; return false; }
def = wide(quoted);
@@ -974,7 +984,9 @@ std::string ChainSessionStore::encode(const ChainSession& session) {
return srStageOf(c)||(c.editor&&c.editor->globals&&srStageOf(*c.editor->globals));});
const auto dualOf=[](const ChainGlobalSettings& g){return g.dualSrEnabled||g.dualSrTarget!=pipeline::SrTarget::Uhd4K||g.dualSrQuality!=4;};
const bool dual=std::any_of(session.configurations.begin(),session.configurations.end(),[&](const auto& c){return dualOf(c)||(c.editor&&c.editor->globals&&dualOf(*c.editor->globals));});
- const int version = dual?12:srStage?11:beauty?10:effects?9:nrModel?8:dlss?7:tuning?6:vfg?5:rendering?4:editor ? (editor->globals ? 3 : 2) : 1;
+ const auto videoAiOf=[](const ChainGlobalSettings& g){return vfxVideoSr(g.videoSrQuality)||vfxVideoSr(g.dualSrQuality);};
+ const bool videoAi=std::any_of(session.configurations.begin(),session.configurations.end(),[&](const auto& c){return videoAiOf(c)||(c.editor&&c.editor->globals&&videoAiOf(*c.editor->globals));});
+ const int version = videoAi?13:dual?12:srStage?11:beauty?10:effects?9:nrModel?8:dlss?7:tuning?6:vfg?5:rendering?4:editor ? (editor->globals ? 3 : 2) : 1;
out << "VEYRA_CHAIN_SESSION " << version << '\n' << int(session.active) << ' ' << session.initialized[0] << ' ' << session.initialized[1];
if(version>=4)out<<' '<<bool(editor);out<<'\n';
std::vector<PresetEntry> entries;
@@ -1028,7 +1040,7 @@ bool ChainSessionStore::decode(const std::string& data, ChainSession& session, b
std::istringstream in(data); in.imbue(std::locale::classic());
std::string magic, body; int version = 0, active = 0, list = 0, node = 0;
if (!(in >> magic >> version >> active >> list >> node) || magic != "VEYRA_CHAIN_SESSION" ||
- (version < 1 || version > 12) || active < 0 || active > 1 || list != 1 || node < 0 || node > 1) return false;
+ (version < 1 || version > 13) || active < 0 || active > 1 || list != 1 || node < 0 || node > 1) return false;
int hasEditor=version>=2?1:0;
if(version>=4&&(!(in>>hasEditor)||hasEditor<0||hasEditor>1))return false;
ChainSession parsed; parsed.active = ChainMode(active); parsed.initialized = {true, node != 0};
@@ -1043,7 +1055,7 @@ bool ChainSessionStore::decode(const std::string& data, ChainSession& session, b
}
if (!(in >> std::quoted(body))) return false;
std::vector<PresetEntry> entries; std::wstring def, error;
- if (!PresetLibrary::parse(body, entries, def, error, nullptr, true, version>=10?15:version>=9?14:version>=8?13:11) || entries.size() != 2 || !def.empty()) return false;
+ if (!PresetLibrary::parse(body, entries, def, error, nullptr, true, version>=13?18:version>=10?15:version>=9?14:version>=8?13:11) || entries.size() != 2 || !def.empty()) return false;
for (size_t i = 0; i < entries.size(); ++i) {
if (entries[i].kind != ChainMode(i)) return false;
parsed.configurations[i].chain = entries[i].chain;
@@ -1077,7 +1089,7 @@ bool ChainSessionStore::decode(const std::string& data, ChainSession& session, b
}
if (!(in >> std::quoted(body))) return false;
entries.clear(); def.clear(); error.clear();
- if (!PresetLibrary::parse(body, entries, def, error, nullptr, true, version>=10?15:version>=9?14:version>=8?13:11) || entries.size() != 1 ||
+ if (!PresetLibrary::parse(body, entries, def, error, nullptr, true, version>=13?18:version>=10?15:version>=9?14:version>=8?13:11) || entries.size() != 1 ||
!def.empty() || entries[0].kind != ChainMode::Node || entries[0].chain.nodeCount != count) return false;
editor->nodes = std::move(entries[0].chain);
for (uint32_t i = 0; i < count; ++i) {
@@ -1094,6 +1106,7 @@ bool ChainSessionStore::decode(const std::string& data, ChainSession& session, b
}
bool ChainSessionStore::load(ChainSession& session) {
+ const auto directVideoAi=std::filesystem::path(path_).concat(L".video-ai");
const auto directDual=std::filesystem::path(path_).concat(L".dual-sr");
const auto directSrStage=std::filesystem::path(path_).concat(L".sr-stage");
const auto directBeauty=std::filesystem::path(path_).concat(L".beauty");
@@ -1138,6 +1151,8 @@ bool ChainSessionStore::load(ChainSession& session) {
else if(std::filesystem::exists(srStagePath,ec))path_=srStagePath;
const auto dualPath=std::filesystem::path(path_).concat(L".dual-sr");
if(std::filesystem::exists(directDual))path_=directDual;else if(std::filesystem::exists(dualPath))path_=dualPath;
+ const auto videoAiPath=std::filesystem::path(path_).concat(L".video-ai");
+ if(std::filesystem::exists(directVideoAi))path_=directVideoAi;else if(std::filesystem::exists(videoAiPath))path_=videoAiPath;
const bool exists = std::filesystem::exists(path_, ec);
if (!exists && !ec) return true;
const auto size = std::filesystem::file_size(path_, ec);
@@ -1167,6 +1182,8 @@ bool ChainSessionStore::save(const ChainSession& session) {
const auto data = encode(session);
ChainSession checked;
if (!decode(data, checked)) { error_ = L"模式会话编码校验失败,未保存"; return false; }
+ if(data.starts_with("VEYRA_CHAIN_SESSION 13")&&!path_.wstring().ends_with(L".video-ai"))path_=std::filesystem::path(path_).concat(L".video-ai");
+ if(!path_.wstring().ends_with(L".video-ai")){
if(data.starts_with("VEYRA_CHAIN_SESSION 12")&&!path_.wstring().ends_with(L".dual-sr"))path_=std::filesystem::path(path_).concat(L".dual-sr");
if(!path_.wstring().ends_with(L".dual-sr")){
if(data.starts_with("VEYRA_CHAIN_SESSION 11")&&!path_.wstring().ends_with(L".sr-stage"))path_=std::filesystem::path(path_).concat(L".sr-stage");
@@ -1200,6 +1217,7 @@ bool ChainSessionStore::save(const ChainSession& session) {
}
}
}
+ }
std::error_code ec;
if (!path_.parent_path().empty()) std::filesystem::create_directories(path_.parent_path(), ec);
if (ec) { error_ = L"模式会话目录无法创建"; return false; }
diff --git a/src/engine/PresetStore.cpp b/src/engine/PresetStore.cpp
index 5b9e6f0d..dbd1633a 100644
--- a/src/engine/PresetStore.cpp
+++ b/src/engine/PresetStore.cpp
@@ -50,14 +50,18 @@ std::string PresetStore::serialize()const{
// v33 appends the three-step SR prescale and output (2026-10-28).
const bool srStage=std::any_of(entries_.begin(),entries_.end(),[](const auto& p){
return p.settings.srPrescale!=pipeline::SrPrescale::Off||p.settings.srOutput!=pipeline::SrOutput::Target;});
- const bool dual=std::any_of(entries_.begin(),entries_.end(),[](const auto& p){return p.settings.dualSrEnabled||p.settings.dualSrTarget!=pipeline::SrTarget::Uhd4K||p.settings.dualSrQuality!=4;});
+ // v35: RTX Video SR high bitrate / streaming values (16..23) as the base or
+ // second SR quality; older readers reject them. The version implies every
+ // earlier field, so it forces the v34 layout.
+ const bool videoAi=std::any_of(entries_.begin(),entries_.end(),[](const auto& p){return vfxVideoSr(p.settings.videoSrQuality)||vfxVideoSr(p.settings.dualSrQuality);});
+ const bool dual=videoAi||std::any_of(entries_.begin(),entries_.end(),[](const auto& p){return p.settings.dualSrEnabled||p.settings.dualSrTarget!=pipeline::SrTarget::Uhd4K||p.settings.dualSrQuality!=4;});
const bool fullSchema=fsr4||higher||rendering||vfg||correction||dlss||nrModel||srStage||dual;
const bool correctionExtended=dual||srStage||nrModel||dlss||std::any_of(entries_.begin(),entries_.end(),[](const auto& p){
if(p.settings.residual.correction.extendedControls())return true;
for(unsigned i=0;i<p.settings.nrLayerCount;++i)if(p.settings.nrLayers[i].residual.correction.extendedControls())return true;
return false;});
// v26 introduces appended resolution IDs; old readers reject this schema.
- std::ostringstream o;o.imbue(std::locale::classic());o<<std::setprecision(std::numeric_limits<float>::max_digits10)<<"VEYRA_PRESETS "<<(dual?34:srStage?33:nrModel?32:dlss?31:correctionExtended?30:correction?29:vfg?28:rendering?27:higher?26:fsr4?25:hold?24:stack?23:multi?22:21)<<'\n'<<std::quoted(utf8(default_))<<' '<<entries_.size()<<'\n';
+ std::ostringstream o;o.imbue(std::locale::classic());o<<std::setprecision(std::numeric_limits<float>::max_digits10)<<"VEYRA_PRESETS "<<(videoAi?35:dual?34:srStage?33:nrModel?32:dlss?31:correctionExtended?30:correction?29:vfg?28:rendering?27:higher?26:fsr4?25:hold?24:stack?23:multi?22:21)<<'\n'<<std::quoted(utf8(default_))<<' '<<entries_.size()<<'\n';
for(auto& p:entries_){const auto& s=p.settings;const auto& m=s.model;const auto& r=s.residual;o<<std::quoted(utf8(p.name))<<' '<<m.intensity<<' '<<m.tone<<' '<<m.structure<<' '<<m.skin<<' '<<m.style<<' '<<m.autoMask<<' '<<m.uiCorrection<<' '<<r.total<<' '<<r.darken<<' '<<r.brighten<<' '<<r.color<<' '<<r.luminance<<' '<<s.nr<<' '<<s.sr<<' '<<s.multiplier<<' '<<int(s.nrPolicy)<<' '<<int(s.flow)<<' '<<int(s.content)<<' '<<s.protection.enabled<<' '<<s.protection.featherPixels;for(auto q:s.protection.regions)o<<' '<<q.left<<' '<<q.top<<' '<<q.right<<' '<<q.bottom;o<<' '<<s.videoSrQuality<<' '<<int(s.frameGenerationBackend)<<' '<<int(s.srTarget)<<' '<<int(s.opticalFlowBackend)<<' '<<s.amdFlowHalfResolution<<' '<<int(s.audioSync)<<' '<<s.audioOffsetMs<<' '<<int(s.nrRuntime)<<' '<<s.captureCompatible<<' '<<s.lowLatency<<' '<<s.forceSdrPreview<<' '<<int(s.captureAudio)<<' '<<s.exportBitrateMbps<<' '<<s.captureFlipVertical<<' '<<int(s.captureBuffer)<<' ';writeColorSettings(o,s.color,utf8(s.color.lutNameString()));o<<' '<<s.videoHdr.enabled<<' '<<s.videoHdr.contrast<<' '<<s.videoHdr.saturation<<' '<<s.videoHdr.middleGray<<' '<<s.videoHdr.peakNits<<' '<<s.nrTemporal;
if(multi||fullSchema){o<<' '<<s.additionalColorCount;for(unsigned i=0;i<s.additionalColorCount;++i){o<<' ';writeColorSettings(o,s.additionalColors[i],utf8(s.additionalColors[i].lutNameString()));}}
if(stack||fullSchema){
@@ -92,7 +96,7 @@ std::string PresetStore::serialize()const{
}
bool PresetStore::parse(const std::string& data,std::vector<UserPreset>& out,std::wstring& def){
if(data.size()>kMaxPresetBytes)return false;std::istringstream in(data);in.imbue(std::locale::classic());std::string magic,d;int version=0;size_t count=0;
- if(!(in>>magic>>version)||magic!="VEYRA_PRESETS"||(version<1||version>34)||!(in>>std::quoted(d)>>count)||count>64)return false;def=wide(d);if(!d.empty()&&def.empty())return false;
+ if(!(in>>magic>>version)||magic!="VEYRA_PRESETS"||(version<1||version>35)||!(in>>std::quoted(d)>>count)||count>64)return false;def=wide(d);if(!d.empty()&&def.empty())return false;
for(size_t i=0;i<count;++i){UserPreset p;std::string n;int policy,flow,content,nr,sr;auto& s=p.settings;auto& m=s.model;auto& r=s.residual;
if(!(in>>std::quoted(n)>>m.intensity>>m.tone>>m.structure>>m.skin>>m.style>>m.autoMask>>m.uiCorrection>>r.total>>r.darken>>r.brighten>>r.color>>r.luminance>>nr>>sr>>s.multiplier>>policy>>flow>>content))return false;
if(version>=2){int enabled;if(!(in>>enabled>>s.protection.featherPixels)||enabled<0||enabled>1)return false;s.protection.enabled=enabled!=0;
diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cpp
index 99ef8a0a..27f0e0f1 100644
--- a/src/pipeline/EnhanceGraph.cpp
+++ b/src/pipeline/EnhanceGraph.cpp
@@ -39,6 +39,7 @@
#include "veyra/ngx/DlssNrRuntimeAdapter.h"
#include "veyra/ngx/DlssSrBackend.h"
#include "veyra/ngx/VideoSrBackend.h"
+#include "veyra/pipeline/VfxSrBackend.h"
#include "veyra/ngx/TrueHdrBackend.h"
#include "veyra/ngx/NgxCoreHost.h"
#include "veyra/ngx/DlssgLite.h"
@@ -65,6 +66,23 @@ namespace {
constexpr int64_t usPerSecond = 1000000;
float uintBits(uint32_t v) { return std::bit_cast<float>(v); }
+// RTX Video SR passes. The final pass (SR input -> SR output) takes the second
+// quality under double SR; the first pass (source -> first result) exists only
+// there. Each pass runs its own family's runtime: NGX for the standard family,
+// Video Effects VideoSuperRes for high bitrate and streaming.
+uint32_t finalVideoSrQuality(const EnhanceGraphDesc& d){return d.dualSr?d.dualSrQuality:d.videoSrQuality;}
+bool ngxVideoSrPass(const EnhanceGraphDesc& d){
+ return engine::rtxVideoSr(d.videoSrQuality)&&(engine::ngxVideoSr(finalVideoSrQuality(d))||(d.dualSr&&engine::ngxVideoSr(d.videoSrQuality)));
+}
+// The Video Effects families only enlarge: a first double SR result at the
+// source size (source already at the base target) is the source itself.
+bool vfxFirstSrPass(const EnhanceGraphDesc& d){
+ return d.dualSr&&engine::vfxVideoSr(d.videoSrQuality)&&(d.firstSrWidth!=d.sourceWidth||d.firstSrHeight!=d.sourceHeight);
+}
+unsigned vfxVideoSrPasses(const EnhanceGraphDesc& d){
+ if(!engine::rtxVideoSr(d.videoSrQuality))return 0;
+ return unsigned(engine::vfxVideoSr(finalVideoSrQuality(d)))+unsigned(vfxFirstSrPass(d));
+}
// N1 packed capture ingress helpers. Codes match pipeline::packedInputCode:
// 1 BGR24, 2 RGB555, 3 RGB565, 4 UYVY, 5 YVYU, 6 v210, 7 RGBXLE10.
@@ -556,7 +574,7 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)
veyra::log::info("graph","diagnostic SR motion override active; no product entry point enables this");
}
desc_ = desc;lastSourceColor_={};tracker_={};prevValid_=false;fgHistorySkipped_=false;cadence_.reset();scene_.reset();sceneLastSourceId_=0;previousLuma_.clear();
- if(desc.videoSrQuality>engine::kVideoSrFsr){veyra::log::error("graph",std::format("invalid video SR quality value={}",desc.videoSrQuality));return false;}
+ if(!engine::validVideoSrQuality(desc.videoSrQuality)){veyra::log::error("graph",std::format("invalid video SR quality value={}",desc.videoSrQuality));return false;}
srcW_ = desc.sourceWidth;
srcH_ = desc.sourceHeight;
workW_ = desc.workWidth;
@@ -592,7 +610,7 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)
if((desc.srInputWidth==0)!=(desc.srInputHeight==0)||(desc.srOutputWidth==0)!=(desc.srOutputHeight==0)){veyra::log::error("resolution","partial SR extent is invalid");return false;}
srInW_=desc.srInputWidth?desc.srInputWidth:srcW_;srInH_=desc.srInputHeight?desc.srInputHeight:srcH_;
srOutW_=desc.srOutputWidth?desc.srOutputWidth:workW_;srOutH_=desc.srOutputHeight?desc.srOutputHeight:workH_;
- if(desc.dualSr&&(!engine::srStageBackend(desc.videoSrQuality)||desc.dualSrQuality<1||desc.dualSrQuality>4||
+ if(desc.dualSr&&(!engine::rtxVideoSr(desc.videoSrQuality)||!engine::rtxVideoSr(desc.dualSrQuality)||
!Extent{desc.firstSrWidth,desc.firstSrHeight}.valid()||!srPrescaleActive())){
veyra::log::error("dual-sr","invalid independent SR stages or missing reduction");return false;
}
@@ -601,7 +619,7 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)
// 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 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;}
+ if(!desc.enableSr||!engine::rtxVideoSr(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_));
@@ -654,7 +672,12 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)
// 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
+ // Each Video Effects SR pass keeps a shared CUDA input and output buffer.
+ const bool vfxFinal=srEnabled_&&engine::rtxVideoSr(desc_.videoSrQuality)&&engine::vfxVideoSr(finalVideoSrQuality(desc_));
+ const bool vfxFirst=srEnabled_&&vfxFirstSrPass(desc_);
+ const uint64_t vfxSrBytes=(vfxFinal?uint64_t(srInW_)*srInH_*4u+uint64_t(srOutW_)*srOutH_*4u:0)+
+ (vfxFirst?uint64_t(srcW_)*srcH_*4u+uint64_t(desc_.firstSrWidth)*desc_.firstSrHeight*4u:0);
+ const uint64_t estimate=vfxSrBytes+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);
@@ -666,8 +689,11 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)
// The new reservation belongs to the staged graphs (double SR and the
// supersample shrink). Keep the existing single-pass admission policy,
// including ordinary 8K.
+ // 256 MiB per loaded SR model: the NGX feature (shared by its passes) and
+ // each Video Effects instance. An estimate, not a measured SDK peak.
+ const uint64_t srModels=std::max(1u,unsigned(vfxFinal)+unsigned(vfxFirst)+unsigned(srEnabled_&&ngxVideoSrPass(desc_)));
const uint64_t sdkReserve=stagedSr?((nrEnabled_?(1024ull<<20):0)+
- (vfg?uint64_t(workW_)*workH_*128u:0)+(256ull<<20)):0;
+ (vfg?uint64_t(workW_)*workH_*128u:0)+srModels*(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,stagedSr?20:0));
@@ -1317,7 +1343,7 @@ bool EnhanceGraph::initNgxFeatures()
// FSR upscaling is a FidelityFX effect: a session whose only feature is
// FSR SR must not require (or fail on) the NGX core.
const bool needNgxCore = (nrEnabled_ && !lmxxfNr_) || (fgEnabled_ && !fsrEnabled() && !vfgBackend_) || desc_.convertVideoHdr() ||
- (srEnabled_ && desc_.videoSrQuality!=engine::kVideoSrFsr);
+ (srEnabled_ && (desc_.videoSrQuality==0 || ngxVideoSrPass(desc_)));
if (!needNgxCore) {
veyra::log::info("graph", "NGX core skipped: lmxxf NR / AMD FSR stages use their own runtimes");
}
@@ -1541,7 +1567,23 @@ bool EnhanceGraph::initNgxFeatures()
}
if(desc_.nrAutoPoolLayer&&!createAutoNrPool())return false;
- if (srEnabled_ && !desc_.noFeatures && desc_.videoSrQuality!=engine::kVideoSrFsr) {
+ // Video Effects SR passes run on their own CUDA streams, without an NGX list.
+ if(srEnabled_&&!desc_.noFeatures&&vfxVideoSrPasses(desc_)){
+ failedBackend_=engine::FailedBackend::Sr;
+ if(engine::vfxVideoSr(finalVideoSrQuality(desc_))){
+ vfxSrBackend_=std::make_unique<VfxSrBackend>();
+ if(!vfxSrBackend_->initialize(context_,desc_.runtimeAbsPath,srInW_,srInH_,srOutW_,srOutH_,finalVideoSrQuality(desc_)))return false;
+ veyra::log::info("video-sr",std::format("selected quality={} runtime=video-effects input={}x{} output={}x{}{}",finalVideoSrQuality(desc_),srcW_,srcH_,workW_,workH_,
+ 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(vfxFirstSrPass(desc_)){
+ firstVfxSrBackend_=std::make_unique<VfxSrBackend>();
+ if(!firstVfxSrBackend_->initialize(context_,desc_.runtimeAbsPath,srcW_,srcH_,desc_.firstSrWidth,desc_.firstSrHeight,desc_.videoSrQuality))return false;
+ }
+ failedBackend_=engine::FailedBackend::Infrastructure;
+ }
+ if (srEnabled_ && !desc_.noFeatures && (desc_.videoSrQuality==0||ngxVideoSrPass(desc_))) {
ngx::DlssSrBackend::CreateDesc sd{};
sd.inputWidth = srcW_; sd.inputHeight = srcH_;
sd.outputWidth = workW_; sd.outputHeight = workH_;
@@ -1549,16 +1591,18 @@ bool EnhanceGraph::initNgxFeatures()
ID3D12GraphicsCommandList* list = ring_.acquire(0, st);
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_,
+ if(desc_.videoSrQuality){
+ if(engine::ngxVideoSr(finalVideoSrQuality(desc_))){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_,
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;
+ srResolveActive()?std::format(" supersample evaluate={}x{} output={}x{}",srOutW_,srOutH_,workW_,workH_):std::string()));}
+ if(desc_.dualSr&&engine::ngxVideoSr(desc_.videoSrQuality)){firstVideoSrBackend_=std::make_unique<ngx::VideoSrBackend>();if(!firstVideoSrBackend_->create(*coreHost_,list,srcW_,srcH_,desc_.firstSrWidth,desc_.firstSrHeight)){
+ // A shared create key reuses the final pass's feature; without one there is no fallback.
+ if(!videoSrBackend_||!firstVideoSrBackend_->duplicateCreation())return false;
firstVideoSrBackend_.reset();
veyra::log::info("dual-sr","SDK create key shared; two ordered evaluations with separate textures");
}
- if(firstVideoSrBackend_&&firstVideoSrBackend_->identity()==videoSrBackend_->identity()){veyra::log::error("dual-sr","runtime aliased the independent feature handles");return false;}
- veyra::log::info("dual-sr",std::format("passes=2 source={}x{} first={}x{} shrink={}x{} second={}x{} output={}x{} firstQuality={} secondQuality={}",srcW_,srcH_,desc_.firstSrWidth,desc_.firstSrHeight,srInW_,srInH_,srOutW_,srOutH_,workW_,workH_,desc_.videoSrQuality,desc_.dualSrQuality));}
+ if(firstVideoSrBackend_&&videoSrBackend_&&firstVideoSrBackend_->identity()==videoSrBackend_->identity()){veyra::log::error("dual-sr","runtime aliased the independent feature handles");return false;}
+ }
}
else if (!srBackend_->create(*coreHost_, list, ngxParams_, sd, st) || !srBackend_->created()) {
veyra::log::error("graph", "SR create failed");
@@ -1568,6 +1612,10 @@ bool EnhanceGraph::initNgxFeatures()
if(!ring_.submitAndSignal(0)||!ring_.waitIdle())return false;
}
+ if(srEnabled_&&!desc_.noFeatures&&desc_.dualSr&&(videoSrBackend_||vfxSrBackend_))
+ veyra::log::info("dual-sr",std::format("passes=2 source={}x{} first={}x{} shrink={}x{} second={}x{} output={}x{} firstQuality={} secondQuality={} firstRuntime={} secondRuntime={}",srcW_,srcH_,desc_.firstSrWidth,desc_.firstSrHeight,srInW_,srInH_,srOutW_,srOutH_,workW_,workH_,desc_.videoSrQuality,desc_.dualSrQuality,
+ firstVfxSrBackend_?"video-effects":engine::vfxVideoSr(desc_.videoSrQuality)?"copy":"ngx",vfxSrBackend_?"video-effects":"ngx"));
+
// Still images have no temporal pair and must not depend on FG support.
// FG create + warm-up evaluate BEFORE descriptor views (the runtime
// allocates internals at the first evaluate and would fail after views
@@ -2626,6 +2674,20 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
auto runVideoSr=[&]()->bool{
gpuTimer_.mark(list,GpuStage::Sr);
+ // Video Effects hand-off: copy in, submit, queue signal -> CUDA run -> queue
+ // wait, then copy out on the next list of this slot. No CPU wait.
+ auto runVfx=[&](VfxSrBackend& vfx,ID3D12Resource* input,ID3D12Resource* output)->bool{
+ tracker_.transition(list,input,D3D12_RESOURCE_STATE_COPY_SOURCE);
+ if(!vfx.copyIn(list,input)){failedBackend_=engine::FailedBackend::Sr;return false;}
+ tracker_.transition(list,input,D3D12_RESOURCE_STATE_COMMON);
+ if(!submitGraph(slot))return false;
+ if(!vfx.run(ring_.queue())){failedBackend_=engine::FailedBackend::Sr;return false;}
+ list=ring_.acquireNext(slot,st);if(!list)return false;
+ tracker_.transition(list,output,D3D12_RESOURCE_STATE_COPY_DEST);
+ if(!vfx.copyOut(list,output)){failedBackend_=engine::FailedBackend::Sr;return false;}
+ tracker_.transition(list,output,D3D12_RESOURCE_STATE_COMMON);
+ return true;
+ };
if(desc_.dualSr){
tracker_.transition(list,srStageInput(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
tracker_.transition(list,firstSrInput_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
@@ -2633,8 +2695,16 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
blitPass_.bind(list,encFirst,gpuHandleOf(blitPass_,22).ptr,gpuHandleOf(blitPass_,23).ptr);
list->Dispatch((srcW_+15)/16,(srcH_+15)/16,1);tracker_.uavBarrier(list,firstSrInput_.Get());
tracker_.transition(list,firstSrInput_.Get(),D3D12_RESOURCE_STATE_COMMON);tracker_.transition(list,firstSrOutput_.Get(),D3D12_RESOURCE_STATE_COMMON);
- auto* first=firstVideoSrBackend_?firstVideoSrBackend_.get():videoSrBackend_.get();
- if(!first->evaluate(list,firstSrInput_.Get(),firstSrOutput_.Get(),desc_.videoSrQuality)){failedBackend_=engine::FailedBackend::Sr;return false;}
+ if(firstVfxSrBackend_){if(!runVfx(*firstVfxSrBackend_,firstSrInput_.Get(),firstSrOutput_.Get()))return false;}
+ else if(engine::vfxVideoSr(desc_.videoSrQuality)){
+ // Video Effects families only enlarge; at the source size the first result is the source.
+ tracker_.transition(list,firstSrInput_.Get(),D3D12_RESOURCE_STATE_COPY_SOURCE);tracker_.transition(list,firstSrOutput_.Get(),D3D12_RESOURCE_STATE_COPY_DEST);
+ list->CopyResource(firstSrOutput_.Get(),firstSrInput_.Get());
+ tracker_.transition(list,firstSrInput_.Get(),D3D12_RESOURCE_STATE_COMMON);tracker_.transition(list,firstSrOutput_.Get(),D3D12_RESOURCE_STATE_COMMON);
+ }else{
+ auto* first=firstVideoSrBackend_?firstVideoSrBackend_.get():videoSrBackend_.get();
+ if(!first||!first->evaluate(list,firstSrInput_.Get(),firstSrOutput_.Get(),desc_.videoSrQuality)){failedBackend_=engine::FailedBackend::Sr;return false;}
+ }
tracker_.uavBarrier(list,firstSrOutput_.Get());tracker_.transition(list,firstSrOutput_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
tracker_.transition(list,firstSrLinear_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
const float decFirst[8]={uintBits(desc_.firstSrWidth),uintBits(desc_.firstSrHeight),uintBits(desc_.firstSrWidth),uintBits(desc_.firstSrHeight),-1,0,0,0};
@@ -2659,7 +2729,8 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
const float enc[8]={uintBits(srInW_),uintBits(srInH_),uintBits(srInW_),uintBits(srInH_),desc_.hdrWorking()?3.0f:1.0f,0,0,0};
blitPass_.bind(list,enc,gpuHandleOf(blitPass_,prescaled?21:desc_.nrBeforeSr||sourcePostOutput_?18:0).ptr,gpuHandleOf(blitPass_,16).ptr);list->Dispatch((srInW_+15)/16,(srInH_+15)/16,1);tracker_.uavBarrier(list,videoSrInput_.Get());
tracker_.transition(list,videoSrInput_.Get(),D3D12_RESOURCE_STATE_COMMON);tracker_.transition(list,videoSrOutput_.Get(),D3D12_RESOURCE_STATE_COMMON);
- if(!videoSrBackend_->evaluate(list,videoSrInput_.Get(),videoSrOutput_.Get(),desc_.dualSr?desc_.dualSrQuality:desc_.videoSrQuality)){failedBackend_=engine::FailedBackend::Sr;return false;}
+ if(vfxSrBackend_){if(!runVfx(*vfxSrBackend_,videoSrInput_.Get(),videoSrOutput_.Get()))return false;}
+ else if(!videoSrBackend_->evaluate(list,videoSrInput_.Get(),videoSrOutput_.Get(),desc_.dualSr?desc_.dualSrQuality:desc_.videoSrQuality)){failedBackend_=engine::FailedBackend::Sr;return false;}
tracker_.uavBarrier(list,videoSrOutput_.Get());tracker_.transition(list,videoSrOutput_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);tracker_.transition(list,workRgba_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
// HDR restore and the resolve take the base that was encoded.
const UINT restoreSet=prescaled?7:desc_.nrBeforeSr||sourcePostOutput_?4:0;
@@ -2853,7 +2924,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
++metrics_.srEvaluateCount;gpuTimer_.mark(list,GpuStage::Sr,true);
tracker_.uavBarrier(list,workRgba_.Get());
tracker_.transition(list,workRgba_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
- } else if(srEnabled_&&videoSrBackend_){
+ } else if(srEnabled_&&(videoSrBackend_||vfxSrBackend_)){
if(!runVideoSr())return false;
} else if (srEnabled_ && srBackend_ && srBackend_->created()) {
gpuTimer_.mark(list,GpuStage::Sr);
@@ -3746,6 +3817,7 @@ void EnhanceGraph::shutdown()
if (fgBackend_) featuresReleased=fgBackend_->release()&&featuresReleased;
if(firstVideoSrBackend_){featuresReleased=firstVideoSrBackend_->release()&&featuresReleased;firstVideoSrBackend_.reset();}
if(videoSrBackend_){featuresReleased=videoSrBackend_->release()&&featuresReleased;videoSrBackend_.reset();}
+ vfxSrBackend_.reset();firstVfxSrBackend_.reset();
if(videoHdrBackend_)featuresReleased=videoHdrBackend_->release()&&featuresReleased;
videoHdrBackend_.reset();videoHdrInput_.Reset();videoHdrOutput_.Reset();
if (srBackend_) featuresReleased=srBackend_->release()&&featuresReleased;
diff --git a/src/pipeline/VfxSrBackend.cpp b/src/pipeline/VfxSrBackend.cpp
new file mode 100644
index 00000000..7d6760b4
--- /dev/null
+++ b/src/pipeline/VfxSrBackend.cpp
@@ -0,0 +1,313 @@
+#include "veyra/pipeline/VfxSrBackend.h"
+#include "veyra/pipeline/VfgBackend.h"
+#include "veyra/engine/EnhancementSettings.h"
+#include "veyra/gfx/D3D12DeviceContext.h"
+#include "veyra/Log.h"
+#include <Windows.h>
+#include <wrl/client.h>
+#include <array>
+#include <chrono>
+#include <filesystem>
+#include <format>
+#include <vector>
+#ifdef VEYRA_HAVE_CUDA_DRIVER_HEADERS
+#include <cuda.h>
+#endif
+
+namespace veyra::pipeline {
+namespace {
+namespace fs=std::filesystem;
+constexpr DWORD kDllFlags=LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR|LOAD_LIBRARY_SEARCH_SYSTEM32|LOAD_LIBRARY_SEARCH_USER_DIRS;
+bool regularFile(const fs::path& path){std::error_code error;return fs::is_regular_file(path,error);}
+HMODULE load(const fs::path& path){
+ const auto dll=LoadLibraryExW(path.c_str(),nullptr,kDllFlags);
+ if(!dll){const auto bytes=path.u8string();
+ log::error("vfx-sr",std::format("LoadLibrary failed path={} win32={}",std::string(reinterpret_cast<const char*>(bytes.data()),bytes.size()),GetLastError()));}
+ return dll;
+}
+template<class T> bool bind(HMODULE dll,const char* name,T& fn){
+ fn=reinterpret_cast<T>(GetProcAddress(dll,name));
+ if(!fn)log::error("vfx-sr",std::format("missing API {} win32={}",name,GetLastError()));
+ return fn!=nullptr;
+}
+bool hr(HRESULT value,const char* operation){
+ if(SUCCEEDED(value))return true;
+ log::error("vfx-sr",std::format("{} HRESULT=0x{:08X}",operation,unsigned(value)));return false;
+}
+}
+
+bool VfxSrBackend::runtimeAvailable(const std::wstring& root){
+#ifdef VEYRA_HAVE_CUDA_DRIVER_HEADERS
+ const fs::path directory=VfgBackend::runtimeDirectory(root);
+ if(directory.empty())return false;
+ for(auto name:{L"NVVideoEffects.dll",L"NVCVImage.dll",L"nvngxruntime.dll",L"cudart64_12.dll",L"nvVFXVideoSuperRes.dll",L"nvngx_vsr.dll"})
+ if(!regularFile(directory/name))return false;
+ return true;
+#else
+ (void)root;return false;
+#endif
+}
+
+struct VfxSrBackend::Impl {
+#ifdef VEYRA_HAVE_CUDA_DRIVER_HEADERS
+ int (__cdecl* create)(const char*,void**)=nullptr;
+ void (__cdecl* destroy)(void*)=nullptr;
+ int (__cdecl* setU32)(void*,const char*,unsigned)=nullptr;
+ int (__cdecl* setImage)(void*,const char*,void*)=nullptr;
+ int (__cdecl* setStream)(void*,const char*,CUstream)=nullptr;
+ int (__cdecl* loadEffect)(void*)=nullptr;
+ int (__cdecl* runEffect)(void*,int)=nullptr;
+ int (__cdecl* imageCreate)(unsigned,unsigned,int,int,unsigned,unsigned,unsigned,void**)=nullptr;
+ void (__cdecl* imageDealloc)(void*)=nullptr;
+ void (__cdecl* imageDestroy)(void*)=nullptr;
+ int (__cdecl* imageInit)(void*,unsigned,unsigned,int,void*,int,int,unsigned,unsigned)=nullptr;
+ int (__cdecl* fromD3D)(DXGI_FORMAT,int*,int*,unsigned char*)=nullptr;
+ const char* (__cdecl* errorString)(int)=nullptr;
+#define CU_FN(name) decltype(&name) name##Fn=nullptr
+ CU_FN(cuInit);CU_FN(cuDeviceGetCount);CU_FN(cuDeviceGet);CU_FN(cuDeviceGetLuid);CU_FN(cuDeviceGetAttribute);
+ CU_FN(cuDevicePrimaryCtxRetain);CU_FN(cuDevicePrimaryCtxRelease);CU_FN(cuCtxPushCurrent);CU_FN(cuCtxPopCurrent);
+ CU_FN(cuStreamCreate);CU_FN(cuStreamDestroy);CU_FN(cuStreamSynchronize);
+ CU_FN(cuImportExternalMemory);CU_FN(cuExternalMemoryGetMappedBuffer);CU_FN(cuDestroyExternalMemory);CU_FN(cuMemFree);
+ CU_FN(cuImportExternalSemaphore);CU_FN(cuDestroyExternalSemaphore);CU_FN(cuWaitExternalSemaphoresAsync);CU_FN(cuSignalExternalSemaphoresAsync);
+ CU_FN(cuGetErrorName);CU_FN(cuGetErrorString);
+#undef CU_FN
+ struct Buffer {
+ Microsoft::WRL::ComPtr<ID3D12Resource> resource;
+ CUexternalMemory memory=nullptr;
+ CUdeviceptr pointer=0;
+ void* image=nullptr;
+ D3D12_PLACED_SUBRESOURCE_FOOTPRINT footprint{};
+ uint64_t bytes=0;
+ };
+ Buffer input,output;
+ gfx::D3D12DeviceContext* context=nullptr;
+ Microsoft::WRL::ComPtr<ID3D12Fence> producer,completion;
+ CUexternalSemaphore inputSemaphore=nullptr,outputSemaphore=nullptr;
+ CUcontext cudaContext=nullptr;CUstream stream=nullptr;CUdevice device=0;
+ void* effect=nullptr;
+ bool retained=false,ready=false;
+ uint64_t signalValue=0;
+ std::vector<HMODULE> libraries;
+ bool cv(int code,const char* name){
+ if(code==0)return true;
+ log::error("vfx-sr",std::format("{} status={} detail={}",name,code,errorString?errorString(code):"unavailable"));return false;
+ }
+ bool cu(CUresult code,const char* name){
+ if(code==CUDA_SUCCESS)return true;
+ const char* label=nullptr;const char* detail=nullptr;
+ if(cuGetErrorNameFn)cuGetErrorNameFn(code,&label);
+ if(cuGetErrorStringFn)cuGetErrorStringFn(code,&detail);
+ log::error("vfx-sr-cuda",std::format("{} result={} name={} detail={}",name,unsigned(code),label?label:"?",detail?detail:"?"));return false;
+ }
+ struct Current {
+ Impl& owner;bool active=false;
+ explicit Current(Impl& p):owner(p){active=p.cu(p.cuCtxPushCurrentFn(p.cudaContext),"cuCtxPushCurrent");}
+ ~Current(){if(active){CUcontext previous=nullptr;owner.cu(owner.cuCtxPopCurrentFn(&previous),"cuCtxPopCurrent");}}
+ };
+ bool importFence(ID3D12Fence* fence,CUexternalSemaphore& semaphore){
+ HANDLE handle=nullptr;
+ if(!hr(context->device()->CreateSharedHandle(fence,nullptr,GENERIC_ALL,nullptr,&handle),"CreateSharedHandle fence"))return false;
+ CUDA_EXTERNAL_SEMAPHORE_HANDLE_DESC desc{};desc.type=CU_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE;desc.handle.win32.handle=handle;
+ const auto code=cuImportExternalSemaphoreFn(&semaphore,&desc);CloseHandle(handle);
+ return cu(code,"cuImportExternalSemaphore");
+ }
+ // A shared row-major buffer laid out as the texture's copyable footprint,
+ // mapped into CUDA and wrapped (not owned) by an NvCVImage descriptor.
+ bool makeBuffer(Buffer& buffer,unsigned width,unsigned height,int pixelFormat,int componentType,unsigned layout){
+ D3D12_RESOURCE_DESC texture{};texture.Dimension=D3D12_RESOURCE_DIMENSION_TEXTURE2D;texture.Width=width;texture.Height=height;
+ texture.DepthOrArraySize=1;texture.MipLevels=1;texture.Format=DXGI_FORMAT_R8G8B8A8_UNORM;texture.SampleDesc.Count=1;
+ UINT rows=0;uint64_t rowBytes=0,total=0;context->device()->GetCopyableFootprints(&texture,0,1,0,&buffer.footprint,&rows,&rowBytes,&total);
+ buffer.bytes=uint64_t(buffer.footprint.Footprint.RowPitch)*height;
+ D3D12_HEAP_PROPERTIES heap{};heap.Type=D3D12_HEAP_TYPE_DEFAULT;
+ D3D12_RESOURCE_DESC desc{};desc.Dimension=D3D12_RESOURCE_DIMENSION_BUFFER;desc.Width=buffer.bytes;desc.Height=1;
+ desc.DepthOrArraySize=1;desc.MipLevels=1;desc.SampleDesc.Count=1;desc.Layout=D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
+ if(!hr(context->device()->CreateCommittedResource(&heap,D3D12_HEAP_FLAG_SHARED,&desc,D3D12_RESOURCE_STATE_COMMON,nullptr,IID_PPV_ARGS(&buffer.resource)),"Create shared buffer"))return false;
+ HANDLE handle=nullptr;
+ if(!hr(context->device()->CreateSharedHandle(buffer.resource.Get(),nullptr,GENERIC_ALL,nullptr,&handle),"CreateSharedHandle buffer"))return false;
+ CUDA_EXTERNAL_MEMORY_HANDLE_DESC imported{};
+ imported.type=CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE;imported.handle.win32.handle=handle;
+ imported.size=context->device()->GetResourceAllocationInfo(0,1,&desc).SizeInBytes;imported.flags=CUDA_EXTERNAL_MEMORY_DEDICATED;
+ const auto code=cuImportExternalMemoryFn(&buffer.memory,&imported);CloseHandle(handle);
+ if(!cu(code,"cuImportExternalMemory"))return false;
+ CUDA_EXTERNAL_MEMORY_BUFFER_DESC mapped{};mapped.size=buffer.bytes;
+ if(!cu(cuExternalMemoryGetMappedBufferFn(&buffer.pointer,buffer.memory,&mapped),"cuExternalMemoryGetMappedBuffer"))return false;
+ if(!cv(imageCreate(1,1,pixelFormat,componentType,layout,0,1,&buffer.image),"NvCVImage_Create"))return false;
+ imageDealloc(buffer.image);
+ return cv(imageInit(buffer.image,width,height,int(buffer.footprint.Footprint.RowPitch),reinterpret_cast<void*>(buffer.pointer),pixelFormat,componentType,layout,1),"NvCVImage_Init");
+ }
+ void releaseBuffer(Buffer& buffer){
+ if(buffer.image){imageDestroy(buffer.image);buffer.image=nullptr;}
+ if(buffer.pointer){cu(cuMemFreeFn(buffer.pointer),"cuMemFree external mapping");buffer.pointer=0;}
+ if(buffer.memory){cu(cuDestroyExternalMemoryFn(buffer.memory),"cuDestroyExternalMemory");buffer.memory=nullptr;}
+ buffer.resource.Reset();
+ }
+ bool copy(ID3D12GraphicsCommandList* list,ID3D12Resource* texture,const Buffer& buffer,bool toBuffer){
+ if(!ready||!list||!texture)return false;
+ D3D12_TEXTURE_COPY_LOCATION shared{};shared.pResource=buffer.resource.Get();shared.Type=D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;shared.PlacedFootprint=buffer.footprint;
+ D3D12_TEXTURE_COPY_LOCATION image{};image.pResource=texture;image.Type=D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;image.SubresourceIndex=0;
+ if(toBuffer)list->CopyTextureRegion(&shared,0,0,0,&image,nullptr);else list->CopyTextureRegion(&image,0,0,0,&shared,nullptr);
+ return true;
+ }
+#endif
+};
+
+VfxSrBackend::VfxSrBackend():impl_(std::make_unique<Impl>()){}
+VfxSrBackend::~VfxSrBackend(){shutdown();}
+
+bool VfxSrBackend::initialize(gfx::D3D12DeviceContext& context,const std::wstring& root,unsigned inputWidth,unsigned inputHeight,
+ unsigned outputWidth,unsigned outputHeight,unsigned quality){
+ shutdown();
+#ifdef VEYRA_HAVE_CUDA_DRIVER_HEADERS
+ auto& p=*impl_;
+ if(context.adapter().vendorId!=0x10DE||!runtimeAvailable(root)||!engine::vfxVideoSr(quality)||
+ !inputWidth||!inputHeight||outputWidth<inputWidth||outputHeight<inputHeight){
+ log::error("vfx-sr","unsupported adapter/runtime/mode/dimensions");return false;
+ }
+ p.context=&context;
+ std::array<wchar_t,32768> system{};const auto n=GetSystemDirectoryW(system.data(),UINT(system.size()));if(!n||n>=system.size())return false;
+ HMODULE driver=load(fs::path(system.data())/L"nvcuda.dll");if(!driver)return false;p.libraries.push_back(driver);
+#define BIND_CU(name,exported) if(!bind(driver,exported,p.name##Fn))return false
+ BIND_CU(cuInit,"cuInit");BIND_CU(cuDeviceGetCount,"cuDeviceGetCount");BIND_CU(cuDeviceGet,"cuDeviceGet");BIND_CU(cuDeviceGetLuid,"cuDeviceGetLuid");
+ BIND_CU(cuDeviceGetAttribute,"cuDeviceGetAttribute");BIND_CU(cuDevicePrimaryCtxRetain,"cuDevicePrimaryCtxRetain");
+ BIND_CU(cuDevicePrimaryCtxRelease,"cuDevicePrimaryCtxRelease_v2");BIND_CU(cuCtxPushCurrent,"cuCtxPushCurrent_v2");BIND_CU(cuCtxPopCurrent,"cuCtxPopCurrent_v2");
+ BIND_CU(cuStreamCreate,"cuStreamCreate");BIND_CU(cuStreamDestroy,"cuStreamDestroy_v2");BIND_CU(cuStreamSynchronize,"cuStreamSynchronize");
+ BIND_CU(cuImportExternalMemory,"cuImportExternalMemory");BIND_CU(cuExternalMemoryGetMappedBuffer,"cuExternalMemoryGetMappedBuffer");
+ BIND_CU(cuDestroyExternalMemory,"cuDestroyExternalMemory");BIND_CU(cuMemFree,"cuMemFree_v2");
+ BIND_CU(cuImportExternalSemaphore,"cuImportExternalSemaphore");BIND_CU(cuDestroyExternalSemaphore,"cuDestroyExternalSemaphore");
+ BIND_CU(cuWaitExternalSemaphoresAsync,"cuWaitExternalSemaphoresAsync");BIND_CU(cuSignalExternalSemaphoresAsync,"cuSignalExternalSemaphoresAsync");
+ BIND_CU(cuGetErrorName,"cuGetErrorName");BIND_CU(cuGetErrorString,"cuGetErrorString");
+#undef BIND_CU
+ if(!p.cu(p.cuInitFn(0),"cuInit"))return false;
+ int count=0;if(!p.cu(p.cuDeviceGetCountFn(&count),"cuDeviceGetCount"))return false;
+ bool matched=false;
+ for(int i=0;i<count;++i){CUdevice device=0;uint64_t luid=0;unsigned node=0;
+ if(!p.cu(p.cuDeviceGetFn(&device,i),"cuDeviceGet")||!p.cu(p.cuDeviceGetLuidFn(reinterpret_cast<char*>(&luid),&node,device),"cuDeviceGetLuid"))return false;
+ if(luid==context.adapter().luid&&node){p.device=device;matched=true;break;}
+ }
+ if(!matched){log::error("vfx-sr","CUDA/D3D12 adapter LUID mismatch");return false;}
+ int major=0,minor=0;
+ if(!p.cu(p.cuDeviceGetAttributeFn(&major,CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR,p.device),"compute major")||
+ !p.cu(p.cuDeviceGetAttributeFn(&minor,CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR,p.device),"compute minor"))return false;
+ // Tensor cores (Turing) for every mode; the SDK lists streaming modes for Ampere or newer.
+ if(major<7||(major==7&&minor<5)||(engine::vfxVideoSrNeedsAmpere(quality)&&major<8)){
+ log::error("vfx-sr",std::format("mode {} not supported on compute {}.{}",quality,major,minor));return false;
+ }
+ if(!p.cu(p.cuDevicePrimaryCtxRetainFn(&p.cudaContext,p.device),"cuDevicePrimaryCtxRetain"))return false;p.retained=true;
+ Impl::Current current(p);if(!current.active)return false;
+ // A blocking stream, unlike VFG's: VideoSuperRes queues part of its work on
+ // the legacy default stream, which orders only against blocking streams. On a
+ // non-blocking stream it read the input before the producer fence and finished
+ // after the completion signal (2026-11-05: black first frames, outputs 1-4
+ // frames late with repeats and skips; aligned on every frame once blocking).
+ if(!p.cu(p.cuStreamCreateFn(&p.stream,CU_STREAM_DEFAULT),"cuStreamCreate"))return false;
+ const fs::path runtime=VfgBackend::runtimeDirectory(root);
+ HMODULE core=nullptr,image=nullptr;
+ for(auto name:{L"cudart64_12.dll",L"NVCVImage.dll",L"nvngxruntime.dll",L"NVVideoEffects.dll",L"nvVFXVideoSuperRes.dll"}){
+ auto dll=load(runtime/name);if(!dll)return false;p.libraries.push_back(dll);
+ if(std::wstring_view(name)==L"NVVideoEffects.dll")core=dll;if(std::wstring_view(name)==L"NVCVImage.dll")image=dll;
+ }
+#define BIND_VFX(member,name) if(!bind(core,name,p.member))return false
+ BIND_VFX(create,"NvVFX_CreateEffect");BIND_VFX(destroy,"NvVFX_DestroyEffect");BIND_VFX(setU32,"NvVFX_SetU32");BIND_VFX(setImage,"NvVFX_SetImage");
+ BIND_VFX(setStream,"NvVFX_SetCudaStream");BIND_VFX(loadEffect,"NvVFX_Load");BIND_VFX(runEffect,"NvVFX_Run");
+#undef BIND_VFX
+#define BIND_IMAGE(member,name) if(!bind(image,name,p.member))return false
+ BIND_IMAGE(imageCreate,"NvCVImage_Create");BIND_IMAGE(imageDealloc,"NvCVImage_Dealloc");BIND_IMAGE(imageDestroy,"NvCVImage_Destroy");
+ BIND_IMAGE(imageInit,"NvCVImage_Init");BIND_IMAGE(fromD3D,"NvCVImage_FromD3DFormat");BIND_IMAGE(errorString,"NvCV_GetErrorStringFromCode");
+#undef BIND_IMAGE
+ int pixelFormat=0,componentType=0;unsigned char layout=0;
+ if(!p.cv(p.fromD3D(DXGI_FORMAT_R8G8B8A8_UNORM,&pixelFormat,&componentType,&layout),"NvCVImage_FromD3DFormat"))return false;
+ if(!p.makeBuffer(p.input,inputWidth,inputHeight,pixelFormat,componentType,layout)||
+ !p.makeBuffer(p.output,outputWidth,outputHeight,pixelFormat,componentType,layout))return false;
+ if(!hr(context.device()->CreateFence(0,D3D12_FENCE_FLAG_SHARED,IID_PPV_ARGS(&p.producer)),"CreateFence producer")||
+ !hr(context.device()->CreateFence(0,D3D12_FENCE_FLAG_SHARED,IID_PPV_ARGS(&p.completion)),"CreateFence completion")||
+ !p.importFence(p.producer.Get(),p.inputSemaphore)||!p.importFence(p.completion.Get(),p.outputSemaphore))return false;
+ const auto start=std::chrono::steady_clock::now();
+ if(!p.cv(p.create("VideoSuperRes",&p.effect),"NvVFX_CreateEffect(VideoSuperRes)")||
+ !p.cv(p.setImage(p.effect,"SrcImage0",p.input.image),"SrcImage0")||!p.cv(p.setImage(p.effect,"DstImage0",p.output.image),"DstImage0")||
+ !p.cv(p.setStream(p.effect,"CudaStream",p.stream),"CudaStream")||!p.cv(p.setU32(p.effect,"QualityLevel",quality),"QualityLevel")||
+ !p.cv(p.loadEffect(p.effect),"NvVFX_Load(VideoSuperRes)"))return false;
+ p.ready=true;
+ log::info("vfx-sr",std::format("VideoSuperRes quality={} input={}x{} output={}x{} compute={}.{} LUID={} loadMs={:.0f}",
+ quality,inputWidth,inputHeight,outputWidth,outputHeight,major,minor,context.adapter().luidString,
+ std::chrono::duration<double,std::milli>(std::chrono::steady_clock::now()-start).count()));
+ return true;
+#else
+ (void)context;(void)root;(void)inputWidth;(void)inputHeight;(void)outputWidth;(void)outputHeight;(void)quality;
+ log::error("vfx-sr","built without CUDA driver headers");return false;
+#endif
+}
+
+bool VfxSrBackend::created()const{
+#ifdef VEYRA_HAVE_CUDA_DRIVER_HEADERS
+ return impl_->ready;
+#else
+ return false;
+#endif
+}
+
+bool VfxSrBackend::copyIn(ID3D12GraphicsCommandList* list,ID3D12Resource* texture){
+#ifdef VEYRA_HAVE_CUDA_DRIVER_HEADERS
+ return impl_->copy(list,texture,impl_->input,true);
+#else
+ (void)list;(void)texture;return false;
+#endif
+}
+
+bool VfxSrBackend::copyOut(ID3D12GraphicsCommandList* list,ID3D12Resource* texture){
+#ifdef VEYRA_HAVE_CUDA_DRIVER_HEADERS
+ return impl_->copy(list,texture,impl_->output,false);
+#else
+ (void)list;(void)texture;return false;
+#endif
+}
+
+bool VfxSrBackend::run(ID3D12CommandQueue* queue){
+#ifdef VEYRA_HAVE_CUDA_DRIVER_HEADERS
+ auto& p=*impl_;
+ if(!p.ready||!queue)return false;
+ const uint64_t value=++p.signalValue;
+ if(!hr(queue->Signal(p.producer.Get(),value),"signal VideoSuperRes producer"))return false;
+ bool waited=false,ok=false;
+ {
+ Impl::Current current(p);
+ if(current.active){
+ CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS wait{};wait.params.fence.value=value;
+ waited=p.cu(p.cuWaitExternalSemaphoresAsyncFn(&p.inputSemaphore,&wait,1,p.stream),"cuWaitExternalSemaphoresAsync");
+ ok=waited&&p.cv(p.runEffect(p.effect,1),"NvVFX_Run(VideoSuperRes)");
+ CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS signal{};signal.params.fence.value=value;
+ ok=p.cu(p.cuSignalExternalSemaphoresAsyncFn(&p.outputSemaphore,&signal,1,p.stream),"cuSignalExternalSemaphoresAsync")&&ok;
+ // A rejected job must never leave the graph queue waiting: drain what
+ // CUDA accepted and release the completion value from the host.
+ if(!ok){if(waited)p.cu(p.cuStreamSynchronizeFn(p.stream),"rejected VideoSuperRes drain");hr(p.completion->Signal(value),"release failed VideoSuperRes job");}
+ }else hr(p.completion->Signal(value),"release VideoSuperRes without CUDA context");
+ }
+ if(!hr(queue->Wait(p.completion.Get(),value),"queue wait VideoSuperRes completion"))return false;
+ if(!ok)p.ready=false;
+ return ok;
+#else
+ (void)queue;return false;
+#endif
+}
+
+void VfxSrBackend::shutdown(){
+#ifdef VEYRA_HAVE_CUDA_DRIVER_HEADERS
+ auto& p=*impl_;p.ready=false;
+ if(p.cudaContext&&p.cuCtxPushCurrentFn&&p.cuCtxPopCurrentFn){
+ Impl::Current current(p);
+ if(current.active){
+ // Teardown, not per-frame synchronization: the graph drains its queue first.
+ if(p.stream)p.cu(p.cuStreamSynchronizeFn(p.stream),"teardown cuStreamSynchronize");
+ if(p.effect){p.destroy(p.effect);p.effect=nullptr;}
+ p.releaseBuffer(p.output);p.releaseBuffer(p.input);
+ if(p.outputSemaphore)p.cu(p.cuDestroyExternalSemaphoreFn(p.outputSemaphore),"destroy output semaphore");
+ if(p.inputSemaphore)p.cu(p.cuDestroyExternalSemaphoreFn(p.inputSemaphore),"destroy input semaphore");
+ if(p.stream)p.cu(p.cuStreamDestroyFn(p.stream),"cuStreamDestroy");
+ }
+ }
+ if(p.retained)p.cu(p.cuDevicePrimaryCtxReleaseFn(p.device),"cuDevicePrimaryCtxRelease");
+ p.producer.Reset();p.completion.Reset();
+ for(auto i=p.libraries.rbegin();i!=p.libraries.rend();++i)FreeLibrary(*i);
+ impl_=std::make_unique<Impl>();
+#endif
+}
+}
diff --git a/src/ui/bridge/Enhancement.cpp b/src/ui/bridge/Enhancement.cpp
index a41b143a..80ea9b8f 100644
--- a/src/ui/bridge/Enhancement.cpp
+++ b/src/ui/bridge/Enhancement.cpp
@@ -1,5 +1,6 @@
// QML bridge: Enhancement responsibilities.
#include "../QmlPlayerBridge_p.h"
+#include <optional>
namespace veyra::ui {
// --- settings ---------------------------------------------------------------
@@ -43,7 +44,7 @@ int QmlPlayerBridge::srPrescale() const { return int(settings().srPrescale); }
bool QmlPlayerBridge::dualSrEnabled() const { return settings().dualSrEnabled; }
void QmlPlayerBridge::setDualSrEnabled(bool enabled){
auto s=settings();if(s.dualSrEnabled==enabled)return;
- if(enabled&&!engine::srStageBackend(s.videoSrQuality))return;
+ if(enabled&&!engine::rtxVideoSr(s.videoSrQuality))return;
s.dualSrEnabled=enabled;
// 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;
@@ -58,16 +59,64 @@ void QmlPlayerBridge::setDualSrTargetIndex(int index){
auto s=settings();s.dualSrTarget=targets[index-1];if(impl_->commit(s))emit settingsChanged();
}
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();}
+// The second pass may use any RTX Video SR family and tier, independent of the base.
+void QmlPlayerBridge::setDualSrQuality(int quality){
+ if(quality<0||!engine::rtxVideoSr(unsigned(quality)))return;
+ const auto cap=effectCapabilities().value("sr"+QString::number(quality)).toMap();
+ if(!cap.value("available").toBool()){emit notice(cap.value("reason").toString(),true);return;}
+ auto s=settings();if(int(s.dualSrQuality)==quality)return;
+ s.dualSrQuality=uint32_t(quality);if(impl_->commit(s))emit settingsChanged();
+}
+// Algorithm ids of the SR lists: "rtx" standard, "rtx-hb" high bitrate and
+// "rtx-st" streaming RTX Video SR (each with tiers 1 low .. 4 ultra); DLSS SR
+// and FSR keep their numeric ids.
+QString QmlPlayerBridge::srAlgorithmOf(int quality) const {
+ if(quality<0||!engine::rtxVideoSr(unsigned(quality)))return QString::number(quality);
+ switch(engine::videoSrFamily(unsigned(quality))){
+ case engine::VideoSrFamily::HighBitrate:return QStringLiteral("rtx-hb");
+ case engine::VideoSrFamily::Streaming:return QStringLiteral("rtx-st");
+ default:return QStringLiteral("rtx");
+ }
+}
+int QmlPlayerBridge::srTierOf(int quality) const {
+ return quality>=0&&engine::rtxVideoSr(unsigned(quality))?int(engine::videoSrTier(unsigned(quality))):0;
+}
+// The stored quality for an algorithm at a tier. Coming from DLSS SR or FSR
+// there is no tier yet, so an RTX family starts at ultra.
+int QmlPlayerBridge::srQualityFor(const QString& algorithm,int tier) const {
+ const auto family=algorithm==QLatin1String("rtx")?std::optional(engine::VideoSrFamily::Standard):
+ algorithm==QLatin1String("rtx-hb")?std::optional(engine::VideoSrFamily::HighBitrate):
+ algorithm==QLatin1String("rtx-st")?std::optional(engine::VideoSrFamily::Streaming):std::nullopt;
+ if(family)return int(engine::videoSrQualityFor(*family,tier>=1&&tier<=4?unsigned(tier):4u));
+ bool ok=false;const int value=algorithm.toInt(&ok);
+ return ok&&value>=0&&engine::validVideoSrQuality(unsigned(value))?value:-1;
+}
+// Streaming has only the medium and ultra tiers.
+QVariantList QmlPlayerBridge::srTierChoices(int quality) const {
+ const bool streaming=quality>=0&&engine::rtxVideoSr(unsigned(quality))&&engine::videoSrFamily(unsigned(quality))==engine::VideoSrFamily::Streaming;
+ const QString labels[]={tr("低"),tr("中"),tr("高"),tr("超高")};
+ QVariantList out;
+ for(int tier=1;tier<=4;++tier)if(!streaming||tier==2||tier==4)out<<QVariantMap{{"id",QString::number(tier)},{"label",labels[tier-1]}};
+ return out;
+}
+// "超高", or "高码率 超高" with the family. Empty for DLSS SR and FSR.
+QString QmlPlayerBridge::srQualityLabel(int quality,bool withFamily) const {
+ if(quality<0||!engine::rtxVideoSr(unsigned(quality)))return {};
+ const QString tiers[]={tr("低"),tr("中"),tr("高"),tr("超高")};
+ const QString tier=tiers[engine::videoSrTier(unsigned(quality))-1];
+ if(!withFamily)return tier;
+ const auto family=engine::videoSrFamily(unsigned(quality));
+ return (family==engine::VideoSrFamily::HighBitrate?tr("高码率"):family==engine::VideoSrFamily::Streaming?tr("流媒体"):tr("标准"))+QLatin1Char(' ')+tier;
+}
int QmlPlayerBridge::srOutput() const { return int(settings().srOutput); }
-// Double SR and the supersample shrink run on RTX Video SR only; other backends
-// keep the single step.
+// Double SR and the supersample shrink run on RTX Video SR (every family) 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::rtxVideoSr(s.videoSrQuality)) { emit notice(tr("双重超分目前仅 RTX 视频超分支持"), true); return; }
s.srPrescale = want;
if (impl_->commit(s)) emit settingsChanged();
}
@@ -76,12 +125,12 @@ 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::rtxVideoSr(s.videoSrQuality)) { emit notice(tr("超分后缩回目前仅 RTX 视频超分支持"), true); return; }
s.srOutput = want;
if (impl_->commit(s)) emit settingsChanged();
}
void QmlPlayerBridge::setVideoSrQuality(int value) {
- if (value < 0 || value > 5) return;
+ if (value < 0 || !engine::validVideoSrQuality(unsigned(value))) return;
const auto cap = effectCapabilities().value("sr" + QString::number(value)).toMap();
if (!cap.value("available").toBool()) { emit notice(cap.value("reason").toString(), true); return; }
auto s = settings();
diff --git a/src/ui/bridge/Hardware.cpp b/src/ui/bridge/Hardware.cpp
index d863cf0d..ca9feb6e 100644
--- a/src/ui/bridge/Hardware.cpp
+++ b/src/ui/bridge/Hardware.cpp
@@ -2,6 +2,7 @@
#include "../QmlPlayerBridge_p.h"
#include "veyra/pipeline/Rdna3NrBackend.h"
#include "veyra/pipeline/AmdNrProvider.h"
+#include "veyra/pipeline/VfxSrBackend.h"
namespace veyra::ui {
@@ -61,6 +62,7 @@ ui::EffectGpu effectGpu() {
result.rtx = name.contains("RTX", Qt::CaseInsensitive);
result.blackwell = name.contains("RTX 50", Qt::CaseInsensitive) || name.contains("Blackwell", Qt::CaseInsensitive);
result.ada = name.contains("RTX 40", Qt::CaseInsensitive) || name.contains("Ada", Qt::CaseInsensitive);
+ result.ampere = name.contains("GeForce RTX 30", Qt::CaseInsensitive);
result.rx9000 = name.contains("RX 90", Qt::CaseInsensitive);
result.rx7000 = pipeline::amdNrProvider(d->VendorId,d->Description)==pipeline::AmdNrProvider::RedDukeRdna3;
return result;
@@ -97,6 +99,10 @@ static QVariantMap scanEffectCapabilities() {
}
add("sr0", H::Nvidia, exists(nr / "nvngx_dlss.dll"), QObject::tr("需要 NVIDIA RTX 显卡"));
for (int i = 1; i <= 4; ++i) add("sr" + QString::number(i), H::Nvidia, exists(nr / "nvngx_vsr.dll"), QObject::tr("需要 NVIDIA RTX 显卡"));
+ // RTX Video SR high bitrate / streaming: Video Effects VideoSuperRes, from the VFG runtime directory.
+ const bool vfxSr = pipeline::VfxSrBackend::runtimeAvailable(nr.wstring());
+ for (int q : {16, 17, 18, 19}) add("sr" + QString::number(q), H::Nvidia, vfxSr, QObject::tr("需要 NVIDIA RTX 显卡"));
+ for (int q : {21, 23}) add("sr" + QString::number(q), H::NvidiaAmpere, vfxSr, QObject::tr("需要 NVIDIA RTX 30 及更新显卡"));
add("sr5", H::CrossVendor, fsrLoader && exists(fsr / "amd_fidelityfx_upscaler_dx12.dll"), QObject::tr("需要支持 DirectX 12 的硬件显卡"));
add("dlss", H::Nvidia, exists(nr / "nvngx_dlssg.dll"), QObject::tr("需要 NVIDIA RTX 显卡"));
add("vfg", H::Vfg, pipeline::VfgBackend::runtimeAvailable(nr.wstring()), QObject::tr("需要 NVIDIA RTX 40 / 50(Ada / Blackwell)"));
@@ -135,6 +141,8 @@ QString unavailableEffects(const engine::EnhancementSettings& settings) {
QStringList requested;
if (settings.nr) requested << "nr" + QString::number(int(engine::currentNrRuntime(settings.nrRuntime)));
if (settings.sr) requested << "sr" + QString::number(settings.videoSrQuality);
+ // Double SR runs a second RTX Video SR pass with its own family and tier.
+ if (settings.sr && settings.dualSrEnabled && engine::rtxVideoSr(settings.videoSrQuality)) requested << "sr" + QString::number(settings.dualSrQuality);
if (settings.multiplier > 1) requested << fgEffectId(settings.frameGenerationBackend);
if (settings.videoHdr.enabled) requested << "hdr";
for (const auto& id : requested) {
@@ -217,9 +225,14 @@ QVariantList QmlPlayerBridge::nrRuntimeChoices() const {
QVariantList QmlPlayerBridge::srBackendChoices() const {
QVariantList choices;
const auto caps = effectCapabilities();
- for (const auto& entry : std::initializer_list<std::pair<int, QString>>{{0, "DLSS SR"}, {4, tr("RTX 视频超分")}, {5, effectGpu().vendor == 0x1002 ? tr("FSR 3.1 / 4 · 自动兼容") : QString("FSR 3.1")}}) {
- const auto cap = caps.value("sr" + QString::number(entry.first)).toMap();
- choices << QVariantMap{{"id", QString::number(entry.first)}, {"label", entry.second}, {"disabled", !cap.value("available").toBool()}, {"note", cap.value("reason")}};
+ // RTX Video SR families take string ids (srAlgorithmOf); the tier is chosen
+ // separately. Availability follows each family's runtime.
+ struct Entry { QString id; int capability; QString label; };
+ for (const auto& entry : std::initializer_list<Entry>{{"0", 0, "DLSS SR"}, {"rtx", 4, tr("RTX 视频超分 · 标准")},
+ {"rtx-hb", 16, tr("RTX 视频超分 · 高码率")}, {"rtx-st", 21, tr("RTX 视频超分 · 流媒体")},
+ {"5", 5, effectGpu().vendor == 0x1002 ? tr("FSR 3.1 / 4 · 自动兼容") : QString("FSR 3.1")}}) {
+ const auto cap = caps.value("sr" + QString::number(entry.capability)).toMap();
+ choices << QVariantMap{{"id", entry.id}, {"label", entry.label}, {"disabled", !cap.value("available").toBool()}, {"note", cap.value("reason")}};
}
return choices;
}
diff --git a/src/ui/bridge/Status.cpp b/src/ui/bridge/Status.cpp
index 54d40810..bd3a0729 100644
--- a/src/ui/bridge/Status.cpp
+++ b/src/ui/bridge/Status.cpp
@@ -34,6 +34,9 @@ QString QmlPlayerBridge::srStageNote() const {
QStringList notes;
if (plan.srPrescaleIneffective) notes << tr("第二次超分未执行:再次降低后的尺寸须小于基础超分结果及第二次目标。");
if (plan.srOutputIneffective) notes << tr("超分后缩回未生效:超分须先放大画面,且缩回尺寸要小于超分结果。");
+ // Only the standard family restores a source already at the target size.
+ if (s.applied.sr && engine::vfxVideoSr(s.applied.videoSrQuality) && !plan.srApplied)
+ notes << tr("高码率和流媒体只做放大:片源已达到目标尺寸,所以没有运行;同尺寸修复请用标准。");
return notes.join(QStringLiteral(";"));
}
diff --git a/tests/integration/VideoAiExportProbe.cpp b/tests/integration/VideoAiExportProbe.cpp
new file mode 100644
index 00000000..2bfca53f
--- /dev/null
+++ b/tests/integration/VideoAiExportProbe.cpp
@@ -0,0 +1,55 @@
+// Diagnostic entry into RTX Video SR (every family, single, double SR and
+// supersample) and VFG through the actual graph + D3D12 NVENC + mux/verify. No
+// SR, interpolation or encoding implementation here.
+// Usage: input output [--sr QUALITY] [--target 1440|4k] [--sr-output source|1440|4k]
+// [--dual-quality Q --dual-target 1440|4k --dual-prescale 720|900|1080|1440]
+// [--vfg M [--vfg-quality Q]] [--frames N]
+#include "veyra/engine/VideoExportJob.h"
+#include <windows.h>
+#include <timeapi.h>
+#include <atomic>
+#include <iostream>
+#include <string>
+#pragma comment(lib,"winmm.lib")
+int wmain(int argc,wchar_t** argv){
+ using namespace veyra::engine;
+ using veyra::pipeline::SrTarget;using veyra::pipeline::SrPrescale;using veyra::pipeline::SrOutput;
+ if(argc<3)return 2;
+ EnhancementSettings s;unsigned frames=0;
+ const auto target=[](const std::wstring& v){return v==L"1440"?SrTarget::Qhd:SrTarget::Uhd4K;};
+ try{
+ for(int i=3;i<argc;++i){
+ const std::wstring flag=argv[i];
+ if(i+1>=argc)return 2;
+ const std::wstring value=argv[++i];
+ if(flag==L"--sr"){s.sr=true;s.videoSrQuality=std::stoul(value);}
+ else if(flag==L"--target")s.srTarget=target(value);
+ else if(flag==L"--sr-output")s.srOutput=value==L"source"?SrOutput::Source:value==L"1440"?SrOutput::Qhd:SrOutput::Uhd4K;
+ else if(flag==L"--dual-quality"){s.dualSrEnabled=true;s.dualSrQuality=std::stoul(value);}
+ else if(flag==L"--dual-target"){s.dualSrEnabled=true;s.dualSrTarget=target(value);}
+ else if(flag==L"--dual-prescale"){s.dualSrEnabled=true;s.srPrescale=value==L"720"?SrPrescale::P720:value==L"900"?SrPrescale::P900:value==L"1440"?SrPrescale::P1440:SrPrescale::P1080;}
+ else if(flag==L"--vfg"){s.frameGenerationBackend=FrameGenerationBackend::Vfg;s.multiplier=std::stoul(value);}
+ else if(flag==L"--vfg-quality")s.vfgQuality=std::stoul(value);
+ else if(flag==L"--frames")frames=std::stoul(value);
+ else return 2;
+ }
+ }catch(...){return 2;}
+ if(s.dualSrEnabled&&s.srPrescale==SrPrescale::Off)s.srPrescale=SrPrescale::P1080;
+ s.nrPolicy=veyra::pipeline::NrSizePolicy::Native;s.exportBitrateMbps=18;
+ if(const auto error=s.validate();!error.empty()){std::cout<<"VIDEO_AI_PRODUCT invalid="<<error<<'\n';return 2;}
+ // Serial FG exports poll the GPU fence with 1 ms sleeps; at the default timer
+ // resolution each one is a 15.6 ms tick, which hides the backend's cost.
+ timeBeginPeriod(1);
+ CoInitializeEx(nullptr,COINIT_MULTITHREADED);
+ auto options=PlayerOptions::from(s);options.exportRateControl=veyra::sink::ExportRateControl::Vbr;
+ std::atomic<bool> cancel{false};ExportCounts last;
+ const bool ok=exportVideo(argv[1],argv[2],options,true,cancel,
+ [](double p,const std::wstring& msg){std::wcout<<int(p*100)<<L"% "<<msg<<L'\n';},frames,{},
+ [&](const ExportCounts& c){last=c;});
+ const unsigned m=s.multiplier;
+ std::cout<<"VIDEO_AI_PRODUCT source="<<last.source<<" generated="<<last.generated<<" hold="<<last.holds<<" output="<<last.encoded
+ <<" multiplier="<<m<<" sr="<<(s.sr?int(s.videoSrQuality):-1)<<" dual="<<(s.dualSrEnabled?int(s.dualSrQuality):-1)
+ <<" backend="<<frameGenerationBackendName(s.frameGenerationBackend)<<" ok="<<ok<<'\n';
+ CoUninitialize();timeEndPeriod(1);
+ return ok&&last.source>1&&(m<=1||last.generated>0)&&last.encoded==last.source*m?0:1;
+}
diff --git a/tests/unit/VideoAiSettingsTests.cpp b/tests/unit/VideoAiSettingsTests.cpp
new file mode 100644
index 00000000..baae982b
--- /dev/null
+++ b/tests/unit/VideoAiSettingsTests.cpp
@@ -0,0 +1,184 @@
+// RTX Video SR model families (standard 1..4, high bitrate 16..19, streaming
+// 21/23) with tiers, double SR and the supersample shrink across families, and
+// persistence. Older readers reject the Video Effects values, so files that use
+// them (as the base or the second SR) get a new version (settings presets) or a
+// .video-ai sidecar (preset library, mode session); the older file stays as it was.
+#include "veyra/engine/GraphDescription.h"
+#include "veyra/engine/PresetStore.h"
+#include "veyra/engine/PresetLibrary.h"
+#include <algorithm>
+#include <filesystem>
+#include <fstream>
+#include <iostream>
+#include <map>
+#include <memory>
+using namespace veyra::engine;
+using veyra::pipeline::SrTarget;using veyra::pipeline::SrPrescale;using veyra::pipeline::SrOutput;
+namespace {
+unsigned checks=0,failures=0;
+void check(bool ok,const char* why){++checks;if(!ok){++failures;std::cout<<"FAIL "<<why<<'\n';}}
+std::string bytes(const std::filesystem::path& p){std::ifstream f(p,std::ios::binary);return {(std::istreambuf_iterator<char>(f)),{}};}
+std::filesystem::path sidecar(const std::filesystem::path& p){return std::filesystem::path(p).concat(L".video-ai");}
+// Every file of one library: the base name plus the sidecars older versions chained onto it.
+std::map<std::wstring,std::string> files(const std::filesystem::path& base){
+ std::map<std::wstring,std::string> out;
+ for(const auto& e:std::filesystem::directory_iterator(base.parent_path()))
+ if(e.path().filename().wstring().starts_with(base.filename().wstring()))out[e.path().filename().wstring()]=bytes(e.path());
+ return out;
+}
+bool kept(const std::map<std::wstring,std::string>& before,const std::map<std::wstring,std::string>& after){
+ return std::all_of(before.begin(),before.end(),[&](const auto& f){const auto it=after.find(f.first);return it!=after.end()&&it->second==f.second;});
+}
+veyra::pipeline::EnhanceGraphDesc describe(const EnhancementSettings& s,uint32_t width,uint32_t height,veyra::pipeline::ResolutionPlan* plan=nullptr){
+ StageRequest request;request.sr=s.sr;request.width=width;request.height=height;
+ veyra::pipeline::EnhanceGraphDesc desc;const auto p=describeStages(request,s,desc);
+ if(plan)*plan=p;
+ return desc;
+}
+}
+int wmain(int argc,wchar_t** argv){
+ if(argc!=2||!std::filesystem::path(argv[1]).is_absolute())return 2;
+ const std::filesystem::path root=argv[1];if(!std::filesystem::create_directories(root))return 2;
+
+ // Stored values: 0 DLSS, 5 FSR, and the three RTX Video SR families.
+ for(uint32_t q=0;q<40;++q){
+ const bool rtx=(q>=1&&q<=4)||(q>=16&&q<=19)||q==21||q==23;
+ check(rtxVideoSr(q)==rtx,"RTX Video SR family values");
+ check(validVideoSrQuality(q)==(rtx||q==0||q==kVideoSrFsr),"stored SR quality table");
+ EnhancementSettings s;s.sr=true;s.videoSrQuality=q;
+ check(s.validate().empty()==validVideoSrQuality(q),"validation accepts exactly the stored SR qualities");
+ check(ngxVideoSr(q)==(q>=1&&q<=4)&&vfxVideoSr(q)==(rtx&&q>4),"standard runs on NGX, the others on Video Effects");
+ }
+ check(vfxVideoSrNeedsAmpere(21)&&vfxVideoSrNeedsAmpere(23)&&!vfxVideoSrNeedsAmpere(16)&&!vfxVideoSrNeedsAmpere(19)&&!vfxVideoSrNeedsAmpere(4),
+ "only the streaming family needs Ampere");
+ // Family + tier <-> stored value.
+ for(uint32_t tier=1;tier<=4;++tier){
+ check(videoSrQualityFor(VideoSrFamily::Standard,tier)==tier,"standard tiers are 1..4");
+ check(videoSrQualityFor(VideoSrFamily::HighBitrate,tier)==15+tier,"high bitrate tiers are 16..19");
+ check(videoSrQualityFor(VideoSrFamily::Streaming,tier)==(tier<=2?21u:23u),"streaming has medium and ultra only");
+ for(auto family:{VideoSrFamily::Standard,VideoSrFamily::HighBitrate}){
+ const auto q=videoSrQualityFor(family,tier);
+ check(videoSrFamily(q)==family&&videoSrTier(q)==tier,"family and tier round trip");
+ }
+ }
+ check(videoSrFamily(21)==VideoSrFamily::Streaming&&videoSrTier(21)==2&&videoSrFamily(23)==VideoSrFamily::Streaming&&videoSrTier(23)==4,
+ "streaming values report medium and ultra");
+ check(videoSrQualityFor(VideoSrFamily::HighBitrate,0)==16&&videoSrQualityFor(VideoSrFamily::HighBitrate,9)==19,"tiers clamp to 1..4");
+
+ // Double SR and the supersample shrink accept every family, also mixed.
+ {
+ EnhancementSettings s;s.sr=true;s.videoSrQuality=19;s.dualSrEnabled=true;s.dualSrQuality=23;s.srPrescale=SrPrescale::P1080;
+ check(s.validate().empty(),"high bitrate base with a streaming second pass");
+ auto active=s.activeVideoSettings();
+ check(active.dualSrEnabled&&active.dualSrQuality==23&&active.srPrescale==SrPrescale::P1080,"double SR stays active on high bitrate");
+ for(uint32_t bad2:{0u,5u,20u,22u,24u}){auto bad=s;bad.dualSrQuality=bad2;check(!bad.validate().empty(),"second SR must be an RTX Video SR value");}
+ s.videoSrQuality=4;s.dualSrQuality=17;check(s.validate().empty()&&s.activeVideoSettings().dualSrEnabled,"standard base with a high bitrate second pass");
+ s.videoSrQuality=0;check(!s.activeVideoSettings().dualSrEnabled,"DLSS SR keeps its single pass");
+ s.videoSrQuality=kVideoSrFsr;check(!s.activeVideoSettings().dualSrEnabled,"FSR keeps its single pass");
+ EnhancementSettings ss;ss.sr=true;ss.videoSrQuality=16;ss.srOutput=SrOutput::Source;
+ check(ss.activeVideoSettings().srOutput==SrOutput::Source,"supersample shrink stays on high bitrate");
+ ss.videoSrQuality=0;check(ss.activeVideoSettings().srOutput==SrOutput::Target,"DLSS SR drops the supersample shrink");
+ }
+ // The graph plan: two passes with each family's quality, supersample sizes, and no same-size restore for Video Effects.
+ {
+ EnhancementSettings s;s.sr=true;s.videoSrQuality=19;s.srTarget=SrTarget::Uhd4K;
+ s.dualSrEnabled=true;s.dualSrQuality=23;s.dualSrTarget=SrTarget::Uhd4K;s.srPrescale=SrPrescale::P1080;
+ const auto desc=describe(s,1280,720);
+ check(desc.enableSr&&desc.dualSr&&desc.videoSrQuality==19&&desc.dualSrQuality==23,"double SR plan carries both families");
+ check(desc.firstSrWidth==3840&&desc.firstSrHeight==2160&&desc.srInputWidth==1920&&desc.srInputHeight==1080&&
+ desc.srOutputWidth==3840&&desc.srOutputHeight==2160&&desc.workWidth==3840,"double SR sizes: 720p -> 4K -> 1080p -> 4K");
+ s.videoSrQuality=4;s.dualSrQuality=16;
+ check(describe(s,1280,720).dualSr,"standard base with high bitrate second pass plans two passes");
+ s.videoSrQuality=0;check(!describe(s,1280,720).dualSr,"DLSS SR plans one pass");
+ EnhancementSettings ss;ss.sr=true;ss.videoSrQuality=17;ss.srTarget=SrTarget::Uhd4K;ss.srOutput=SrOutput::Qhd;
+ const auto sd=describe(ss,1280,720);
+ check(sd.enableSr&&!sd.dualSr&&sd.srOutputWidth==3840&&sd.workWidth==2560&&sd.workHeight==1440,"high bitrate supersample: SR to 4K, shrink to 1440p");
+ EnhancementSettings same;same.sr=true;same.srTarget=SrTarget::Uhd4K;same.videoSrQuality=19;
+ check(!describe(same,3840,2160).enableSr,"Video Effects families do not run at the target size");
+ same.videoSrQuality=4;check(describe(same,3840,2160).enableSr,"standard family restores at the target size");
+ }
+
+ EnhancementSettings vsr;vsr.sr=true;vsr.videoSrQuality=23;vsr.srTarget=SrTarget::Qhd;
+ EnhancementSettings second;second.sr=true;second.videoSrQuality=4;second.dualSrEnabled=true;second.dualSrQuality=18;second.srPrescale=SrPrescale::P900;
+ EnhancementSettings both=vsr;both.videoSrQuality=19;both.dualSrEnabled=true;both.dualSrQuality=21;both.srPrescale=SrPrescale::P1080;
+
+ // Settings presets: v35 only when a Video Effects value is stored.
+ {
+ PresetStore plain(root/L"plain.txt");check(plain.load()&&plain.put(L"plain",EnhancementSettings{}),"plain settings preset");
+ check(!bytes(root/L"plain.txt").starts_with("VEYRA_PRESETS 35"),"settings without new values keep the older version");
+ EnhancementSettings stdDual;stdDual.sr=true;stdDual.dualSrEnabled=true;stdDual.dualSrQuality=2;stdDual.srPrescale=SrPrescale::P1080;
+ PresetStore standardDual(root/L"standard-dual.txt");
+ check(standardDual.load()&&standardDual.put(L"std",stdDual)&&bytes(root/L"standard-dual.txt").starts_with("VEYRA_PRESETS 34"),"standard double SR keeps v34");
+ PresetStore store(root/L"video-ai.txt");
+ check(store.load()&&store.put(L"vsr",vsr)&&store.put(L"second",second)&&store.put(L"both",both),"settings presets with new values");
+ check(bytes(root/L"video-ai.txt").starts_with("VEYRA_PRESETS 35"),"a Video Effects value writes v35");
+ PresetStore reader(root/L"video-ai.txt");check(reader.load()&&reader.entries().size()==3,"v35 reload");
+ const auto find=[&](const wchar_t* name)->const EnhancementSettings*{
+ for(const auto& e:reader.entries())if(e.name==name)return &e.settings;return nullptr;};
+ const auto* a=find(L"vsr");const auto* b=find(L"second");const auto* c=find(L"both");
+ check(a&&a->sr&&a->videoSrQuality==23&&a->srTarget==SrTarget::Qhd,"v35 restores the base family and tier");
+ check(b&&b->videoSrQuality==4&&b->dualSrEnabled&&b->dualSrQuality==18&&b->srPrescale==SrPrescale::P900,"v35 restores a Video Effects second pass");
+ check(c&&c->videoSrQuality==19&&c->dualSrQuality==21&&c->srPrescale==SrPrescale::P1080,"v35 restores both passes");
+ }
+
+ // Preset library: new entries go to a v18 .video-ai sidecar; the older files stay.
+ {
+ const auto path=root/L"library.preset";
+ {
+ PresetLibrary old(path);old.setIncludeBuiltins(false);
+ auto e=std::make_unique<PresetEntry>();e->name=L"old";EnhancementSettings s;e->chain=toChain(s);e->globals=ChainGlobalSettings::capture(s);
+ check(old.load()&&old.put(*e),"older library entry");
+ }
+ const auto before=files(path);
+ check(before.size()==1&&!before.begin()->second.starts_with("VEYRA_PRESET_LIBRARY 18")&&!before.begin()->first.ends_with(L".video-ai"),
+ "library without new values keeps an older version and file");
+ std::vector<std::unique_ptr<PresetEntry>> saved;
+ for(const auto& [name,settings]:{std::pair{L"vsr",&vsr},std::pair{L"second",&second},std::pair{L"both",&both}}){
+ PresetLibrary library(path);library.setIncludeBuiltins(false);check(library.load(),"library reload before save");
+ auto e=std::make_unique<PresetEntry>();e->name=name;e->chain=toChain(*settings);e->globals=ChainGlobalSettings::capture(*settings);
+ check(library.put(*e),"save an entry with a Video Effects value");saved.push_back(std::move(e));
+ }
+ const auto after=files(path);
+ check(kept(before,after),"older library file untouched");
+ check(after.size()==before.size()+1&&std::any_of(after.begin(),after.end(),[&](const auto& f){
+ return !before.contains(f.first)&&f.first.ends_with(L".video-ai")&&f.second.starts_with("VEYRA_PRESET_LIBRARY 18");}),
+ "library writes v18 to one new .video-ai sidecar");
+ PresetLibrary reloaded(path);reloaded.setIncludeBuiltins(false);
+ check(reloaded.load()&&reloaded.entries().size()==4,"library reload reads the sidecar");
+ for(const auto& e:saved){
+ const auto it=std::find_if(reloaded.entries().begin(),reloaded.entries().end(),[&](const auto& r){return r.name==e->name;});
+ check(it!=reloaded.entries().end()&&*it==*e,"library restores the full entry");
+ if(it==reloaded.entries().end()||!e->globals)continue;
+ EnhancementSettings applied;PresetLibrary::apply(*it,applied);
+ check(applied.videoSrQuality==e->globals->videoSrQuality&&applied.dualSrQuality==e->globals->dualSrQuality&&
+ applied.dualSrEnabled==e->globals->dualSrEnabled,"applying restores both SR passes");
+ }
+ // Removing the new values keeps the newer build on the sidecar.
+ PresetLibrary trimmed(path);trimmed.setIncludeBuiltins(false);check(trimmed.load(),"reload before removal");
+ for(const auto* name:{L"vsr",L"second",L"both"}){
+ const auto& list=trimmed.entries();
+ const auto it=std::find_if(list.begin(),list.end(),[&](const auto& r){return r.name==name;});
+ check(it!=list.end()&&trimmed.erase(size_t(it-list.begin())),"remove new entry");
+ }
+ const auto removed=files(path);
+ check(kept(before,removed)&&removed.size()==before.size()+1,"removal writes the sidecar, not the older file");
+ }
+
+ // Mode session (node mode, high bitrate base with a streaming second pass).
+ {
+ auto session=std::make_unique<ChainSession>(ChainSession::initial(both));check(session->select(ChainMode::Node),"node mode initializes");
+ auto editor=std::make_shared<NodeEditorDocument>();editor->nodes=session->configurations[1].chain;
+ editor->globals=ChainGlobalSettings::capture(both);check(editor->layout.initialize(editor->nodes).accepted,"node draft layout");
+ session->configurations[1].editor=editor;check(session->valid(),"session valid");
+ const auto path=root/L"modes.session";
+ ChainSessionStore writer(path);check(writer.save(*session),"session save");
+ check(!std::filesystem::exists(path)&&bytes(sidecar(path)).starts_with("VEYRA_CHAIN_SESSION 13"),"session writes v13 to the .video-ai sidecar only");
+ auto restored=std::make_unique<ChainSession>();ChainSessionStore reader(path);
+ check(reader.load(*restored)&&*session==*restored,"session restart restores both SR passes");
+ auto plain=std::make_unique<ChainSession>(ChainSession::initial(EnhancementSettings{}));
+ const auto plainPath=root/L"plain.session";ChainSessionStore plainWriter(plainPath);
+ check(plainWriter.save(*plain)&&std::filesystem::exists(plainPath)&&!std::filesystem::exists(sidecar(plainPath)),"plain session keeps the older file");
+ }
+
+ std::cout<<"Video AI settings "<<checks<<" checks, "<<failures<<" failures\n";return failures?1:0;
+}