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(xess): Edge Aegis switch and refined motion on AMD optical flow

Veyra Goal Agente46bbdf08569
diff --git a/AGENTS.md b/AGENTS.md
index bfc90be2..f93ff84e 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,5 +1,7 @@
# Veyra 项目 Agent 执行规则
+> **2026-10-12 边缘神盾开关与 AMD 光流(Claude,同一分支续做)**:用户问精修是否只对 NV 光流生效,要求“如果不可能就把AMD光流也加上这个优化,并且把这个设置成一个独立的开关,在选择补帧光流的下面,你给取一个屌炸天的名字”。开关「边缘神盾」(`EnhancementSettings::fgMotionRefine`,桥接 `edgeAegis`,默认开)放在列表/节点页“光流算法”下面,作为全局控件存进界面偏好 `edgeAegis`(不改会话/预设格式),只在 XeSS+运动来源“光流”时生效并重建图。AMD FidelityFX 光流接入同一精修,无后向光流时用新 `FlowClaim.hlsl` 认领检查判定露出背景;NVIDIA 路径逐位不变。合成测试 AMD XeSS 轮廓带误差 −4%~−29%,成本约 +0.6 ms;AMD 实卡未验。无 merge/push/Release、无子 Agent;详见 docs/XESS_FLOW_REVIEW_2026-10-12.md 第 9 节。
+
> **2026-10-12 XeSS 光流修复复审(Claude)**:用户“codex完成了后续的修复工作,但实际效果一般,你可以审一下,看看还有没有可以优化的地方,有没有可能是默认光流是1080p的问题?当然codex还在处理其他的任务,你不要打断他,你们不要互相影响到”。只读 Codex 分支/构建/回执;存档 `checkpoint/pre-claude-xess-tune-20261012`(f0fafdf)与 E 盘 `archives/claude-xess-tune-20261012`,分支 `claude/xess-flow-tune-20261012`,产物统一 `{用途}/claude-xess-tune-20261012`。屏幕/GUI/GPU 计时前检查无其他 Veyra 进程,Codex 测试期间等待。结论:Codex 接线无缺陷;1080p 默认光流不是原因(全分辨率几乎无改善且更贵);新增 NVOF 后向光流的前后向一致性只用于判定/填补人物移开露出的背景(候选选择保持 Codex 版),仅 XeSS+光流+NVIDIA NVOF,NR/SR 光流逐字节不变;`VEYRA_TEST_FLOW_CONSISTENCY=0` 恢复 Codex 版。一致性参与选择的负收益方案已撤回。四肢与栏杆残差未解决。不改自动模式/其他补帧/运行库/模型/用户配置;无 merge/push/Release、无子 Agent。详见 docs/XESS_FLOW_REVIEW_2026-10-12.md。
> **2026-10-12 Claude 计划漏项补齐**:用户追问 FSR bug 和 Claude 其他工作完成情况。重新核对其最后获准的 JELLY_FIX_PLAN,FSR 单独开启补帧时初始化光流本来在接手范围内,初次接手排除它是 Agent 漏项。保留 f468dfb 和初次验收存档,在同一本地隔离分支按 docs/FSR_FLOW_FOLLOWUP_2026-10-12.md 补齐 FSR 光流消费者条件及真实 GPU/GUI 回归;不把 XeSS 精修扩到 FSR,不改自动选择规则、其他算法/UI节奏/默认优先级/运行组件/真实配置。新产物 E:/项目/Veyra/{用途}/fsr-flow-followup-20261012,初次所有回执和旧树基线保持。无子Agent、main合并、push、发布、关机。已证旧代码 NR/SR/standalone 全关时NVOF=0且合同失败,修复后显式光流/Automatic各9次、Zero0次,八组回归、真实FSR GUI及双入口通过;同时补齐密集竖条横移11/11中间帧A/B,无本组负收益。代码/本机回归完成,真实游戏观感待用户,栏杆模型问题/延迟仍暂缓。
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 15112217..d225c2c5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -299,6 +299,7 @@ veyra_add_compute_shader(veyra_shader_nr_hold NrHold)
veyra_add_compute_shader(veyra_shader_flow_adapt FlowAdapt)
veyra_add_compute_shader(veyra_shader_flow_refine FlowRefine)
veyra_add_compute_shader(veyra_shader_flow_fill FlowFill)
+veyra_add_compute_shader(veyra_shader_flow_claim FlowClaim)
# VfgShotChange: per-pair shot-change test for VFG (replaces the SDK's automatic one).
veyra_add_compute_shader(veyra_shader_vfg_shot_change VfgShotChange)
veyra_add_compute_shader(veyra_shader_rgb_nv12 RgbToNv12)
@@ -558,7 +559,7 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avform
# veyra_sources: product input sources (Playbook R3/R7). MediaFileSource
# composes veyra_media; no second decode implementation exists.
- add_dependencies(veyra_pipeline veyra_shader_nr_downsample veyra_shader_nr_residual veyra_shader_nr_temporal veyra_shader_nr_hold veyra_shader_flow_adapt veyra_shader_flow_refine veyra_shader_flow_fill veyra_shader_vfg_shot_change)
+ add_dependencies(veyra_pipeline veyra_shader_nr_downsample veyra_shader_nr_residual veyra_shader_nr_temporal veyra_shader_nr_hold veyra_shader_flow_adapt veyra_shader_flow_refine veyra_shader_flow_fill veyra_shader_flow_claim veyra_shader_vfg_shot_change)
add_library(veyra_sources STATIC
src/source/NativeCaptureSink.cpp
src/source/MediaFileSource.cpp
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index fee94336..9122a274 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -9221,3 +9221,14 @@ audit.py核对测试/GUI/所有app原件、两份旧final、旧JSON和源码bund
结果(XeSS 抓屏 11/11 帧、采集/D3D12 0 错误,Codex 版数字本构建逐位复现):run27 6.3781→6.4016(+0.37%),run80 7.4180→7.3042(−1.53%),orbit80 3.0332→2.5901(−14.61%,距理想 2.0984 的差距缩小 47%),bars27 9.7037→9.6196(−0.87%);侧跑场景 >32 级像素比例略增(7.96→8.88、9.01→9.63)。无窗口运动:露出区 run80 38.5→6.6、orbit80 41.9→7.5。成本:4K 无窗口光流阶段 1.52→2.27 ms;真实 GUI(GTA VI 4K30、原版 NR 1080p、XeSS 2X、class2、帧 300–840 共 541 帧)光流阶段 1.53→2.26 ms,整图 9.52→9.19 ms 属波动不声称提速,提交 60/60。回归:Codex 合同测试 160/0、debug 0;GUI 生命周期(Codex ProbeXess 原样复制)52.6s 通过,三种运动路径与 NVOF 双向仅在 XeSS 分支。
本地测试版 tests/claude-xess-tune-20261012/delivery(Codex 测试包复制、去测试 EXE、换本版 EXE 与两个着色器;New/Codex/Original 三入口共用一份设置)。全部数字与来源见 reports/claude-xess-tune-20261012/results.json,报告 docs/XESS_FLOW_REVIEW_2026-10-12.md。四肢、栏杆残差,真实游戏观感、AMD/Intel、长期显存、屏幕延迟未验;无 merge/push/Release/子 Agent/关机。
+
+## 2026-10-12 边缘神盾开关与 AMD 光流(Claude)
+
+用户追问精修是否只对 NV 光流生效,要求给 AMD 光流也加上,做成独立开关放在补帧光流选择下面并起名。答:此前精修与前后向检查都只限 NVIDIA NVOF。同一分支 claude/xess-flow-tune-20261012 续做;Codex 期间运行 pro-video-geometry 等 GUI 测试,抓屏/GUI/GPU 计时脚本启动前检查其他 Veyra 进程,多次等待其结束。
+
+实现:EnhancementSettings::fgMotionRefine(默认开,非 XeSS 光流运动时视为非活动)→ GraphDescription → EnhanceGraphDesc;requiresGraphRebuild 与图的实时设置检查在其变化时重建。桥接 edgeAegis 存界面偏好(同 NR 抗闪烁/音频同步,启动时会话后恢复),会话/预设格式不变。列表页“光流 · 运动估算”与节点“输入 · 光流”卡在光流算法下加开关「边缘神盾」;catalog 只追加 4 条译文(本分支 catalog 与全量 extract.py 本就不同步,未全量重提取)。图:FlowRefine 增加 FidelityFX 向量(网格8、整像素、预热/场景切换零运动);新 FlowClaim.hlsl(清零/认领/结算,InterlockedMax 按代价认领上一帧位置,与胜者向量差进 FlowFill,阈值同 NVIDIA);CMake 登记。测试:EffectChainTests 加开关活动性/重建断言;运动质量与 XeSS 抓屏测试加 AMD 后端(多跑帧避开预热),运动质量测试 perf 模式支持 AMD。构建 build-20261012-160356(42 对象、全部 EXE)与 161421(测试)。
+
+结果:NVIDIA 运动误差与改动前逐位相同。AMD 无窗口露出区 EPE run80 71.7→67.3→19.7、run27 35.4→41.0→23.8、orbit80 68.0→63.3→17.4(修复前→只精修→精修+认领),密集竖条 FidelityFX 自身场景切换判定三路均零运动(原有行为)。AMD XeSS 抓屏轮廓带 MAE8:run27 7.5361→7.6048→7.2088,run80 8.2161→7.8578→7.2462,orbit80 3.8166→3.2447→2.6991,均 11/11 帧、采集/D3D12 0 错误。4K 无窗口光流阶段:AMD 0.41→0.91→1.01 ms,NVIDIA 1.03→1.58→2.29 ms。回归:效果链、预设库、Codex 合同 160/0、界面合同、修复合同 259/0、HDR 颜色、非活动效果 9/0、真实视频设置重建全部通过。GUI(gui_aegis.py,GTA VI 4K30):默认开→NVOF 前后向、关→校验光流、AMD+开→FidelityFX 认领、重启保持关、再开写回偏好,截图 reports/claude-xess-tune-20261012/edge-aegis-ui.png;首两次运行因夹具期望序列未计入中间重建及截图前未切到补帧页而判失败,修夹具后通过,失败记录保留。
+
+测试版 tests/claude-xess-tune-20261012/delivery 更新为新 EXE/着色器/两个 QML 页,入口改为 New/Codex 两个(关开关即修复前)。AMD 实卡、真实游戏观感未验;无 merge/push/Release/子 Agent。
+
diff --git a/docs/XESS_FLOW_REVIEW_2026-10-12.md b/docs/XESS_FLOW_REVIEW_2026-10-12.md
index a258a203..14a0a56e 100644
--- a/docs/XESS_FLOW_REVIEW_2026-10-12.md
+++ b/docs/XESS_FLOW_REVIEW_2026-10-12.md
@@ -148,10 +148,10 @@
## 7. 本地测试版
位置:`E:/项目/Veyra/tests/claude-xess-tune-20261012/delivery`。
-- 同一个 EXE、同一份设置(XeSS 2X、运动来源光流、NVIDIA 光流、原版 NR 1080p),三个入口:
+- 同一个 EXE、同一份设置(XeSS 2X、运动来源光流、NVIDIA 光流、原版 NR 1080p),两个入口:
- `Start-XeSS-New.cmd`:本版;
- - `Start-XeSS-Codex.cmd`:Codex 版;
- - `Start-XeSS-Original.cmd`:修复前。
+ - `Start-XeSS-Codex.cmd`:Codex 版。
+- “修复前”改由软件内「边缘神盾」开关关闭得到(第 9 节)。最初的第三个入口 `Start-XeSS-Original.cmd` 已移除。
- 日志:`logs/claude-xess-tune-20261012/manual/`。
- 程序 SHA256、着色器哈希、全部数字及来源文件见 `reports/claude-xess-tune-20261012/results.json`。
@@ -161,3 +161,87 @@
- **四肢**:需要更强的光流,例如能处理旋转或周期纹理,本轮未做。
- **栏杆**:属于光流混叠和 XeSS 模型问题,按用户要求不处理。
- 本机只有 RTX 5070。AMD、Intel 显卡、长期显存、屏幕端到端延迟都未验证。
+
+## 9. 追加:「边缘神盾」开关与 AMD 光流(同日)
+
+用户:“这个修复是只在NV光流上生效吗,还是AMD光流也可以用?如果不可能就把AMD光流也加上这个优化,并且把这个设置成一个独立的开关,在选择补帧光流的下面,你给取一个屌炸天的名字”。
+
+**回答**:此前 Codex 的精修和本版的前后向检查都只在 NVIDIA NVOF 上生效;AMD 光流和 GPU DIS 仍走原光流。
+
+### 开关「边缘神盾」(Edge Aegis)
+
+- **位置**:
+ - 列表模式:补帧页 →「光流 · 运动估算」→「光流算法」下面一行;
+ - 节点模式:「输入 · 光流」卡,光流算法下面。
+- **行为**:
+ - 默认开启;关闭即修复前的光流;
+ - 只在 XeSS 补帧、运动来源“光流”时起作用,此时切换会重建处理图。其他组合不受影响,也不会因为它重建(`activeVideoSettings` 把它视为非活动设置)。
+- **保存方式**:与 NR 抗闪烁、音频同步一样,作为全局控件存进界面偏好 `qml-preferences.v1.json` 的 `edgeAegis`,启动时在会话之后恢复。会话和预设文件格式都不改,旧版本读取不受影响。
+- **代码链路**:`EnhancementSettings::fgMotionRefine` → `GraphDescription` → `EnhanceGraphDesc::fgMotionRefine`,以及桥接属性 `edgeAegis`。
+- **翻译**:繁中、英、日。只追加本次 4 条;本分支的 catalog 与全量提取本来就不同步,所以没有运行 `extract.py`。
+
+### AMD(FidelityFX)光流
+
+**FlowRefine 读取 FidelityFX 向量**
+- 网格 8,整像素;
+- 与 NvofDensify 同样处理:预热帧和场景切换历史期间输出零运动。
+
+**露出区检测:新增 `FlowClaim.hlsl`**
+
+FidelityFX 只算单向,没有后向光流。改用“认领”检查,每帧三次派发:
+- **清零**;
+- **认领**:每个光流像素认领它落到的上一帧位置。按颜色代价排序,用 `InterlockedMax`,代价最低者得;
+- **结算**:记录每个像素的向量与认领胜者向量的差,供 FlowFill 使用,与 NVIDIA 的前后向差同一阈值(>2 填补,≤0.5 可借出)。
+
+原理:新露出的背景无论带哪个向量,落点都被别的像素以更好的匹配占着:
+- 落在人物上,人物还在原地,与自己完全匹配;
+- 落在移走的背景上,被现在显示那块背景的像素认领。
+
+这两种情况下它的向量都与胜者不同。同向的像素(取整、缩放)差为 0,不受影响。
+
+**其他**:测试开关 `VEYRA_TEST_FLOW_CONSISTENCY=0` 同样关掉 AMD 的认领检查。
+
+### 结果
+
+**NVIDIA 路径不变**:无窗口运动误差与改动前逐位相同(run80:总 2.07、露出区 6.61)。
+
+**AMD 无窗口运动误差**(露出背景 EPE;修复前 → 只精修 → 精修+认领):
+
+| 场景 | 修复前 | 只精修 | 精修+认领 |
+| --- | ---: | ---: | ---: |
+| run80 | 71.7 | 67.3 | 19.7 |
+| run27 | 35.4 | 41.0 | 23.8 |
+| orbit80 | 68.0 | 63.3 | 17.4 |
+
+密集竖条:FidelityFX 自带的场景切换判断在该图案上一直触发,三条路径都是零运动。这是原有行为,未改。
+
+**AMD XeSS 实际插值帧**(轮廓带 MAE8;AMD 跑 22 帧,前 10 帧预热不计分,每项 11/11 帧,采集与 D3D12 错误 0):
+
+| 场景 | 修复前 | 只精修 | 精修+认领 | 相对修复前 |
+| --- | ---: | ---: | ---: | ---: |
+| 侧跑 27 | 7.5361 | 7.6048 | 7.2088 | −4.3% |
+| 侧跑 80 | 8.2161 | 7.8578 | 7.2462 | −11.8% |
+| 背景横移 80 | 3.8166 | 3.2447 | 2.6991 | −29.3% |
+
+误差 >32 级的像素比例也同步下降:9.89% → 9.02%,2.99% → 2.38%。
+
+**成本**(无窗口 4K,1080p 光流,RTX 5070,152 帧中位数):
+- AMD:光流阶段 0.41 → 0.91(只精修)→ 1.01 ms(加认领);
+- NVIDIA:1.03 → 1.58 → 2.29 ms。
+
+AMD 的认领检查只多约 0.1 ms,NVIDIA 的后向光流约多 0.7 ms。
+
+**回归**:
+- 效果链测试:新增“只在 XeSS+光流时生效、切换重建、自动模式不重建”;
+- 预设库、Codex 合同测试 160/0、界面合同(384 布局用例)、修复合同 259/0、HDR 颜色、非活动效果编辑 9/0、真实视频设置重建:全部通过。
+
+**GUI 实测**(GTA VI 4K30,XeSS 2X):
+- 默认开 → NVOF 前后向;
+- 关 → 校验光流;
+- AMD 光流 + 开 → FidelityFX 认领;
+- 回 NVIDIA 开 → 关;
+- 重启后保持“关”,再打开写回偏好;
+- 截图见 `reports/claude-xess-tune-20261012/edge-aegis-ui.png`。
+
+**限制**:AMD 路径在本机 RTX 5070 上运行 FidelityFX 光流,未在 AMD 显卡上验证。认领检查弱于 NVIDIA 的真实后向光流:run80 露出区剩 19.7,NVIDIA 为 6.6。
+
diff --git a/i18n/catalog.json b/i18n/catalog.json
index 60ca10cd..f9bb8684 100644
--- a/i18n/catalog.json
+++ b/i18n/catalog.json
@@ -15275,6 +15275,34 @@
"zh-TW": "VFG 中間影格約 %1 ms、其餘每張約 %2 ms,目前負載約可穩定 %3X",
"en": "VFG takes about %1 ms for the middle frame and %2 ms for each other frame; about %3X holds at the current load",
"ja": "VFG は中央の 1 枚が約 %1 ms、その他は 1 枚あたり約 %2 ms、現在の負荷で安定するのは約 %3X"
+ },
+ {
+ "zh": "边缘神盾",
+ "src": "qml/ProPage.qml",
+ "zh-TW": "邊緣神盾",
+ "en": "Edge Aegis",
+ "ja": "エッジイージス"
+ },
+ {
+ "zh": "XeSS 补帧、运动来源选“光流”时生效:修人物边缘果冻,背景不再被人物拖着晃",
+ "src": "qml/ProPage.qml",
+ "zh-TW": "XeSS 補幀、運動來源選「光流」時生效:修人物邊緣果凍,背景不再被人物拖著晃",
+ "en": "For XeSS frame generation with the optical-flow motion source: stops the jelly at character edges, so the background no longer drags along",
+ "ja": "XeSS フレーム生成で動きの推定を「オプティカルフロー」にしたときに有効:人物の輪郭のゼリー状の揺れを抑え、背景が人物に引きずられなくなります"
+ },
+ {
+ "zh": "边缘神盾(XeSS 防果冻)",
+ "src": "qml/NodePage.qml",
+ "zh-TW": "邊緣神盾(XeSS 防果凍)",
+ "en": "Edge Aegis (XeSS anti-jelly)",
+ "ja": "エッジイージス(XeSS ゼリー対策)"
+ },
+ {
+ "zh": "引擎未接受边缘神盾,原设置保留",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "引擎未接受邊緣神盾,原設定保留",
+ "en": "The engine did not accept Edge Aegis; previous setting kept",
+ "ja": "エンジンがエッジイージスを受け付けなかったため、元の設定のままです"
}
]
}
diff --git a/include/veyra/engine/EnhancementSettings.h b/include/veyra/engine/EnhancementSettings.h
index 323db12e..0d72ab72 100644
--- a/include/veyra/engine/EnhancementSettings.h
+++ b/include/veyra/engine/EnhancementSettings.h
@@ -347,6 +347,9 @@ struct EnhancementSettings {
FlowQuality flow=FlowQuality::Balanced;
OpticalFlowBackend opticalFlowBackend=OpticalFlowBackend::Nvidia;
bool amdFlowHalfResolution=false;
+ // UI "边缘神盾": refined optical-flow motion for XeSS frame generation (edge refinement
+ // and the uncovered-background fill). A global control kept in shell preferences.
+ bool fgMotionRefine=true;
ContentRate content=ContentRate::Transport;
AudioSyncMode audioSync=AudioSyncMode::Automatic;
int32_t audioOffsetMs=0;
@@ -398,6 +401,9 @@ struct EnhancementSettings {
(sr&&(videoSrQuality==0||videoSrQuality==kVideoSrFsr)&&motionUsesFlow(srMotion))||
(multiplier>1&&motionUsesFlow(fgMotion,frameGenerationBackend));
if(!flowUsed){active.flow=defaults.flow;active.opticalFlowBackend=defaults.opticalFlowBackend;active.amdFlowHalfResolution=defaults.amdFlowHalfResolution;}
+ // Only XeSS frame generation with optical-flow motion reads the refined vectors.
+ if(!(multiplier>1&&frameGenerationBackend==FrameGenerationBackend::XeSS&&motionUsesFlow(fgMotion,frameGenerationBackend)))
+ active.fgMotionRefine=defaults.fgMotionRefine;
return active;
}
bool sameActiveVideoParameters(const EnhancementSettings& other) const {
diff --git a/include/veyra/engine/GraphDescription.h b/include/veyra/engine/GraphDescription.h
index ea09f54b..f7a07f11 100644
--- a/include/veyra/engine/GraphDescription.h
+++ b/include/veyra/engine/GraphDescription.h
@@ -125,7 +125,7 @@ inline pipeline::ResolutionPlan describeStages(const StageRequest& request,const
desc.flowQuality=settings.flow;
desc.contentRate=settings.content;
desc.opticalFlowBackend=settings.opticalFlowBackend;
- desc.amdFlowHalfResolution=settings.amdFlowHalfResolution;
+ desc.amdFlowHalfResolution=settings.amdFlowHalfResolution;desc.fgMotionRefine=settings.fgMotionRefine;
desc.nrLayersExtent.clear();
for(uint32_t i=0;i<chain.nodeCount;++i){
auto& node=chain.nodes[i];
diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.h
index 41416050..e2c50ee0 100644
--- a/include/veyra/pipeline/EnhanceGraph.h
+++ b/include/veyra/pipeline/EnhanceGraph.h
@@ -131,6 +131,9 @@ struct EnhanceGraphDesc {
engine::FlowQuality flowQuality=engine::FlowQuality::Balanced;
engine::OpticalFlowBackend opticalFlowBackend=engine::OpticalFlowBackend::Nvidia;
bool amdFlowHalfResolution=false;
+ // XeSS motion refinement with the optical-flow source (UI "边缘神盾"): FlowRefine/
+ // FlowFill plus NVOF forward-backward or FidelityFX FlowClaim. Off: validated flow.
+ bool fgMotionRefine=true;
engine::ContentRate contentRate=engine::ContentRate::Transport;
engine::NrSettings model;
engine::ResidualSettings residual;
@@ -704,9 +707,10 @@ private:
uint32_t nrLayerCount_=1;
ComPtr<ID3D12Resource> presentMotion_[2];
bool presentMotionValid_[2]={};
- // XeSS present-path motion with the optical-flow source: per-pixel refined NVOF
- // vectors with disocclusion fill (FlowRefine/FlowFill), never zeroed. NR/SR keep
- // the validated baseFlow_. VEYRA_TEST_FLOW_REFINE=0 restores the previous input.
+ // XeSS present-path motion with the optical-flow source: per-pixel refined NVOF or
+ // FidelityFX vectors with disocclusion fill (FlowRefine/FlowFill), never zeroed. NR/SR
+ // keep the validated baseFlow_. desc.fgMotionRefine=false (or VEYRA_TEST_FLOW_REFINE=0)
+ // restores the previous input.
bool flowRefine_=false;
ComPtr<ID3D12Resource> fgFlowRefined_,fgFlowFilled_,fgBaseFlow_;
// NVOF backward output (previous->current) for the refinement's forward-backward check
@@ -714,6 +718,10 @@ private:
// NVOF forward-only (photometric refinement). NR/SR never read it.
bool flowConsistency_=false;
ComPtr<ID3D12Resource> nvofReverseTex_,nvofReverseCostTex_;
+ // FidelityFX flow has no backward output: FlowClaim's previous-frame claims stand in
+ // for the forward-backward check (same VEYRA_TEST_FLOW_CONSISTENCY switch).
+ bool flowClaims_=false;
+ ComPtr<ID3D12Resource> fgFlowClaims_,fgFlowAgreement_;
uint64_t motionPreviousSource_[2]={},previousSource_=0;
ComPtr<ID3D12Resource> proxyTex_;
ComPtr<ID3D12Resource> neuralTex_;
@@ -739,7 +747,7 @@ private:
float toneMapPeakNits_=0; // latched per graph/source; never varies with frame brightness
ComputePass rgbPass_,hdrVideoSrPass_;
ComputePass downsamplePass_,residualPass_,stackProtectionPass_,flowAdaptPass_;
- ComputePass flowRefinePass_,flowFillPass_,fgFlowAdaptPass_;
+ ComputePass flowRefinePass_,flowFillPass_,fgFlowAdaptPass_,flowClaimPass_;
// Stage-5 output stabiliser (anti-flicker). Constructed only when the
// setting is non-zero; a default (0) session never allocates it and the
// dispatch is skipped, so the disabled path is unchanged.
diff --git a/include/veyra/ui/QmlPlayerBridge.h b/include/veyra/ui/QmlPlayerBridge.h
index 86e95ac8..fc5ded1d 100644
--- a/include/veyra/ui/QmlPlayerBridge.h
+++ b/include/veyra/ui/QmlPlayerBridge.h
@@ -322,6 +322,8 @@ class QmlPlayerBridge : public QObject {
// AMD half-resolution flow, content cadence (engine::ContentRate order).
Q_PROPERTY(int flowQuality READ flowQuality WRITE setFlowQuality NOTIFY settingsChanged)
Q_PROPERTY(bool amdFlowHalf READ amdFlowHalf WRITE setAmdFlowHalf NOTIFY settingsChanged)
+ // 边缘神盾: refined optical-flow motion for XeSS (EnhancementSettings::fgMotionRefine).
+ Q_PROPERTY(bool edgeAegis READ edgeAegis WRITE setEdgeAegis NOTIFY settingsChanged)
Q_PROPERTY(int contentRate READ contentRate WRITE setContentRate NOTIFY settingsChanged)
Q_PROPERTY(int hdrOutputMode READ hdrOutputMode WRITE setHdrOutputMode NOTIFY settingsChanged)
Q_PROPERTY(int fgMotionSource READ fgMotionSource WRITE setFgMotionSource NOTIFY settingsChanged)
@@ -837,6 +839,8 @@ public:
void setFlowQuality(int value);
bool amdFlowHalf() const;
void setAmdFlowHalf(bool value);
+ bool edgeAegis() const;
+ void setEdgeAegis(bool value);
int contentRate() const;
void setContentRate(int value);
int displaySync() const;
diff --git a/qml/Veyra/NodePage.qml b/qml/Veyra/NodePage.qml
index e32aefc6..9db73aaf 100644
--- a/qml/Veyra/NodePage.qml
+++ b/qml/Veyra/NodePage.qml
@@ -656,6 +656,11 @@ VPage {
value: options[veyra.opticalFlowChoice]?.label ?? (veyra.opticalFlowChoice === 2 ? qsTr("GPU DIS 已移除,请重选") : qsTr("未知配置"))
onPicked: id => veyra.setOpticalFlowChoice(Number(id))
}
+ RowLayout {
+ Layout.fillWidth: true
+ NodeLabel { Layout.fillWidth: true; text: qsTr("边缘神盾(XeSS 防果冻)") }
+ VSwitch { objectName: "node-edge-aegis"; checked: veyra.edgeAegis; onToggled: checked => veyra.edgeAegis = checked }
+ }
NodeLabel { text: qsTr("运动估算质量") }
VSeg {
objectName: "node-flow-quality"
diff --git a/qml/Veyra/ProPage.qml b/qml/Veyra/ProPage.qml
index 7a342dce..ca18a94f 100644
--- a/qml/Veyra/ProPage.qml
+++ b/qml/Veyra/ProPage.qml
@@ -1752,7 +1752,7 @@ VPage {
Layout.fillWidth: true
Layout.topMargin: 6
label: qsTr("光流 · 运动估算")
- count: veyra.opticalFlowChoice === 1 ? 4 : 3
+ count: veyra.opticalFlowChoice === 1 ? 5 : 4
expanded: true
VRow {
label: qsTr("光流算法")
@@ -1764,6 +1764,15 @@ VPage {
onPicked: id => veyra.setOpticalFlowChoice(Number(id))
}
}
+ VRow {
+ label: qsTr("边缘神盾")
+ hint: qsTr("XeSS 补帧、运动来源选“光流”时生效:修人物边缘果冻,背景不再被人物拖着晃")
+ VSwitch {
+ objectName: "list-edge-aegis"
+ checked: veyra.edgeAegis
+ onToggled: checked => veyra.edgeAegis = checked
+ }
+ }
VRow {
label: qsTr("AMD 性能档")
hint: qsTr("光流宽高减半,更省但更糙")
diff --git a/shaders/FlowClaim.hlsl b/shaders/FlowClaim.hlsl
new file mode 100644
index 00000000..b693ec94
--- /dev/null
+++ b/shaders/FlowClaim.hlsl
@@ -0,0 +1,51 @@
+// Disocclusion test for frame-generation motion without backward flow (FidelityFX optical
+// flow estimates one direction only). Every flow pixel claims the previous-frame pixel its
+// refined vector lands on, and the best photometric match keeps the claim. Background a
+// moving object has just uncovered lands either on the object, which is still there and
+// matches itself exactly, or on background that moved on and is claimed by the pixel now
+// showing it - with a different vector either way. The disagreement with the winner's
+// vector then stands in for NVOF's forward-backward check in FlowFill. Pixels sharing a
+// target with the same motion (rounding, zoom) disagree by nothing.
+// Three dispatches per frame: clear, claim, resolve.
+Texture2D<float4> refined : register(t0); // xy vector, z cost (FlowRefine)
+RWTexture2D<uint> claims : register(u0); // flow extent: inverted cost << indexBits | pixel index
+RWTexture2D<float> agreement : register(u1); // flow extent: disagreement with the winner, flow pixels
+
+cbuffer FlowClaimConstants : register(b0)
+{
+ uint flowW;
+ uint flowH;
+ uint mode; // 0 clear, 1 claim, 2 resolve
+ uint indexBits; // bits holding the claiming pixel's index; the rest rank its cost
+ uint unused0;
+ uint unused1;
+ uint unused2;
+ uint unused3;
+};
+
+[numthreads(16, 16, 1)]
+void main(uint3 id : SV_DispatchThreadID)
+{
+ if (id.x >= flowW || id.y >= flowH) return;
+ const int2 p = int2(id.xy);
+ if (mode == 0) { claims[p] = 0; return; }
+ const float4 r = refined[p];
+ const int2 t = p + int2(round(r.xy));
+ const bool inside = all(t >= 0) && t.x < int(flowW) && t.y < int(flowH);
+ if (mode == 1) {
+ if (!inside) return;
+ const uint rankMax = (1u << (32u - indexBits)) - 1u;
+ // Lower cost ranks higher; costs above 0.25 all rank last.
+ const uint rank = rankMax - uint(saturate(r.z * 4.0) * float(rankMax));
+ uint previous;
+ InterlockedMax(claims[t], (rank << indexBits) | (uint(p.y) * flowW + uint(p.x)), previous);
+ return;
+ }
+ // Outside the previous frame there is nothing to compare: keep the vector.
+ float disagreement = 0;
+ if (inside) {
+ const uint index = claims[t] & ((1u << indexBits) - 1u);
+ disagreement = length(r.xy - refined[int2(index % flowW, index / flowW)].xy);
+ }
+ agreement[p] = disagreement;
+}
diff --git a/shaders/FlowFill.hlsl b/shaders/FlowFill.hlsl
index 1f7eb244..f1271993 100644
--- a/shaders/FlowFill.hlsl
+++ b/shaders/FlowFill.hlsl
@@ -8,8 +8,10 @@
// correspondence either. Only pixels that pass it clearly lend their vector: next to an
// object NVOF's backward vectors lean towards the object too, so a few uncovered pixels
// pass narrowly and must not spread the object's vector over the background beside them.
+// FidelityFX flow brings the same disagreement from FlowClaim instead.
Texture2D<float4> refined : register(t0); // xy vector, z cost, w disagreement (FlowRefine)
Texture2D<float4> currentColor : register(t1); // flow extent
+Texture2D<float> claimed : register(t2); // FlowClaim disagreement (FidelityFX flow)
RWTexture2D<float2> output : register(u0); // flow extent, current->previous pixels
cbuffer FlowFillConstants : register(b0)
@@ -20,15 +22,16 @@ cbuffer FlowFillConstants : register(b0)
float distanceWeight; // colour distance added per pixel of search distance
float consistencyThreshold; // disagreement above this (flow pixels) has none; 0 = unused
float sourceThreshold; // disagreement up to this lends its vector
- uint unused2;
+ uint fromClaims; // 1: disagreement from FlowClaim, else FlowRefine's w
uint unused3;
};
static const int2 kDirections[8] = { int2(1, 0), int2(-1, 0), int2(0, 1), int2(0, -1), int2(1, 1), int2(-1, 1), int2(1, -1), int2(-1, -1) };
static const int kRadii[9] = { 2, 4, 8, 12, 16, 24, 32, 48, 64 };
-bool confident(float4 r) { return r.z <= threshold && (consistencyThreshold <= 0 || r.w <= sourceThreshold); }
-bool filled(float4 r) { return r.z > threshold || (consistencyThreshold > 0 && r.w > consistencyThreshold); }
+float disagreement(int2 q, float4 r) { return fromClaims != 0 ? claimed[q] : r.w; }
+bool confident(int2 q, float4 r) { return r.z <= threshold && (consistencyThreshold <= 0 || disagreement(q, r) <= sourceThreshold); }
+bool filled(int2 q, float4 r) { return r.z > threshold || (consistencyThreshold > 0 && disagreement(q, r) > consistencyThreshold); }
[numthreads(16, 16, 1)]
void main(uint3 id : SV_DispatchThreadID)
@@ -36,7 +39,7 @@ void main(uint3 id : SV_DispatchThreadID)
if (id.x >= flowW || id.y >= flowH) return;
const int2 p = int2(id.xy);
const float4 own = refined[p];
- if (!filled(own)) { output[p] = own.xy; return; }
+ if (!filled(p, own)) { output[p] = own.xy; return; }
const float3 colour = currentColor[p].rgb;
float bestScore = 1e9;
float2 vector = own.xy;
@@ -45,7 +48,7 @@ void main(uint3 id : SV_DispatchThreadID)
const int2 q = p + kDirections[d] * kRadii[r];
if (any(q < 0) || q.x >= int(flowW) || q.y >= int(flowH)) continue;
const float4 candidate = refined[q];
- if (!confident(candidate)) continue;
+ if (!confident(q, candidate)) continue;
const float3 delta = currentColor[q].rgb - colour;
const float score = dot(abs(delta), float3(1, 1, 1)) + distanceWeight * kRadii[r];
if (score < bestScore) { bestScore = score; vector = candidate.xy; }
diff --git a/shaders/FlowRefine.hlsl b/shaders/FlowRefine.hlsl
index b8c66ca0..92a07b90 100644
--- a/shaders/FlowRefine.hlsl
+++ b/shaders/FlowRefine.hlsl
@@ -1,6 +1,6 @@
// Frame-generation motion refinement (XeSS, motion source "optical flow").
-// NVOF returns one current->previous vector per grid cell, so a cell that straddles a
-// moving character and the background moves both with one vector. Per flow pixel, pick
+// Optical flow returns one current->previous vector per grid cell, so a cell that straddles
+// a moving character and the background moves both with one vector. Per flow pixel, pick
// the vector of the 3x3 neighbouring cells whose 3x3 luma patch matches the previous
// frame best: motion boundaries follow the picture instead of the grid. Unlike
// NvofDensify nothing is zeroed; the best cost is kept for FlowFill to find pixels that
@@ -11,10 +11,12 @@
// that covered it, the object's vector on background that moved on - even where a wrong
// vector matches the smooth background beside it photometrically. The choice itself stays
// photometric: on rotating limbs and repetitive texture the check is too noisy to rank by.
-Texture2D<int2> rawFlow : register(t0); // grid extent, S10.5 flow pixels
+// FidelityFX optical flow has no backward output; FlowClaim makes the same check for it.
+Texture2D<int2> rawFlow : register(t0); // grid extent: NVOF S10.5 or FidelityFX integer pixels
Texture2D<float4> previousColor : register(t1); // flow extent
Texture2D<float4> currentColor : register(t2); // flow extent
-Texture2D<int2> reverseFlow : register(t3); // grid extent, S10.5, previous->current
+Texture2D<int2> reverseFlow : register(t3); // grid extent, S10.5, previous->current (NVOF)
+Texture2D<uint> sceneChanges : register(t4); // FidelityFX scene-change history at (1,0)
RWTexture2D<float4> refined : register(u0); // xy vector, z best cost, w forward-backward disagreement
cbuffer FlowRefineConstants : register(b0)
@@ -25,7 +27,8 @@ cbuffer FlowRefineConstants : register(b0)
uint flowH;
uint gridSize;
float tieBias; // added to every neighbour cell's cost: the own cell wins ties
- uint backward; // 1: reverseFlow holds NVOF's backward output (else w = 0)
+ uint flags; // 1 reverseFlow holds NVOF's backward output (else w = 0); 2 FidelityFX
+ // vectors; 4 FidelityFX still warming up
uint unused0;
};
@@ -36,6 +39,11 @@ void main(uint3 id : SV_DispatchThreadID)
{
if (id.x >= flowW || id.y >= flowH) return;
const int2 p = int2(id.xy);
+ const bool fidelity = (flags & 2u) != 0;
+ // The frames NvofDensify zeroes for FidelityFX (warm-up and its four-frame cut history)
+ // carry no motion here either.
+ if ((flags & 4u) != 0 || (fidelity && (sceneChanges[uint2(1, 0)] & 15u) != 0)) { refined[p] = 0; return; }
+ const float scale = fidelity ? 1.0 : 1.0 / 32.0;
const int2 limit = int2(flowW - 1, flowH - 1);
float current[9];
[unroll] for (int j = 0; j < 9; ++j)
@@ -46,7 +54,7 @@ void main(uint3 id : SV_DispatchThreadID)
float2 best = 0;
[unroll] for (int k = 0; k < 9; ++k) {
const int2 offset = int2(k % 3 - 1, k / 3 - 1);
- const float2 v = float2(rawFlow[clamp(cell + offset, int2(0, 0), cellLimit)]) / 32.0;
+ const float2 v = float2(rawFlow[clamp(cell + offset, int2(0, 0), cellLimit)]) * scale;
const int2 q = p + int2(round(v));
float cost = 0;
[unroll] for (int j = 0; j < 9; ++j)
@@ -56,7 +64,7 @@ void main(uint3 id : SV_DispatchThreadID)
if (cost < bestCost) { bestCost = cost; best = v; }
}
float disagreement = 0;
- if (backward) {
+ if ((flags & 1u) != 0) {
const int2 back = clamp(int2(floor((float2(p) + .5 + best) / float(gridSize))), int2(0, 0), cellLimit);
disagreement = length(best + float2(reverseFlow[back]) / 32.0);
}
diff --git a/src/engine/EffectChain.cpp b/src/engine/EffectChain.cpp
index 7ae32c1d..a7e9b7d1 100644
--- a/src/engine/EffectChain.cpp
+++ b/src/engine/EffectChain.cpp
@@ -647,6 +647,7 @@ bool requiresGraphRebuild(const EnhancementSettings& savedPrevious, const Enhanc
if (previous.vfgQuality != next.vfgQuality) return true;
if (previous.opticalFlowBackend != next.opticalFlowBackend) return true;
if (previous.amdFlowHalfResolution != next.amdFlowHalfResolution) return true;
+ if (previous.fgMotionRefine != next.fgMotionRefine) return true;
if (previous.flow != next.flow) return true;
if (previous.captureCompatible != next.captureCompatible) return true;
if (previous.forceSdrPreview != next.forceSdrPreview) return true;
diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cpp
index 2484ec90..ca110148 100644
--- a/src/pipeline/EnhanceGraph.cpp
+++ b/src/pipeline/EnhanceGraph.cpp
@@ -457,10 +457,13 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)
if(desc_.opticalFlowBackend==engine::OpticalFlowBackend::AmdFidelityFx&&desc.amdFlowHalfResolution){nvofW_=std::max(1u,nvofW_/2);nvofH_=std::max(1u,nvofH_/2);}
wchar_t refine[4]{};
const bool refineDisabled=GetEnvironmentVariableW(L"VEYRA_TEST_FLOW_REFINE",refine,4)&&refine[0]==L'0';
- flowRefine_=presentSinkFg()&&desc_.fgUsesFlow()&&
- desc_.opticalFlowBackend==engine::OpticalFlowBackend::Nvidia&&!refineDisabled;
+ const bool nvidiaFlow=desc_.opticalFlowBackend==engine::OpticalFlowBackend::Nvidia,
+ fidelityFlow=desc_.opticalFlowBackend==engine::OpticalFlowBackend::AmdFidelityFx;
+ flowRefine_=presentSinkFg()&&desc_.fgUsesFlow()&&desc_.fgMotionRefine&&(nvidiaFlow||fidelityFlow)&&!refineDisabled;
wchar_t consistency[4]{};
- flowConsistency_=flowRefine_&&!(GetEnvironmentVariableW(L"VEYRA_TEST_FLOW_CONSISTENCY",consistency,4)&&consistency[0]==L'0');
+ const bool occlusionCheck=flowRefine_&&!(GetEnvironmentVariableW(L"VEYRA_TEST_FLOW_CONSISTENCY",consistency,4)&&consistency[0]==L'0');
+ flowConsistency_=occlusionCheck&&nvidiaFlow;
+ flowClaims_=occlusionCheck&&fidelityFlow;
uint64_t budget=0,usage=0;
// Every NR layer allocates its own full set of textures, and a stabilised
// layer adds two history/guide pairs on top. The stack is bounded (16 nodes),
@@ -487,7 +490,7 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)
const uint64_t estimate=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:12u)+uint64_t(workW_)*workH_*4u:0);
+ +(flowRefine_?uint64_t(nvofW_)*nvofH_*(flowConsistency_?13u:flowClaims_?18u:12u)+uint64_t(workW_)*workH_*4u:0);
if(context_.videoMemoryInfo(budget,usage)){
veyra::log::info("memory",std::format("graph lower-bound={}MiB budget={}MiB usage={}MiB; SDK allocations additional",estimate>>20,budget>>20,usage>>20));
if(usage>=budget||estimate>budget-usage){veyra::log::error("memory","insufficient adapter budget for requested graph textures");return false;}
@@ -609,15 +612,22 @@ bool EnhanceGraph::createResources()
baseFlow_=makeTexture(context_.device(),workW_,workH_,DXGI_FORMAT_R16G16_FLOAT,true);
if(presentSinkFg())for(auto& motion:presentMotion_){motion=makeTexture(context_.device(),workW_,workH_,DXGI_FORMAT_R16G16_FLOAT,false);if(!motion)return false;}
if(!residualRgba_||!nrFlow_||!baseFlow_)return false;
- // XeSS with the optical-flow source: refined NVOF vectors (FlowRefine/FlowFill).
- // NVOF only - the refinement reads NVOF's grid vectors.
+ // XeSS with the optical-flow source: refined NVOF or FidelityFX vectors (FlowRefine/
+ // FlowFill) - the refinement reads their grid vectors.
if(flowRefine_){
fgFlowRefined_=makeTexture(context_.device(),nvofW_,nvofH_,DXGI_FORMAT_R16G16B16A16_FLOAT,true);
fgFlowFilled_=makeTexture(context_.device(),nvofW_,nvofH_,DXGI_FORMAT_R16G16_FLOAT,true);
fgBaseFlow_=makeTexture(context_.device(),workW_,workH_,DXGI_FORMAT_R16G16_FLOAT,true);
if(!fgFlowRefined_||!fgFlowFilled_||!fgBaseFlow_)return false;
+ if(flowClaims_){
+ fgFlowClaims_=makeTexture(context_.device(),nvofW_,nvofH_,DXGI_FORMAT_R32_UINT,true);
+ fgFlowAgreement_=makeTexture(context_.device(),nvofW_,nvofH_,DXGI_FORMAT_R16_FLOAT,true);
+ if(!fgFlowClaims_||!fgFlowAgreement_)return false;
+ }
}
- if(presentSinkFg())veyra::log::info("graph",std::format("present-sink FG motion: {}",!desc_.fgUsesFlow()?"zero":flowConsistency_?"refined NVOF (FlowRefine+FlowFill, forward-backward)":flowRefine_?"refined NVOF (FlowRefine+FlowFill)":"validated flow"));
+ if(presentSinkFg())veyra::log::info("graph",std::format("present-sink FG motion: {}",!desc_.fgUsesFlow()?"zero":flowConsistency_?"refined NVOF (FlowRefine+FlowFill, forward-backward)":
+ flowClaims_?"refined FidelityFX (FlowRefine+FlowClaim+FlowFill)":!flowRefine_?"validated flow":
+ desc_.opticalFlowBackend==engine::OpticalFlowBackend::AmdFidelityFx?"refined FidelityFX (FlowRefine+FlowFill)":"refined NVOF (FlowRefine+FlowFill)"));
// Colour grade tables (v4): only allocated when the stage is enabled.
colorActive_=desc_.color.enabled&&!desc_.nodeColor(0);
if(colorActive_){
@@ -1541,8 +1551,9 @@ bool EnhanceGraph::createComputePasses()
if(!flowAdaptPass_.loadShader("FlowAdapt.dxil",cs)||!flowAdaptPass_.create(context_.device(),cs,3+UINT(nrInstances_.size()),1,1))return false;
if(flowRefine_){
if(!fgFlowAdaptPass_.create(context_.device(),cs,2,1,1))return false;
- if(!flowRefinePass_.loadShader("FlowRefine.dxil",cs)||!flowRefinePass_.create(context_.device(),cs,5,4,1))return false;
- if(!flowFillPass_.loadShader("FlowFill.dxil",cs)||!flowFillPass_.create(context_.device(),cs,3,2,1))return false;
+ if(!flowRefinePass_.loadShader("FlowRefine.dxil",cs)||!flowRefinePass_.create(context_.device(),cs,6,5,1))return false;
+ if(!flowFillPass_.loadShader("FlowFill.dxil",cs)||!flowFillPass_.create(context_.device(),cs,4,3,1))return false;
+ if(flowClaims_&&(!flowClaimPass_.loadShader("FlowClaim.dxil",cs)||!flowClaimPass_.create(context_.device(),cs,3,1,2)))return false;
}
// Stage-5 output stabiliser. Only allocated when the setting is non-zero:
// a default session never pays for it and the dispatch is skipped below, so
@@ -1741,17 +1752,26 @@ bool EnhanceGraph::createViews()
for(size_t i=0;i<nrInstances_.size();++i)
makeUav(context_.device(),nrInstances_[i]->motion(),DXGI_FORMAT_R16G16_FLOAT,cpu(flowAdaptPass_,3+UINT(i)));
if(flowRefine_){
- // FlowRefine: 0 raw grid vectors, 1 previous, 2 current, 3 backward grid vectors (null
- // without flowConsistency_); 4 refined. FlowFill: 0 refined,
- // 1 current; 2 filled. Adapt: 0 filled; 1 work-extent XeSS motion.
+ // FlowRefine: 0 raw grid vectors, 1 previous, 2 current, 3 NVOF backward grid vectors,
+ // 4 FidelityFX scene changes (3/4 null when unused); 5 refined. FlowClaim: 0 refined;
+ // 1 claims, 2 disagreement. FlowFill: 0 refined, 1 current, 2 FlowClaim disagreement
+ // (null without); 3 filled. Adapt: 0 filled; 1 work-extent XeSS motion.
D3D12_SHADER_RESOURCE_VIEW_DESC raw{};raw.Format=DXGI_FORMAT_R16G16_SINT;raw.ViewDimension=D3D12_SRV_DIMENSION_TEXTURE2D;
raw.Shader4ComponentMapping=D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;raw.Texture2D.MipLevels=1;
stager_.stageSrv(nvofRawTex_.Get(),&raw,flowRefinePass_.heap.Get(),0);
stagedSrv(nvofInA_.Get(),DXGI_FORMAT_B8G8R8A8_UNORM,flowRefinePass_,1);stagedSrv(nvofInB_.Get(),DXGI_FORMAT_B8G8R8A8_UNORM,flowRefinePass_,2);
stager_.stageSrv(nvofReverseTex_.Get(),&raw,flowRefinePass_.heap.Get(),3);
- makeUav(context_.device(),fgFlowRefined_.Get(),DXGI_FORMAT_R16G16B16A16_FLOAT,cpu(flowRefinePass_,4));
+ D3D12_SHADER_RESOURCE_VIEW_DESC single=raw;single.Format=DXGI_FORMAT_R32_UINT;
+ stager_.stageSrv(amdOf_?amdOf_->sceneChanges():nullptr,&single,flowRefinePass_.heap.Get(),4);
+ makeUav(context_.device(),fgFlowRefined_.Get(),DXGI_FORMAT_R16G16B16A16_FLOAT,cpu(flowRefinePass_,5));
+ if(flowClaims_){
+ stagedSrv(fgFlowRefined_.Get(),DXGI_FORMAT_R16G16B16A16_FLOAT,flowClaimPass_,0);
+ makeUav(context_.device(),fgFlowClaims_.Get(),DXGI_FORMAT_R32_UINT,cpu(flowClaimPass_,1));
+ makeUav(context_.device(),fgFlowAgreement_.Get(),DXGI_FORMAT_R16_FLOAT,cpu(flowClaimPass_,2));
+ }
stagedSrv(fgFlowRefined_.Get(),DXGI_FORMAT_R16G16B16A16_FLOAT,flowFillPass_,0);stagedSrv(nvofInB_.Get(),DXGI_FORMAT_B8G8R8A8_UNORM,flowFillPass_,1);
- makeUav(context_.device(),fgFlowFilled_.Get(),DXGI_FORMAT_R16G16_FLOAT,cpu(flowFillPass_,2));
+ single.Format=DXGI_FORMAT_R16_FLOAT;stager_.stageSrv(fgFlowAgreement_.Get(),&single,flowFillPass_.heap.Get(),2);
+ makeUav(context_.device(),fgFlowFilled_.Get(),DXGI_FORMAT_R16G16_FLOAT,cpu(flowFillPass_,3));
stagedSrv(fgFlowFilled_.Get(),DXGI_FORMAT_R16G16_FLOAT,fgFlowAdaptPass_,0);
makeUav(context_.device(),fgBaseFlow_.Get(),DXGI_FORMAT_R16G16_FLOAT,cpu(fgFlowAdaptPass_,1));
}
@@ -2360,7 +2380,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
gpuTimer_.mark(list,GpuStage::Flow);
if(!amdOf_->dispatch(list,nvofInB_.Get(),!prevValid_))return false;
++metrics_.amdOfExecuteCount;haveFlow=prevValid_;
- gpuTimer_.mark(list,GpuStage::Flow,true);
+ if(!flowRefine_||!haveFlow)gpuTimer_.mark(list,GpuStage::Flow,true);
}
if(gpuDis_ && prevValid_){
gpuTimer_.mark(list,GpuStage::Flow);
@@ -2412,16 +2432,34 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
// XeSS motion: per-pixel candidate choice, then disocclusion fill.
tracker_.transition(list,fgFlowRefined_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
if(flowConsistency_)tracker_.transition(list,nvofReverseTex_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
- const float rc[8]={uintBits(rawW_),uintBits(rawH_),uintBits(nvofW_),uintBits(nvofH_),uintBits(selectedGrid_),.004f,uintBits(flowConsistency_?1u:0u),0};
- flowRefinePass_.bind(list,rc,gpuHandleOf(flowRefinePass_,0).ptr,gpuHandleOf(flowRefinePass_,4).ptr);
+ // Flags: 1 NVOF backward output, 2 FidelityFX vectors, 4 FidelityFX warming up.
+ const uint32_t refineFlags=(flowConsistency_?1u:0u)|(amdOf_?2u:0u)|(amdOf_&&!amdOf_->warmedUp()?4u:0u);
+ const float rc[8]={uintBits(rawW_),uintBits(rawH_),uintBits(nvofW_),uintBits(nvofH_),uintBits(selectedGrid_),.004f,uintBits(refineFlags),0};
+ flowRefinePass_.bind(list,rc,gpuHandleOf(flowRefinePass_,0).ptr,gpuHandleOf(flowRefinePass_,5).ptr);
list->Dispatch((nvofW_+15)/16,(nvofH_+15)/16,1);
tracker_.uavBarrier(list,fgFlowRefined_.Get());
tracker_.transition(list,fgFlowRefined_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ if(flowClaims_){
+ // FidelityFX: clear, claim and resolve the previous-frame claims.
+ tracker_.transition(list,fgFlowClaims_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
+ tracker_.transition(list,fgFlowAgreement_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
+ uint32_t indexBits=1;while((uint64_t(1)<<indexBits)<uint64_t(nvofW_)*nvofH_)++indexBits;
+ for(uint32_t mode=0;mode<3;++mode){
+ const float cc[8]={uintBits(nvofW_),uintBits(nvofH_),uintBits(mode),uintBits(indexBits),0,0,0,0};
+ flowClaimPass_.bind(list,cc,gpuHandleOf(flowClaimPass_,0).ptr,gpuHandleOf(flowClaimPass_,1).ptr);
+ list->Dispatch((nvofW_+15)/16,(nvofH_+15)/16,1);
+ tracker_.uavBarrier(list,fgFlowClaims_.Get());
+ }
+ tracker_.uavBarrier(list,fgFlowAgreement_.Get());
+ tracker_.transition(list,fgFlowAgreement_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ }
tracker_.transition(list,fgFlowFilled_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
- // A chosen vector off by more than 2 flow pixels forward-backward is filled, from
- // pixels within 0.5 (consistent background/body: ~0.2 at P90).
- const float fc[8]={uintBits(nvofW_),uintBits(nvofH_),.06f,.002f,flowConsistency_?2.f:0.f,flowConsistency_?.5f:0.f,0,0};
- flowFillPass_.bind(list,fc,gpuHandleOf(flowFillPass_,0).ptr,gpuHandleOf(flowFillPass_,2).ptr);
+ // A chosen vector off by more than 2 flow pixels (forward-backward or from the
+ // claim winner) is filled, from pixels within 0.5 (consistent background/body:
+ // ~0.2 at P90).
+ const bool occlusion=flowConsistency_||flowClaims_;
+ const float fc[8]={uintBits(nvofW_),uintBits(nvofH_),.06f,.002f,occlusion?2.f:0.f,occlusion?.5f:0.f,uintBits(flowClaims_?1u:0u),0};
+ flowFillPass_.bind(list,fc,gpuHandleOf(flowFillPass_,0).ptr,gpuHandleOf(flowFillPass_,3).ptr);
list->Dispatch((nvofW_+15)/16,(nvofH_+15)/16,1);
tracker_.uavBarrier(list,fgFlowFilled_.Get());
tracker_.transition(list,fgFlowFilled_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
@@ -3179,6 +3217,8 @@ bool EnhanceGraph::applySettings(const engine::EnhancementSettings& s){
const bool usesSharedFlow=nvofStandalone_||(desc_.enableFg&&desc_.fgUsesFlow())||
(srEnabled_&&desc_.srUsesFlow()&&(desc_.videoSrQuality==0||desc_.videoSrQuality==engine::kVideoSrFsr));
if(usesSharedFlow&&(requestedFlow!=desc_.opticalFlowBackend||s.amdFlowHalfResolution!=desc_.amdFlowHalfResolution))return false;
+ // The XeSS motion refinement owns textures, passes and NVOF's direction.
+ if(presentSinkFg()&&desc_.fgUsesFlow()&&s.fgMotionRefine!=desc_.fgMotionRefine)return false;
// DLSS allocates multiplier-specific feature/output resources.
// XeSS has a fixed 2X proxy swapchain contract. Settings callers must
// rebuild instead of accepting a change that cannot take effect in place.
@@ -3457,6 +3497,7 @@ void EnhanceGraph::shutdown()
for(auto& layer:nrAutoPool_)layer.reset();nrAutoLevel_=0;nrAutoPoolReady_=nrAutoResetPending_=false;
residualRgba_.Reset();preSrProtectionRgba_.Reset();interNrProtectionRgba_.Reset();nrFlow_.Reset();baseFlow_.Reset();
fgFlowRefined_.Reset();fgFlowFilled_.Reset();fgBaseFlow_.Reset();flowRefinePass_={};flowFillPass_={};fgFlowAdaptPass_={};flowRefine_=flowConsistency_=false;
+ fgFlowClaims_.Reset();fgFlowAgreement_.Reset();flowClaimPass_={};flowClaims_=false;
for(unsigned i=0;i<kGeneratedPoolSlots;++i){if(fgDisableMapped_[i]&&fgDisableReadback_[i]){D3D12_RANGE written{0,0};fgDisableReadback_[i]->Unmap(0,&written);}fgDisableMapped_[i]=nullptr;fgDisable_[i].Reset();fgDisableReadback_[i].Reset();generatedLeases_[i].reset();genFrame_[i].Reset();}for(auto& lease:realLeases_)lease.reset();fgDisableInit_.Reset();
encPass_ = ComputePass{};
blitPass_ = ComputePass{};hdrVideoSrPass_={};
diff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cpp
index b896cc74..437d46c0 100644
--- a/src/ui/QmlPlayerBridge.cpp
+++ b/src/ui/QmlPlayerBridge.cpp
@@ -1172,6 +1172,10 @@ QmlPlayerBridge::QmlPlayerBridge(engine::EngineController& engine, std::filesyst
const int ms = p.value(QStringLiteral("audioOffsetMs")).toInt();
if (ms >= -250 && ms <= 250 && s.audioOffsetMs != ms) { s.audioOffsetMs = ms; changed = true; }
}
+ if (p.contains(QStringLiteral("edgeAegis"))) {
+ const bool on = p.value(QStringLiteral("edgeAegis")).toBool();
+ if (s.fgMotionRefine != on) { s.fgMotionRefine = on; changed = true; }
+ }
if (!defaultFlowApplied && p.contains(QStringLiteral("contentRate"))) {
const int rate = p.value(QStringLiteral("contentRate")).toInt();
if (rate >= 0 && rate <= int(engine::ContentRate::Capture60To30) && int(s.content) != rate) { s.content = static_cast<engine::ContentRate>(rate); changed = true; }
@@ -6584,6 +6588,16 @@ void QmlPlayerBridge::setAmdFlowHalf(bool value) {
if (!impl_->commit(std::move(s))) { emit notice(tr("引擎未接受 AMD 性能档,原设置保留"), true); return; }
emit settingsChanged();
}
+bool QmlPlayerBridge::edgeAegis() const { return settings().fgMotionRefine; }
+void QmlPlayerBridge::setEdgeAegis(bool value) {
+ auto s = settings();
+ if (s.fgMotionRefine == value) return;
+ s.fgMotionRefine = value;
+ if (!impl_->commit(std::move(s))) { emit notice(tr("引擎未接受边缘神盾,原设置保留"), true); return; }
+ impl_->prefs[QStringLiteral("edgeAegis")] = value;
+ if (!impl_->savePrefs()) veyra::log::warn("ui-prefs", "edge aegis not saved");
+ emit settingsChanged();
+}
int QmlPlayerBridge::contentRate() const { return int(settings().content); }
void QmlPlayerBridge::setContentRate(int value) {
if (value < 0 || value > int(engine::ContentRate::Capture60To30)) return;
diff --git a/tests/integration/FgXessBoundaryTests.cpp b/tests/integration/FgXessBoundaryTests.cpp
index 47385ea7..20a0835a 100644
--- a/tests/integration/FgXessBoundaryTests.cpp
+++ b/tests/integration/FgXessBoundaryTests.cpp
@@ -51,7 +51,10 @@ extern "C" {
using namespace veyra;
using Microsoft::WRL::ComPtr;
namespace {
-constexpr int W=2560,H=1440,FlowW=1280,FlowH=720,N=16,Warmup=4,Band=40,X0=480,CW=1600;
+constexpr int W=2560,H=1440,FlowW=1280,FlowH=720,Band=40,X0=480,CW=1600;
+// FidelityFX optical flow (VEYRA_TEST_FLOW_BACKEND=amd) zeroes its first frames while it
+// warms up: run longer and score only after it.
+int N=16,Warmup=4;
float hash01(int x,int y,uint32_t seed){
uint32_t v=uint32_t(x)*0x9e3779b9u^uint32_t(y)*0x85ebca6bu^seed*0xc2b2ae35u;
@@ -204,6 +207,7 @@ int wmain(int argc,wchar_t** argv){
if(!window)return 2;ShowWindow(window,SW_SHOW);SetForegroundWindow(window);UpdateWindow(window);
auto pump=[]{MSG m;while(PeekMessageW(&m,nullptr,0,0,PM_REMOVE)){TranslateMessage(&m);DispatchMessageW(&m);}};
pump();
+ if(wchar_t b[8]{};GetEnvironmentVariableW(L"VEYRA_TEST_FLOW_BACKEND",b,8)&&std::wstring(b)==L"amd"){N=22;Warmup=10;}
const Scene scene=makeScene(run,speed,bars);
gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status st=Status::Ok;gfx::DeviceContextDesc dd;dd.enableDebugLayer=true;
if(!ctx.initialize(dd,st)||!ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),6,st))return 2;
diff --git a/tests/integration/XessMotionQualityTests.cpp b/tests/integration/XessMotionQualityTests.cpp
index 8bb5b3c7..412ad7d6 100644
--- a/tests/integration/XessMotionQualityTests.cpp
+++ b/tests/integration/XessMotionQualityTests.cpp
@@ -15,9 +15,11 @@
// veyra_xess_motion_quality_tests <outDir> perf <frames> [tag]
// perf: product extents (3840x2160 source/work, 1920x1080 flow, the run scene upscaled), GPU
// time of the optical-flow stage (NVOF wait, densify, refinement, adaptation) and of the whole
-// graph per path; median and P95 after 8 warm-up frames.
+// graph per path; median and P95 after 8 warm-up frames. VEYRA_TEST_FLOW_BACKEND=amd times
+// FidelityFX flow (FlowClaim instead of NVOF's backward output).
// Knobs (environment) as FgXessBoundaryTests: VEYRA_TEST_FLOW_FULL=1, VEYRA_TEST_FLOW_QUALITY,
-// VEYRA_TEST_FLOW_VALIDATE=0, VEYRA_TEST_NVOF_GRID (read by EnhanceGraph).
+// VEYRA_TEST_FLOW_VALIDATE=0, VEYRA_TEST_FLOW_BACKEND=amd (FidelityFX: 24 frames, the first 9
+// unscored while it warms up), VEYRA_TEST_NVOF_GRID (read by EnhanceGraph).
#include "veyra/pipeline/EnhanceGraph.h"
#include "veyra/pipeline/GpuPassUtils.h"
#include "veyra/gfx/D3D12DeviceContext.h"
@@ -46,7 +48,8 @@ extern "C" {
using namespace veyra;
using Microsoft::WRL::ComPtr;
namespace {
-constexpr int W=2560,H=1440,FlowW=1280,FlowH=720,N=16,Warmup=2,Band=40,X0=480,CW=1600;
+constexpr int W=2560,H=1440,FlowW=1280,FlowH=720,Band=40,X0=480,CW=1600;
+int N=16,Warmup=2;
float hash01(int x,int y,uint32_t seed){
uint32_t v=uint32_t(x)*0x9e3779b9u^uint32_t(y)*0x85ebca6bu^seed*0xc2b2ae35u;
@@ -196,6 +199,8 @@ int perf(const std::filesystem::path& dir,int frames,const std::string& label){
gd.sourceWidth=gd.workWidth=PW;gd.sourceHeight=gd.workHeight=PH;gd.flowWidth=PW/2;gd.flowHeight=PH/2;gd.rgbInput=true;
gd.enableNr=false;gd.enableSr=false;gd.enableFg=true;gd.noNgx=true;gd.fgMultiplier=2;
gd.frameGenerationBackend=engine::FrameGenerationBackend::XeSS;gd.fgMotion=engine::MotionSource::OpticalFlow;
+ if(wchar_t backend[8]{};GetEnvironmentVariableW(L"VEYRA_TEST_FLOW_BACKEND",backend,8)&&std::wstring(backend)==L"amd")
+ gd.opticalFlowBackend=engine::OpticalFlowBackend::AmdFidelityFx;
gd.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();
if(!graph.initialize(gd)||!graph.createViews()){std::cerr<<"graph open failed"<<std::endl;ok=false;break;}
graph.recordGpuTimings();std::vector<double> flow,span;
@@ -227,6 +232,8 @@ int wmain(int argc,wchar_t** argv){
const bool run=sceneName==L"run",bars=sceneName==L"bars";if(!run&&!bars&&sceneName!=L"orbit")return 2;if(speed<1||speed>200)return 2;
std::filesystem::create_directories(dir);CoInitializeEx(nullptr,COINIT_MULTITHREADED); // WIC image export
const std::string label=std::format("motion-{}{}{}",bars?"bars":run?"run":"orbit",speed,argc==5?"-"+std::filesystem::path(argv[4]).string():std::string());
+ wchar_t backend[8]{};GetEnvironmentVariableW(L"VEYRA_TEST_FLOW_BACKEND",backend,8);
+ const bool fidelity=std::wstring(backend)==L"amd";if(fidelity){N=24;Warmup=9;}
Logger::instance().openFile((dir/(label+".log")).wstring());
const Scene scene=makeScene(run,speed,bars);
gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status st=Status::Ok;gfx::DeviceContextDesc dd;dd.enableDebugLayer=true;
@@ -250,6 +257,7 @@ int wmain(int argc,wchar_t** argv){
if(knob(L"VEYRA_TEST_FLOW_FULL")==L"1"){gd.flowWidth=W;gd.flowHeight=H;}
if(const auto q=knob(L"VEYRA_TEST_FLOW_QUALITY");!q.empty())gd.flowQuality=engine::FlowQuality(std::clamp(_wtoi(q.c_str()),0,2));
if(knob(L"VEYRA_TEST_FLOW_VALIDATE")==L"0")gd.validateMotion=false;
+ if(fidelity)gd.opticalFlowBackend=engine::OpticalFlowBackend::AmdFidelityFx;
gd.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();
if(!graph.initialize(gd)||!graph.createViews()){std::cerr<<"graph open failed"<<std::endl;ok=false;break;}
Region bgBand,uncovered,fgBand,outside,all,parts[6];std::vector<uint16_t> motion(size_t(W)*H*2);
diff --git a/tests/unit/EffectChainTests.cpp b/tests/unit/EffectChainTests.cpp
index 546fb5f0..6c7f988a 100644
--- a/tests/unit/EffectChainTests.cpp
+++ b/tests/unit/EffectChainTests.cpp
@@ -992,6 +992,7 @@ __declspec(noinline) void testInactiveEffectEdits(){
edited.videoHdr.peakNits=700;edited.protection.featherPixels=40;edited.nrHoldTolerance=.25f;
edited.hdrCurve.midGrayNits=400;edited.hdrMetadata.maxCllNits=2000;
edited.flow=FlowQuality::Performance;edited.opticalFlowBackend=OpticalFlowBackend::GpuDis;edited.amdFlowHalfResolution=true;
+ edited.fgMotionRefine=false;
check(edited.validate().empty()&&off!=edited,"inactive edits remain valid distinct persistent settings");
check(off.sameActiveVideoParameters(edited)&&edited.sameActiveVideoParameters(off)&&off.sameVideoConfiguration(edited),"all bypassed effect parameters are absent from active GPU identity");
check(!requiresGraphRebuild(off,edited)&&!requiresGraphRebuild(edited,off),"bypassed topology/LUT/backend edits do not rebuild in either direction");
@@ -1016,6 +1017,12 @@ __declspec(noinline) void testInactiveEffectEdits(){
check(active.sameVideoConfiguration(next)==(backend==FrameGenerationBackend::Vfg),"shared flow stays active for every external-flow FG consumer");
next=active;next.nrPolicy=veyra::pipeline::NrSizePolicy::Native;next.nrRuntime=NrRuntime::LmxxfAmd;
check(active.sameVideoConfiguration(next),"active FG does not activate stored NR parameters");
+ // 边缘神盾 (fgMotionRefine) shapes only XeSS motion taken from optical flow.
+ next=active;next.fgMotionRefine=false;
+ const bool refines=backend==FrameGenerationBackend::XeSS;
+ check(active.sameVideoConfiguration(next)!=refines&&requiresGraphRebuild(active,next)==refines,"edge aegis rebuilds only XeSS optical-flow motion");
+ auto automatic=active;automatic.fgMotion=MotionSource::Automatic;next=automatic;next.fgMotionRefine=false;
+ check(!requiresGraphRebuild(automatic,next),"edge aegis is inactive while XeSS motion stays automatic");
}
auto stack=populated();stack.nrLayerCount=2;stack.nrLayers[0].enabled=false;stack.nrLayers[1].enabled=true;
stack.nrLayers[1].runtime=stack.nrRuntime;stack.nrLayers[1].lowLatencyPairing=stack.lowLatency;