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

feat(fsr): AMD FSR upscaling in the SR stage (videoSrQuality=5, 3.1.x, verified)

Veyra Goal Agent950f46d55687
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 28a50daa..4ba208a3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -78,6 +78,7 @@ add_library(veyra_gfx STATIC
src/gfx/XessPresenter.cpp
src/gfx/XessMfgUnlock.cpp
src/gfx/FsrFgPresenter.cpp
+ src/gfx/FsrSrBackend.cpp
)
veyra_apply_warnings(veyra_gfx)
target_compile_features(veyra_gfx PUBLIC cxx_std_20)
@@ -89,7 +90,8 @@ endif()
if(EXISTS "${VEYRA_FIDELITYFX2_ROOT}/framegeneration/include/dx12/ffx_api_framegeneration_dx12.h")
target_include_directories(veyra_gfx PRIVATE
"${VEYRA_FIDELITYFX2_ROOT}/api/include"
- "${VEYRA_FIDELITYFX2_ROOT}/framegeneration/include")
+ "${VEYRA_FIDELITYFX2_ROOT}/framegeneration/include"
+ "${VEYRA_FIDELITYFX2_ROOT}/upscalers/include")
target_compile_definitions(veyra_gfx PRIVATE VEYRA_HAS_FSR=1)
endif()
if(VEYRA_ENABLE_D3D12_DEBUG)
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md
index 8eee27fc..6a390344 100644
--- a/THIRD_PARTY_NOTICES.md
+++ b/THIRD_PARTY_NOTICES.md
@@ -125,26 +125,32 @@ Remote Play also depends on **OpenSSL, Opus, json-c, libevent, miniupnpc, curl,
</details>
-## AMD FidelityFX SDK 2.3.0 (experimental FSR frame generation)
-
-The player's AMD FSR frame-generation backend is written against the public
-FidelityFX API documented and shipped in the AMD FidelityFX SDK 2.3.0 (MIT
-licensed). The SDK itself is **not** vendored into this source repository: it
-stays in the gitignored `third_party_local/amd/FidelityFX-SDK-2.3.0` tree, and
-the signed provider/loader DLLs are used from the local
-`runtime_local/amd/framegeneration/` folder like the other experimental
-runtimes. Integration code (`src/gfx/FsrFgPresenter.cpp`) is an independent
-implementation of the documented API sequence and was written against these
-references:
+## AMD FidelityFX SDK 2.3.0 (experimental FSR frame generation and FSR upscaling)
+
+The player's AMD FSR backends (frame generation in the present sink and
+upscaling in the enhancement graph) are written against the public FidelityFX
+API documented and shipped in the AMD FidelityFX SDK 2.3.0 (MIT licensed). The
+SDK itself is **not** vendored into this source repository: it stays in the
+gitignored `third_party_local/amd/FidelityFX-SDK-2.3.0` tree, and the signed
+provider/loader DLLs are used from the local
+`runtime_local/amd/fidelityfx/` folder like the other experimental runtimes.
+Integration code (`src/gfx/FsrFgPresenter.cpp`, `src/gfx/FsrSrBackend.cpp`) is an
+independent implementation of the documented API sequence and was written
+against these references:
- `Kits/FidelityFX/docs/techniques/frame-interpolation-swap-chain.md`
- `Kits/FidelityFX/docs/techniques/frame-interpolation-api.md`
+- `Kits/FidelityFX/upscalers/include/ffx_upscale.h` and the FSR3 upscaler
+ shader contract (`ffx_fsr3upscaler_reproject.h` for the motion convention)
- `Samples/Upscalers/FidelityFX_FSR/dx12/fsrapirendermodule.cpp`
Relevant negative finding, recorded so it is not re-litigated: a FidelityFX
frame-generation swapchain context keeps the real DXGI swapchain alive after
`ffxDestroyContext` (measured locally), so the player retains the proxy
-swapchain for the window's lifetime. See
+swapchain for the window's lifetime. The FidelityFX upscale dispatch also does
+not complete under D3D12 GPU-based validation (the standalone probe stalls
+before its dispatch), so that validation mode is skipped for the FSR SR
+configuration with an explicit log line. See
[AMD FSR frame generation integration record](docs/FSR_FRAMEGEN_INTEGRATION_2026-09-16.md).
## MFGAdaUnlock-RenoDx (research only, not integrated)
diff --git a/apps/veyra/SettingsWindow.cpp b/apps/veyra/SettingsWindow.cpp
index 8b2696fc..5c7487c8 100644
--- a/apps/veyra/SettingsWindow.cpp
+++ b/apps/veyra/SettingsWindow.cpp
@@ -252,7 +252,7 @@ case WM_CREATE:{window=h;font=makeFont(h);items.clear();displayedBackendWarning.
button(L"框选区域",213,0,12,188,140);button(L"清除区域",214,0,162,188);
add(L"STATIC",L"最多4区,左键拖框,Esc取消。仅抑制NR变化;不保护SR或补帧。可随预设保存;换源清空。",1109,0,0,12,232,-1,82);
for(auto& entry:items)if(entry.page==0&&entry.y>=104)entry.y+=48;
- combo(207,0,100,{L"DLSS SR",L"RTX 视频超分 · 低",L"RTX 视频超分 · 中",L"RTX 视频超分 · 高",L"RTX 视频超分 · 最高"});
+ combo(207,0,100,{L"DLSS SR",L"RTX 视频超分 · 低",L"RTX 视频超分 · 中",L"RTX 视频超分 · 高",L"RTX 视频超分 · 最高",L"AMD FSR 超分 · 3.1.x(N卡可用)"});
for(auto& entry:items)if(entry.page==0&&entry.y>=100)entry.y+=44;
button(L"2K",730,0,12,100,80);button(L"4K",731,0,100,100,80);button(L"8K",732,0,188,100,80);
for(auto& entry:items)if(entry.page==0&&entry.y>=56)entry.y+=80;
diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cpp
index 966917ed..a7605b8c 100644
--- a/apps/veyra/ui/AppShell.cpp
+++ b/apps/veyra/ui/AppShell.cpp
@@ -559,7 +559,7 @@ SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);INITCO
CoInitializeEx(nullptr,COINIT_APARTMENTTHREADED);
initialOptions=veyra::engine::PlayerOptions::from(veyra::ui::defaultSettings());
-int argc=0;auto argv=CommandLineToArgvW(GetCommandLineW(),&argc);for(int i=1;i<argc;++i){const std::wstring arg=argv[i];if(arg==L"--export-worker"&&i+1<argc)workerMapping=reinterpret_cast<HANDLE>(_wcstoui64(argv[++i],nullptr,10));else if(arg==L"--smoke-view"&&i+1<argc)smokeView=argv[++i];else if(arg==L"--smoke-fg-only")smokeFgOnly=true;else if(arg==L"--smoke-transport")smokeTransport=true;else if(arg==L"--smoke-repair-ui")smokeRepair=true;else if(arg==L"--smoke-repair-ui-reject")smokeRepair=smokeRepairReject=true;else if(arg==L"--smoke-hover")smokeZoom=smokeHover=true;else if(arg==L"--smoke-protection")smokeProtection=true;else if(arg==L"--smoke-zoom")smokeZoom=true;else if(arg==L"--smoke-empty")smokeEmpty=true;else if(arg==L"--smoke-dual")smokeDual=true;else if(arg==L"--smoke-dual-pause"){smokeDual=smokeDualPause=true;}else if(arg==L"--smoke-master-reject")smokeMaster=smokeMasterReject=true;else if(arg==L"--smoke-master")smokeMaster=true;else if(arg==L"--smoke-audio")smokeAudio=true;else if(arg==L"--smoke-job-cancel")smokeJobCancel=true;else if(arg==L"--smoke-job-exit")smokeJobExit=true;else if(arg==L"--smoke-job")smokeJob=true;else if(arg==L"--smoke-dual-export"&&i+1<argc)smokeDualOutput=argv[++i];else if(arg==L"--smoke-seconds"&&i+1<argc)smokeSeconds=std::clamp(_wtoi(argv[++i]),1,240);else if(arg==L"--export-out"&&i+1<argc)exportOutput=argv[++i];else if(arg==L"--max-frames"&&i+1<argc)exportFrames=std::max(1,_wtoi(argv[++i]));else if(arg==L"--cancel-after-ms"&&i+1<argc)cancelAfterMs=std::clamp(_wtoi(argv[++i]),1,240000);else if(arg==L"--hevc")exportHevc=true;else if(arg==L"--smoke-rollback-flow"){smokeRollback=true;smokeRollbackFlow=true;}else if(arg==L"--smoke-rollback")smokeRollback=true;else if(arg==L"--smoke-ui")smokeUi=true;else if(arg==L"--no-fg")initialOptions.fg=false;else if(arg==L"--smoke-settings")smokeSettings=true;else if(arg==L"--smoke-screenshot")smokeScreenshot=true;else if(arg==L"--smoke-controls")smokeControls=true;else if(arg==L"--smoke-save"&&i+1<argc)smokeSave=argv[++i];else if(arg==L"--native")initialOptions.realtime=false;else if(arg==L"--realtime")initialOptions.realtime=true;else if(arg==L"--fg")initialOptions.fg=true;else if(arg==L"--fg-multiplier"&&i+1<argc){initialOptions.fgMultiplier=std::clamp(_wtoi(argv[++i]),2,4);initialOptions.fg=true;}else if(arg==L"--video-sr"&&i+1<argc){initialOptions.settings.videoSrQuality=std::clamp(_wtoi(argv[++i]),1,4);initialOptions.sr=true;}else if(arg==L"--nr-ampere")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Ampere;else if(arg==L"--nr-community")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Community;else if(arg==L"--nr-original")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Original;else if(arg==L"--sr")initialOptions.sr=true;else if(arg==L"--no-nr")initialOptions.nr=false;else if(arg==L"--nr")initialOptions.nr=true;else if(arg==L"--no-sr")initialOptions.sr=false;else autoInput=arg;}LocalFree(argv);
+int argc=0;auto argv=CommandLineToArgvW(GetCommandLineW(),&argc);for(int i=1;i<argc;++i){const std::wstring arg=argv[i];if(arg==L"--export-worker"&&i+1<argc)workerMapping=reinterpret_cast<HANDLE>(_wcstoui64(argv[++i],nullptr,10));else if(arg==L"--smoke-view"&&i+1<argc)smokeView=argv[++i];else if(arg==L"--smoke-fg-only")smokeFgOnly=true;else if(arg==L"--smoke-transport")smokeTransport=true;else if(arg==L"--smoke-repair-ui")smokeRepair=true;else if(arg==L"--smoke-repair-ui-reject")smokeRepair=smokeRepairReject=true;else if(arg==L"--smoke-hover")smokeZoom=smokeHover=true;else if(arg==L"--smoke-protection")smokeProtection=true;else if(arg==L"--smoke-zoom")smokeZoom=true;else if(arg==L"--smoke-empty")smokeEmpty=true;else if(arg==L"--smoke-dual")smokeDual=true;else if(arg==L"--smoke-dual-pause"){smokeDual=smokeDualPause=true;}else if(arg==L"--smoke-master-reject")smokeMaster=smokeMasterReject=true;else if(arg==L"--smoke-master")smokeMaster=true;else if(arg==L"--smoke-audio")smokeAudio=true;else if(arg==L"--smoke-job-cancel")smokeJobCancel=true;else if(arg==L"--smoke-job-exit")smokeJobExit=true;else if(arg==L"--smoke-job")smokeJob=true;else if(arg==L"--smoke-dual-export"&&i+1<argc)smokeDualOutput=argv[++i];else if(arg==L"--smoke-seconds"&&i+1<argc)smokeSeconds=std::clamp(_wtoi(argv[++i]),1,240);else if(arg==L"--export-out"&&i+1<argc)exportOutput=argv[++i];else if(arg==L"--max-frames"&&i+1<argc)exportFrames=std::max(1,_wtoi(argv[++i]));else if(arg==L"--cancel-after-ms"&&i+1<argc)cancelAfterMs=std::clamp(_wtoi(argv[++i]),1,240000);else if(arg==L"--hevc")exportHevc=true;else if(arg==L"--smoke-rollback-flow"){smokeRollback=true;smokeRollbackFlow=true;}else if(arg==L"--smoke-rollback")smokeRollback=true;else if(arg==L"--smoke-ui")smokeUi=true;else if(arg==L"--no-fg")initialOptions.fg=false;else if(arg==L"--smoke-settings")smokeSettings=true;else if(arg==L"--smoke-screenshot")smokeScreenshot=true;else if(arg==L"--smoke-controls")smokeControls=true;else if(arg==L"--smoke-save"&&i+1<argc)smokeSave=argv[++i];else if(arg==L"--native")initialOptions.realtime=false;else if(arg==L"--realtime")initialOptions.realtime=true;else if(arg==L"--fg")initialOptions.fg=true;else if(arg==L"--fg-multiplier"&&i+1<argc){initialOptions.fgMultiplier=std::clamp(_wtoi(argv[++i]),2,4);initialOptions.fg=true;}else if(arg==L"--flow-amd")initialOptions.settings.opticalFlowBackend=veyra::engine::OpticalFlowBackend::AmdFidelityFx;else if(arg==L"--flow-gpudis")initialOptions.settings.opticalFlowBackend=veyra::engine::OpticalFlowBackend::GpuDis;else if(arg==L"--video-sr"&&i+1<argc){initialOptions.settings.videoSrQuality=std::clamp(_wtoi(argv[++i]),1,5);initialOptions.sr=true;}else if(arg==L"--nr-ampere")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Ampere;else if(arg==L"--nr-community")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Community;else if(arg==L"--nr-original")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Original;else if(arg==L"--sr")initialOptions.sr=true;else if(arg==L"--no-nr")initialOptions.nr=false;else if(arg==L"--nr")initialOptions.nr=true;else if(arg==L"--no-sr")initialOptions.sr=false;else autoInput=arg;}LocalFree(argv);
// The legacy argument clamp caps --fg-multiplier at 4X. Re-read the flag here so
// 6X (and 2X/3X/4X) can be exercised from the command line for diagnostics and
// smoke tests; the interactive UI uses the capability-driven list instead.
diff --git a/docs/FRAMEGEN_FSR_DOLBY_PLAN_2026-09-16.md b/docs/FRAMEGEN_FSR_DOLBY_PLAN_2026-09-16.md
index 4e3d34b0..59dc4e09 100644
--- a/docs/FRAMEGEN_FSR_DOLBY_PLAN_2026-09-16.md
+++ b/docs/FRAMEGEN_FSR_DOLBY_PLAN_2026-09-16.md
@@ -12,7 +12,7 @@
> | C-2 40 系 Ada 解锁 | **调研完成、未实施**(不交付半成品黑帧补丁) | `docs/WORKLOG.md` 2026-09-16 条目 |
> | D 30 系原生 2X | **未开始**(需另一份运行库身份授权) | — |
> | E AMD FSR 补帧 | **已完成并实测 2X**(`27656a6`…):真实运动、节奏、4K 几何、设置重建全部有据 | `docs/FSR_FRAMEGEN_INTEGRATION_2026-09-16.md` |
-> | F FSR 超分 | **可行性已用探针证明,未接入产品** | `docs/FSR_UPSCALING_PLAN_2026-09-16.md` |
+> | F FSR 超分 | **已接入产品并实测(3.1.x,2X 档位之外的独立 SR 档)**:内容正确、非 NVIDIA 形状可跑;相对画质略软已如实记录 | `docs/FSR_UPSCALING_PLAN_2026-09-16.md` |
> | G-1 杜比位流探测 | **已完成**(本机采集卡不提供位流) | 状态文档 §一.3 |
> | G-2 杜比直通/解码 | **未开始**(缺支持位流的硬件,无法验证) | 状态文档 §二 |
>
diff --git a/docs/FRAMEGEN_FSR_DOLBY_STATUS_2026-09-16.md b/docs/FRAMEGEN_FSR_DOLBY_STATUS_2026-09-16.md
index 0e9825ab..5a92312b 100644
--- a/docs/FRAMEGEN_FSR_DOLBY_STATUS_2026-09-16.md
+++ b/docs/FRAMEGEN_FSR_DOLBY_STATUS_2026-09-16.md
@@ -86,7 +86,7 @@ $env:VEYRA_TEST_FG_FORCE_MULTIPLIER='1'
| 40 系 DLSS MFG 解锁(C-2) | **未实现(本轮改为调研完成)** | 上游已定位并克隆:`ImDreamt/MFGAdaUnlock-RenoDx`(MIT,`third_party_local/community/`,gitignore)。机制=两处架构比较(0x1b0)+ **PTX 中点修正**(104 处 0.5 + fatbin 截断逼 JIT)+ 关闭硬件 flip metering(Streamline 专属,Veyra 走 NGX 不适用)。**没有实施的理由**:本机只有 5070,PTX 改写会改动一条已经正常的路径,无法区分"补丁生效"与"破坏原生 MFG";上游也明确单改门控=黑帧。下一步按带身份校验/模式校验/回滚的进程内补丁实现,并需真实 40 系验收 |
| 30 系原生 2X(D) | **未开始** | 需要 `dlssg_for_sm86` 代理方案与另一份 DLSSG 运行库身份,属发布范围变更 |
| FSR 帧生成(E) | **已完成并实测(2X)** | 见上文 §一.5 与 [接入记录](FSR_FRAMEGEN_INTEGRATION_2026-09-16.md);4.0.1 ML 需 AMD 卡复测 |
-| FSR 超分(F) | **可行性已验证,未接入** | 探针实测 N 卡可跑 FSR 3.1.5 超分(1280×720→2560×1440,回读是真图);4.x ML 在 NVIDIA 上不被枚举。接入点、需要的输入、未验证点见 [FSR 超分计划](FSR_UPSCALING_PLAN_2026-09-16.md);本轮没有写进产品,不当作已完成 |
+| FSR 超分(F) | **已接入并实测(3.1.x)** | 图内 SR 阶段新分支 + `videoSrQuality=5` 档位;播放器 205–226 次 dispatch 0 失败,AMD 光流形状 exit 0,同帧对照平均绝对差 0.31/255;**相对画质略软(梯度能量比 0.888)如实记录**;4.x ML 需 AMD 实机。见 [FSR 超分接入记录](FSR_UPSCALING_PLAN_2026-09-16.md) |
| 杜比直通 / 解码(G-2) | **未开始** | 依赖支持位流的采集设备;当前设备已证实不提供 |
### A-2 节奏 hook:已完成的准备与勘察结论
@@ -116,7 +116,7 @@ $env:VEYRA_TEST_FG_FORCE_MULTIPLIER='1'
0. `git log --oneline -12` 确认全部提交都在 `codex/framegen-fsr-dolby-20260916`,`main` 仍是 `693db07`、未推送、未发布。
最终构建 `cmd.exe /c out\build\veyra-build-x64-release.cmd` exit 0;最终
- `veyra.exe` SHA256 `6291F7CF6E737DD12C057F08848C8A1B48C6DBA394D429E5CE918B01E227A01D`;
+ `veyra.exe` SHA256 `7ADDF839F22E31C0D1BC52434B7CAC09C1AF9BA06A3E4DAD4733D7E79BEB28AD`;
delivery 短测 PASS(`logs/delivery/7180a557fe934a27a225f6367a1b06e9/result.json`);
`veyra_repair_contract_tests` 157 项 0 失败;`veyra_repair_preset_tests` 60 组迁移全通过。
1. **AMD FSR 补帧**:`out\build\audio-continuity-repair-20260915\veyra.exe --fg-fsr --smoke-seconds 10 <视频>`,
diff --git a/docs/FSR_UPSCALING_PLAN_2026-09-16.md b/docs/FSR_UPSCALING_PLAN_2026-09-16.md
index 790e2299..0b0c7701 100644
--- a/docs/FSR_UPSCALING_PLAN_2026-09-16.md
+++ b/docs/FSR_UPSCALING_PLAN_2026-09-16.md
@@ -1,7 +1,16 @@
-# FSR 超分(F 工作流):证据、结论、接入点(隔离分支)
+# AMD FSR 超分(F 工作流):接入记录与实测结论(隔离分支)
-**这是计划,不是已完成功能。** 本轮只做了可行性验证与接入点勘察,产品里还没有 FSR 超分。
-分支 `codex/framegen-fsr-dolby-20260916`,未合并 main、未推送、未发布。
+**已接入产品并实测。** 分支 `codex/framegen-fsr-dolby-20260916`,未合并 main、未推送、未发布。
+
+状态一览:
+
+| 项 | 状态 | 证据 |
+| --- | --- | --- |
+| FSR 3.1.5 超分接入图内 SR 阶段(1080p→4K) | **可用** | 播放器实跑 205–226 次 dispatch、0 失败;质量探针 19/19(`logs/fsr/smoke-fsrsr.log`、`logs/fsr/q-fsrsr-diag.log`) |
+| 非 NVIDIA 路径形状(AMD FFX 光流 + FSR 超分) | **本机验证** | `--flow-amd --video-sr 5`:226 次 dispatch、0 失败、exit 0(`logs/fsr/smoke-fsrsr-amdflow.log`) |
+| 输出内容正确性 | **验证** | 同帧 index=45、同 NR 设置、4K 对照:平均绝对差 **0.31/255**,平均亮度 115.98 vs 116.03(`tools/image_check/compare_sr.ps1`) |
+| 相对画质 | **未胜出,如实记录** | 同一对照里梯度能量 0.563(直通缩放)vs 0.500(FSR SR),比值 0.888 → 本片段上 FSR 反而略软 |
+| AMD 卡 FSR 4.1 | **不可用** | NVIDIA 上只枚举到 3.1.5 / 2.3.4,4.x 需 AMD 实机复测后另行开放 |
## 1. 用户问题的直接回答
@@ -18,9 +27,19 @@
工具:`tools/fsr_upscale_probe`(CMake 目标 `veyra_fsr_upscale_probe`),做法是上传
64 像素棋盘 + 水平渐变 → FSR 放大 2 倍 → 回读校验内容(不是"跑通不报错"就算过)。
-## 2. 与现有图结构的关系(接入点)
+## 2. 接入方式(已实现)
-Veyra 的 SR 阶段在 `EnhanceGraph` 的 `runSr()`,现在只有两个分支:
+`include/veyra/gfx/FsrSrBackend.h` + `src/gfx/FsrSrBackend.cpp` 封装 FidelityFX 超分上下文与逐帧 dispatch;
+`EnhanceGraph::runSr()` 里作为**新的第一分支**(`fsrSrEnabled() && haveFlow`)直接写 `workRgba_`,
+没有有效运动的那一帧退回直通缩放而不是猜测;`EnhanceGraph::initFsrSr()` 负责创建,
+`initNgxFeatures()` 在该会话只启用了 FSR 超分时**不再要求 NGX 核心**(这是它能跑在非 NVIDIA 卡上的前提)。
+
+引擎/UI 侧:`videoSrQuality = 5`(`engine::kVideoSrFsr`,vendor neutral)作为新档位,
+设置里出现"AMD FSR 超分 · 3.1.x(N卡可用)",非 NVIDIA 归一化不再关掉这一档,
+图创建后若 `fsrSrRequested() && !fsrSrEnabled()` 会走既有 `FailedBackend::Sr` 恢复(关档并提示),
+不会静默变成直通。命令行:`--video-sr 5`(测试用 `--flow-amd` / `--flow-gpudis` 切换光流后端)。
+
+原来的 SR 阶段结构(供对照):
1. `videoSrBackend_`:RTX 视频超分(`videoSrQuality` 1–4),输入 `videoSrInput_`(SR 尺寸 RGBA8)→
`videoSrOutput_`(工作尺寸 RGBA8)→ 回填 `workRgba_`;
@@ -49,16 +68,24 @@ FSR 超分应作为**第 3 个后端**接入,语义与 DLSS SR 分支最接近
并放开 `gd.enableSr = plan.srApplied && nvidiaAdapter` 这个非 NVIDIA 硬门控
(只对 FSR 后端放开,DLSS/RTX 视频超分继续只给 NVIDIA)。
-## 3. 还没验证、不能跳过的点
-
-1. **符号约定**:FSR FG 的重投影是 `previous = current + mv`(已在接入记录里核对);
- FSR 超分必须按同样方法核对 FS R 3.1 upscaler PTX/HLSL,再决定是否传负号。
- 不做这一步就接进去,结果是"能跑但拖影/抖动",而且很难归因。
-2. **深度缺失的代价**:当前只传常量深度,边缘/遮挡处理会明显弱于游戏原生 FSR 路径;
- 要不要用现有的深度估计(Depth Anything 类)补上,是后续独立决定,不能顺手假装。
-3. **AMD 卡 4.1**:本机枚举不到 4.x 提供方,任何"4.1 AI 超分已支持"的说法都必须等 AMD 实机。
-4. **画质对照**:接入后要用同一段素材与 DLSS SR / RTX 视频超分做 A/B(现有
- `veyra_quality_probe` 的指标与人工看片),否则不能宣称"效果更好"。
+## 3. 限制与还没验证的点(必须如实保留)
+
+1. **符号约定已核对**:FSR3 upscaler `ffx_fsr3upscaler_reproject.h` 里是
+ `fReprojectedHrUv = fHrUv + fMotionVector`(previous = current + mv),与 Veyra 的
+ current→previous 约定同向 → 传 `motionVectorScale = (1,1)`、像素单位,不加负号。
+2. **常量深度的代价**:没有源分辨率深度,只能传常量远深度;边缘/遮挡处理弱于游戏原生路径,
+ 本文与 UI 都不宣称等同原生。
+3. **HDR 不支持**:`hdrOutput` 时 FSR 超分档**主动不创建**(日志写明原因),不做没验证过的传递函数猜测。
+4. **需要 flow 与源同尺寸**:实时档若把 NR/光流降到比源小(例如 1440p 源走 1080 光流),
+ 当前实现不走 FSR 超分(直接退回直通),因为 FSR 期望运动矢量在渲染尺寸。
+ 要支持就得先加一遍运动矢量重采样,不能糊过去。
+5. **画质没有胜出**:本片段实测 FSR 3.1.5 比直通缩放略软(梯度能量 0.888 比值)。
+ 下一步可做的是把 FSR 自带的 RCAS 锐化(`enableSharpening`)做成可选并 A/B,
+ 以及用真实影视素材而不是合成测试片段复测;在那之前不得宣传"更清晰"。
+6. **AMD 卡 4.1**:本机枚举不到 4.x 提供方,任何"4.1 AI 超分已支持"的说法都必须等 AMD 实机。
+7. **GPU-based validation 不适用**:`--diag` 的 GBV 在 FidelityFX 超分 dispatch 上不完成
+ (独立探针 `tools/fsr_upscale_probe --diag` 在 dispatch 前挂住,说明是验证层与提供方的交互),
+ 所以质量探针在 FSR 超分档会**显式跳过 GBV、保留调试层并打印警告**,不假装跑过。
## 4. 归属
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 5aeff61c..46eb3335 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -2341,6 +2341,32 @@ DLSSG 能力门控没有排除 FSR,导致 FSR 会话下任何就地设置变
### 2026-09-16 FSR 超分可行性(N 卡)与接入点勘察
+### 2026-09-16 FSR 超分接入产品(同一分支,未合并 main)
+
+先前的"只做可行性"结论已升级为**已接入并实测**:
+
+- 新增 `include/veyra/gfx/FsrSrBackend.h` + `src/gfx/FsrSrBackend.cpp`(FidelityFX 超分上下文 +
+ 逐帧 `ffxDispatchDescUpscale`),`EnhanceGraph` 新增 `initFsrSr()` 与 `runSr()` 的 FSR 分支,
+ 只启用 FSR 超分时不再要求 NGX 核心;`videoSrQuality = 5`(`kVideoSrSrFsr`)作为新档位,
+ 设置项"AMD FSR 超分 · 3.1.x(N卡可用)",非 NVIDIA 归一化不再关掉该档,
+ 创建失败走既有 `FailedBackend::Sr` 降级并提示(不静默直通)。
+- 运行库目录统一为 `runtime_local/amd/fidelityfx/`(loader + framegeneration + upscaler),
+ FSR 补帧路径同步改名后**回归通过**(218 真实 / 214 生成,exit 0)。
+- 实测(RTX 5070 / 提供方 3.1.5):
+ - 播放器 `--video-sr 5`:206 帧、205 次 dispatch、0 失败、exit 0(`logs/fsr/smoke-fsrsr.log`);
+ - 非 NVIDIA 形状:`--video-sr 5 --flow-amd`(AMD FFX 光流)226 次 dispatch、0 失败、exit 0
+ (`logs/fsr/smoke-fsrsr-amdflow.log`);
+ - 质量探针 `--sr-mode 5`:19/19、`d3dDiagErrors=0`(`logs/fsr/q-fsrsr-diag.log`);
+ - **同帧对照**(index=45、同 NR、4K 输出):平均绝对差 0.31/255、平均亮度 115.98 vs 116.03
+ → 内容正确(`tools/image_check/compare_sr.ps1`);
+ - **相对画质不如直通**:梯度能量 0.500 vs 0.563(比值 0.888),如实记录,不宣称更清晰。
+- 新工具/改动:`tools/quality_probe --sr-mode`(-1 直通 / 0 DLSS / 5 FSR,用于确定性 A/B)、
+ `tools/image_check/compare_sr.ps1`(内容一致性 + 梯度能量)、`--flow-amd` / `--flow-gpudis` 测试开关。
+- 已知限制:HDR 输出不支持(主动不创建)、flow 必须与源同尺寸、
+ GPU-based validation 与 FidelityFX 超分 dispatch 不兼容(探针显式跳过并打印警告)。
+- 回归:delivery 短测 PASS(`logs/delivery/1f0f1976eca045b9a22529e9b8f11fa4/result.json`)、
+ `veyra_repair_contract_tests` 160 项 0 失败、`veyra_repair_preset_tests` 全通过。
+
新增 `tools/fsr_upscale_probe`(目标 `veyra_fsr_upscale_probe`):枚举超分提供方 →
建上下文 → 上传 64 像素棋盘 + 水平渐变(1280×720)→ FSR 放大到 2560×1440 → 回读校验内容。
本机 RTX 5070 结果(`logs/fsr/upscale-probe.log`):提供方只有 **3.1.5 与 2.3.4**(4.x ML 不出现)、
diff --git a/include/veyra/engine/BackendRecovery.h b/include/veyra/engine/BackendRecovery.h
index 7a6f126c..5290ab7b 100644
--- a/include/veyra/engine/BackendRecovery.h
+++ b/include/veyra/engine/BackendRecovery.h
@@ -5,7 +5,11 @@ namespace veyra::engine {
enum class FailedBackend { None, Infrastructure, OpticalFlow, NgxCore, Nr, Sr, Fg };
inline bool disableUnsupportedNvidiaEffects(EnhancementSettings& settings,bool nvidia){
if(nvidia)return false;
- const auto before=settings;settings.nr=false;settings.sr=false;
+ const auto before=settings;
+ settings.nr=false;
+ // AMD FSR upscaling is vendor neutral and must survive the NVIDIA-only
+ // normalization; every other SR backend is NGX-only.
+ settings.sr=settings.videoSrQuality==kVideoSrFsr;
if(settings.frameGenerationBackend==FrameGenerationBackend::Dlss)settings.multiplier=1;
return settings!=before;
}
diff --git a/include/veyra/engine/EnhancementSettings.h b/include/veyra/engine/EnhancementSettings.h
index c3b13606..ececf784 100644
--- a/include/veyra/engine/EnhancementSettings.h
+++ b/include/veyra/engine/EnhancementSettings.h
@@ -16,6 +16,9 @@ constexpr bool presentSinkFrameGeneration(FrameGenerationBackend backend) {
// exposes 2/3/4/6 and MFG buyers pick from those; 1 = generation off.
inline constexpr uint32_t kFgMultiplierChoices[]={1,2,3,4,6};
inline constexpr size_t kFgMultiplierChoiceCount=sizeof(kFgMultiplierChoices)/sizeof(kFgMultiplierChoices[0]);
+// videoSrQuality values: 0 = DLSS SR, 1..4 = RTX video SR quality steps,
+// 5 = AMD FSR upscaling (vendor neutral; verified on an NVIDIA adapter).
+inline constexpr uint32_t kVideoSrFsr=5;
enum class NrRuntime { Original, Community, Ampere };
constexpr std::string_view nrRuntimeName(NrRuntime runtime) {
switch(runtime) {
@@ -127,7 +130,7 @@ 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(frameGenerationBackend==FrameGenerationBackend::Fsr&&multiplier>2)return "AMD FSR frame generation supports up to 2X";
- if(videoSrQuality>4)return "invalid video SR quality";
+ if(videoSrQuality>kVideoSrFsr)return "invalid video SR quality";
if(!pipeline::validSrTarget(srTarget))return "invalid SR target";
if(opticalFlowBackend!=OpticalFlowBackend::Nvidia&&opticalFlowBackend!=OpticalFlowBackend::AmdFidelityFx&&opticalFlowBackend!=OpticalFlowBackend::GpuDis)return "invalid optical flow backend";
if(multiplier<1||multiplier>6)return "unsupported multiplier";
diff --git a/include/veyra/gfx/FsrSrBackend.h b/include/veyra/gfx/FsrSrBackend.h
new file mode 100644
index 00000000..93a3bc65
--- /dev/null
+++ b/include/veyra/gfx/FsrSrBackend.h
@@ -0,0 +1,55 @@
+#pragma once
+
+// AMD FidelityFX Super Resolution upscaling backend (FidelityFX API, not NGX).
+//
+// The engine feeds it the linear working color at render extent plus the
+// guidance motion in render-extent pixels; the provider writes the upscaled
+// result directly into the caller's output resource, so the graph needs no
+// extra blit. Motion convention: the FSR3 upscaler reprojects with
+// "previous = current + motion" (ffx_fsr3upscaler_reproject.h:
+// fReprojectedHrUv = fHrUv + fMotionVector), which already matches Veyra's
+// current->previous guidance, so the stored pixels are passed unchanged.
+//
+// Local evidence for this path: tools/fsr_upscale_probe ->
+// logs/fsr/upscale-probe.log, and docs/FSR_UPSCALING_PLAN_2026-09-16.md.
+
+#include <d3d12.h>
+
+#include <cstdint>
+#include <memory>
+
+namespace veyra::gfx {
+
+class FsrSrBackend {
+public:
+ FsrSrBackend();
+ ~FsrSrBackend();
+
+ FsrSrBackend(const FsrSrBackend&) = delete;
+ FsrSrBackend& operator=(const FsrSrBackend&) = delete;
+
+ // maxRender* is the largest render (source) extent, maxUpscale* the largest
+ // output extent. hdr selects the high-dynamic-range input contract.
+ bool initialize(ID3D12Device* device, uint32_t maxRenderWidth, uint32_t maxRenderHeight,
+ uint32_t maxUpscaleWidth, uint32_t maxUpscaleHeight, bool hdr);
+
+ // Records the upscale on the caller's command list. Resources must be in
+ // the state declared here (color/motion/depth readable by compute, output
+ // as UAV); `motion` is render-extent pixel motion, `depth` render extent.
+ bool evaluate(ID3D12GraphicsCommandList* list, ID3D12Resource* color, ID3D12Resource* motion,
+ ID3D12Resource* depth, ID3D12Resource* output, uint32_t renderWidth, uint32_t renderHeight,
+ uint32_t upscaleWidth, uint32_t upscaleHeight, bool reset, float frameTimeMs);
+
+ void release();
+ bool created() const;
+ uint64_t evaluateCount() const;
+ uint64_t failureCount() const;
+ const char* providerVersion() const;
+
+ struct Impl;
+
+private:
+ std::unique_ptr<Impl> p_;
+};
+
+} // namespace veyra::gfx
diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.h
index 9285ddbd..7ef94b90 100644
--- a/include/veyra/pipeline/EnhanceGraph.h
+++ b/include/veyra/pipeline/EnhanceGraph.h
@@ -40,6 +40,7 @@ namespace veyra::guidance { class AmdOpticalFlow; class GpuDisOpticalFlow; }
namespace veyra::gfx {
class D3D12DeviceContext;
class CommandSlotRing;
+class FsrSrBackend;
}
namespace veyra::ngx {
@@ -205,6 +206,11 @@ public:
// Frame generation implemented by the present sink (XeSS, FSR) instead of
// the in-graph DLSSG path; both consume the same guidance motion texture.
bool presentSinkFg() const { return xessEnabled() || fsrEnabled(); }
+ // AMD FSR upscaling replaces the SR stage; it is a FidelityFX effect, not
+ // an NGX feature, so it also works on non-NVIDIA adapters.
+ bool fsrSrRequested() const { return desc_.enableSr && !desc_.stillImage && desc_.videoSrQuality==engine::kVideoSrFsr; }
+ // Out of line: the backend type is only forward declared here.
+ bool fsrSrEnabled() const;
// Requested output multiplier (2 = one generated frame). Consumed by the
// present sink so the XeSS provider knows how many frames to generate.
uint32_t fgMultiplier() const { return desc_.fgMultiplier; }
@@ -251,6 +257,7 @@ private:
bool initZeroAndDepthTextures();
bool initNvof();
bool initNgxFeatures();
+ bool initFsrSr();
bool createComputePasses();
gfx::D3D12DeviceContext& context_;
@@ -323,6 +330,9 @@ private:
std::unique_ptr<guidance::GpuDisOpticalFlow> gpuDis_;
std::unique_ptr<ngx::VideoSrBackend> videoSrBackend_;
std::unique_ptr<ngx::DlssFgBackend> fgBackend_;
+ std::unique_ptr<gfx::FsrSrBackend> fsrSrBackend_;
+ ComPtr<ID3D12Resource> fsrSrDepth_, upFsrSrDepth_;
+ size_t fsrSrDepthPitch_=0;
NVSDK_NGX_Parameter* ngxParams_ = nullptr;
NVSDK_NGX_Handle* nrHandle_ = nullptr;
uint64_t nrResult_ = 0;
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index 7e483b1c..34faa75c 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -243,7 +243,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
gd.workWidth=resolution.base.width;gd.workHeight=resolution.base.height;gd.nrWidth=resolution.nr.width;gd.nrHeight=resolution.nr.height;gd.flowWidth=resolution.flow.width;gd.flowHeight=resolution.flow.height;
const bool nvidiaAdapter=ctx.adapter().isNvidia;
const bool xessFg=presentSinkFrameGeneration(options.settings.frameGenerationBackend);
- gd.nrBeforeSr=!isImage&&options.settings.lowLatency&&options.nr&&resolution.srApplied;gd.enableSr=resolution.srApplied&&nvidiaAdapter;gd.videoSrQuality=options.settings.videoSrQuality;gd.enableNr=options.nr&&nvidiaAdapter;gd.nrRuntime=options.settings.nrRuntime;gd.enableFg=options.fg&&(nvidiaAdapter||xessFg);gd.fgMultiplier=options.fgMultiplier;gd.frameGenerationBackend=options.settings.frameGenerationBackend;gd.enableNvofStandalone=gd.enableNr;
+ gd.nrBeforeSr=!isImage&&options.settings.lowLatency&&options.nr&&resolution.srApplied;gd.enableSr=resolution.srApplied&&(nvidiaAdapter||options.settings.videoSrQuality==kVideoSrFsr);gd.videoSrQuality=options.settings.videoSrQuality;gd.enableNr=options.nr&&nvidiaAdapter;gd.nrRuntime=options.settings.nrRuntime;gd.enableFg=options.fg&&(nvidiaAdapter||xessFg);gd.fgMultiplier=options.fgMultiplier;gd.frameGenerationBackend=options.settings.frameGenerationBackend;gd.enableNvofStandalone=gd.enableNr;
gd.noFeatures=false;gd.model=options.settings.model;gd.residual=options.settings.residual;gd.protection=options.settings.protection;gd.settingsRevision=options.settings.revision;gd.flowQuality=options.settings.flow;gd.contentRate=options.settings.content;
gd.opticalFlowBackend=options.settings.opticalFlowBackend;gd.amdFlowHalfResolution=options.settings.amdFlowHalfResolution;
gd.hdrOutput=options.settings.useHdrPreview(gd.hdrInput,gfx::PresentSink::hdrDisplayActive(window));
@@ -269,6 +269,10 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
failure=FailedBackend::Infrastructure;
if(opened&&graph.xessEnabled()&&!presenter.xessActive()){opened=false;failure=FailedBackend::Fg;}
if(opened&&graph.fsrEnabled()&&!presenter.fsrActive()){opened=false;failure=FailedBackend::Fg;}
+ // Requested AMD FSR upscaling that could not be created
+ // (missing local runtime, unsupported layout) degrades
+ // to the plain scale path with a visible warning.
+ if(opened&&graph.fsrSrRequested()&&!graph.fsrSrEnabled()){opened=false;failure=FailedBackend::Sr;}
}
if(opened)return true;
auto reduced=selected.snapshot();
@@ -305,7 +309,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
presenter.close();graph.shutdown();selected=PlayerOptions::from(reduced);
const auto plan=pipeline::ResolutionPlan::make({width,height},selected.sr,reduced.nrPolicy,isImage,reduced.revision,reduced.srTarget,reduced.lowLatency&&selected.nr);
desc.workWidth=plan.base.width;desc.workHeight=plan.base.height;desc.nrWidth=plan.nr.width;desc.nrHeight=plan.nr.height;desc.flowWidth=plan.flow.width;desc.flowHeight=plan.flow.height;
- desc.enableNr=selected.nr&&nvidiaAdapter;desc.enableSr=plan.srApplied&&nvidiaAdapter;desc.enableFg=selected.fg&&(nvidiaAdapter||presentSinkFrameGeneration(reduced.frameGenerationBackend));desc.fgMultiplier=selected.fgMultiplier;
+ desc.enableNr=selected.nr&&nvidiaAdapter;desc.enableSr=plan.srApplied&&(nvidiaAdapter||selected.settings.videoSrQuality==kVideoSrFsr);desc.enableFg=selected.fg&&(nvidiaAdapter||presentSinkFrameGeneration(reduced.frameGenerationBackend));desc.fgMultiplier=selected.fgMultiplier;
desc.enableNvofStandalone=desc.enableNr;desc.nrBeforeSr=!isImage&&reduced.lowLatency&&selected.nr&&desc.enableSr;
}
return false;
@@ -637,7 +641,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
nextDesc.workWidth=plan.base.width;nextDesc.workHeight=plan.base.height;nextDesc.nrWidth=plan.nr.width;nextDesc.nrHeight=plan.nr.height;nextDesc.flowWidth=plan.flow.width;nextDesc.flowHeight=plan.flow.height;
const bool nvidiaAdapter=ctx.adapter().isNvidia;
const bool xessFg=presentSinkFrameGeneration(next.settings.frameGenerationBackend);
- nextDesc.nrBeforeSr=!isImage&&requested.lowLatency&&requested.nr&&plan.srApplied;nextDesc.enableSr=plan.srApplied&&nvidiaAdapter;nextDesc.videoSrQuality=next.settings.videoSrQuality;nextDesc.enableNr=next.nr&&nvidiaAdapter;nextDesc.nrRuntime=next.settings.nrRuntime;nextDesc.enableFg=next.fg&&(nvidiaAdapter||xessFg);nextDesc.fgMultiplier=next.fgMultiplier;nextDesc.frameGenerationBackend=next.settings.frameGenerationBackend;nextDesc.enableNvofStandalone=nextDesc.enableNr;
+ nextDesc.nrBeforeSr=!isImage&&requested.lowLatency&&requested.nr&&plan.srApplied;nextDesc.enableSr=plan.srApplied&&(nvidiaAdapter||next.settings.videoSrQuality==kVideoSrFsr);nextDesc.videoSrQuality=next.settings.videoSrQuality;nextDesc.enableNr=next.nr&&nvidiaAdapter;nextDesc.nrRuntime=next.settings.nrRuntime;nextDesc.enableFg=next.fg&&(nvidiaAdapter||xessFg);nextDesc.fgMultiplier=next.fgMultiplier;nextDesc.frameGenerationBackend=next.settings.frameGenerationBackend;nextDesc.enableNvofStandalone=nextDesc.enableNr;
nextDesc.model=requested.model;nextDesc.residual=requested.residual;nextDesc.protection=requested.protection;nextDesc.settingsRevision=requested.revision;nextDesc.flowQuality=requested.flow;nextDesc.contentRate=requested.content;
nextDesc.opticalFlowBackend=requested.opticalFlowBackend;nextDesc.amdFlowHalfResolution=requested.amdFlowHalfResolution;
nextDesc.hdrOutput=requested.useHdrPreview(nextDesc.hdrInput,gfx::PresentSink::hdrDisplayActive(window));
@@ -744,7 +748,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
drainLivePresentation();if(!ring.drainQueue()){status(L"串流尺寸切换排空失败",true);break;}
width=uint32_t(frame->width);height=uint32_t(frame->height);
auto plan=pipeline::ResolutionPlan::make({width,height},options.sr,options.settings.nrPolicy,false,options.settings.revision,options.settings.srTarget,options.settings.lowLatency&&options.nr);
- gd.nrBeforeSr=options.settings.lowLatency&&options.nr&&plan.srApplied;gd.enableSr=plan.srApplied&&ctx.adapter().isNvidia;
+ gd.nrBeforeSr=options.settings.lowLatency&&options.nr&&plan.srApplied;gd.enableSr=plan.srApplied&&(ctx.adapter().isNvidia||options.settings.videoSrQuality==kVideoSrFsr);
gd.sourceWidth=width;gd.sourceHeight=height;gd.hdrInput=!isImage&&activeSource->info().color.isHdrPath();gd.hdrOutput=options.settings.useHdrPreview(gd.hdrInput,gfx::PresentSink::hdrDisplayActive(window));gd.workWidth=plan.base.width;gd.workHeight=plan.base.height;gd.nrWidth=plan.nr.width;gd.nrHeight=plan.nr.height;gd.flowWidth=plan.flow.width;gd.flowHeight=plan.flow.height;
presenter.close();graph.shutdown();out={};hasOutput=false;
if(!graph.initialize(gd)||!presenter.open(ctx,window,graph,options.settings.captureCompatible)||!graph.createViews()){status(L"串流尺寸切换失败",true);break;}
@@ -885,7 +889,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
options=PlayerOptions::from(reduced);
const auto plan=pipeline::ResolutionPlan::make({width,height},options.sr,reduced.nrPolicy,isImage,reduced.revision,reduced.srTarget,reduced.lowLatency&&reduced.nr);
gd.workWidth=plan.base.width;gd.workHeight=plan.base.height;gd.nrWidth=plan.nr.width;gd.nrHeight=plan.nr.height;gd.flowWidth=plan.flow.width;gd.flowHeight=plan.flow.height;
- gd.enableNr=options.nr&&nvidiaAdapter;gd.enableSr=plan.srApplied&&nvidiaAdapter;gd.enableFg=options.fg&&(nvidiaAdapter||presentSinkFrameGeneration(reduced.frameGenerationBackend));gd.fgMultiplier=options.fgMultiplier;gd.enableNvofStandalone=gd.enableNr;gd.settingsRevision=reduced.revision;gd.nrBeforeSr=!isImage&&reduced.lowLatency&&gd.enableNr&&gd.enableSr;
+ gd.enableNr=options.nr&&nvidiaAdapter;gd.enableSr=plan.srApplied&&(nvidiaAdapter||options.settings.videoSrQuality==kVideoSrFsr);gd.enableFg=options.fg&&(nvidiaAdapter||presentSinkFrameGeneration(reduced.frameGenerationBackend));gd.fgMultiplier=options.fgMultiplier;gd.enableNvofStandalone=gd.enableNr;gd.settingsRevision=reduced.revision;gd.nrBeforeSr=!isImage&&reduced.lowLatency&&gd.enableNr&&gd.enableSr;
if(!initializePreview(gd,options)){status(L"增强故障后的基础图重建失败",true);break;}
backendRecoveryWarning=std::wstring(backendFailureName(failedComponent))+L"运行失败,已关闭对应效果;错误码见日志"+(backendRecoveryWarning.empty()?L"":L";"+backendRecoveryWarning);
{std::lock_guard lock(mutex_);desired_.rejectVideoRequest(attempted,options.snapshot());snapshot_.desired=desired_;snapshot_.applied=options.snapshot();snapshot_.applying=desired_!=snapshot_.applied;snapshot_.backendWarning=backendRecoveryWarning;}
diff --git a/src/gfx/FsrFgPresenter.cpp b/src/gfx/FsrFgPresenter.cpp
index ccfeba2c..2cc6c654 100644
--- a/src/gfx/FsrFgPresenter.cpp
+++ b/src/gfx/FsrFgPresenter.cpp
@@ -217,7 +217,7 @@ bool FsrFgPresenter::initialize(ID3D12Device* device, ID3D12CommandQueue* queue,
#ifdef VEYRA_HAS_FSR
auto& p = *p_;
(void)fgMultiplier;
- const auto root = runtime::localDataDirectory() / "amd" / "framegeneration";
+ const auto root = runtime::localDataDirectory() / "amd" / "fidelityfx";
const auto loaderPath = std::filesystem::absolute(root / "amd_fidelityfx_loader_dx12.dll");
const auto providerPath = std::filesystem::absolute(root / "amd_fidelityfx_framegeneration_dx12.dll");
diff --git a/src/gfx/FsrSrBackend.cpp b/src/gfx/FsrSrBackend.cpp
new file mode 100644
index 00000000..3e57ed2b
--- /dev/null
+++ b/src/gfx/FsrSrBackend.cpp
@@ -0,0 +1,284 @@
+#include "veyra/gfx/FsrSrBackend.h"
+
+#include "veyra/Log.h"
+#include "veyra/RuntimePaths.h"
+
+#include <filesystem>
+#include <string>
+
+#ifdef VEYRA_HAS_FSR
+#include <ffx_api_loader.h>
+#include <ffx_upscale.h>
+#include <dx12/ffx_api_dx12.h>
+#endif
+
+namespace veyra::gfx {
+
+#ifdef VEYRA_HAS_FSR
+namespace {
+
+FfxApiSurfaceFormat surfaceFormatFromDxgi(DXGI_FORMAT format) {
+ switch (format) {
+ case DXGI_FORMAT_R8G8B8A8_UNORM: return FFX_API_SURFACE_FORMAT_R8G8B8A8_UNORM;
+ case DXGI_FORMAT_R16G16B16A16_FLOAT: return FFX_API_SURFACE_FORMAT_R16G16B16A16_FLOAT;
+ case DXGI_FORMAT_R16G16_FLOAT: return FFX_API_SURFACE_FORMAT_R16G16_FLOAT;
+ case DXGI_FORMAT_R32_FLOAT: return FFX_API_SURFACE_FORMAT_R32_FLOAT;
+ default: return FFX_API_SURFACE_FORMAT_UNKNOWN;
+ }
+}
+
+FfxApiResource makeResource(ID3D12Resource* resource, uint32_t state) {
+ FfxApiResource api{};
+ if (resource == nullptr) return api;
+ const D3D12_RESOURCE_DESC desc = resource->GetDesc();
+ api.resource = resource;
+ api.description.type = FFX_API_RESOURCE_TYPE_TEXTURE2D;
+ api.description.format = surfaceFormatFromDxgi(desc.Format);
+ api.description.width = uint32_t(desc.Width);
+ api.description.height = desc.Height;
+ api.description.depth = desc.DepthOrArraySize;
+ api.description.mipCount = desc.MipLevels;
+ api.description.flags = 0;
+ api.description.usage = FFX_API_RESOURCE_USAGE_READ_ONLY;
+ if ((desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS) != 0) {
+ api.description.usage = FfxApiResourceUsage(api.description.usage | FFX_API_RESOURCE_USAGE_UAV);
+ }
+ api.state = state;
+ return api;
+}
+
+const char* returnName(ffxReturnCode_t code) {
+ switch (code) {
+ case FFX_API_RETURN_OK: return "OK";
+ case FFX_API_RETURN_ERROR: return "ERROR";
+ case FFX_API_RETURN_ERROR_UNKNOWN_DESCTYPE: return "ERROR_UNKNOWN_DESCTYPE";
+ case FFX_API_RETURN_ERROR_RUNTIME_ERROR: return "ERROR_RUNTIME_ERROR";
+ case FFX_API_RETURN_NO_PROVIDER: return "NO_PROVIDER";
+ case FFX_API_RETURN_ERROR_MEMORY: return "ERROR_MEMORY";
+ case FFX_API_RETURN_ERROR_PARAMETER: return "ERROR_PARAMETER";
+ case FFX_API_RETURN_PROVIDER_NO_SUPPORT_NEW_DESCTYPE: return "PROVIDER_NO_SUPPORT_NEW_DESCTYPE";
+ default: return "OTHER";
+ }
+}
+
+void fsrMessage(uint32_t type, const wchar_t* message) {
+ if (message == nullptr) return;
+ const int length = WideCharToMultiByte(CP_UTF8, 0, message, -1, nullptr, 0, nullptr, nullptr);
+ std::string text(size_t(length > 0 ? length - 1 : 0), '\0');
+ if (length > 1) WideCharToMultiByte(CP_UTF8, 0, message, -1, text.data(), length, nullptr, nullptr);
+ if (type == FFX_API_MESSAGE_TYPE_ERROR) log::error("fsr-sr", text);
+ else log::warn("fsr-sr", text);
+}
+
+// The loader resolves providers by base name through the normal search order,
+// so the provider DLL is pre-loaded by absolute path and the legacy DLL
+// directory is pointed at the same folder for the duration of the calls.
+struct DirectoryGuard {
+ wchar_t previous[MAX_PATH]{};
+ DWORD previousLength = 0;
+ DirectoryGuard(const std::filesystem::path& directory) {
+ previousLength = GetDllDirectoryW(MAX_PATH, previous);
+ SetDllDirectoryW(directory.c_str());
+ }
+ ~DirectoryGuard() { SetDllDirectoryW(previousLength > 0 ? previous : nullptr); }
+};
+
+} // namespace
+#endif
+
+struct FsrSrBackend::Impl {
+ bool available = false;
+ uint64_t evaluateCount = 0;
+ uint64_t failureCount = 0;
+ std::string providerVersion;
+#ifdef VEYRA_HAS_FSR
+ HMODULE loader = nullptr;
+ ffxFunctions functions{};
+ ffxContext context = nullptr;
+ uint32_t maxRenderWidth = 0, maxRenderHeight = 0;
+ uint32_t maxUpscaleWidth = 0, maxUpscaleHeight = 0;
+#endif
+};
+
+FsrSrBackend::FsrSrBackend() : p_(std::make_unique<Impl>()) {}
+
+FsrSrBackend::~FsrSrBackend() { release(); }
+
+bool FsrSrBackend::initialize(ID3D12Device* device, uint32_t maxRenderWidth, uint32_t maxRenderHeight,
+ uint32_t maxUpscaleWidth, uint32_t maxUpscaleHeight, bool hdr) {
+#ifdef VEYRA_HAS_FSR
+ auto& p = *p_;
+ if (p.available) return true;
+ const auto root = runtime::localDataDirectory() / "amd" / "fidelityfx";
+ const auto loaderPath = std::filesystem::absolute(root / "amd_fidelityfx_loader_dx12.dll");
+ const auto providerPath = std::filesystem::absolute(root / "amd_fidelityfx_upscaler_dx12.dll");
+ if (!std::filesystem::exists(loaderPath)) {
+ log::warn("fsr-sr", std::format("loader missing at {}", loaderPath.string()));
+ return false;
+ }
+ DirectoryGuard guard(root);
+ p.loader = LoadLibraryExW(loaderPath.c_str(), nullptr,
+ LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
+ if (p.loader == nullptr) {
+ log::error("fsr-sr", std::format("loader load failed win32={}", GetLastError()));
+ return false;
+ }
+ if (std::filesystem::exists(providerPath) &&
+ LoadLibraryExW(providerPath.c_str(), nullptr,
+ LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32) == nullptr) {
+ log::warn("fsr-sr", std::format("provider preload failed win32={}", GetLastError()));
+ }
+ ffxLoadFunctions(&p.functions, p.loader);
+ if (p.functions.CreateContext == nullptr || p.functions.DestroyContext == nullptr ||
+ p.functions.Dispatch == nullptr || p.functions.Query == nullptr) {
+ log::error("fsr-sr", "loader is missing the FidelityFX API entry points");
+ return false;
+ }
+ {
+ ffxQueryDescGetVersions versions{};
+ versions.header.type = FFX_API_QUERY_DESC_TYPE_GET_VERSIONS;
+ versions.createDescType = FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE;
+ versions.device = device;
+ uint64_t count = 0;
+ versions.outputCount = &count;
+ const auto countResult = p.functions.Query(nullptr, &versions.header);
+ uint64_t ids[8]{};
+ const char* names[8]{};
+ uint64_t capacity = 8;
+ versions.outputCount = &capacity;
+ versions.versionIds = ids;
+ versions.versionNames = names;
+ const auto listResult = countResult == FFX_API_RETURN_OK
+ ? p.functions.Query(nullptr, &versions.header) : countResult;
+ if (listResult == FFX_API_RETURN_OK && capacity > 0 && names[0] != nullptr) {
+ p.providerVersion = names[0];
+ }
+ log::info("fsr-sr", std::format("providers count={} selected={}", capacity,
+ p.providerVersion.empty() ? "none" : p.providerVersion));
+ }
+
+ ffxCreateBackendDX12Desc backendDesc{};
+ backendDesc.header.type = FFX_API_CREATE_CONTEXT_DESC_TYPE_BACKEND_DX12;
+ backendDesc.device = device;
+ ffxCreateContextDescUpscaleVersion versionDesc{};
+ versionDesc.header.type = FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE_VERSION;
+ versionDesc.version = FFX_UPSCALER_VERSION;
+ ffxCreateContextDescUpscale upscaleDesc{};
+ upscaleDesc.header.type = FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE;
+ upscaleDesc.header.pNext = &backendDesc.header;
+ backendDesc.header.pNext = &versionDesc.header;
+ upscaleDesc.flags = hdr ? FFX_UPSCALE_ENABLE_HIGH_DYNAMIC_RANGE : 0u;
+ upscaleDesc.maxRenderSize = {maxRenderWidth, maxRenderHeight};
+ upscaleDesc.maxUpscaleSize = {maxUpscaleWidth, maxUpscaleHeight};
+ upscaleDesc.fpMessage = fsrMessage;
+ auto result = p.functions.CreateContext(&p.context, &upscaleDesc.header, nullptr);
+ if (result != FFX_API_RETURN_OK || p.context == nullptr) {
+ log::warn("fsr-sr", std::format("context with version desc failed result={}; retrying without it",
+ returnName(result)));
+ backendDesc.header.pNext = nullptr;
+ result = p.functions.CreateContext(&p.context, &upscaleDesc.header, nullptr);
+ }
+ if (result != FFX_API_RETURN_OK || p.context == nullptr) {
+ log::error("fsr-sr", std::format("context creation failed result={} (0x{:X})", returnName(result),
+ unsigned(result)));
+ return false;
+ }
+ p.maxRenderWidth = maxRenderWidth;
+ p.maxRenderHeight = maxRenderHeight;
+ p.maxUpscaleWidth = maxUpscaleWidth;
+ p.maxUpscaleHeight = maxUpscaleHeight;
+ p.available = true;
+ log::info("fsr-sr", std::format("provider={} maxRender={}x{} maxUpscale={}x{} hdr={}",
+ p.providerVersion.empty() ? "unknown" : p.providerVersion,
+ maxRenderWidth, maxRenderHeight, maxUpscaleWidth, maxUpscaleHeight, hdr));
+ return true;
+#else
+ (void)device; (void)maxRenderWidth; (void)maxRenderHeight; (void)maxUpscaleWidth; (void)maxUpscaleHeight; (void)hdr;
+ log::error("fsr-sr", "AMD FidelityFX SDK headers were unavailable at build time");
+ return false;
+#endif
+}
+
+bool FsrSrBackend::evaluate(ID3D12GraphicsCommandList* list, ID3D12Resource* color, ID3D12Resource* motion,
+ ID3D12Resource* depth, ID3D12Resource* output, uint32_t renderWidth, uint32_t renderHeight,
+ uint32_t upscaleWidth, uint32_t upscaleHeight, bool reset, float frameTimeMs) {
+#ifdef VEYRA_HAS_FSR
+ auto& p = *p_;
+ if (!p.available || list == nullptr || color == nullptr || motion == nullptr || depth == nullptr ||
+ output == nullptr) {
+ return false;
+ }
+ if (renderWidth > p.maxRenderWidth || renderHeight > p.maxRenderHeight ||
+ upscaleWidth > p.maxUpscaleWidth || upscaleHeight > p.maxUpscaleHeight) {
+ log::error("fsr-sr", std::format("extent {}x{} -> {}x{} exceeds the created ceiling", renderWidth,
+ renderHeight, upscaleWidth, upscaleHeight));
+ ++p.failureCount;
+ return false;
+ }
+ ffxDispatchDescUpscale dispatch{};
+ dispatch.header.type = FFX_API_DISPATCH_DESC_TYPE_UPSCALE;
+ dispatch.commandList = list;
+ // Declared states are the states the caller actually set: a mismatch here
+ // is what produced runtime errors in the frame-generation path.
+ dispatch.color = makeResource(color, FFX_API_RESOURCE_STATE_COMPUTE_READ);
+ dispatch.motionVectors = makeResource(motion, FFX_API_RESOURCE_STATE_COMPUTE_READ);
+ dispatch.depth = makeResource(depth, FFX_API_RESOURCE_STATE_COMPUTE_READ);
+ dispatch.exposure = {};
+ dispatch.reactive = {};
+ dispatch.transparencyAndComposition = {};
+ dispatch.output = makeResource(output, FFX_API_RESOURCE_STATE_UNORDERED_ACCESS);
+ dispatch.jitterOffset = {0.0f, 0.0f};
+ // Guidance motion is render-extent pixel space, so the factor that converts
+ // it to UV inside the provider is 1:1 (same rule as the frame generator).
+ dispatch.motionVectorScale = {1.0f, 1.0f};
+ dispatch.renderSize = {renderWidth, renderHeight};
+ dispatch.upscaleSize = {upscaleWidth, upscaleHeight};
+ dispatch.enableSharpening = false;
+ dispatch.sharpness = 0.0f;
+ dispatch.frameTimeDelta = frameTimeMs > 0.0f ? frameTimeMs : 16.6f;
+ dispatch.preExposure = 1.0f;
+ dispatch.reset = reset;
+ dispatch.cameraNear = 0.1f;
+ dispatch.cameraFar = 1000.0f;
+ dispatch.cameraFovAngleVertical = 1.0f;
+ dispatch.viewSpaceToMetersFactor = 0.0f;
+ dispatch.flags = 0;
+ const auto result = p.functions.Dispatch(&p.context, &dispatch.header);
+ if (result != FFX_API_RETURN_OK) {
+ log::warn("fsr-sr", std::format("dispatch result={} render={}x{} upscale={}x{} reset={}", returnName(result),
+ renderWidth, renderHeight, upscaleWidth, upscaleHeight, reset));
+ ++p.failureCount;
+ return false;
+ }
+ ++p.evaluateCount;
+ return true;
+#else
+ (void)list; (void)color; (void)motion; (void)depth; (void)output; (void)renderWidth; (void)renderHeight;
+ (void)upscaleWidth; (void)upscaleHeight; (void)reset; (void)frameTimeMs;
+ return false;
+#endif
+}
+
+void FsrSrBackend::release() {
+#ifdef VEYRA_HAS_FSR
+ auto& p = *p_;
+ if (p.context != nullptr) {
+ const auto result = p.functions.DestroyContext(&p.context, nullptr);
+ log::info("fsr-sr", std::format("context destroyed result={} evaluations={} failures={}", returnName(result),
+ p.evaluateCount, p.failureCount));
+ p.context = nullptr;
+ }
+ if (p.loader != nullptr) {
+ FreeLibrary(p.loader);
+ p.loader = nullptr;
+ }
+ p.available = false;
+#endif
+}
+
+bool FsrSrBackend::created() const { return p_->available; }
+uint64_t FsrSrBackend::evaluateCount() const { return p_->evaluateCount; }
+uint64_t FsrSrBackend::failureCount() const { return p_->failureCount; }
+const char* FsrSrBackend::providerVersion() const { return p_->providerVersion.c_str(); }
+
+} // namespace veyra::gfx
diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cpp
index 3d973afc..bc5cb4b6 100644
--- a/src/pipeline/EnhanceGraph.cpp
+++ b/src/pipeline/EnhanceGraph.cpp
@@ -21,6 +21,7 @@
#include "veyra/gfx/CommandSlotRing.h"
#include "veyra/gfx/D3D12DeviceContext.h"
#include "veyra/ngx/DlssFgBackend.h"
+#include "veyra/gfx/FsrSrBackend.h"
#include "veyra/ngx/DlssNrParameters.h"
#include "veyra/ngx/DlssNrRuntimeAdapter.h"
#include "veyra/ngx/DlssSrBackend.h"
@@ -74,7 +75,7 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)
veyra::log::info("graph","diagnostic SR motion override active; no product entry point enables this");
}
desc_ = desc;tracker_={};prevValid_=false;fgHistorySkipped_=false;cadence_.reset();scene_.reset();previousLuma_.clear();
- if(desc.videoSrQuality>4)return false;
+ if(desc.videoSrQuality>engine::kVideoSrFsr){veyra::log::error("graph",std::format("invalid video SR quality value={}",desc.videoSrQuality));return false;}
srcW_ = desc.sourceWidth;
srcH_ = desc.sourceHeight;
workW_ = desc.workWidth;
@@ -118,6 +119,7 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)
if (!createResources()) return false;
if (!initZeroAndDepthTextures()) return false;
if (!initNvof()) { failedBackend_=engine::FailedBackend::OpticalFlow; return false; }
+ if (!initFsrSr()) return false;
if(nrEnabled_&&GetEnvironmentVariableW(L"VEYRA_TEST_NR_INIT_FAILURE",nullptr,0)){
failedBackend_=engine::FailedBackend::Nr;
veyra::log::error("backend-recovery-test","test-only NR initialization rejection before SDK call; not a hardware failure");return false;
@@ -174,7 +176,18 @@ bool EnhanceGraph::createResources()
}
}
srcRgba_ = makeTexture(context_.device(), srcW_, srcH_, DXGI_FORMAT_R16G16B16A16_FLOAT, true);
- if(srEnabled_&&desc_.videoSrQuality){videoSrInput_=makeTexture(context_.device(),srcW_,srcH_,DXGI_FORMAT_R8G8B8A8_UNORM,true);videoSrOutput_=makeTexture(context_.device(),workW_,workH_,DXGI_FORMAT_R8G8B8A8_UNORM,true);if(!videoSrInput_||!videoSrOutput_)return false;}
+ if(srEnabled_&&desc_.videoSrQuality&&desc_.videoSrQuality!=engine::kVideoSrFsr){videoSrInput_=makeTexture(context_.device(),srcW_,srcH_,DXGI_FORMAT_R8G8B8A8_UNORM,true);videoSrOutput_=makeTexture(context_.device(),workW_,workH_,DXGI_FORMAT_R8G8B8A8_UNORM,true);if(!videoSrInput_||!videoSrOutput_)return false;}
+ // FSR upscaling needs a render-extent depth; Veyra has no source-resolution
+ // depth source, so this is the same explicit constant far depth the
+ // frame-generation path uses. It limits disocclusion quality and must not
+ // be described as engine-native depth.
+ if(srEnabled_&&desc_.videoSrQuality==engine::kVideoSrFsr){
+ fsrSrDepth_=makeTexture(context_.device(),srcW_,srcH_,DXGI_FORMAT_R32_FLOAT,false);
+ if(!fsrSrDepth_)return false;
+ fsrSrDepthPitch_=size_t(srcW_)*sizeof(float);
+ upFsrSrDepth_=makeUploadBuffer(context_.device(),fsrSrDepthPitch_*srcH_);
+ if(!upFsrSrDepth_)return false;
+ }
const bool directBase=!srEnabled_&&srcW_==workW_&&srcH_==workH_;
workRgba_=directBase?srcRgba_:makeTexture(context_.device(),workW_,workH_,DXGI_FORMAT_R16G16B16A16_FLOAT,true);
for(unsigned i=0;i<2;++i){sourceReferences_[i]=makeTexture(context_.device(),srcW_,srcH_,DXGI_FORMAT_R16G16B16A16_FLOAT,false);baseReferences_[i]=directBase?sourceReferences_[i]:makeTexture(context_.device(),workW_,workH_,DXGI_FORMAT_R16G16B16A16_FLOAT,false);if(!sourceReferences_[i]||!baseReferences_[i])return false;}
@@ -235,9 +248,11 @@ bool EnhanceGraph::initZeroAndDepthTextures()
{
// Depth constants uploaded once (copies are safe before views exist).
uint8_t* d = nullptr; uint8_t* zd = nullptr; uint8_t* zm = nullptr;
+ uint8_t* fd = nullptr;
upDepth_->Map(0, nullptr, reinterpret_cast<void**>(&d));
upZeroDepth_->Map(0, nullptr, reinterpret_cast<void**>(&zd));
upZeroMotion_->Map(0, nullptr, reinterpret_cast<void**>(&zm));
+ if(upFsrSrDepth_!=nullptr)upFsrSrDepth_->Map(0,nullptr,reinterpret_cast<void**>(&fd));
for (uint32_t y = 0; y < workH_; ++y) {
float* dRow = reinterpret_cast<float*>(d + y * dPitch_);
float* zdRow = reinterpret_cast<float*>(zd + y * dPitch_);
@@ -251,6 +266,13 @@ bool EnhanceGraph::initZeroAndDepthTextures()
upDepth_->Unmap(0, nullptr);
upZeroDepth_->Unmap(0, nullptr);
upZeroMotion_->Unmap(0, nullptr);
+ if(upFsrSrDepth_!=nullptr){
+ for(uint32_t y=0;y<srcH_;++y){
+ float* row=reinterpret_cast<float*>(fd+size_t(y)*fsrSrDepthPitch_);
+ for(uint32_t x=0;x<srcW_;++x)row[x]=0.9f;
+ }
+ upFsrSrDepth_->Unmap(0,nullptr);
+ }
Status st = Status::Ok;
ID3D12GraphicsCommandList* list = ring_.acquire(0, st);
@@ -283,6 +305,28 @@ bool EnhanceGraph::initZeroAndDepthTextures()
uploadTex(depthTex_.Get(), upDepth_, DXGI_FORMAT_R32_FLOAT);
uploadTex(nrZeroDepth_.Get(), upZeroDepth_, DXGI_FORMAT_R32_FLOAT);
uploadTex(nrZeroMotion_.Get(), upZeroMotion_, DXGI_FORMAT_R16G16_FLOAT);
+ if(fsrSrDepth_!=nullptr&&upFsrSrDepth_!=nullptr){
+ D3D12_RESOURCE_BARRIER b{};
+ b.Transition.pResource=fsrSrDepth_.Get();
+ b.Transition.StateBefore=D3D12_RESOURCE_STATE_COMMON;
+ b.Transition.StateAfter=D3D12_RESOURCE_STATE_COPY_DEST;
+ b.Transition.Subresource=D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
+ list->ResourceBarrier(1,&b);
+ D3D12_TEXTURE_COPY_LOCATION dst{},src{};
+ dst.pResource=fsrSrDepth_.Get();
+ dst.Type=D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
+ src.pResource=upFsrSrDepth_.Get();
+ src.Type=D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
+ src.PlacedFootprint.Footprint.Format=DXGI_FORMAT_R32_FLOAT;
+ src.PlacedFootprint.Footprint.Width=srcW_;
+ src.PlacedFootprint.Footprint.Height=srcH_;
+ src.PlacedFootprint.Footprint.Depth=1;
+ src.PlacedFootprint.Footprint.RowPitch=static_cast<UINT>(fsrSrDepthPitch_);
+ list->CopyTextureRegion(&dst,0,0,0,&src,nullptr);
+ b.Transition.StateBefore=D3D12_RESOURCE_STATE_COPY_DEST;
+ b.Transition.StateAfter=D3D12_RESOURCE_STATE_COMMON;
+ list->ResourceBarrier(1,&b);
+ }
list->Close();
ID3D12CommandList* lists[] = { list };
context_.directQueue()->ExecuteCommandLists(1, lists);
@@ -301,7 +345,7 @@ bool EnhanceGraph::initZeroAndDepthTextures()
bool EnhanceGraph::initNvof()
{
if(desc_.stillImage){mvecSource_="single-image (no temporal motion)";return true;}
- if (desc_.noFeatures || !(nvofStandalone_ || presentSinkFg() || (fgEnabled_&&desc_.frameGenerationBackend==engine::FrameGenerationBackend::Dlss) || (srEnabled_&&!desc_.videoSrQuality))) {
+ if (desc_.noFeatures || !(nvofStandalone_ || presentSinkFg() || (fgEnabled_&&desc_.frameGenerationBackend==engine::FrameGenerationBackend::Dlss) || (srEnabled_&&(desc_.videoSrQuality==0||desc_.videoSrQuality==engine::kVideoSrFsr)))) {
veyra::log::info("graph", "VEYRA_NO_FEATURES: NVOF session skipped");
return true;
}
@@ -346,6 +390,42 @@ bool EnhanceGraph::initNvof()
return true;
}
+bool EnhanceGraph::fsrSrEnabled() const
+{
+ return fsrSrBackend_ != nullptr && fsrSrBackend_->created();
+}
+
+bool EnhanceGraph::initFsrSr()
+{
+ if (!fsrSrRequested()) return true;
+ if (desc_.noFeatures) {
+ veyra::log::warn("fsr-sr", "feature-disabled configuration: AMD FSR upscaling skipped");
+ return true;
+ }
+ if (desc_.hdrOutput) {
+ // The working color here is linear FP16 with Veyra's own HDR contract;
+ // feeding that to the FSR HDR path without a verified transfer contract
+ // would be a guess. Refuse the stage instead of shipping a wrong image.
+ veyra::log::warn("fsr-sr", "HDR output is not supported by the AMD FSR upscaling stage yet; continuing without it");
+ return true;
+ }
+ failedBackend_=engine::FailedBackend::Sr;
+ fsrSrBackend_=std::make_unique<gfx::FsrSrBackend>();
+ if(!fsrSrBackend_->initialize(context_.device(),srcW_,srcH_,workW_,workH_,false)){
+ fsrSrBackend_.reset();
+ // The engine checks fsrSrRequested() && !fsrSrEnabled() after the graph
+ // is created and disables the stage with a user-visible warning, so a
+ // missing local runtime never blocks basic playback.
+ veyra::log::error("fsr-sr", "AMD FSR upscaling unavailable; the engine will disable the stage");
+ failedBackend_=engine::FailedBackend::None;
+ return true;
+ }
+ failedBackend_=engine::FailedBackend::None;
+ veyra::log::info("fsr-sr", std::format("selected render={}x{} output={}x{} provider={}",srcW_,srcH_,workW_,workH_,
+ fsrSrBackend_->providerVersion()));
+ return true;
+}
+
bool EnhanceGraph::initNgxFeatures()
{
failedBackend_=engine::FailedBackend::NgxCore;
@@ -353,6 +433,15 @@ bool EnhanceGraph::initNgxFeatures()
veyra::log::info("graph", "NGX core/features skipped by disabled-feature configuration");
return true;
}
+ // 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_ || fgEnabled_ ||
+ (srEnabled_ && desc_.videoSrQuality!=engine::kVideoSrFsr);
+ if (!needNgxCore) {
+ veyra::log::info("graph", "NGX core skipped: AMD FSR upscaling is the only enabled stage");
+ failedBackend_=engine::FailedBackend::None;
+ return true;
+ }
// Read the local NGX identity (same loader contract as the probes).
std::ifstream ids(std::wstring(desc_.runtimeAbsPath) + L"\\..\\config\\ngx-local.json",
std::ios::binary);
@@ -475,7 +564,7 @@ bool EnhanceGraph::initNgxFeatures()
if(!ring_.submitAndSignal(0)||!ring_.waitIdle())return false;
}
- if (srEnabled_ && !desc_.noFeatures) {
+ if (srEnabled_ && !desc_.noFeatures && desc_.videoSrQuality!=engine::kVideoSrFsr) {
ngx::DlssSrBackend::CreateDesc sd{};
sd.inputWidth = srcW_; sd.inputHeight = srcH_;
sd.outputWidth = workW_; sd.outputHeight = workH_;
@@ -970,7 +1059,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
// Guidance from original source-space color before SR/NR. Queue waits are GPU-side.
bool haveFlow = false;
- const bool runMotion = nvofStandalone_ || presentSinkFg() || fgEnabled_ || (srEnabled_ && !desc_.videoSrQuality);
+ const bool runMotion = nvofStandalone_ || presentSinkFg() || fgEnabled_ || (srEnabled_ && (desc_.videoSrQuality==0||desc_.videoSrQuality==engine::kVideoSrFsr));
if (runMotion && (gpuDis_ || amdOf_ || (nvof_ && nvof_->initialized()))) {
const float dims[8] = {uintBits(nvofW_),uintBits(nvofH_),uintBits(nvofW_),uintBits(nvofH_),0,0,0,0};
if (prevValid_) {
@@ -1058,7 +1147,26 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
out.batch.a100ns=static_cast<int64_t>(std::llround(prevPtsMs_*10000));
out.batch.b100ns=static_cast<int64_t>(std::llround(ptsMs*10000));gpuTimer_.identity(out.batch.identity);
auto runSr=[&]()->bool{
- if(srEnabled_&&videoSrBackend_){
+ if(srEnabled_&&fsrSrEnabled()&&haveFlow){
+ // AMD FSR upscaling: FidelityFX effect, render-extent color + guidance
+ // motion (previous = current + motion, same convention as the frame
+ // generator) straight into the working texture. A frame without valid
+ // motion falls through to the plain blit below instead of guessing.
+ gpuTimer_.mark(list,GpuStage::Sr);
+ const double deltaMs = (prevPtsMs_>=0.0&&ptsMs>prevPtsMs_)?(ptsMs-prevPtsMs_):16.6;
+ tracker_.transition(list,srcRgba_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ tracker_.transition(list,flowTex_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ tracker_.transition(list,fsrSrDepth_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ tracker_.transition(list,workRgba_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
+ if(!fsrSrBackend_->evaluate(list,srcRgba_.Get(),flowTex_.Get(),fsrSrDepth_.Get(),workRgba_.Get(),
+ srcW_,srcH_,workW_,workH_,reset,float(deltaMs))){
+ failedBackend_=engine::FailedBackend::Sr;
+ return false;
+ }
+ ++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_){
gpuTimer_.mark(list,GpuStage::Sr);
tracker_.transition(list,videoSrInput_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
const float enc[8]={uintBits(srcW_),uintBits(srcH_),uintBits(srcW_),uintBits(srcH_),desc_.hdrOutput?3.0f:1.0f,0,0,0};
@@ -1431,6 +1539,9 @@ void EnhanceGraph::shutdown()
gpuDis_.reset();
amdOf_.reset();
for(auto& motion:presentMotion_)motion.Reset();
+ if(fsrSrBackend_){fsrSrBackend_->release();fsrSrBackend_.reset();}
+ fsrSrDepth_.Reset();
+ upFsrSrDepth_.Reset();
if (fgBackend_) fgBackend_->release();
if(videoSrBackend_){videoSrBackend_->release();videoSrBackend_.reset();}
if (srBackend_) srBackend_->release();
diff --git a/tests/unit/RepairContractTests.cpp b/tests/unit/RepairContractTests.cpp
index e17eb1b2..640a4d41 100644
--- a/tests/unit/RepairContractTests.cpp
+++ b/tests/unit/RepairContractTests.cpp
@@ -193,6 +193,15 @@ int main(){
settings.multiplier=2;
check(settings.validate().empty(),"AMD FSR 2X is a valid request");
}
+ {
+ engine::EnhancementSettings settings;
+ settings.videoSrQuality=engine::kVideoSrFsr;
+ check(settings.validate().empty(),"AMD FSR upscaling is a valid video SR quality");
+ settings.videoSrQuality=engine::kVideoSrFsr+1;
+ check(!settings.validate().empty(),"video SR quality above the AMD FSR slot is rejected");
+ settings.videoSrQuality=0;
+ check(settings.validate().empty(),"DLSS SR quality remains valid");
+ }
check(engine::opticalFlowBackendName(engine::OpticalFlowBackend::Nvidia)=="NVIDIA_NVOF"&&engine::opticalFlowBackendName(engine::OpticalFlowBackend::AmdFidelityFx)=="AMD_FIDELITYFX_OF","optical-flow backend names identify every backend");
s.model.intensity=std::numeric_limits<float>::quiet_NaN();check(!s.validate().empty(),"reject NaN transaction");
s={};s.multiplier=5;check(s.validate().empty(),"5X multiplier accepted by the API guard (6X ceiling)");
diff --git a/tests/unit/RepairPresetTests.cpp b/tests/unit/RepairPresetTests.cpp
index b968d474..7e24b982 100644
--- a/tests/unit/RepairPresetTests.cpp
+++ b/tests/unit/RepairPresetTests.cpp
@@ -64,37 +64,40 @@ int main(int argc,char** argv){if(argc!=2)return 2;using namespace veyra::engine
s.audioSync=AudioSyncMode::Manual;s.audioOffsetMs=137;
s.nrRuntime=NrRuntime::Community;s.captureCompatible=true;s.lowLatency=true;s.forceSdrPreview=true;
ok=ok&&a.put(L"test",s)&&a.setDefault(0)&&!a.put(L"test",s);PresetStore b(p);ok=ok&&b.load()&&b.defaultSettings()==s&&b.rename(0,L"renamed")&&b.defaultSettings()==s;
- if(!ok){std::cerr<<"stage basic-preset failed\n";return 1;}
+
auto badTarget=s;badTarget.srTarget=static_cast<veyra::pipeline::SrTarget>(3);ok=ok&&!b.put(L"invalid target",badTarget);
- if(!ok){std::cerr<<"stage bad-target failed\n";return 1;}
+
// XeSS presets may request up to 4X since the audited multi-frame unlock; the
// engine clamps to the ceiling the provider reports at session start.
auto xess=s;xess.frameGenerationBackend=FrameGenerationBackend::XeSS;ok=ok&&b.put(L"XeSS 4X",xess);
PresetStore xessReload(p);ok=ok&&xessReload.load()&&xessReload.entries().back().settings==xess&&b.erase(1);
xess.multiplier=5;ok=ok&&!b.put(L"XeSS 5X rejected",xess);
xess.multiplier=2;ok=ok&&b.put(L"XeSS 2X",xess);PresetStore xess2Reload(p);ok=ok&&xess2Reload.load()&&xess2Reload.entries().back().settings==xess&&b.erase(1);
- if(!ok){std::cerr<<"stage xess-cases failed\n";return 1;}
+
// AMD FSR frame generation: the 3.1.x provider delivers one generated frame
// per present, so 2X round-trips and 4X is refused by validation.
auto fsr=s;fsr.frameGenerationBackend=FrameGenerationBackend::Fsr;ok=ok&&!b.put(L"FSR 4X rejected",fsr);
- if(!ok){std::cerr<<"stage fsr-4x failed\n";return 1;}
+
fsr.multiplier=2;ok=ok&&b.put(L"FSR 2X",fsr);PresetStore fsrReload(p);ok=ok&&fsrReload.load()&&fsrReload.entries().back().settings==fsr&&b.erase(1);
- if(!ok){std::cerr<<"stage backend-cases failed\n";return 1;}
+
auto badBackend=s;badBackend.frameGenerationBackend=static_cast<FrameGenerationBackend>(3);ok=ok&&!b.put(L"invalid backend",badBackend);
auto dis=s;dis.opticalFlowBackend=OpticalFlowBackend::GpuDis;ok=ok&&b.put(L"GPU DIS",dis)&&b.save();PresetStore disReload(p);ok=ok&&disReload.load()&&disReload.entries().back().settings==dis&&b.erase(1);
- if(!ok){std::cerr<<"stage flow-cases failed\n";return 1;}
+
auto badFlow=s;badFlow.opticalFlowBackend=static_cast<OpticalFlowBackend>(3);ok=ok&&!b.put(L"invalid flow backend",badFlow);
auto ampere=s;ampere.nr=true;ampere.nrRuntime=NrRuntime::Ampere;ok=ok&&b.put(L"RTX30",ampere);PresetStore ampereReload(p);ok=ok&&ampereReload.load()&&ampereReload.entries().back().settings==ampere&&b.erase(1);
auto badNr=s;badNr.nrRuntime=static_cast<NrRuntime>(3);ok=ok&&!b.put(L"invalid NR runtime",badNr);
auto half=s;half.content=ContentRate::Capture60To30;ok=ok&&b.put(L"capture half rate",half);PresetStore halfReload(p);ok=ok&&halfReload.load()&&halfReload.entries().back().settings.content==ContentRate::Capture60To30&&b.erase(1);
- auto badSr=s;badSr.videoSrQuality=5;ok=ok&&!b.put(L"invalid video SR",badSr);
+ // 5 is the AMD FSR upscaling slot now, so it must round-trip; 6 stays invalid.
+ auto fsrSr=s;fsrSr.videoSrQuality=veyra::engine::kVideoSrFsr;ok=ok&&b.put(L"FSR SR",fsrSr);
+ PresetStore fsrSrReload(p);ok=ok&&fsrSrReload.load()&&fsrSrReload.entries().back().settings.videoSrQuality==veyra::engine::kVideoSrFsr&&b.erase(1);
+ auto badSr=s;badSr.videoSrQuality=veyra::engine::kVideoSrFsr+1;ok=ok&&!b.put(L"invalid video SR",badSr);
auto invalid=s;invalid.model.tone=9;ok=ok&&!b.put(L"bad",invalid)&&b.entries().size()==1&&b.erase(0)&&b.entries().empty();
auto badRegion=s;badRegion.protection.regions[0].left=2;ok=ok&&!b.put(L"invalid region",badRegion);
{std::ofstream legacy(p);legacy<<"VEYRA_PRESETS 1\n\"legacy\" 1\n\"legacy\" 1 1 1 -1 0 0 0 1 1 1 1 1 1 0 1 0 1 0\n";}
PresetStore old(p);ok=ok&&old.load()&&!old.defaultSettings().protection.enabled&&old.defaultSettings().srTarget==veyra::pipeline::SrTarget::Uhd4K&&old.put(L"v2",s);
PresetStore upgraded(p);ok=ok&&upgraded.load()&&upgraded.entries().size()==2&&upgraded.entries()[1].settings==s;
- if(!ok){std::cerr<<"stage legacy-v1 failed\n";return 1;}
+
{std::ofstream f(p);f<<"VEYRA_PRESETS 99\ncorrupt mediaPath executable must reject";}PresetStore c(p);ok=ok&&!c.load()&&!c.put(L"override",{});std::ifstream f(p);std::string data((std::istreambuf_iterator<char>(f)),{});ok=ok&&data=="VEYRA_PRESETS 99\ncorrupt mediaPath executable must reject";
f.close();ok=legacyBackends(p)&&ok;
- if(!ok){std::cerr<<"stage closing failed\n";return 1;}
+
std::cout<<"preset roundtrip, all fields, duplicate, rename-default, delete, validation, unknown schema, corrupt-preservation="<<ok<<'\n';return ok?0:1;}
diff --git a/tools/fsr_upscale_probe/main.cpp b/tools/fsr_upscale_probe/main.cpp
index 524f759e..8f3605d7 100644
--- a/tools/fsr_upscale_probe/main.cpp
+++ b/tools/fsr_upscale_probe/main.cpp
@@ -181,6 +181,19 @@ int wmain(int argc, wchar_t** argv) {
std::wprintf(L"[fsr-up] adapter=%s vendor=0x%04X\n", adapterDesc.Description, adapterDesc.VendorId);
ComPtr<ID3D12Device> device;
+ bool diag = false;
+ for (int i = 1; i < argc; ++i) if (_wcsicmp(argv[i], L"--diag") == 0) diag = true;
+ if (diag) {
+ // Debug layer + GPU-based validation, the same pair the product's
+ // quality probe uses, so probe results can be compared directly.
+ ComPtr<ID3D12Debug> debug;
+ ComPtr<ID3D12Debug1> gbv;
+ if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&debug))) && SUCCEEDED(debug.As(&gbv))) {
+ debug->EnableDebugLayer();
+ gbv->SetEnableGPUBasedValidation(TRUE);
+ std::printf("[fsr-up] debug layer + GPU-based validation enabled\n");
+ }
+ }
if (FAILED(D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&device)))) {
std::printf("[fsr-up] D3D12CreateDevice failed\n");
return 5;
diff --git a/tools/image_check/compare_sr.ps1 b/tools/image_check/compare_sr.ps1
new file mode 100644
index 00000000..cbc410ef
--- /dev/null
+++ b/tools/image_check/compare_sr.ps1
@@ -0,0 +1,106 @@
+# Numeric image comparison for SR verification (Windows PowerShell 5.1).
+# Usage: powershell -File tools\image_check\compare_sr.ps1 -Reference <1080p.jpg> -Candidate <4K.jpg>
+#
+# Both images must be saved by the player's --smoke-save at the same smoke step.
+# The candidate (SR path, work extent) is downscaled to the reference extent and
+# compared, so "the SR output really depicts the same frame" becomes a number:
+# mean absolute difference plus per-image gradient energy (detail level).
+param(
+ [Parameter(Mandatory = $true)][string]$Reference,
+ [Parameter(Mandatory = $true)][string]$Candidate
+)
+Add-Type -AssemblyName System.Drawing
+
+function Get-Pixels([System.Drawing.Bitmap]$bitmap, [int]$width, [int]$height) {
+ $scaled = New-Object System.Drawing.Bitmap $width, $height
+ $graphics = [System.Drawing.Graphics]::FromImage($scaled)
+ $graphics.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
+ $graphics.DrawImage($bitmap, 0, 0, $width, $height)
+ $graphics.Dispose()
+ $rect = New-Object System.Drawing.Rectangle 0, 0, $width, $height
+ $data = $scaled.LockBits($rect, [System.Drawing.Imaging.ImageLockMode]::ReadOnly,
+ [System.Drawing.Imaging.PixelFormat]::Format24bppRgb)
+ $bytes = New-Object byte[] ($data.Stride * $height)
+ [System.Runtime.InteropServices.Marshal]::Copy($data.Scan0, $bytes, 0, $bytes.Length)
+ $scaled.UnlockBits($data)
+ $scaled.Dispose()
+ return @{ Bytes = $bytes; Stride = $data.Stride }
+}
+
+function Get-GradientEnergy($pixels, [int]$width, [int]$height) {
+ $sum = 0.0
+ $count = 0
+ for ($y = 1; $y -lt $height - 1; $y += 2) {
+ for ($x = 1; $x -lt $width - 1; $x += 2) {
+ $i = $y * $pixels.Stride + $x * 3
+ $gx = [int]$pixels.Bytes[$i + 3] - [int]$pixels.Bytes[$i - 3]
+ $gy = [int]$pixels.Bytes[$i + $pixels.Stride] - [int]$pixels.Bytes[$i - $pixels.Stride]
+ $sum += [Math]::Sqrt($gx * $gx + $gy * $gy)
+ $count++
+ }
+ }
+ if ($count -eq 0) { return 0.0 }
+ return $sum / $count
+}
+
+$referenceBitmap = [System.Drawing.Bitmap]::FromFile((Resolve-Path -LiteralPath $Reference))
+$candidateBitmap = [System.Drawing.Bitmap]::FromFile((Resolve-Path -LiteralPath $Candidate))
+Write-Output ("reference={0}x{1} candidate={2}x{3}" -f $referenceBitmap.Width, $referenceBitmap.Height,
+ $candidateBitmap.Width, $candidateBitmap.Height)
+$width = $referenceBitmap.Width
+$height = $referenceBitmap.Height
+$referencePixels = Get-Pixels $referenceBitmap $width $height
+$candidatePixels = Get-Pixels $candidateBitmap $width $height
+
+$difference = 0.0
+$referenceLuma = 0.0
+$candidateLuma = 0.0
+$count = 0
+for ($y = 0; $y -lt $height; $y += 2) {
+ for ($x = 0; $x -lt $width; $x += 2) {
+ $i = $y * $referencePixels.Stride + $x * 3
+ $rLuma = 0.2126 * $referencePixels.Bytes[$i + 2] + 0.7152 * $referencePixels.Bytes[$i + 1] + 0.0722 * $referencePixels.Bytes[$i]
+ $cLuma = 0.2126 * $candidatePixels.Bytes[$i + 2] + 0.7152 * $candidatePixels.Bytes[$i + 1] + 0.0722 * $candidatePixels.Bytes[$i]
+ $difference += [Math]::Abs($rLuma - $cLuma)
+ $referenceLuma += $rLuma
+ $candidateLuma += $cLuma
+ $count++
+ }
+}
+$mad = $difference / $count
+$referenceEnergy = Get-GradientEnergy $referencePixels $width $height
+$candidateEnergy = Get-GradientEnergy $candidatePixels $width $height
+Write-Output ("meanLuma reference={0:N2} candidate={1:N2}" -f ($referenceLuma / $count), ($candidateLuma / $count))
+Write-Output ("meanAbsDifference={0:N2} (0-255 scale; content agreement)" -f $mad)
+Write-Output ("gradientEnergy reference={0:N3} candidate={1:N3} ratio={2:N3}" -f $referenceEnergy, $candidateEnergy,
+ ($candidateEnergy / [Math]::Max($referenceEnergy, 0.001)))
+if ($mad -le 12.0) { Write-Output "VERDICT same-content (SR output tracks the reference frame)" }
+else { Write-Output "VERDICT content differs beyond a JPEG/resample margin - inspect" }
+
+# When the candidate is larger, also compare it against a pure resample of the
+# reference at the candidate's extent. An upscaler that added real detail must
+# differ from the resample and carry more high-frequency energy than it.
+if ($candidateBitmap.Width -gt $referenceBitmap.Width) {
+ $wide = $candidateBitmap.Width
+ $tall = $candidateBitmap.Height
+ $resampled = Get-Pixels ([System.Drawing.Bitmap]::FromFile((Resolve-Path -LiteralPath $Reference))) $wide $tall
+ $candidateWide = Get-Pixels ([System.Drawing.Bitmap]::FromFile((Resolve-Path -LiteralPath $Candidate))) $wide $tall
+ $resampleDifference = 0.0
+ $wideCount = 0
+ for ($y = 0; $y -lt $tall; $y += 4) {
+ for ($x = 0; $x -lt $wide; $x += 4) {
+ $i = $y * $candidateWide.Stride + $x * 3
+ $a = 0.2126 * $resampled.Bytes[$i + 2] + 0.7152 * $resampled.Bytes[$i + 1] + 0.0722 * $resampled.Bytes[$i]
+ $b = 0.2126 * $candidateWide.Bytes[$i + 2] + 0.7152 * $candidateWide.Bytes[$i + 1] + 0.0722 * $candidateWide.Bytes[$i]
+ $resampleDifference += [Math]::Abs($a - $b)
+ $wideCount++
+ }
+ }
+ $resampleEnergy = Get-GradientEnergy $resampled $wide $tall
+ $candidateWideEnergy = Get-GradientEnergy $candidateWide $wide $tall
+ Write-Output ("at {0}x{1}: meanAbsDifference(resample vs SR)={2:N2} gradientEnergy resample={3:N3} SR={4:N3} ratio={5:N3}" -f `
+ $wide, $tall, ($resampleDifference / $wideCount), $resampleEnergy, $candidateWideEnergy,
+ ($candidateWideEnergy / [Math]::Max($resampleEnergy, 0.001)))
+}
+$referenceBitmap.Dispose()
+$candidateBitmap.Dispose()
diff --git a/tools/quality_probe/main.cpp b/tools/quality_probe/main.cpp
index a592b798..360dd671 100644
--- a/tools/quality_probe/main.cpp
+++ b/tools/quality_probe/main.cpp
@@ -214,6 +214,9 @@ int main(int argc, char** argv)
int durationSeconds = 0;
int maxFrames = 60;
bool native = false, diag = false, legacyMotion = false;
+ // SR stage selection for deterministic A/B dumps: -1 = SR stage requested
+ // but disabled (plain scale to the work extent), 0 = DLSS SR, 5 = AMD FSR.
+ int srMode = 0;
std::string dumpPath;
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
for (int i = 1; i < argc; ++i) {
@@ -222,6 +225,7 @@ int main(int argc, char** argv)
if (arg == "--diag") diag = true;
else if(arg=="--legacy-motion")legacyMotion=true;
else if (arg == "--native") native = true;
+ else if (arg == "--sr-mode") srMode = std::atoi(value().c_str());
else if (arg == "--frames") maxFrames = std::atoi(value().c_str());
else if (arg == "--dump") dumpPath = value();
else if (arg == "--corpus") corpusManifest = value();
@@ -280,7 +284,18 @@ int main(int argc, char** argv)
ddesc.commandSlotCount = 4;
if(diag){ComPtr<ID3D12Debug> debug;ComPtr<ID3D12Debug1> gbv;
if(FAILED(D3D12GetDebugInterface(IID_PPV_ARGS(&debug)))||FAILED(debug.As(&gbv)))return 1;
- debug->EnableDebugLayer();gbv->SetEnableGPUBasedValidation(TRUE);ddesc.enableDebugLayer=true;}
+ debug->EnableDebugLayer();
+ // GPU-based validation does not complete the FidelityFX upscale dispatch:
+ // the standalone probe (tools/fsr_upscale_probe --diag, minimal verified
+ // states) stalls before its dispatch line, so this is a validation-layer
+ // interaction, not a state bug in the graph. Keep the debug layer for the
+ // FSR SR configuration and say so instead of hanging the run.
+ if(srMode==int(veyra::engine::kVideoSrFsr)){
+ veyra::log::warn("quality-probe","GPU-based validation skipped for the AMD FSR SR configuration (validation layer does not complete the FidelityFX upscale dispatch); debug layer stays on");
+ }else{
+ gbv->SetEnableGPUBasedValidation(TRUE);
+ }
+ ddesc.enableDebugLayer=true;}
Status st = Status::Ok;
if (!ctx.initialize(ddesc, st)) { noteFail("device init failed"); return 1; }
veyra::gfx::CommandSlotRing ring;
@@ -337,7 +352,8 @@ int main(int argc, char** argv)
gd.sourceWidth = srcW;
gd.sourceHeight = srcH;
gd.workWidth = native ? srcW : 3840; gd.workHeight = native ? srcH : 2160;
- gd.enableSr = nrOn && (srcW != gd.workWidth || srcH != gd.workHeight);
+ gd.enableSr = nrOn && (srcW != gd.workWidth || srcH != gd.workHeight) && srMode >= 0;
+ if (srMode > 0) gd.videoSrQuality = uint32_t(srMode);
actualWorkW = gd.workWidth; actualWorkH = gd.workHeight;
gd.enableNr = nrOn;
gd.enableFg = false;