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

Fix NR-first output handoff to FSR and scaling fallback

Veyra Goal Agentbf6e6517a62a
diff --git a/AGENTS.md b/AGENTS.md
index 4f5aae10..df236072 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,5 +1,7 @@
# Veyra 项目 Agent 执行规则
+> **2026-10-07 AMD NR/FSR现场修复**:用户报告1080p文件与XSX1080p60开关AMD NR无画面变化,提供veyra-qml(37).log。按docs/AMD_NR_FSR_PLAN_2026-10-07.md从4294341在E盘codex/amd-nr-fsr-handoff-20261007隔离修复共享NR→FSR资源交接和必要定向测试/构建/本地候选;这些具体接点覆盖历史冻结。先运行amd-nr-fsr-control.py,独立start/bundle保护32个工作树、495个脏文件与3672项已发布/候选文件,不改旧guard。运行库/模型原字节、正常链路不回读;无子Agent/竞争压力、不改用户配置/驱动/其他工作树、无新main合并/push/Release/关机。每测试≤300秒、构建≤900秒,所有产物E盘。本机RTX共享交接验证不等于RX9070/HIP/XSX实卡验收。
+
> **2026-10-07 Blackmagic采集兼容授权**:用户要求兼容日志中的 Blackmagic WDM Capture / Decklink Video Capture,并说明不能确认物理卡数。从已验VFG候选cc22e88在E盘codex/blackmagic-capture-20261007按docs/BLACKMAGIC_CAPTURE_PLAN_2026-10-07.md隔离修复必要DirectShow上游连接/HDYC格式/驱动属性页/源黑帧诊断与QML及针对性构建验收。本次具体接点覆盖历史冻结;不改其它补帧/NR算法、不碰驱动/用户配置/其他工作树。独立start和Git bundle在archives/blackmagic-capture-20261007,先执行blackmagic-control.py,不改旧guard/baseline。无子Agent、压力/竞争负载;单测试≤300秒、构建≤900秒,产物统一E盘。运行库/模型原字节且不进Git;没有新merge/push/Release/关机授权。实卡未验不能宣称已解决。
> **2026-10-07 VFG专项优化授权**:用户明确“尝试优化VFG,其他的补帧暂时不动”。从已封存排查aec800e在E盘codex/vfg-optimization-20261007按docs/VFG_OPTIMIZATION_PLAN_2026-10-07.md实施VFG必要提交/互操作/专属调度及定向构建验收、本地候选;这些具体接点覆盖旧冻结。DLSS/XeSS/FSR实现与策略保持,不改NR算法、用户配置、驱动或其它工作树。独立不可变start及source-before.bundle在archives/vfg-optimization-20261007,先运行vfg-opt-control.py,不改旧guard/baseline。不派Agent、无压力/竞争负载,测试≤300秒、构建≤900秒,产物全在E盘;没有新merge/push/Release/关机授权,运行库/模型原字节保留且不进源码Git。
diff --git a/docs/AMD_NR_FSR_PLAN_2026-10-07.md b/docs/AMD_NR_FSR_PLAN_2026-10-07.md
new file mode 100644
index 00000000..8c31ac67
--- /dev/null
+++ b/docs/AMD_NR_FSR_PLAN_2026-10-07.md
@@ -0,0 +1,25 @@
+# AMD NR 结果被 FSR 覆盖:现场排查和修复
+
+用户报告:1080p 文件和 XSX 1080p60 串流开关 AMD NR 均看不到变化,提供 veyra-qml(37).log。本轮只处理共享 NR → FSR 的资源交接及定向回归;不改 NR 模型/运行库、补帧算法、采集、音频或解码器。
+
+## 已核实的现场事实
+
+- RX 9070 XT,文件1920×1080/23.976,XSX1920×1080/60,两者均 NR → residual(source) → FSR SR(3840×2160) → XeSS FG。AMD session/enqueue、modules_ok=62、HIP=1、图重建和设置版本确认均存在。仅凭这些记录不能证明增强像素进入最终输出。
+- 开关 NR 已传到 graph;文件 NR GPU 约11.1–11.47ms。FSR evaluate 非 split 顺序取 preSrColorOutput 或原始 srcRgba,没有取 NR residual。这条代码也存在于已发布2.0.5/main af5bfc3,不是本轮VFG或Blackmagic改动引入。
+- 首帧/断点没有有效光流时走普通 blit,同样只在 split/独立调色时选择 SR 边界结果,会覆盖普通 NR-first 输出。
+- XSX另有6次D3D12VA send_packet -22、硬解重启后回退软解并恢复帧的记录;它不解释正常本地文件同样无NR效果,本轮不凭该日志改解码器。
+- 原始日志SHA256 b0e8ce013adf600fd033133e26235fc2cf195612e9f39085ed04bb3f71ac90bf。日志含私人会话数据,只留E盘私有证据,不进入源码或测试包。
+
+## 隔离与最小改动
+
+从已验4294341(保留VFG和Blackmagic候选改动)在E:/项目/Veyra/worktrees/amd-nr-fsr-handoff-20261007 / codex/amd-nr-fsr-handoff-20261007施工。新独立start.json和完整bundle在archives同任务目录;保护32个既有工作树/495个未提交文件和3672项原包/模型/运行库/证据。先运行amd-nr-fsr-control.py,旧guard/baseline保持。所有构建/测试/临时/候选放E盘;不派Agent、不施加竞争负载,不改用户配置/驱动,不合并main、推送或发布。
+
+1. 扩展现有测试专用C ABI provider,加入固定非恒等GPU输出。现有identity模式、ABI失败测试保持;测试provider绝不进入产品包。
+2. 修复前使用实际FSR provider和实际共享graph/shader跑像素断言,要求NR-off、SR→NR对照通过,NR→SR出现期望失败;否则不能把静态代码疑点当复现。
+3. FSR evaluate统一使用已有srStageInput契约;普通缩放回退选择同一边界描述符,显式设置其读状态。保持NR-off、split节点顺序、调色/保护边界的含义,不新增每帧CPU等待或生产像素回读。
+4. 修复后跑非恒等、光流首帧/稳态/断点、单/多层、不同帧率及1080p→4K,保留原identity/4K导出和ABI回归;核对D3D12 debug错误。每测试≤300秒、构建≤900秒。
+5. 构建本地AMD测试候选和对应源码,沿用已发布2.0.5 AMD包运行库/模型原字节,准确记录本机RTX测试的是共享交接而非AMD/HIP推理;RX9070/XSX需要用户实机复测。
+
+## 审查重点
+
+不能以NR耗时、Create/Enqueue成功、源码模式匹配或identity provider当作增强效果通过证明。必须让NR输出区别于输入,并断言最终像素保留变化,同时确认NR-off和SR→NR顺序无变化。测试读取像素仅为诊断,正常播放链路不得添加GPU→CPU回读。
diff --git a/docs/AMD_NR_FSR_REPORT_2026-10-07.md b/docs/AMD_NR_FSR_REPORT_2026-10-07.md
new file mode 100644
index 00000000..05b6d7ac
--- /dev/null
+++ b/docs/AMD_NR_FSR_REPORT_2026-10-07.md
@@ -0,0 +1,61 @@
+# AMD NR 开关无变化:已复现的资源交接错误和测试候选
+
+1080p 文件和 XSX 的日志都存在同一条确定错误:NR 已执行并合成到源尺寸结果,但普通 NR → FSR 顺序让 FSR 重新读原始画面,最终输出丢弃了 NR 的变化。没有有效光流的首帧/断点回退缩放也读了原图。本轮已修复这两处并通过共享 GPU 链路像素回归;RX 9070 XT/HIP 与真实 XSX 串流仍待用户复测。
+
+## 证据与原因
+
+用户 veyra-qml(37).log(SHA256 b0e8ce013adf600fd033133e26235fc2cf195612e9f39085ed04bb3f71ac90bf)记录 RX 9070 XT、文件1920×1080/23.976与串流1920×1080/60。两者均为 NR → residual(source) → FSR SR(3840×2160) → XeSS FG,FSR枚举选中4.1.1。NR开关触发了设置版本应用和graph重建;AMD session 1–5有成功enqueue、HIP=1、modules_ok=62、共享合成记录,文件NR计时约11.1–11.47ms。这说明有工作执行,不说明结果已经送显。
+
+EnhanceGraph::runSr 中,非split且无独立pre-SR调色时,FSR color参数被指向srcRgba_;应使用已包含NR残差、保护和边界调色的srStageInput()。普通blit也只在split或调色存在时选择该边界。代码在已发布2.0.5/main af5bfc3中已经存在;git -S追溯至4fbc2b0的2.0.0整合,当前VFG/Blackmagic候选没有引入它。此追溯只说明Git首次出现,不猜测历史作者的具体编辑时刻。
+
+生产改动仅 EnhanceGraph.cpp:FSR color统一取srStageInput;普通缩放统一读已有描述符18并设置读取状态。NR推理、模型、FSR provider选择、XeSS/DLSS/FSR/VFG补帧、解码器、采集及着色器均未改。该修复纠正结果路径,不宣称AMD推理耗时降低。
+
+旧AMD测试provider原样复制输入,原图与NR输出相同,无法检测“后续读错原图”。新增测试marker为确定的线性FP16颜色(0.5,0.125,0.0625),GPU一次上传后按原ABI交付,与源(32,96,160)的sRGB代码明显不同;最终送显纹理必须保留该变化。测试provider只用于测试,不能进入产品包。正常播放没有新增像素回读或CPU等待。
+
+## 本机验证
+
+本机为RTX5070,真实FSR provider为3.1.5;AMD NR使用仅供测试的C ABI provider,测试专用graph只替换AMD厂商准入条件。生产厂商准入保持原样。以下结果不能替代AMD/HIP、FSR4.1.1画质/性能或真实Xbox网络串流验收。
+
+| 检查 | 结果 |
+| --- | --- |
+| 修复前同一非恒等测试 | 6个NR-before-SR用例失败;NR和FSR均有执行,最终仍是原图;期望marker的最大8bit代码误差156 |
+| 修复后10个交接用例 | 全通过,所采样位置最大代码误差0;包含23.976/60fps合成时间戳、单/双层、时域、NR零强度、NR关闭、SR→NR对照、普通缩放及光流首帧/断点回退 |
+| 1080p→4K交接 | 合成1920×1080/60fps PTS输入、3840×2160输出、2次reset、6次NR/4次真实FSR执行通过;不是实际XSX播放性能测试 |
+| 原有7个GPU恒等合成用例 | 单/双/四层及时域开关全通过;逐像素最大误差0 |
+| 原有3个4K导出图用例 | NR关闭/单层/双层,完整3840×2160输出及内部1080p预算全通过;这不是实际编码导出测试 |
+| D3D12 debug | 修复前后均0个ERROR/CORRUPTION,设备存活 |
+| C ABI/失败处理回归 | 62项,0失败,含旧ABI、厂商拒绝、缺失运行库、坏函数表、enqueue失败 |
+| 既有effect chain检查 | 264条PASS,最终all checks passed |
+| 产品冷启动/基础文件播放 | 13.140秒,退出0,26个Qt/FFmpeg模块均从候选自身目录加载;无QML/引擎ERROR,独立E盘profile,默认效果关闭 |
+
+命令(均在本轮E盘worktree,python为本机3.11,-B不创建源码pycache):
+
+```text
+python -B scripts/acceptance/amd-nr-fsr-build.py build-before veyra_amd_nr_graph_tests veyra_lmxxf_nr_tests veyra_effect_chain_tests
+python -B scripts/acceptance/amd-nr-fsr-tests.py pixels-before before
+python -B scripts/acceptance/amd-nr-fsr-build.py build-after veyra_qml_ui veyra_amd_nr_graph_tests veyra_lmxxf_nr_tests veyra_effect_chain_tests
+python -B scripts/acceptance/amd-nr-fsr-tests.py pixels-after after
+python -B scripts/acceptance/amd-nr-fsr-tests.py abi-after abi
+python -B scripts/acceptance/amd-nr-fsr-tests.py chain-after units
+python -B scripts/acceptance/amd-nr-fsr-package.py prepare
+python -B scripts/acceptance/amd-nr-fsr-package.py cold cold-after
+python -B scripts/acceptance/amd-nr-fsr-package.py final
+```
+
+两次构建分别77.094/81.829秒exit0;修复前GPU测试3.812秒exit1为明确预期失败,修复后2.500秒exit0;ABI0.390秒、chain0.031秒。全部串行GPU测试,无竞争负载,每进程≤300秒,构建≤900秒。日志、各步JSON回执在E:/项目/Veyra/logs/amd-nr-fsr-handoff-20261007;构建在build/同任务,测试/profile在tests/同任务,临时目录在tmp/同任务。原始日志副本含私人会话数据,只留私有证据目录,不进入源码和便携包。
+
+## 候选与实机复测
+
+- 本地便携目录:E:/项目/Veyra/test-packages/amd-nr-fsr-handoff-20261007/Veyra-2.0.5-amd-nr-test-AMD-win64-portable
+- 便携ZIP:上述目录名.zip;对应源码:同目录下Veyra-2.0.5-amd-nr-test-source.zip。
+- EXE显示版本2.0.5-amd-nr-test,SHA256 c57ef5fa2db6d297d5f9393b45c5866faa1504a7ffabe9621d52f91d2ecc6b9b。
+- 沿用正式2.0.5 AMD运行库/模型/许可证/patched FFmpeg原字节;包内保留先前VFG cc22e88和Blackmagic4294341候选改动。更新EXE、既有Blackmagic界面/notice及本轮说明/manifest,没有替换NR DLL、模型或FSR运行库。包内shader与本次GPU测试使用的build/shaders逐文件相同。
+- 最终审计由amd-nr-fsr-package.py final在打包后写入E:/项目/Veyra/verify/amd-nr-fsr-handoff-20261007/final-check.json,包含源码对应、ZIP CRC与每项payload hash、候选/原包隔离和测试provider不入包的检查。主分支和其它32个工作树保持。
+
+请完整解压到新目录,先用原1080p视频和相同预设保持NR→FSR顺序,确认打开/关闭NR能改变同一段或暂停帧;再复测XSX1080p60。需先确认NR该层和FSR已启用,总变化强度大于0。对比时可暂关自动画面调控并设总变化强度2,减少保护参数抵消变化的干扰;测试后恢复个人设置。开关需要graph重建,等待状态完成再判断。
+
+## 另一个独立记录与限制
+
+XSX日志另有6次D3D12VA send_packet -22,硬解重启仍失败后回退软解并恢复帧。这不能解释正常本地文件同样无NR变化,本轮未改该解码路径;若测试时串流出帧异常,需要按该独立故障继续取证。
+
+自查确认修复没有绕过生产AMD准入,没有以identity输出或Create/Enqueue成功代替增强像素证明;NR关闭、零强度和SR→NR对照均保持原图/预期结果,原多层和4K输出未截断。没有独立Reviewer或AMD实卡验收记录。物理Blackmagic兼容、此前NVIDIA显存持续增长和较高VFG倍率限制仍保留原候选边界。本轮只交本地测试候选,不改变正式发布版本。
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 0ebb4985..f903e26e 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -1,5 +1,17 @@
# Veyra 工作记录
+## 2026-10-07 AMD NR → FSR结果丢失修复
+
+用户提交veyra-qml(37).log,报告1080p文件和XSX1080p60开关AMD NR无变化。从已验4294341在codex/amd-nr-fsr-handoff-20261007隔离修复,保留先前VFG和Blackmagic候选。独立start.json SHA256 0db892110ae4d7f358ed19cb9debbef747ea12cbbffd128f69a82040a5341499、全引用source-before.bundle SHA256 dcd0d2ce954b54b7aacf807d35d35395bc86d849a4e58cec8c7d9a0cf583f40a位于E:/项目/Veyra/archives/amd-nr-fsr-handoff-20261007;新amd-nr-fsr-control.py保护32个原工作树、495份未提交文件和3672项原包/运行库/模型/证据,不改旧guard/baseline、桌面/main/用户配置/驱动。不派Agent、不做竞争负载,不合并main/push/Release/关机。
+
+日志RX9070XT:两来源均NR→FSR(枚举4.1.1)→XeSS,NR已成功enqueue/合成且开关触发设置版本应用,并非按钮未传入。发现普通NR-first顺序FSR color读srcRgba而丢弃NR residual,光流首帧/断点普通blit也取原图;这条错误已存在2.0.5/main af5bfc3,并非本轮VFG/Blackmagic改动引入。生产只改EnhanceGraph.cpp:FSR与普通blit统一取已有srStageInput/descriptor18,设置必要资源读状态;模型、DLL、FSR选择和补帧/解码/采集/着色器不改。新增测试专用非恒等GPU marker,填补此前identity fixture无法检测结果被覆盖的缺口。
+
+执行python -B scripts/acceptance/amd-nr-fsr-build.py build-before ...:77.094秒exit0;amd-nr-fsr-tests.py pixels-before before:3.812秒exit1为预期复现,6个NR-before-SR用例确实算了NR却输出原图,marker误差156,NR-off/SR→NR/零强度对照通过。生产修复后build-after veyra_qml_ui veyra_amd_nr_graph_tests veyra_lmxxf_nr_tests veyra_effect_chain_tests:81.829秒exit0。pixels-after after:2.500秒,20个GPU用例0失败,非恒等交接采样最大误差0;含1080p/60fps合成PTS→4K、首帧/断点、时域、单/多层和原4K输出identity回归,D3D12错误0。abi-after abi:62项0失败/0.390秒;chain-after units:264条PASS/0.031秒。本机RTX5070执行真实FSR3.1.5和测试C ABI NR,不能外推RX9070/HIP、FSR4.1.1或实际XSX验收。
+
+amd-nr-fsr-package.py prepare独立复制正式AMD包,仅换EXE与保留的Blackmagic QML/notice;cold cold-after:13.140秒exit0、26个Qt/codec模块均来自候选、文件基础播放及QML无ERROR,使用E盘独立profile、默认增强关闭。EXE c57ef5fa2db6d297d5f9393b45c5866faa1504a7ffabe9621d52f91d2ecc6b9b,显示2.0.5-amd-nr-test。构建/测试/logs/tmp均在E:/项目/Veyra下同任务目录,每测试≤300秒、构建≤900秒;修复前失败证据保留。详细命令/原因/自查/限制与复测步骤在docs/AMD_NR_FSR_REPORT_2026-10-07.md。原日志含私人串流数据不入Git/便携包。XSX另有D3D12VA六次-22后软解回退,不与NR资源交接问题混为一谈,本轮未修改解码器。
+
+本地对应源码与完整AMD便携ZIP由amd-nr-fsr-package.py final审计生成到E:/项目/Veyra/test-packages/amd-nr-fsr-handoff-20261007,核验编译输入对应、runtime/model/shader原字节、测试provider不入包和ZIP逐文件hash/CRC;最终回执路径E:/项目/Veyra/verify/amd-nr-fsr-handoff-20261007/final-check.json。AMD实卡和真实XSX需用户复测;此前Blackmagic实卡/较高VFG倍率/NVIDIA显存增长边界不变。没有独立Reviewer验收声明。
+
## 2026-10-07 Blackmagic / DeckLink 采集黑屏兼容
用户要求兼容截图中 Blackmagic WDM Capture、Decklink Video Capture 两个入口,随后确认无法判断物理卡数。按 docs/BLACKMAGIC_CAPTURE_PLAN_2026-10-07.md,从已验 VFG 候选 cc22e88 隔离到 codex/blackmagic-capture-20261007,保留 VFG 优化。开工 tag checkpoint/pre-blackmagic-capture-20261007;E:/项目/Veyra/archives/blackmagic-capture-20261007 保存完整 source-before.bundle、不可变 start.json,原日志/截图只读副本在 logs/blackmagic-capture-20261007/input。新 guard 逐文件保护其它 31 个工作树及 1346 个原始文件,不改旧 baseline/guard、桌面脏区、main、发布包、运行库、驱动或用户配置。无子 Agent、竞争 GPU 压力、merge/push/Release/关机操作。
diff --git a/scripts/acceptance/amd-nr-fsr-build.py b/scripts/acceptance/amd-nr-fsr-build.py
new file mode 100644
index 00000000..29d91935
--- /dev/null
+++ b/scripts/acceptance/amd-nr-fsr-build.py
@@ -0,0 +1,28 @@
+"""Build the isolated routing fix with the accepted 2.0.5 dependencies."""
+from pathlib import Path
+import hashlib,json,os,subprocess,sys,time
+ROOT=Path(__file__).resolve().parents[2];BASE=Path('E:/项目/Veyra');TASK='amd-nr-fsr-handoff-20261007'
+label=sys.argv[1];assert label.replace('-','').isalnum()
+BUILD=BASE/'build'/TASK;TMP=BASE/'tmp'/TASK/'build';LOG=BASE/'logs'/TASK/(label+'.log')
+for p in (BUILD,TMP,LOG.parent):p.mkdir(parents=True,exist_ok=True)
+guard=[sys.executable,'-B',str(ROOT/'scripts/acceptance/amd-nr-fsr-control.py')];subprocess.run(guard,check=True)
+cache=BASE/'build/release-2.0.5-20261007/standard/CMakeCache.txt';settings=[]
+for line in cache.read_text(encoding='utf8').splitlines():
+ if ':' not in line or '=' not in line or line.startswith(('#','//')):continue
+ keytype,value=line.split('=',1);key,kind=keytype.split(':',1)
+ if kind in ('INTERNAL','STATIC') or key in ('VEYRA_DISPLAY_VERSION','VEYRA_AMD_NR_TEST_GRAPH_SOURCE'):continue
+ if key.startswith('VEYRA_') or key in ('CMAKE_PREFIX_PATH','CMAKE_MAKE_PROGRAM','PROTOC','PKG_CONFIG_EXECUTABLE'):
+ settings.append(f'set({key} [[{value}]] CACHE {kind} "Accepted dependencies" FORCE)')
+settings.append('set(VEYRA_DISPLAY_VERSION [[2.0.5-amd-nr-test]] CACHE STRING "Local AMD NR/FSR repair" FORCE)')
+(TMP/'dependencies.cmake').write_text('\n'.join(settings),encoding='utf8')
+targets=sys.argv[2:] or ['veyra_qml_ui','veyra_amd_nr_graph_tests','veyra_lmxxf_nr_tests','veyra_effect_chain_tests']
+assert all(t.replace('_','').isalnum() for t in targets)
+cmd=TMP/'build.cmd';cmd.write_text('@echo off\nchcp 65001 >nul\ncall "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat" >nul 2>&1\nif errorlevel 1 exit /b 4\n"%TASK_CMAKE%" --preset x64-release -S "%TASK_ROOT%" -B "%TASK_BUILD%" -C "%TASK_TMP%\\dependencies.cmake"\nif errorlevel 1 exit /b 5\n"%TASK_CMAKE%" --build "%TASK_BUILD%" --parallel 6 --target '+' '.join(targets)+'\nexit /b %errorlevel%\n',encoding='ascii')
+env=os.environ.copy();env.update(TEMP=str(TMP),TMP=str(TMP),VSLANG='1033',TASK_ROOT=str(ROOT),TASK_BUILD=str(BUILD),TASK_TMP=str(TMP),TASK_CMAKE='C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin/cmake.exe')
+source={str(p.relative_to(ROOT)).replace('\\','/'):hashlib.sha256(p.read_bytes()).hexdigest() for folder in ('src','include','shaders','qml','tests') for p in (ROOT/folder).rglob('*') if p.is_file()}
+start=time.monotonic()
+with LOG.open('x',encoding='utf8') as stream:
+ try:rc=subprocess.run(['cmd.exe','/d','/c',str(cmd)],cwd=ROOT,env=env,stdout=stream,stderr=subprocess.STDOUT,timeout=890).returncode
+ except subprocess.TimeoutExpired:rc=124
+LOG.with_suffix('.json').write_text(json.dumps({'exit':rc,'seconds':time.monotonic()-start,'targets':targets,'sourceHead':subprocess.check_output(['git','rev-parse','HEAD'],cwd=ROOT,encoding='ascii').strip(),'sourceFiles':source,'dependencyCacheSha256':hashlib.sha256(cache.read_bytes()).hexdigest()},indent=2),encoding='utf8')
+print('BUILD',rc,LOG);print('\n'.join(LOG.read_text(encoding='utf8',errors='replace').splitlines()[-14:]));subprocess.run(guard,check=True);raise SystemExit(rc)
diff --git a/scripts/acceptance/amd-nr-fsr-control.py b/scripts/acceptance/amd-nr-fsr-control.py
new file mode 100644
index 00000000..737a0e56
--- /dev/null
+++ b/scripts/acceptance/amd-nr-fsr-control.py
@@ -0,0 +1,31 @@
+"""Check the independent AMD NR -> FSR repair scope and preserved inputs."""
+from pathlib import Path
+import hashlib,json,subprocess
+ROOT=Path(__file__).resolve().parents[2];BASE=Path('E:/项目/Veyra');TASK='amd-nr-fsr-handoff-20261007'
+START=BASE/'archives'/TASK/'start.json'
+ALLOWED={'AGENTS.md','docs/WORKLOG.md','src/pipeline/EnhanceGraph.cpp',
+ 'tests/unit/LmxxfNrFakeRuntime.cpp','tests/integration/LmxxfNrGraphTests.cpp'}
+def sha(p):
+ with p.open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest()
+def git(*args,cwd=ROOT):return subprocess.check_output(['git',*args],cwd=cwd)
+def others():
+ out=[]
+ for line in git('worktree','list','--porcelain').decode('utf8').splitlines():
+ if not line.startswith('worktree '):continue
+ p=Path(line[9:])
+ if p.resolve()==ROOT.resolve():continue
+ names=set(git('ls-files','-m','-o','--exclude-standard','-z',cwd=p).decode('utf8').split('\0'))-{''}
+ out.append({'path':str(p),'head':git('rev-parse','HEAD',cwd=p).decode().strip(),
+ 'statusHex':git('status','--porcelain=v1','-z','--untracked-files=all',cwd=p).hex(),
+ 'changed':{n:sha(p/n) if (p/n).is_file() else None for n in sorted(names)}})
+ return out
+def allowed(n):return n in ALLOWED or n.startswith(('docs/AMD_NR_FSR_','scripts/acceptance/amd-nr-fsr-'))
+assert sha(START)=='0db892110ae4d7f358ed19cb9debbef747ea12cbbffd128f69a82040a5341499','Immutable baseline changed'
+start=json.loads(START.read_text(encoding='utf8'))
+changed=[n for n,d in start['files'].items() if not (ROOT/n).is_file() or sha(ROOT/n)!=d]
+current=set(git('ls-files','-c','-o','--exclude-standard','-z').decode('utf8').split('\0'))-{''}
+changed+=sorted(current-set(start['files']))
+assert all(allowed(n) for n in changed),[n for n in changed if not allowed(n)]
+assert others()==start['otherWorktrees'],'Another worktree changed; preserve and investigate'
+for n,d in start['immutable'].items():assert sha(Path(n))==d,n
+print('AMD NR/FSR guard passed:',len(set(changed)),'scope files;',len(start['otherWorktrees']),'other worktrees preserved;',len(start['immutable']),'immutable files intact')
diff --git a/scripts/acceptance/amd-nr-fsr-package.py b/scripts/acceptance/amd-nr-fsr-package.py
new file mode 100644
index 00000000..5cc382b7
--- /dev/null
+++ b/scripts/acceptance/amd-nr-fsr-package.py
@@ -0,0 +1,133 @@
+"""Prepare, cold-start and audit the local AMD candidate; never publish."""
+from pathlib import Path
+import ast,hashlib,json,os,re,shutil,subprocess,sys,time,zipfile,psutil
+ROOT=Path(__file__).resolve().parents[2];BASE=Path('E:/项目/Veyra');TASK='amd-nr-fsr-handoff-20261007'
+LOGS=BASE/'logs'/TASK;OUT=BASE/'test-packages'/TASK;VERIFY=BASE/'verify'/TASK
+APP=OUT/'Veyra-2.0.5-amd-nr-test-AMD-win64-portable'
+PACKAGE=BASE/'releases/publish-2.0.5-20261007/packages/Veyra-2.0.5-AMD-win64-portable'
+BUILD=BASE/'build'/TASK
+def read(p):return json.loads(p.read_text(encoding='utf-8-sig'))
+def sha(p):
+ with p.open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest()
+def git(*args):return subprocess.check_output(['git',*args],cwd=ROOT).decode('utf8').strip()
+def verifyBuild():
+ build=read(LOGS/'build-after.json');assert build['exit']==0
+ for n,d in build['sourceFiles'].items():assert sha(ROOT/n)==d,'Build input changed: '+n
+ original=(ROOT/'src/pipeline/EnhanceGraph.cpp').read_text(encoding='utf8')
+ before='ring_.queue(),context_.adapter().vendorId) || !instance->amd->admits'
+ after='ring_.queue(),0x1002 /* identity fixture only */) || !instance->amd->admits'
+ assert original.count(before)==1
+ assert (BUILD/'amd-nr-graph-test/EnhanceGraph.cpp').read_text(encoding='utf8')==original.replace(before,after),'Unexpected graph test substitution'
+ return build
+guard=[sys.executable,'-B',str(ROOT/'scripts/acceptance/amd-nr-fsr-control.py')]
+subprocess.run(guard,cwd=ROOT,check=True)
+assert not any(p.info['name'].lower() in ('veyra.exe','veyra_qml_ui.exe','veyra_amd_nr_graph_tests.exe','veyra_lmxxf_nr_tests.exe') for p in psutil.process_iter(['name']))
+mode=sys.argv[1];assert mode in ('prepare','cold','final')
+build=verifyBuild();old=read(PACKAGE/'package-manifest.json');exe=sha(BUILD/'veyra_qml_ui.exe')
+changed={'veyra_qml_ui.exe','qml/Veyra/DialogHost.qml','THIRD_PARTY_NOTICES.md'}
+for row in old['files']:
+ assert sha(PACKAGE/row['path'])==row['sha256'].lower(),row['path']
+ if row['path'].startswith('shaders/'):
+ assert sha(BUILD/row['path'])==row['sha256'].lower(),'Shader differs from actual GPU-tested build: '+row['path']
+if mode=='prepare':
+ assert not APP.exists();OUT.mkdir(parents=True,exist_ok=True)
+ shutil.copytree(PACKAGE,APP,copy_function=shutil.copy2)
+ shutil.copy2(BUILD/'veyra_qml_ui.exe',APP/'veyra_qml_ui.exe')
+ for n in changed-{'veyra_qml_ui.exe'}:shutil.copy2(ROOT/n,APP/n)
+ result={'candidate':str(APP),'exeSha256':exe,'build':'build-after','independentCopies':True,'shadersIdenticalToGpuTest':True}
+ (LOGS/'prepare.json').write_text(json.dumps(result,ensure_ascii=False,indent=2),encoding='utf8');print(json.dumps(result,ensure_ascii=False))
+elif mode=='cold':
+ assert sha(APP/'veyra_qml_ui.exe')==exe
+ label=sys.argv[2];assert label.replace('-','').isalnum()
+ out=BASE/'tests'/TASK/label;tmp=BASE/'tmp'/TASK/label;logs=LOGS/label
+ for p in (out,tmp,logs):p.mkdir(parents=True,exist_ok=False)
+ profile=out/'profile';profile.mkdir()
+ (profile/'qml-preferences.v1.json').write_text(json.dumps({'overlayCompat':'off','gpuPriority':'normal','obsGameCapture':False}),encoding='utf8')
+ env={k:v for k,v in os.environ.items() if not k.upper().startswith(('VEYRA_','QT_','QSG_'))}
+ windows=Path(env['WINDIR']);engine=logs/'engine.log';console=logs/'console.log'
+ env.update(TEMP=str(tmp),TMP=str(tmp),CUDA_CACHE_PATH=str(tmp/'cuda-cache'),VEYRA_LOG_FILE=str(engine),QML_DISABLE_DISK_CACHE='1',QT_FORCE_STDERR_LOGGING='1',PATH=os.pathsep.join(map(str,(windows/'System32',windows,windows/'System32/Wbem'))))
+ video=BASE/'tests/field-fixes-20261005/media/fx-embedded.mkv';assert video.is_file()
+ args=[str(APP/'veyra_qml_ui.exe'),'--data-dir',str(profile),'--page','pro','--size','1280x800','--exit-after','10000',str(video)]
+ start=time.monotonic();modules=[]
+ with console.open('xb') as f:
+ process=subprocess.Popen(args,cwd=APP,env=env,stdout=f,stderr=subprocess.STDOUT)
+ try:
+ time.sleep(3)
+ for module in psutil.Process(process.pid).memory_maps():
+ p=Path(module.path)
+ if p.name.startswith(('Qt6','avcodec-','avformat-','avutil-','swscale-','swresample-')):
+ assert p.resolve().is_relative_to(APP.resolve()),str(p);modules.append(str(p))
+ rc=process.wait(timeout=50)
+ except BaseException:
+ process.kill();process.wait(timeout=10);raise
+ text=engine.read_text(encoding='utf8',errors='replace')+'\n'+console.read_text(encoding='utf8',errors='replace')
+ bad=[line for line in text.splitlines() if any(word in line for word in ('[ERROR]','[FATAL]','ReferenceError:','TypeError:','no root object'))]
+ passed=rc==0 and not bad and len(modules)>10 and 'track ready events=5' in text and 'fonts configured container=1' in text
+ result={'passed':bool(passed),'exit':rc,'seconds':time.monotonic()-start,'exeSha256':exe,'command':args,'ownQtAndCodecModules':modules,'console':str(console),'engine':str(engine),'errors':bad[:20],'scope':'NVIDIA local cold startup/playback with default effects off; not AMD inference'}
+ (logs/'summary.json').write_text(json.dumps(result,ensure_ascii=False,indent=2),encoding='utf8');print(json.dumps(result,ensure_ascii=False),flush=True)
+ assert passed,result
+else:
+ assert not git('status','--porcelain=v1'),'Commit the reviewed source before archiving'
+ subprocess.run(['git','diff','--check'],cwd=ROOT,check=True)
+ for p in (ROOT/'scripts/acceptance').glob('amd-nr-fsr-*.py'):ast.parse(p.read_text(encoding='utf8'),filename=str(p))
+ tests={label:read(LOGS/label/'summary.json') for label in ('pixels-before','pixels-after','abi-after','chain-after')}
+ for label,rows in tests.items():
+ assert len(rows)==1 and rows[0]['passed']
+ row=rows[0];assert sha(Path(row['command'][0]))==row['exeSha256']
+ assert row['providerSha256']==sha(BUILD/'lmxxf-test-runtime/LmxxfNrRuntime.dll')
+ if label!='pixels-before':assert row['sourceGraphSha256']==sha(ROOT/'src/pipeline/EnhanceGraph.cpp')
+ assert tests['pixels-before'][0]['exit']==1 and tests['pixels-after'][0]['exit']==0
+ cold=read(LOGS/'cold-after/summary.json');assert cold['passed'] and cold['exeSha256']==exe
+ assert sha(APP/'veyra_qml_ui.exe')==exe
+ note=ROOT/'docs/AMD_NR_FSR_REPORT_2026-10-07.md';assert exe in note.read_text(encoding='utf8')
+ shutil.copy2(note,APP/'AMD-NR-TEST-NOTES.zh-CN.md')
+ oldPaths={x['path'] for x in old['files']}
+ for row in old['files']:
+ rel=row['path'];assert not os.path.samefile(APP/rel,PACKAGE/rel),'Writable hardlink: '+rel
+ if rel not in changed:assert sha(APP/rel)==row['sha256'].lower(),'Unexpected payload change: '+rel
+ for rel in changed-{'veyra_qml_ui.exe'}:assert sha(APP/rel)==sha(ROOT/rel),rel
+ assert sha(APP/'runtime/amd-nr/LmxxfNrRuntime.dll')!=sha(BUILD/'lmxxf-test-runtime/LmxxfNrRuntime.dll'),'Test fixture must never ship'
+ assert {p.relative_to(APP).as_posix() for p in APP.rglob('*') if p.is_file()}==oldPaths|{'package-manifest.json','AMD-NR-TEST-NOTES.zh-CN.md'}
+ head=git('rev-parse','HEAD');source=OUT/'Veyra-2.0.5-amd-nr-test-source.zip';assert not source.exists()
+ subprocess.run(['git','archive','--format=zip','--prefix=Veyra-amd-nr-test/','--output='+str(source),head],cwd=ROOT,check=True,timeout=90)
+ with zipfile.ZipFile(source) as z:
+ assert z.testzip() is None
+ for item in z.infolist():assert not re.search(r'\.(dll|lib|exe|pdb|onnx|f16|hsaco|cubin)$',item.filename,re.I),item.filename
+ for n in build['sourceFiles']:
+ assert z.read('Veyra-amd-nr-test/'+n).replace(b'\r\n',b'\n')==(ROOT/n).read_bytes().replace(b'\r\n',b'\n'),n
+ manifest={'schema':3,'version':'2.0.5','candidate':'2.0.5-amd-nr-test','displayVersion':'2.0.5-amd-nr-test',
+ 'releaseReady':False,'localOnly':True,'gpuPackage':'AMD','baseCommit':build['sourceHead'],'sourceArchiveCommit':head,
+ 'buildInputReceipt':'build-after.json','compiledSourceFilesVerified':len(build['sourceFiles']),
+ 'publishedBaseVersion':'2.0.5','publishedBaseExeSha256':sha(PACKAGE/'veyra_qml_ui.exe'),
+ 'correspondingSource':{'application':'../'+source.name,'applicationSha256':sha(source),
+ 'dependencies':old['correspondingSource']['dependencies'],'dependencySha256':old['correspondingSource']['dependencySha256'],
+ 'instructions':'docs/BUILD_2.0.5.md','displayVersionOverride':'-DVEYRA_DISPLAY_VERSION=2.0.5-amd-nr-test'},
+ 'validation':'RTX5070 actual FSR3.1.5 + non-identity/identity test NR provider: shared handoff only; AMD HIP/RX9070/XSX field test pending',
+ 'includedPriorCandidates':['VFG optimization cc22e88','Blackmagic capture compatibility 4294341'],
+ 'knownIssues':['No local AMD HIP inference or Xbox streaming hardware verification','Independent XSX hardware decode fallback in field log is unchanged',
+ 'Physical Blackmagic compatibility remains unverified','NVIDIA VRAM growth remains unresolved'],
+ 'files':[]}
+ for p in sorted(APP.rglob('*')):
+ if p.is_file() and p.name!='package-manifest.json':manifest['files'].append({'path':p.relative_to(APP).as_posix(),'size':p.stat().st_size,'sha256':sha(p)})
+ (APP/'package-manifest.json').write_text(json.dumps(manifest,ensure_ascii=False,indent=2),encoding='utf8')
+ portable=OUT/(APP.name+'.zip');assert not portable.exists();start=time.monotonic()
+ with zipfile.ZipFile(portable,'x',compression=zipfile.ZIP_DEFLATED,compresslevel=3,allowZip64=True) as z:
+ for p in sorted(APP.rglob('*')):
+ if p.is_file():z.write(p,APP.name+'/'+p.relative_to(APP).as_posix())
+ expected={APP.name+'/'+x['path']:x['sha256'] for x in manifest['files']};expected[APP.name+'/package-manifest.json']=sha(APP/'package-manifest.json')
+ with zipfile.ZipFile(portable) as z:
+ assert len(z.namelist())==len(expected) and set(z.namelist())==set(expected)
+ for name,d in expected.items():
+ with z.open(name) as f:assert hashlib.file_digest(f,'sha256').hexdigest()==d,name
+ assert z.testzip() is None
+ print('ZIP payload verified',len(expected),'files',round(time.monotonic()-start,3),'seconds',flush=True)
+ subprocess.run(guard,cwd=ROOT,check=True);assert not git('status','--porcelain=v1')
+ result={'passed':True,'head':head,'branch':git('branch','--show-current'),'candidate':str(APP),'exeSha256':exe,
+ 'source':str(source),'sourceSha256':sha(source),'portable':str(portable),'portableSha256':sha(portable),
+ 'packageManifestSha256':sha(APP/'package-manifest.json'),'compiledSourceFilesVerified':len(build['sourceFiles']),
+ 'payloadFiles':len(expected),'tests':tests,'cold':cold,'otherWorktreesAndOriginalPackagesPreserved':True,
+ 'runtimeModelShaderBytesUnchanged':True,'noTestRuntimeInCandidate':True,'noProprietaryBinariesInSource':True,
+ 'amdHardwareValidation':False,'sourceAndPortableCrcAndPayloadVerified':True}
+ VERIFY.mkdir(parents=True,exist_ok=True);(VERIFY/'final-check.json').write_text(json.dumps(result,ensure_ascii=False,indent=2),encoding='utf8')
+ print(json.dumps({k:result[k] for k in ('passed','head','candidate','exeSha256','portable','portableSha256','source','payloadFiles','compiledSourceFilesVerified')},ensure_ascii=False),flush=True)
+if mode!='final':subprocess.run(guard,cwd=ROOT,check=True)
diff --git a/scripts/acceptance/amd-nr-fsr-tests.py b/scripts/acceptance/amd-nr-fsr-tests.py
new file mode 100644
index 00000000..5544f85f
--- /dev/null
+++ b/scripts/acceptance/amd-nr-fsr-tests.py
@@ -0,0 +1,41 @@
+"""Bounded serial pixel regressions with real FSR and a test-only NR provider."""
+from pathlib import Path
+import hashlib,json,os,re,shutil,subprocess,sys,time,psutil
+ROOT=Path(__file__).resolve().parents[2];BASE=Path('E:/项目/Veyra');TASK='amd-nr-fsr-handoff-20261007'
+label,phase=sys.argv[1:3];assert label.replace('-','').isalnum() and phase in ('before','after','abi','units')
+BUILD=BASE/'build'/TASK;PACKAGE=BASE/'releases/publish-2.0.5-20261007/packages/Veyra-2.0.5-AMD-win64-portable'
+out=BASE/'tests'/TASK/label;tmp=BASE/'tmp'/TASK/label;logs=BASE/'logs'/TASK/label
+for p in (out,tmp,logs):p.mkdir(parents=True,exist_ok=False)
+guard=[sys.executable,'-B',str(ROOT/'scripts/acceptance/amd-nr-fsr-control.py')];subprocess.run(guard,check=True)
+assert not any(p.info['name'].lower() in ('veyra.exe','veyra_qml_ui.exe','veyra_amd_nr_graph_tests.exe') for p in psutil.process_iter(['name']))
+for p in PACKAGE.glob('*.dll'):shutil.copyfile(p,out/p.name)
+shutil.copytree(BUILD/'shaders',out/'shaders')
+if phase in ('before','after'):
+ targets=['veyra_amd_nr_graph_tests']
+ d=out/'runtime/amd-nr';d.mkdir(parents=True);(d/'assets').mkdir()
+ shutil.copyfile(BUILD/'lmxxf-test-runtime/LmxxfNrRuntime.dll',d/'LmxxfNrRuntime.dll')
+ (out/'runtime/nvidia').mkdir()
+ shutil.copytree(PACKAGE/'runtime_local/amd/fidelityfx',out/'runtime_local/amd/fidelityfx')
+elif phase=='abi':
+ targets=['veyra_lmxxf_nr_tests'];shutil.copytree(BUILD/'lmxxf-test-runtime',out/'lmxxf-test-runtime')
+else:targets=['veyra_effect_chain_tests']
+env={k:v for k,v in os.environ.items() if not k.upper().startswith(('VEYRA_','QT_','QSG_'))}
+env.update(TEMP=str(tmp),TMP=str(tmp),CUDA_CACHE_PATH=str(tmp/'cuda-cache'),VEYRA_LOCAL_DATA_DIR=str(out/'profile'))
+results=[]
+for target in targets:
+ exe=out/(target+'.exe');shutil.copyfile(BUILD/exe.name,exe);log=logs/(target+'.log')
+ child=env.copy();child['VEYRA_LOG_FILE']=str(logs/(target+'-engine.log'));start=time.monotonic()
+ with log.open('xb') as f:
+ try:rc=subprocess.run([str(exe)],cwd=out,env=child,stdout=f,stderr=subprocess.STDOUT,timeout=290).returncode
+ except subprocess.TimeoutExpired:rc=124
+ text=log.read_text(encoding='utf8',errors='replace');passed=rc==0 and not re.search(r'^FAIL\b|\bpass=0\b',text,re.M)
+ markers=re.findall(r'^AMD_NR_SR_MARKER .*',text,re.M)
+ if phase=='before':
+ failed=[re.search(r'case=(\S+)',m).group(1) for m in markers if 'pass=0' in m]
+ passed=rc==1 and set(failed)=={'pre-fsr-one','pre-fsr-two','pre-fsr-temporal','pre-fsr-flow-file','pre-fsr-flow-xsx-1080','pre-blit-one'} and len(markers)==10 and 'D3D12_DEBUG errors=0' in text
+ if phase=='after':passed=passed and len(markers)==10 and all('pass=1' in m for m in markers) and 'D3D12_DEBUG errors=0' in text
+ item={'target':target,'phase':phase,'command':[str(exe)],'exit':rc,'seconds':time.monotonic()-start,'passed':bool(passed),'markers':markers,'exeSha256':hashlib.sha256(exe.read_bytes()).hexdigest(),'providerSha256':hashlib.sha256((BUILD/'lmxxf-test-runtime/LmxxfNrRuntime.dll').read_bytes()).hexdigest(),'sourceGraphSha256':hashlib.sha256((ROOT/'src/pipeline/EnhanceGraph.cpp').read_bytes()).hexdigest(),'log':str(log)}
+ results.append(item);(logs/'summary.json').write_text(json.dumps(results,ensure_ascii=False,indent=2),encoding='utf8')
+ print(json.dumps(item,ensure_ascii=False),flush=True);print('\n'.join(text.splitlines()[-15:]),flush=True)
+ if not passed:raise SystemExit(1)
+subprocess.run(guard,check=True)
diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cpp
index 8fdb76b6..4d9f4b6f 100644
--- a/src/pipeline/EnhanceGraph.cpp
+++ b/src/pipeline/EnhanceGraph.cpp
@@ -1752,6 +1752,7 @@ bool EnhanceGraph::createViews()
// 7/8: videoFrame SRV 9: nvofInB UAV (NVOF B:=video)
// 10: genTex SRV 11/12: videoFrame SRV (presents)
// 13/14: genTex SRV (slot 2)
+ // 18: resolved SR input (pre-SR NR/protection/color, or original source)
if(videoSrInput_&&viewsUav)makeUav(context_.device(),videoSrInput_.Get(),DXGI_FORMAT_R8G8B8A8_UNORM,cpu(blitPass_,16));
if(videoSrOutput_&&viewsTex)stagedSrv(videoSrOutput_.Get(),DXGI_FORMAT_R8G8B8A8_UNORM,blitPass_,17);
if (viewsTex) stagedSrv(srStageInput(),DXGI_FORMAT_R16G16B16A16_FLOAT,blitPass_,18);
@@ -2388,7 +2389,9 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
// 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;
- auto* srInput=desc_.splitNrAcrossSr()?srStageInput():(preSrColorOutput_?preSrColorOutput_:srcRgba_.Get());
+ // The shared boundary includes ordinary NR-first output as well as
+ // split-node/color output. Reading srcRgba_ here discards completed NR.
+ auto* srInput=srStageInput();
tracker_.transition(list,srInput,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
auto* srMotion=desc_.srUsesFlow()?flowTex_.Get():fsrSrZeroMotion_.Get();
tracker_.transition(list,srMotion,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
@@ -2424,11 +2427,12 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
tracker_.uavBarrier(list, workRgba_.Get());
tracker_.transition(list, workRgba_.Get(), D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
} else if(workRgba_.Get()!=srcRgba_.Get()) {
+ tracker_.transition(list,srStageInput(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
tracker_.transition(list, workRgba_.Get(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
const float constants[8] = {
uintBits(srcW_), uintBits(srcH_),
uintBits(workW_), uintBits(workH_), 0, 0, 0, 0 };
- blitPass_.bind(list, constants, gpuHandleOf(blitPass_, (preSrColorOutput_||desc_.splitNrAcrossSr())?18:0).ptr, gpuHandleOf(blitPass_, 1).ptr);
+ blitPass_.bind(list, constants, gpuHandleOf(blitPass_,18).ptr, gpuHandleOf(blitPass_, 1).ptr);
list->Dispatch((workW_ + 15) / 16, (workH_ + 15) / 16, 1);
tracker_.uavBarrier(list, workRgba_.Get());
tracker_.transition(list, workRgba_.Get(), D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
diff --git a/tests/integration/LmxxfNrGraphTests.cpp b/tests/integration/LmxxfNrGraphTests.cpp
index d2707a55..0b5f6f37 100644
--- a/tests/integration/LmxxfNrGraphTests.cpp
+++ b/tests/integration/LmxxfNrGraphTests.cpp
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0-only
-// Actual shared graph and shaders with a GPU identity provider. This checks
+// Actual shared graph and shaders with GPU identity and marker providers. This checks
// composition, chaining and reset, and does NOT execute HIP/AMD neural inference.
#include "veyra/pipeline/EnhanceGraph.h"
#include "veyra/gfx/D3D12DeviceContext.h"
@@ -9,10 +9,73 @@
#include <iostream>
#include <filesystem>
#include <algorithm>
+#include <d3d12sdklayers.h>
extern "C" {
#include <libavutil/frame.h>
}
using namespace veyra;
+namespace {
+void checkSrHandoff(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing& ring,unsigned& checks,unsigned& failures){
+ struct Case {const char* name;unsigned layers;bool temporal,flow,beforeSr,fsr;uint32_t width,height;double fps;float strength=1;};
+ const Case cases[]={
+ {"off-fsr-zero",0,false,false,false,true,128,72,23.976},
+ {"pre-fsr-one",1,false,false,true,true,128,72,23.976},
+ {"pre-fsr-two",2,false,false,true,true,128,72,23.976},
+ {"pre-fsr-temporal",1,true,false,true,true,128,72,23.976},
+ {"pre-fsr-flow-file",1,false,true,true,true,128,72,23.976},
+ {"pre-fsr-flow-xsx-1080",1,false,true,true,true,1920,1080,60},
+ {"post-fsr-one",1,false,false,false,true,128,72,23.976},
+ {"pre-blit-one",1,false,false,true,false,128,72,60},
+ {"pre-fsr-zero-strength",1,false,false,true,true,128,72,60,0},
+ {"off-fsr-flow",0,false,true,false,true,128,72,60}
+ };
+ SetEnvironmentVariableA("VEYRA_TEST_LMXXF_MODE","marker");
+ for(const auto& c:cases){
+ AVFrame* frame=av_frame_alloc();frame->format=AV_PIX_FMT_RGBA;frame->width=int(c.width);frame->height=int(c.height);
+ if(av_frame_get_buffer(frame,32)<0){av_frame_free(&frame);++failures;continue;}
+ for(int y=0;y<frame->height;++y)for(int x=0;x<frame->width;++x){auto* p=frame->data[0]+y*frame->linesize[0]+x*4;p[0]=32;p[1]=96;p[2]=160;p[3]=255;}
+ pipeline::EnhanceGraphDesc gd;
+ gd.sourceWidth=c.width;gd.sourceHeight=c.height;gd.workWidth=c.width*2;gd.workHeight=c.height*2;
+ gd.rgbInput=true;gd.enableNr=c.layers>0;gd.enableSr=c.fsr;gd.enableFg=false;gd.nrBeforeSr=c.beforeSr;
+ gd.videoSrQuality=c.fsr?engine::kVideoSrFsr:0;
+ gd.nrRuntime=engine::NrRuntime::LmxxfAmd;gd.nrMotion=gd.fgMotion=engine::MotionSource::Zero;
+ gd.srMotion=c.flow?engine::MotionSource::OpticalFlow:engine::MotionSource::Zero;
+ gd.opticalFlowBackend=engine::OpticalFlowBackend::AmdFidelityFx;
+ gd.runtimeAbsPath=std::filesystem::absolute("runtime/nvidia").wstring();
+ gd.nrWidth=c.width;gd.nrHeight=c.height;
+ gd.nrLayersModel.resize(c.layers);gd.nrLayersResidual.resize(c.layers);
+ for(auto& r:gd.nrLayersResidual)r.total=c.strength;
+ gd.nrLayersTemporal.assign(c.layers,c.temporal);gd.nrLayersSizePolicy.assign(c.layers,pipeline::NrSizePolicy::Native);
+ gd.nrLayersExtent.assign(c.layers,{c.width,c.height});
+ pipeline::EnhanceGraph graph(ctx,ring);
+ bool executed=graph.initialize(gd)&&graph.createViews();
+ executed=executed&&(!c.fsr||graph.fsrSrEnabled());
+ const uint8_t marker[3]={188,99,71},original[3]={32,96,160};
+ const auto* expected=c.layers&&c.strength>0?marker:original;
+ unsigned worst=0,first=0,last=0;
+ for(unsigned f=0;executed&&f<6;++f){
+ pipeline::EnhanceGraph::FrameOutputs out;sink::RgbaImage image;
+ executed=graph.process(frame,double(f)*1000/c.fps,f==0||f==3,out,f+1)&&
+ sink::readRgba8(ctx,ring,graph.videoFrameResource(out.videoSlot),image);
+ executed=executed&&image.width==gd.workWidth&&image.height==gd.workHeight;
+ unsigned error=0;
+ if(executed)for(unsigned y=1;y<=3;++y)for(unsigned x=1;x<=3;++x)for(unsigned ch=0;ch<3;++ch){
+ const auto offset=(size_t(image.height*y/4)*image.width+image.width*x/4)*4+ch;
+ error=std::max(error,unsigned(std::abs(int(image.pixels[offset])-int(expected[ch]))));
+ }
+ worst=std::max(worst,error);if(f==0)first=error;last=error;
+ }
+ const auto nr=graph.metrics().nrEvaluateCount,sr=graph.metrics().srEvaluateCount;
+ const uint64_t expectedSr=c.fsr?(c.flow?4:6):0;
+ const bool pass=executed&&worst<=3&&nr==uint64_t(c.layers)*6&&sr==expectedSr;
+ ring.drainQueue();graph.shutdown();av_frame_free(&frame);++checks;failures+=!pass;
+ std::cout<<"AMD_NR_SR_MARKER case="<<c.name<<" output="<<gd.workWidth<<'x'<<gd.workHeight
+ <<" fps="<<c.fps<<" nr="<<nr<<" sr="<<sr<<" firstError="<<first<<" lastError="<<last
+ <<" worstCodeDifference="<<worst<<" executed="<<executed<<" pass="<<pass<<'\n';
+ }
+ SetEnvironmentVariableA("VEYRA_TEST_LMXXF_MODE",nullptr);
+}
+}
int main(){
CoInitializeEx(nullptr,COINIT_MULTITHREADED);
gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status st=Status::Ok;
@@ -25,6 +88,7 @@ int main(){
p[0]=uint8_t(30+x);p[1]=uint8_t(40+y*2);p[2]=uint8_t(210-x);p[3]=255;
}
unsigned failures=0,checks=0;
+ checkSrHandoff(ctx,ring,checks,failures);
sink::RgbaImage reference;
for(unsigned layers:{0u,1u,2u,4u})for(bool temporal:{false,true}){
if(!layers&&temporal)continue;
@@ -93,6 +157,18 @@ int main(){
<<" evaluated="<<evaluated<<" maxCodeDifference="<<maximum<<" pass="<<ok<<'\n';
}
uint32_t removed=0;if(!ctx.checkDeviceAlive(removed))++failures;
+ Microsoft::WRL::ComPtr<ID3D12InfoQueue> info;
+ if(SUCCEEDED(ctx.device()->QueryInterface(IID_PPV_ARGS(&info)))){
+ unsigned errors=0;
+ for(UINT64 i=0;i<info->GetNumStoredMessages();++i){
+ SIZE_T bytes=0;info->GetMessage(i,nullptr,&bytes);std::vector<uint8_t> storage(bytes);
+ auto* message=reinterpret_cast<D3D12_MESSAGE*>(storage.data());
+ if(SUCCEEDED(info->GetMessage(i,message,&bytes))&&message->Severity<=D3D12_MESSAGE_SEVERITY_ERROR){
+ if(errors<12)std::cout<<"D3D12_ERROR id="<<message->ID<<" "<<message->pDescription<<'\n';++errors;
+ }
+ }
+ failures+=errors>0;std::cout<<"D3D12_DEBUG errors="<<errors<<'\n';
+ }else{++failures;std::cout<<"D3D12_DEBUG unavailable\n";}
av_frame_free(&frame);CoUninitialize();
std::cout<<"Shared AMD composition GPU test: "<<checks<<" cases, "<<failures<<" failures. Not HIP inference.\n";
return failures?1:0;
diff --git a/tests/unit/LmxxfNrFakeRuntime.cpp b/tests/unit/LmxxfNrFakeRuntime.cpp
index 72bd9759..0eb45f6e 100644
--- a/tests/unit/LmxxfNrFakeRuntime.cpp
+++ b/tests/unit/LmxxfNrFakeRuntime.cpp
@@ -1,14 +1,22 @@
// SPDX-License-Identifier: GPL-3.0-only
-// A test-only identity-copy C ABI provider. No HIP, weights or NR inference.
+// A test-only identity/marker C ABI provider. No HIP, weights or NR inference.
#include "../../third_party/lmxxf/LmxxfNrApi.h"
#include <windows.h>
#include <d3d12.h>
#include <wrl/client.h>
#include <string>
#include <cstring>
+#include <cstdint>
using Microsoft::WRL::ComPtr;
namespace {
-struct Session { ID3D12Resource* color=nullptr; ComPtr<ID3D12Resource> output; ComPtr<ID3D12Device> device; ID3D12CommandQueue* queue=nullptr; unsigned state=0; };
+struct Session {
+ ID3D12Resource* color=nullptr;
+ ComPtr<ID3D12Resource> output,markerUpload;
+ D3D12_PLACED_SUBRESOURCE_FOOTPRINT markerFootprint{};
+ ComPtr<ID3D12Device> device;
+ ID3D12CommandQueue* queue=nullptr;
+ unsigned state=0;
+};
std::string mode(){char b[64]{};GetEnvironmentVariableA("VEYRA_TEST_LMXXF_MODE",b,sizeof(b));return b;}
int caps(LmxxfNrCapabilities* p){p->abi_version=1;p->max_input_width=1920;p->max_input_height=1080;return 0;}
int create(const LmxxfNrCreateInfo* p,void** out){if(p->flags||!p->device||!p->queue)return 2;auto* s=new Session;s->device=static_cast<ID3D12Device*>(p->device);s->queue=static_cast<ID3D12CommandQueue*>(p->queue);*out=s;return 0;}
@@ -19,7 +27,24 @@ int prepare(void* p,const LmxxfNrFrameInfo* info,LmxxfNrJob* job){
if(mode()=="oldabi"&&info->struct_size!=LMXXF_NR_FRAME_INFO_V1_SIZE)return 2;
s->color=static_cast<ID3D12Resource*>(info->color);
if(!s->output){auto desc=s->color->GetDesc();desc.Flags=D3D12_RESOURCE_FLAG_NONE;D3D12_HEAP_PROPERTIES heap{};heap.Type=D3D12_HEAP_TYPE_DEFAULT;
- if(FAILED(s->device->CreateCommittedResource(&heap,D3D12_HEAP_FLAG_NONE,&desc,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE,nullptr,IID_PPV_ARGS(&s->output))))return 5;}
+ if(FAILED(s->device->CreateCommittedResource(&heap,D3D12_HEAP_FLAG_NONE,&desc,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE,nullptr,IID_PPV_ARGS(&s->output))))return 5;
+ if(mode()=="marker"){
+ if(desc.Format!=DXGI_FORMAT_R16G16B16A16_FLOAT)return 2;
+ UINT64 bytes=0;s->device->GetCopyableFootprints(&desc,0,1,0,&s->markerFootprint,nullptr,nullptr,&bytes);
+ D3D12_RESOURCE_DESC upload{};upload.Dimension=D3D12_RESOURCE_DIMENSION_BUFFER;upload.Width=bytes;
+ upload.Height=1;upload.DepthOrArraySize=1;upload.MipLevels=1;upload.SampleDesc.Count=1;
+ upload.Layout=D3D12_TEXTURE_LAYOUT_ROW_MAJOR;heap.Type=D3D12_HEAP_TYPE_UPLOAD;
+ if(FAILED(s->device->CreateCommittedResource(&heap,D3D12_HEAP_FLAG_NONE,&upload,D3D12_RESOURCE_STATE_GENERIC_READ,nullptr,IID_PPV_ARGS(&s->markerUpload))))return 5;
+ uint8_t* mapped=nullptr;D3D12_RANGE noRead{};
+ if(FAILED(s->markerUpload->Map(0,&noRead,reinterpret_cast<void**>(&mapped))))return 5;
+ // Exact half floats: linear (0.5, 0.125, 0.0625, 1). Constant,
+ // deliberately different from the input; uploaded once per session.
+ const uint16_t pixel[4]={0x3800,0x3000,0x2c00,0x3c00};
+ for(UINT y=0;y<desc.Height;++y)for(UINT64 x=0;x<desc.Width;++x)
+ std::memcpy(mapped+s->markerFootprint.Offset+size_t(y)*s->markerFootprint.Footprint.RowPitch+size_t(x)*sizeof(pixel),pixel,sizeof(pixel));
+ s->markerUpload->Unmap(0,nullptr);
+ }
+ }
job->handle=s;job->private_output=s->output.Get();s->state=1;return 0;
}
int inputs(void* p,void* job,void* list){auto* s=static_cast<Session*>(p);if(job!=s||!list||s->state!=1)return 2;s->state=2;return 0;}
@@ -30,7 +55,12 @@ int outputs(void* p,void* job,void* cmd){
for(auto& v:b)v.Type=D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
b[0].Transition={s->color,D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE,D3D12_RESOURCE_STATE_COPY_SOURCE};
b[1].Transition={s->output.Get(),D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE,D3D12_RESOURCE_STATE_COPY_DEST};
- list->ResourceBarrier(2,b);list->CopyResource(s->output.Get(),s->color);
+ list->ResourceBarrier(2,b);
+ if(s->markerUpload){
+ D3D12_TEXTURE_COPY_LOCATION source{};source.pResource=s->markerUpload.Get();source.Type=D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;source.PlacedFootprint=s->markerFootprint;
+ D3D12_TEXTURE_COPY_LOCATION target{};target.pResource=s->output.Get();target.Type=D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
+ list->CopyTextureRegion(&target,0,0,0,&source,nullptr);
+ }else list->CopyResource(s->output.Get(),s->color);
for(auto& v:b)std::swap(v.Transition.StateBefore,v.Transition.StateAfter);list->ResourceBarrier(2,b);s->state=4;return 0;
}
int retire(void* p,void* job){auto* s=static_cast<Session*>(p);if(job!=s||s->state!=4)return 2;s->state=0;return 0;}