Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

Add isolated FSR 4.1 INT8 provider integration and local HDR test delivery

Veyra Goal Agent01d64dc9f45d
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 94c27d08..ca1fad86 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -786,6 +786,10 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avform
target_link_libraries(veyra_multichannel_tests PRIVATE veyra_engine)
add_executable(veyra_hdr_enhancement_tests tests/integration/HdrEnhancementTests.cpp)
add_executable(veyra_video_hdr_tests tests/integration/VideoHdrTests.cpp)
+ add_executable(veyra_fsr41_video_tests tests/integration/Fsr41VideoTests.cpp)
+ target_compile_features(veyra_fsr41_video_tests PRIVATE cxx_std_20)
+ target_compile_definitions(veyra_fsr41_video_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)
+ target_link_libraries(veyra_fsr41_video_tests PRIVATE veyra_engine)
target_compile_features(veyra_video_hdr_tests PRIVATE cxx_std_20)
target_compile_definitions(veyra_video_hdr_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)
target_link_libraries(veyra_video_hdr_tests PRIVATE veyra_engine)
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md
index 984be2dd..e409b99c 100644
--- a/THIRD_PARTY_NOTICES.md
+++ b/THIRD_PARTY_NOTICES.md
@@ -315,6 +315,27 @@ This runtime retains the NVIDIA RTX Video SDK license; it is not relicensed unde
Veyra's GPL. SDK/license and runtime remain external. This change does not publish
or grant redistribution of a new runtime pack.
+## FSR 4.1.1 INT8 research provider (local integration, 2026-09-18)
+
+Source: https://github.com/int3rrobang/fsr4-int8-reverse-engineering
+Commit: `88635b94083965a7c3b5f64e099808b8ba2ce576`, MIT.
+Copyright and license retained in `scripts/fsr41/LICENSE.txt`.
+`scripts/fsr41/provider-veyra.patch` adapts upstream
+`bench/provider411/{provider.h,provider.cpp,frame.cpp,ffx_api_impl.cpp}`:
+six caller-selected fence-retired descriptor/CBV slots; reset on the caller
+command list with immutable clear descriptors; owned-resource destruction;
+explicit exposure instead of approximate auto-exposure. Build/provenance and
+limitations are recorded in `scripts/fsr41/README.md`.
+
+The original upstream checkout, AMD official data, extracted containers/weights,
+generated shader arrays and compiled provider remain outside Veyra Git. Local
+data source is FidelityFX SDK 2.3.0 commit
+`60f4ea81909200d8542eca14dccb2628b763a9a3`, upscaler 4.1.1.2740, SHA256
+`D0DCCCC74A43C44BA435B7A369B456E0970D8A4464E4BD683119B374F2C9FB46`.
+AMD's `docs/license.md` explicitly lists this upscaler DLL in its MIT exception.
+This does not relicense unrelated SDK files or NVIDIA/Intel runtimes. The
+provider is an experimental implementation, not AMD support for NVIDIA.
+
## dav1d (1.3.0 AV1 playback)
FFmpeg dynamically links dav1d 1.5.4 from the pinned local vcpkg build. The portable package includes its complete aggregated copyright/license text in `licenses/DAV1D-COPYRIGHT.txt` and provenance in `licenses/DAV1D-SPDX.json`. The FFmpeg corresponding-source ZIP includes dav1d source and its vcpkg port. Upstream: https://code.videolan.org/videolan/dav1d . License set recorded by the build: Apache-2.0, BSD-2-Clause, ISC and MIT; retain all notices supplied with the source.
diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.md
index 7c8bfbae..ccb6f1f7 100644
--- a/docs/CURRENT_STATUS.md
+++ b/docs/CURRENT_STATUS.md
@@ -21,7 +21,9 @@
- 存档提交 `0e3d4ac`,标签 `checkpoint/pre-video-hdr-fsr41-20260918`。
- 隔离分支 `codex/video-hdr-20260918`;工作区 `E:/项目/Veyra/worktrees/video-hdr-20260918`。
- RTX Video HDR 已接入共享图、设置和 Main10 导出;RTX 5070 / 616.56 上 Create/Evaluate、2X/4X/6X、NR+SR+6X、原生 HDR 回归、HDR 导出与缺库 SDR 回退通过。显示器 HDR 当前未开启,实际 HDR 显示、采集卡、PS5 与 RTX 30/40 未执行。
-- NVIDIA FSR 4.1.1 固定提交的 INT8 研究 provider 已构建,五个导出符号与 CPU 查询通过;GPU 接入尚未执行。上游三槽资源复用及私有队列 reset 需要适配,不默认开放 UI。
+- HDR 里程碑提交 `3477ed2`;后续隔离分支 `codex/fsr41-nvidia-20260918`,同名外部工作区。
+- NVIDIA FSR 4.1.1 INT8 provider 已完成六槽生命周期、同队列 reset、GPU 格式转换和共享图接入;RTX 5070 实际 dispatch、两次独立持续处理、奇数尺寸 D3D12 debug、影片对照及 NR+HDR+DLSS 6X 通过。它仍是显式环境变量开启的研究入口:固定 960x540 模型中间工作类、零 jitter、估计运动/常量深度;不宣称画质更好或 30/40 实卡通过。
+- HDR 参数页在 1280x800 窗口已目视检查,滑块数值即时更新。全部测试、限制及本地包说明见 [本地测试记录](LOCAL_HDR_FSR41_TEST_2026-09-18.md)。
- 本轮无 push、Release 或新增运行库发布授权。
所有新产物放 `E:/项目/Veyra/`,源码/文档留在隔离工作区;逐项结果以 [WORKLOG](WORKLOG.md) 为准。
diff --git a/docs/LOCAL_HDR_FSR41_TEST_2026-09-18.md b/docs/LOCAL_HDR_FSR41_TEST_2026-09-18.md
new file mode 100644
index 00000000..64faee62
--- /dev/null
+++ b/docs/LOCAL_HDR_FSR41_TEST_2026-09-18.md
@@ -0,0 +1,46 @@
+# RTX Video HDR / NVIDIA FSR4 本地测试
+
+这是基于 1.4.1 的本地实验构建,未发布、未合并 main。
+
+## 使用
+
+- 视频 HDR:专业模式 -> 增强页,向下滚动到 RTX Video HDR。默认关闭,支持对比度、饱和度、中间灰、峰值亮度;设置会保存。
+- 预览需要 Windows HDR 与 HDR 显示器;当前显示器未启用 HDR 时保留 SDR 预览。离屏 HDR 视频导出不依赖显示器 HDR,使用 HEVC Main10 / BT.2020 / PQ。
+- 原生 HDR 输入不再做 SDR 转 HDR。字幕与 OSD 在 FG 之后合成。游戏版 RTX HDR 没有加入。
+- FSR4 provider 不随此包分发。研究构建在本机 `E:/项目/Veyra/build/fsr41-provider-20260918/Release/amd_fidelityfx_upscaler_dx12.dll`。仅对测试进程设置 `VEYRA_FSR41_PROVIDER` 为此绝对路径,并选择既有 FSR 超分档;关闭环境变量即走原来的官方 FSR。详情见 `scripts/fsr41/README.md`(包内 `docs/FSR41_EXPERIMENT.md`)。
+- FSR4 失败会报告并关闭 SR,不以 FSR3 成功冒充 FSR4。原有运行库替换自由不变,身份日志不是加载锁。
+
+## 实测
+
+本机 RTX 5070,驱动 616.56 / 32.0.16.1656。以下是本机证据,不替代 30/40 系实测。
+
+HDR:TrueHDR Create/Evaluate/Release 均为 0x1,SEH=0;独立 HDR、DLSS 2X/4X/6X、NR+DLSS SR+6X、原生 HDR 回归通过。90 帧 HDR 导出经开发期 ffprobe 与解码确认 Main10、10bit、BT.2020/PQ;缺 DLL 时 SDR 导出回退通过。未恢复产品导出结束扫描。预设 roundtrip 与 66 个旧格式迁移通过。参数页在 1280x800 窗口无文字重叠,滑块中灰 44 -> 59 即时更新;当前 SDR 显示不能证明实际屏幕 HDR 效果。
+
+FSR4:CPU smoke 和六槽调用方 ABI 通过。使用上游固定提交的真实 ML passes,包含 R11G11B10 输入/输出适配。实验 DLL 874496 字节,未签名,SHA256 `F6EB66096E80CB9A8C066FA7519CF5C82442D0876C8C7A461F489402A6AD44F2`。
+
+| 测试 | 结果 |
+|---|---|
+| 720p -> 1080p 持续处理 | 12000 帧,11675 次 SR,53.24 秒;command GPU 平均 1.84 / P95 4.34 ms;显存 345 -> 388 MiB |
+| 1080p -> 2160p 持续处理 | 3600 帧,3502 次 SR,23.39 秒;command GPU 平均 1.66 / P95 3.88 ms;显存 1088 -> 1131 MiB |
+| 1279x719 -> 1919x1079 | 90 帧 / 87 次 SR,D3D12 debug errors=0 |
+| NR + FSR4 + HDR + DLSS 6X | NR 12、SR 10、生成批次 10,像素与参数变化检查通过 |
+| 实际影片 720p -> 1080p | 同一 60 帧:普通缩放 SR=0、FSR3/FSR4 各 58 次;输出均非空并保持内容 |
+
+持续处理是两个分别重启的进程,不能称为连续十分钟。GPU 时间为整条 command list,不是完整播放链路或单独 SR 的时间,不等于屏幕 FPS。首帧及每 37 帧 reset 时没有光流则暂不 SR,计数不伪造;pending reset 保留到下一次实际 dispatch。
+
+实际影片同帧 PNG 位于 `E:/项目/Veyra/tests/fsr41-nvidia-20260918/media-{baseline,fsr3,fsr4}/fsr-frame.png`。已目视检查内容和几何,FSR4 与基线差异较小,合成棋盘存在边缘/调性差异;没有足够证据宣称画质提升。该对照不是长片动态拖影/闪烁验收。
+
+## 限制与下一步
+
+FSR4 上游模型的中间工作类固定 960x540,PRE/POST 支持不同几何不等于原生 4K 模型质量。视频没有游戏引擎的 jitter、真实 motion/depth;使用零 jitter、估计光流、常量深度和固定曝光。第一次 Create 实测 23.7 秒,后续进程约 0.5 秒;冷启动仍有明显等待。
+
+未执行:RTX 30/40 新功能矩阵、真实 HDR 显示/跨屏、物理采集/PS5 HDR 转换、所有颜色格式和完整动态画质场景。现有 30/40 DLSS 兼容代码没有在本轮修改,但不以 5070 测试代替回归实卡。
+
+下一步:HDR 显示器和 RTX 30/40 本地测试包验收;FSR4 在形成可靠的动态画质证据前保持实验入口。
+
+## 产物与源码
+
+- HDR 提交 `3477ed2`,分支 `codex/video-hdr-20260918`。
+- FSR 分支 `codex/fsr41-nvidia-20260918`,源码在 `E:/项目/Veyra/worktrees/fsr41-nvidia-20260918`。
+- 构建、测试、日志、临时文件分别位于 `E:/项目/Veyra/{build,tests,logs,tmp}/{video-hdr-20260918,fsr41-nvidia-20260918}`。
+- 本地包目录:`E:/项目/Veyra/test-packages/hdr-fsr41-20260918`。二进制、SDK、影片与生成模型数据均未进入源码 Git。
diff --git a/docs/VIDEO_HDR_FSR41_EXECUTION_PLAN_2026-09-18.md b/docs/VIDEO_HDR_FSR41_EXECUTION_PLAN_2026-09-18.md
index 7208157c..dc9c60fa 100644
--- a/docs/VIDEO_HDR_FSR41_EXECUTION_PLAN_2026-09-18.md
+++ b/docs/VIDEO_HDR_FSR41_EXECUTION_PLAN_2026-09-18.md
@@ -70,7 +70,7 @@ FSR 4.1 provider 的官方 DLL、SDK 路径和 SHA-256 在开工时重新登记
- 输出使用 RGB10 PQ/BT.2020 或 FP16 scRGB 的一种明确路径;首个产品闭环优先 RGB10/PQ,以匹配已有 HDR10/HEVC 输出。
- 所有返回值、SEH、资源尺寸/格式、GPU 时间和失败参数进入日志;不照搬样例的逐帧 CPU 阻塞等待。
-TrueHDR 每个源帧最多执行一次,结果进入后续 FG。暂停、seek、resize、源切换、显示器 HDR 切换、device lost 和退出必须释放/重建 Feature 与资源。
+TrueHDR 每个源帧最多执行一次,结果进入后续 FG。实际 SDK 没有时序 reset 参数;暂停/seek 复用同一逐帧 Feature,其他历史模块仍按图合同 reset。尺寸、源、输出 HDR 状态及设备生命周期变化时随图释放/重建,退出释放。不能为暂停/seek 的每次刷新引入额外 CPU/GPU 等待。
### A3. 接入共享 EnhanceGraph
@@ -128,7 +128,7 @@ Video HDR 阶段只有在“播放不回退错误、导出可解码、颜色 met
### B2. Veyra 适配层
-新增实验 `Fsr41NvidiaBackend`,复用 `FsrSrBackend` 的 graph 入口和资源生命周期,但不把 4.1 provider 伪装成现有 AMD 3.1 provider:
+在现有 `FsrSrBackend` 内新增显式实验 provider 分支,复用 graph 入口和资源生命周期;由绝对路径、精确版本与调用方槽位 ABI 区分,不另建重复 backend,也不把 4.1 provider 伪装成现有 AMD 3.1 provider:
- provider 路径、版本、哈希和实验状态显式记录。
- 查询版本后只选择确实为 4.1.1 INT8 的 provider;未知版本拒绝创建。
@@ -171,7 +171,7 @@ FSR 4.1 实验不修改 NVAPI 伪装、DLSS MFG 解锁或现有 FG 调度;这
3. 完成 Main10 导出、字幕/OSD、设置保存、回退和专项日志。
4. 运行 Video HDR 自动门与实机矩阵;未通过项写明,不用旧 HDR 记录替代。
5. 从 HDR 稳定提交建立 FSR4 实验分支,构建上游 provider smoke。
-6. 接入 Fsr41NvidiaBackend 和独立探针,完成 A/B 与硬件矩阵。
+6. 接入 FsrSrBackend 实验分支和独立探针,完成本机 A/B 并记录硬件矩阵缺项。
7. 只有两阶段证据齐全后才讨论 UI 默认项、Release runtime 和版本号。
## 执行记录
@@ -180,4 +180,4 @@ FSR 4.1 实验不修改 NVAPI 伪装、DLSS MFG 解锁或现有 FG 调度;这
RTX 5070 / 616.56:Create/Evaluate/Release 0x1、SEH 0;HDR 独立、2X/4X/6X、NR+DLSS SR+6X、原生 HDR 回归通过。90 帧导出为 Main10/P010 等价编码、BT.2020/PQ,开发期 ffprobe/解码通过;移走 TrueHDR 后导出 SDR 通过。预设 roundtrip/迁移通过。实际 HDR 显示(当前 Windows HDR 未开启)、跨屏、物理采集、PS5 和 RTX 30/40 未执行,不据离屏测试宣称全链路实卡验收。
-FSR provider 已从固定上游提交在外部目录生成/构建,CPU smoke 通过,尚无 GPU 结果。发现三组 CBV/descriptor 的生命周期不能覆盖 Veyra command ring,以及 reset 使用私有队列;B 阶段先修这些合同。命令、数据和路径见 WORKLOG。
+FSR provider 已从固定上游提交在外部目录生成/构建,完成六槽资源与同队列 reset 适配。CPU smoke、RTX 5070 真实影片和合成序列、奇数尺寸、NR+HDR+6X 组合均通过;首次创建耗时 23.7 秒,后续进程约 0.5 秒,不能忽略冷启动成本。画质尚未通过正式开放标准,保持诊断入口;30/40、实际 HDR 显示和完整动态场景矩阵未执行。实际命令和结果见 WORKLOG 与 LOCAL_HDR_FSR41_TEST_2026-09-18.md。
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 5ffbaf6b..c791c90f 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -1,5 +1,30 @@
# Veyra 工作记录
+## 2026-09-18 FSR4 NVIDIA 接入、本地影片验证与测试包
+
+从 HDR 里程碑 `3477ed2` 建立分支 `codex/fsr41-nvidia-20260918`,工作区 `E:/项目/Veyra/worktrees/fsr41-nvidia-20260918`。main 保持存档 `0e3d4ac`;没有 push、Release 或合并 main。
+
+修改:FsrSrBackend 的显式 provider 路径、版本和六槽 ABI;EnhanceGraph 的 R11 输入/输出 GPU 转换、奇数宽度 depth 上传行距、NR-before-SR 输入、无光流帧 pending reset;CMake 与 Fsr41VideoTests;外部 provider 四文件补丁、许可证和重建脚本;package-portable 的 DependencyRoot 和本地 HDR 开关;当前状态、施工方案、测试说明与第三方来源。没有修改 DLSS 30/40 解锁代码;没有把 SDK/权重/DLL 放进 Git。
+
+外部源码固定 `int3rrobang/fsr4-int8-reverse-engineering@88635b94083965a7c3b5f64e099808b8ba2ce576`。`scripts/fsr41/build-provider.ps1` 使用外部源码/构建/临时目录及本机 SDK 参数,以 `-ReuseGenerated` 重建并执行 CPU smoke 通过(provider-repro-script.log);`git -C <external> apply --reverse --check <worktree>/scripts/fsr41/provider-veyra.patch` 通过。首次完整 codegen 的 16 containers、t18/11 kernels 和 AE 构建日志保留。provider DLL 的 SHA256/大小/未签名记录见 LOCAL_HDR_FSR41_TEST_2026-09-18.md,日志身份检查不阻止用户替换 DLL。
+
+产品构建实际命令:`./scripts/build-isolated.ps1 -Root . -BuildDirectory E:/项目/Veyra/build/fsr41-nvidia-20260918 -DependencyCache E:/项目/Veyra/build/video-hdr-20260918/CMakeCache.txt -TempDirectory E:/项目/Veyra/tmp/fsr41-nvidia-20260918 -Targets veyra,veyra_fsr41_video_tests,veyra_video_hdr_tests`。最终 final-build.log exit 0;中间曾把身份日志插入 dispatch 作用域、误用 packet.color,编译指出错误后修正为初始化阶段和 packet.colorInfo。patched FFmpeg 保持,未更换系统驱动。
+
+日志根 `E:/项目/Veyra/logs/fsr41-nvidia-20260918`,测试根 `E:/项目/Veyra/tests/fsr41-nvidia-20260918`,所有子进程 TEMP/TMP 指向 `E:/项目/Veyra/tmp/fsr41-nvidia-20260918`。实际命令/结果(RTX 5070 / 616.56):
+
+- `veyra_fsr41_video_tests.exe <provider> 12000 1280 720 1920 1080`:12000/11675,53.24 秒,pass=1(gpu-sustained1.log)。
+- 同探针 `<provider> 3600 1920 1080 3840 2160`:3600/3502,23.39 秒,pass=1(gpu-sustained2-4k.log)。两次分别启动,不宣称十分钟稳定性。
+- `VEYRA_FSR_TEST_DEBUG=1` 与 `<provider> 90 1279 719 1919 1079`:pass=1,debugErrors=0(gpu-odd-debug.log)。普通缩放与 FSR3 合成对照分别通过(gpu-baseline.log、gpu-fsr3.log)。
+- 由用户 MKV 第 120 秒附近生成 3 秒 720p 私有测试片(FFmpeg libx264 CRF16,仅开发素材),同探针 `{baseline|fsr3|provider} 60 1280 720 1920 1080 ../media.mp4`:全部 pass=1,SR 分别 0/58/58(media-*.log)。目视同帧 PNG 内容与几何正常;不能据单帧宣称动态质量提升。系统 FFmpeg 仅制作素材,产品仍链接 patched FFmpeg。
+- `VEYRA_FSR41_PROVIDER=<provider>` + `veyra_video_hdr_tests.exe 6 1 5`:TrueHDR/NR/FG 返回成功,NR12/SR10/生成批次10、peak390.673 nit、parameterChange0.368853(gpu-hdr-nr-fsr4-fg6.log)。最终复测首次因为既有 video-hdr.jxr 拒绝覆盖而 exit5(final-combination.log);在全新 final-combination 目录复测 exit0(final-combination-fresh-output.log),不删除失败记录。
+- `veyra.exe --video-hdr --no-nr --no-fg --smoke-seconds 180 --smoke-view professional <media>`:Computer Use 在 1280x800 窗口检查参数页,四项标签/滑块无重叠,中灰44->59即时更新。当前 Windows HDR 未启用,屏幕内容仍为 SDR 回退,未声称屏幕 HDR 通过。
+
+FSR4 初次 Create 耗时23.7秒,后续独立进程约0.5秒。中间模型固定960x540,视频输入零jitter/估计光流/常量depth,棋盘有边缘/调性差异。保持显式实验入口,provider 不放入本地便携包。硬件矩阵、完整动态画质、实际 HDR 显示/跨屏、物理采集和 PS5 未执行;单次测试均小于300秒。本次使用针对性回归,未运行仍有旧产物路径假设的通用 delivery.ps1。
+
+打包命令:`./scripts/package-portable.ps1 -Root . -DependencyRoot 'C:/Users/123/Desktop/Veyra DLSS Video Player' -Version 1.4.1 -BuildDirectory E:/项目/Veyra/build/fsr41-nvidia-20260918 -OutputDirectory E:/项目/Veyra/test-packages/hdr-fsr41-20260918 -Label '-video-hdr-test' -LocalVideoHdr`,exit0。包 `Veyra-1.4.1-video-hdr-test-win64-portable.zip` 为467052957字节,SHA256 `19BDF78CA0F32822DC9A3477939C2173CF078486477E6EDCDAE18D4AE2F46C2A`。含 TrueHDR 1.1.0 原件及 NVIDIA SDK 许可证、逐文件 runtime manifest;本地评估,不上传。运行包内 Veyra 同参数8秒 smoke exit0;114个 package-manifest 文件哈希一致,forbiddenFiles=0。短测产生的单个 app 日志移回本任务 logs;没有额外解压副本或中间包要保留。
+
+文档已先刷新后按真实结果更新;全部实现和必要记录留在隔离区,最终提交后检查工作区干净。下一步仅为用户在 HDR 显示器及 RTX30/40 上的实际体验验收,FSR4 的正式开放仍需动态画质证据。
+
## 2026-09-18 Video HDR 共享图实现与 RTX 5070 验证
新增 TrueHdrBackend、VideoHdrSettings、VideoHdrTests 与 build-isolated.ps1;更新 EnhanceGraph 的输入/工作/输出 HDR 合同、共享 graph/恢复/状态、Presenter SDR 对比白位、设置页与 schema 20、Main10 导出、CMake/资源脚本和导出探针。TrueHDR 在 SDR NR/SR/调色后、FG 前执行,原生 HDR 跳过;默认关闭。数值调整不重建图,开关按现有生命周期重建。新 DLL 仅在外部构建目录,未入 Git。
diff --git a/include/veyra/gfx/FsrSrBackend.h b/include/veyra/gfx/FsrSrBackend.h
index 93a3bc65..0e4a567b 100644
--- a/include/veyra/gfx/FsrSrBackend.h
+++ b/include/veyra/gfx/FsrSrBackend.h
@@ -38,10 +38,12 @@ public:
// as UAV); `motion` is render-extent pixel motion, `depth` render extent.
bool evaluate(ID3D12GraphicsCommandList* list, ID3D12Resource* color, ID3D12Resource* motion,
ID3D12Resource* depth, ID3D12Resource* output, uint32_t renderWidth, uint32_t renderHeight,
- uint32_t upscaleWidth, uint32_t upscaleHeight, bool reset, float frameTimeMs);
+ uint32_t upscaleWidth, uint32_t upscaleHeight, bool reset, float frameTimeMs,
+ uint32_t commandSlot = UINT32_MAX);
void release();
bool created() const;
+ bool experimental411() const;
uint64_t evaluateCount() const;
uint64_t failureCount() const;
const char* providerVersion() const;
diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.h
index 19c10dd8..20c40098 100644
--- a/include/veyra/pipeline/EnhanceGraph.h
+++ b/include/veyra/pipeline/EnhanceGraph.h
@@ -409,7 +409,9 @@ private:
std::unique_ptr<ngx::TrueHdrBackend> videoHdrBackend_;
std::unique_ptr<ngx::DlssFgBackend> fgBackend_;
std::unique_ptr<gfx::FsrSrBackend> fsrSrBackend_;
+ bool fsrSrResetPending_ = true;
ComPtr<ID3D12Resource> fsrSrDepth_, upFsrSrDepth_;
+ ComPtr<ID3D12Resource> fsr41Input_, fsr41Output_;
size_t fsrSrDepthPitch_=0;
NVSDK_NGX_Parameter* ngxParams_ = nullptr;
NVSDK_NGX_Handle* nrHandle_ = nullptr;
diff --git a/scripts/fsr41/LICENSE.txt b/scripts/fsr41/LICENSE.txt
new file mode 100644
index 00000000..d3634459
--- /dev/null
+++ b/scripts/fsr41/LICENSE.txt
@@ -0,0 +1,22 @@
+MIT License
+
+Copyright (c) 2025 Advanced Micro Devices, Inc.
+Copyright (c) 2026 int3rrobang
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/scripts/fsr41/README.md b/scripts/fsr41/README.md
new file mode 100644
index 00000000..45eda4ea
--- /dev/null
+++ b/scripts/fsr41/README.md
@@ -0,0 +1,41 @@
+# Local FSR 4.1.1 INT8 provider
+
+Source: https://github.com/int3rrobang/fsr4-int8-reverse-engineering
+
+Pinned revision: `88635b94083965a7c3b5f64e099808b8ba2ce576` (MIT; LICENSE.txt).
+The source checkout and all generated data live outside Veyra Git.
+
+`provider-veyra.patch` adapts `bench/provider411/provider.h`, `provider.cpp`,
+`frame.cpp`, and `ffx_api_impl.cpp`:
+
+- Six descriptor/CBV slots, selected by Veyra's fence-retired command slot via
+ `veyraFsr411SetSlot(context, slot, 1)` before every dispatch.
+- Reset clears scratch/history/recurrent/reprojection on the caller list,
+ with immutable clear descriptors. No reset-time private queue/CPU wait.
+- Owned resources are released on context destruction.
+- Approximate auto-exposure is refused. Video uses explicit exposure 1.
+
+Build with `build-provider.ps1`. Supply the external checkout, external build
+and temporary directories, `SdkRoot` pointing to `Kits/FidelityFX`, the local
+official 4.1.1 DLL, Python and Windows SDK DXC. `ReuseGenerated` skips codegen
+only when rebuilding an existing generation. VS 2022 is required by this script.
+
+Source data used locally: FidelityFX SDK 2.3.0 revision
+`60f4ea81909200d8542eca14dccb2628b763a9a3`, official upscaler 4.1.1.2740,
+SHA256 `D0DCCCC74A43C44BA435B7A369B456E0970D8A4464E4BD683119B374F2C9FB46`.
+The SDK `docs/license.md` explicitly lists the upscaler DLL in its MIT exception;
+upstream `NOTICE.md` provides additional provenance. Neither document makes
+NVIDIA/Intel components MIT. Official data, weights, containers, generated
+shader arrays and the output DLL must never be committed to this repository.
+
+Opt in only for the current process using `VEYRA_FSR41_PROVIDER=<absolute DLL>`
+and select existing FSR SR mode 5. Without the variable, the existing official
+FSR path is used. A missing/incompatible experimental provider is reported;
+the engine disables SR rather than reporting an implicit FSR3 success.
+
+This is a research integration, not AMD support for NVIDIA. It uses zero
+jitter, estimated motion and constant depth. The upstream model's middle
+working class is fixed at 960x540 even though PRE/POST accept other geometries.
+Do not infer native 4K model quality or game-equivalent reconstruction from
+successful dispatch. The interface remains diagnostic until video quality,
+display behavior and the RTX 30/40 hardware matrix have been reviewed.
diff --git a/scripts/fsr41/build-provider.ps1 b/scripts/fsr41/build-provider.ps1
new file mode 100644
index 00000000..362fad92
--- /dev/null
+++ b/scripts/fsr41/build-provider.ps1
@@ -0,0 +1,50 @@
+[CmdletBinding()]
+param(
+ [Parameter(Mandatory)][string]$SourceDirectory,
+ [Parameter(Mandatory)][string]$BuildDirectory,
+ [Parameter(Mandatory)][string]$SdkRoot,
+ [Parameter(Mandatory)][string]$OfficialDll,
+ [Parameter(Mandatory)][string]$Dxc,
+ [Parameter(Mandatory)][string]$TempDirectory,
+ [string]$Python='python',
+ [switch]$ReuseGenerated
+)
+$ErrorActionPreference='Stop'
+Set-StrictMode -Version Latest
+$revision='88635b94083965a7c3b5f64e099808b8ba2ce576'
+$artifactRoot=[IO.Path]::GetFullPath('E:/项目/Veyra/').TrimEnd('\')+'\'
+foreach($directory in @($SourceDirectory,$BuildDirectory,$TempDirectory)) {
+ if(![IO.Path]::GetFullPath($directory).StartsWith($artifactRoot,[StringComparison]::OrdinalIgnoreCase)) {
+ throw 'Provider source, build and temporary data must stay below E:/项目/Veyra/'
+ }
+}
+if(![IO.File]::Exists($OfficialDll)){throw 'Supply the local official provider; this script does not download it'}
+$head=& git -C $SourceDirectory rev-parse HEAD
+if($LASTEXITCODE -or $head -ne $revision){throw "Expected upstream $revision"}
+$patch=Join-Path $PSScriptRoot 'provider-veyra.patch'
+& git -C $SourceDirectory apply --reverse --check $patch 2>$null
+if($LASTEXITCODE){
+ & git -C $SourceDirectory apply --check $patch
+ if($LASTEXITCODE){throw 'Patch conflicts with the external checkout'}
+ & git -C $SourceDirectory apply $patch
+ if($LASTEXITCODE){throw 'Patch failed'}
+}
+$vswhere=Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio/Installer/vswhere.exe'
+$vs=(& $vswhere -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | Select-Object -First 1)
+if(!$vs){throw 'MSVC is required'}
+$cmake=Join-Path $vs 'Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin/cmake.exe'
+$savedTemp=$env:TEMP;$savedTmp=$env:TMP
+New-Item -ItemType Directory -Force -Path $BuildDirectory,$TempDirectory | Out-Null
+try {
+ $env:TEMP=$TempDirectory;$env:TMP=$TempDirectory
+ if(!$ReuseGenerated){
+ & $Python (Join-Path $SourceDirectory 'bench/tools/build_411_dll.py') --dll $OfficialDll --ffx-sdk-root $SdkRoot --dxc $Dxc --build-dir $BuildDirectory --codegen-only
+ if($LASTEXITCODE){throw 'Provider code generation failed'}
+ }
+ & $cmake -S (Join-Path $SourceDirectory 'bench/provider411') -B $BuildDirectory -G 'Visual Studio 17 2022' -A x64 "-DFFX_SDK_ROOT=$SdkRoot" "-DFSR411_GEN_DIR=$BuildDirectory/gen"
+ if($LASTEXITCODE){throw 'Provider configure failed'}
+ & $cmake --build $BuildDirectory --config Release --parallel 4
+ if($LASTEXITCODE){throw 'Provider build failed'}
+ & (Join-Path $BuildDirectory 'Release/ffx411_smoke.exe') (Join-Path $BuildDirectory 'Release/amd_fidelityfx_upscaler_dx12.dll')
+ if($LASTEXITCODE){throw 'CPU API smoke failed'}
+} finally {$env:TEMP=$savedTemp;$env:TMP=$savedTmp}
diff --git a/scripts/fsr41/provider-veyra.patch b/scripts/fsr41/provider-veyra.patch
new file mode 100644
index 00000000..005b798b
--- /dev/null
+++ b/scripts/fsr41/provider-veyra.patch
@@ -0,0 +1,224 @@
+diff --git a/bench/provider411/ffx_api_impl.cpp b/bench/provider411/ffx_api_impl.cpp
+index e8648a1..ca5b0d3 100644
+--- a/bench/provider411/ffx_api_impl.cpp
++++ b/bench/provider411/ffx_api_impl.cpp
+@@ -60,6 +60,7 @@ struct Ffx411Context {
+ uint32_t maxRenderW = 0, maxRenderH = 0, maxUpscaleW = 0, maxUpscaleH = 0;
+ uint32_t createFlags = 0;
+ uint64_t frameIndex = 0;
++ int callerSlot = -1;
+ bool needsReset = true;
+ ffxApiMessage msgFn = nullptr;
+ // P4.1 live constants: previous-frame jitter (for MV jitter cancellation)
+@@ -416,6 +417,13 @@ FFX_API_ENTRY ffxReturnCode_t ffxDestroyContext(ffxContext* context, const ffxAl
+ return FFX_API_RETURN_OK;
+ }
+
++// ABI 1: caller acquires a fence-protected command slot before every dispatch.
++extern "C" __declspec(dllexport) uint32_t veyraFsr411SetSlot(ffxContext* context, uint32_t slot, uint32_t abi) {
++ if (!context || !*context || abi != 1 || slot >= fsr411::Provider::kFrameSlots) return 0;
++ reinterpret_cast<Ffx411Context*>(*context)->callerSlot = int(slot);
++ return 1;
++}
++
+ FFX_API_ENTRY ffxReturnCode_t ffxConfigure(ffxContext* context, const ffxConfigureDescHeader* desc) {
+ if (!desc) return FFX_API_RETURN_ERROR_PARAMETER;
+ if (desc->type == FFX_API_CONFIGURE_DESC_TYPE_GLOBALDEBUG1) {
+@@ -521,15 +529,20 @@ FFX_API_ENTRY ffxReturnCode_t ffxDispatch(ffxContext* context, const ffxDispatch
+ }
+
+ std::string err;
++ const int ring = ctx->callerSlot;
++ ctx->callerSlot = -1;
++ if (ring < 0 || wantAE) {
++ Msg(ctx, L"Veyra provider requires caller slot ABI 1 and explicit exposure=1 (no approximate AE)");
++ return FFX_API_RETURN_ERROR_PARAMETER;
++ }
+ if (getenv("ORACLE_NOZERO")) ctx->needsReset = false;
+ const bool didZero = (d->reset || ctx->needsReset);
+ if (didZero && !getenv("ORACLE_NOZERO")) {
+- if (!ctx->provider.ZeroFrameState(&err)) {
++ if (!ctx->provider.RecordZeroFrameState(cl, &err)) {
+ return FFX_API_RETURN_ERROR_RUNTIME_ERROR;
+ }
+ ctx->needsReset = false;
+ }
+- const int ring = (int)(ctx->frameIndex % 3);
+ // P4.1 live constants: the embedded CBVs carry the captured frame's
+ // jitter/scale/exposure; reusing them verbatim breaks every live frame's
+ // temporal feedback (ghosting -> accumulation blowout). Patch this ring's
+diff --git a/bench/provider411/frame.cpp b/bench/provider411/frame.cpp
+index a0f2124..23298fe 100644
+--- a/bench/provider411/frame.cpp
++++ b/bench/provider411/frame.cpp
+@@ -165,7 +165,7 @@ bool Provider::CreateFrameShells(const uint8_t* preCbv, size_t npre,
+ if (!CreateUpload(device_, postCbv, npost, &postCbv1_, err)) return false;
+ if (!SetTensorCbBytes(tensor, ntensor, err)) return false;
+ // Ring heaps (views written per dispatch by BuildFrameHeaps).
+- for (int r = 0; r < 3; ++r) {
++ for (int r = 0; r < kFrameSlots; ++r) {
+ D3D12_DESCRIPTOR_HEAP_DESC hd = {};
+ hd.NumDescriptors = 31; hd.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
+ hd.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
+@@ -177,7 +177,7 @@ bool Provider::CreateFrameShells(const uint8_t* preCbv, size_t npre,
+ }
+ // P4.1 live-constant rings (upload heaps, CPU-visible) seeded from the
+ // measured exports; per-frame fields patched by PatchFrameCbvs.
+- for (int r = 0; r < 3; ++r) {
++ for (int r = 0; r < kFrameSlots; ++r) {
+ if (!CreateUpload(device_, preCbv, npre, &framePreCbv_[r], err)) return false;
+ if (!CreateUpload(device_, postCbv, npost, &framePostCbv_[r], err)) return false;
+ }
+@@ -241,7 +241,7 @@ bool Provider::PatchFrameCbvs(int ring, float jx, float jy, float mvx, float mvy
+ float preExp, float prevPreExp, std::string* err,
+ uint32_t rw, uint32_t rh,
+ uint32_t uw, uint32_t uh) {
+- if (ring < 0 || ring > 2) FSR411_THROW(err, "ring out of range");
++ if (ring < 0 || ring >= kFrameSlots) FSR411_THROW(err, "ring out of range");
+ if (rw == 0 || rh == 0 || uw == 0 || uh == 0) FSR411_THROW(err, "zero render/upscale dims");
+ auto patch = [&](ID3D12Resource* cbv, const int* bases, int nb) {
+ if (!cbv) return false;
+@@ -374,6 +374,50 @@ bool Provider::StageHash(int idx, uint64_t* out, std::string* err) {
+ return true;
+ }
+
++bool Provider::RecordZeroFrameState(ID3D12GraphicsCommandList* cl, std::string* err) {
++ // Immutable descriptors; reset executes in-order on the caller queue.
++ ID3D12Resource* resources[] = {scratch_, histTex_, recTex_, reprojTex_, aeTex_};
++ if (!clearHeap_) {
++ D3D12_DESCRIPTOR_HEAP_DESC hd{};
++ hd.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
++ hd.NumDescriptors = 5;
++ if (FAILED(device_->CreateDescriptorHeap(&hd, IID_PPV_ARGS(&clearCpuHeap_))))
++ FSR411_THROW(err, "create reset CPU heap");
++ hd.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
++ if (FAILED(device_->CreateDescriptorHeap(&hd, IID_PPV_ARGS(&clearHeap_))))
++ FSR411_THROW(err, "create reset GPU heap");
++ auto cpu = clearCpuHeap_->GetCPUDescriptorHandleForHeapStart();
++ auto gpuCpu = clearHeap_->GetCPUDescriptorHandleForHeapStart();
++ for (int i = 0; i < 5; ++i) {
++ D3D12_UNORDERED_ACCESS_VIEW_DESC view{};
++ view.Format = resources[i]->GetDesc().Format;
++ view.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D;
++ if (i == 0) {
++ view.Format = DXGI_FORMAT_R32_TYPELESS;
++ view.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
++ view.Buffer.NumElements = UINT(kScratchSize / 4);
++ view.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_RAW;
++ }
++ device_->CreateUnorderedAccessView(resources[i], nullptr, &view, cpu);
++ device_->CopyDescriptorsSimple(1, gpuCpu, cpu, hd.Type);
++ cpu.ptr += descriptorSize_; gpuCpu.ptr += descriptorSize_;
++ }
++ }
++ cl->SetDescriptorHeaps(1, &clearHeap_);
++ auto cpu = clearCpuHeap_->GetCPUDescriptorHandleForHeapStart();
++ auto gpu = clearHeap_->GetGPUDescriptorHandleForHeapStart();
++ for (int i = 0; i < 5; ++i) {
++ UAVBarrier(cl, resources[i]);
++ const UINT zeros[4] = {};
++ const float ones[4] = {1, 1, 1, 1};
++ if (i == 4) cl->ClearUnorderedAccessViewFloat(gpu, cpu, resources[i], ones, 0, nullptr);
++ else cl->ClearUnorderedAccessViewUint(gpu, cpu, resources[i], zeros, 0, nullptr);
++ UAVBarrier(cl, resources[i]);
++ cpu.ptr += descriptorSize_; gpu.ptr += descriptorSize_;
++ }
++ return true;
++}
++
+ bool Provider::ZeroFrameState(std::string* err) {
+ // Scratch arena: DEFAULT-heap UAV, contents undefined at create. Any
+ // pass reading a plane before this frame writes it sees VRAM garbage
+@@ -422,7 +466,7 @@ bool Provider::ZeroFrameState(std::string* err) {
+ }
+
+ bool Provider::BuildFrameHeaps(const FrameBindings& b, int ring, std::string* err) {
+- if (ring < 0 || ring > 2) FSR411_THROW(err, "ring out of range");
++ if (ring < 0 || ring >= kFrameSlots) FSR411_THROW(err, "ring out of range");
+ if (!b.histTex || !b.velTex || !b.depthTex || !b.colorTex || !b.recTex || !b.expoTex ||
+ !b.reprojTex || !b.outTex)
+ FSR411_THROW(err, "null frame binding");
+@@ -521,7 +565,7 @@ bool Provider::RecordAutoExposure(ID3D12GraphicsCommandList* cl, const FrameBind
+ bool Provider::RecordFrameDispatch(ID3D12GraphicsCommandList* cl, const FrameBindings& b,
+ int ring, std::vector<PassReport>* reports, std::string* err,
+ bool autoExposure) {
+- if (ring < 0 || ring > 2) FSR411_THROW(err, "ring out of range");
++ if (ring < 0 || ring >= kFrameSlots) FSR411_THROW(err, "ring out of range");
+ if (!BuildFrameHeaps(b, ring, err)) return false;
+ UseFrameHeaps(ring);
+ if (dbgStages_) { if (!TsEnsure(err)) return false; tsSlot_ = 0; }
+diff --git a/bench/provider411/provider.cpp b/bench/provider411/provider.cpp
+index c17e00a..4b6cd83 100644
+--- a/bench/provider411/provider.cpp
++++ b/bench/provider411/provider.cpp
+@@ -32,6 +32,32 @@ void UAVBarrier(ID3D12GraphicsCommandList* cl, ID3D12Resource* res) {
+
+ } // namespace
+
++Provider::~Provider() {
++ // Fixture arrays alias scratch/initializer; release only their owned entries.
++ for (auto p : preSrv_) if (p && p != initializer_) p->Release();
++ for (auto p : postSrv_) if (p && p != initializer_) p->Release();
++ for (auto p : preUav_) if (p && p != scratch_) p->Release();
++ for (auto p : postUav_) if (p && p != scratch_) p->Release();
++ auto release = [](auto* p) { if (p) p->Release(); };
++ for (auto p : psos_) release(p);
++ for (auto p : framePreHeap_) release(p);
++ for (auto p : framePostHeap_) release(p);
++ for (auto p : framePreCbv_) release(p);
++ for (auto p : framePostCbv_) release(p);
++ for (auto p : dbgRb_) release(p);
++ release(rootEpi_); release(rootCompute_); release(rootNoCbv_);
++ release(rootPost_); release(rootPre_); release(rootUtil_);
++ release(scratch_); release(initializer_); release(tensorCb_); release(heap_);
++ release(preHeap_); release(postHeap_); release(preCbv1_); release(postCbv1_);
++ release(histTex_); release(recTex_); release(reprojTex_); release(expoOnesTex_);
++ release(aePSO_); release(aeTex_); release(aeHeap_);
++ release(clearHeap_); release(clearCpuHeap_);
++ release(immList_); release(alloc_); release(fence_);
++ release(tsHeap_); release(tsResolve_);
++ if (fenceEvent_) CloseHandle(fenceEvent_);
++ // device_ and queue_ are borrowed from Ffx411Context.
++}
++
+ bool Provider::Init(ID3D12Device* device, const Config& cfg, std::string* err) {
+ device_ = device;
+ cfg_ = cfg;
+diff --git a/bench/provider411/provider.h b/bench/provider411/provider.h
+index 8ce6679..787a29f 100644
+--- a/bench/provider411/provider.h
++++ b/bench/provider411/provider.h
+@@ -68,6 +68,9 @@ struct PassReport {
+ // P3; heap slots exist and point at the scratch buffer so PSOs validate.
+ class Provider {
+ public:
++ static constexpr int kFrameSlots = 6;
++ ~Provider(); // Caller drains its queue before destroying this provider.
++ bool RecordZeroFrameState(ID3D12GraphicsCommandList* cl, std::string* err);
+ // Creates root signatures + common resources (scratch arena, t18, CBV).
+ bool Init(ID3D12Device* device, const Config& cfg, std::string* err);
+ // Creates the compute PSO for every pass in pass_table.h.
+@@ -244,8 +247,10 @@ private:
+ ID3D12Resource* recTex_ = nullptr; // 1920x1080 RGBA8 recurrent (t4/u6)
+ ID3D12Resource* reprojTex_ = nullptr; // 1920x1080 RGBA16F reproj (u3/t9)
+ ID3D12Resource* expoOnesTex_ = nullptr;// 2x1 R32F exposure=1.0 fallback
+- ID3D12DescriptorHeap* framePreHeap_[3] = {};
+- ID3D12DescriptorHeap* framePostHeap_[3] = {};
++ ID3D12DescriptorHeap* framePreHeap_[kFrameSlots] = {};
++ ID3D12DescriptorHeap* framePostHeap_[kFrameSlots] = {};
++ ID3D12DescriptorHeap* clearHeap_ = nullptr;
++ ID3D12DescriptorHeap* clearCpuHeap_ = nullptr;
+ ID3D12DescriptorHeap* activePreHeap_ = nullptr; // default: fixture heaps
+ ID3D12DescriptorHeap* activePostHeap_ = nullptr;
+ // P4.1 live constants: ring-tripled upload CBVs (3x pre 35584 B + 3x post
+@@ -263,8 +268,8 @@ private:
+ // row5 = rh,preExp,prevPreExp,0). Tensor CB (960x540 working) and
+ // middle-pass dispatches stay fixed: scratch planes are working-res
+ // sized for the 1080p class, independent of the render preset.
+- ID3D12Resource* framePreCbv_[3] = {};
+- ID3D12Resource* framePostCbv_[3] = {};
++ ID3D12Resource* framePreCbv_[kFrameSlots] = {};
++ ID3D12Resource* framePostCbv_[kFrameSlots] = {};
+ ID3D12Resource* activePreCbv_ = nullptr; // null = P3 fixture buffer
+ ID3D12Resource* activePostCbv_ = nullptr;
+ // P4.6 approximate auto-exposure (flag-gated): minimal util root sig
diff --git a/scripts/package-portable.ps1 b/scripts/package-portable.ps1
index 6ba3cea9..aa2796f2 100644
--- a/scripts/package-portable.ps1
+++ b/scripts/package-portable.ps1
@@ -3,12 +3,16 @@ param(
[Parameter(Mandatory = $true)][ValidatePattern('^\d+\.\d+\.\d+$')][string]$Version,
[Parameter(Mandatory = $true)][string]$OutputDirectory,
[string]$BuildDirectory,
+ [string]$DependencyRoot,
+ [switch]$LocalVideoHdr,
# Suffix used only for the staging/archive name (e.g. "beta" -> Veyra-1.3.1beta-win64-portable).
# The numeric $Version still names the docs and must match the EXE's numeric parts.
[string]$Label = ''
)
$ErrorActionPreference = 'Stop'
$resolvedRoot = (Resolve-Path -LiteralPath $Root).Path
+$resolvedDependencies = $resolvedRoot
+if ($DependencyRoot) { $resolvedDependencies = (Resolve-Path -LiteralPath $DependencyRoot).Path }
$resolvedOutput = [IO.Path]::GetFullPath($OutputDirectory)
$bin = Join-Path $resolvedRoot 'out/build/x64-release'
if ($BuildDirectory) { $bin = (Resolve-Path -LiteralPath $BuildDirectory).Path }
@@ -59,8 +63,12 @@ if ([version]$Version -ge [version]'1.3.1') {
if ([version]$Version -ge [version]'1.1.1') {
$runtimeFiles += @{ Name='nvngx_dlssnr.dll'; Folder='runtime/experimental/nr-ampere'; Source='runtime_local/nvidia/nr-ampere/nvngx_dlssnr.dll'; Hash='DCC0DC2414AEDEC4A8E084647070383BE068554042587180C20C784D4772D36F'; Signature='HashMismatch'; Size=165840496; Version='310.8.0.0'; Category='user-provided-NeuralScreen-1.8.2-modified-RTX30-experimental-runtime'; Experimental=$true }
}
+if ($LocalVideoHdr) {
+ if (-not $Label) { throw 'Local HDR package requires an explicit test label.' }
+ $runtimeFiles += @{ Name='nvngx_truehdr.dll'; Folder='runtime/experimental'; Source='third_party_local/nvidia/RTX_Video_SDK_1.1.0/bin/Windows/x64/rel/nvngx_truehdr.dll'; Hash='9A80575F247190C05FE80EAC0C4BAA1D0D4D932348F26808310B5EC4BF9EEB4B'; Size=3955752; Version='1.1.0.0'; Category='official-rtx-video-sdk-1.1.0-local-evaluation'; Experimental=$true }
+}
$records = foreach ($item in $runtimeFiles) {
- $source = Join-Path $resolvedRoot $item.Source
+ $source = Join-Path $resolvedDependencies $item.Source
$file = Get-Item -LiteralPath $source
$hash = (Get-FileHash -LiteralPath $source -Algorithm SHA256).Hash
$sig = Get-AuthenticodeSignature -LiteralPath $source
@@ -108,7 +116,7 @@ foreach ($name in @('LICENSE','NOTICE','PROVENANCE.md','VEYRA_INTEGRATION.md'))
foreach ($notice in Get-ChildItem -LiteralPath (Join-Path $resolvedRoot 'third_party/gpu-dis/licenses') -File) {
Copy-Payload $notice.FullName "licenses/gpu-dis/licenses/$($notice.Name)"
}
-Copy-Payload (Join-Path $resolvedRoot 'runtime_local/config/ngx-local.json') 'runtime/config/ngx-local.json'
+Copy-Payload (Join-Path $resolvedDependencies 'runtime_local/config/ngx-local.json') 'runtime/config/ngx-local.json'
Copy-Payload (Join-Path $ffmpegRoot 'share/ffmpeg/copyright') 'licenses/FFMPEG-COPYRIGHT.txt'
Copy-Payload (Join-Path $ffmpegRoot 'share/ffmpeg/vcpkg.spdx.json') 'licenses/FFMPEG-SPDX.json'
if ($applicationFiles -contains 'dav1d.dll') {
@@ -132,14 +140,14 @@ Copy-Payload (Join-Path $resolvedRoot 'assets/icons/lucide/LICENSE') 'licenses/L
foreach ($name in @('RTX40MFG_LICENSE.txt','HDE_LICENSE.txt')) {
Copy-Payload (Join-Path $resolvedRoot "src/ngx/compat/$name") "licenses/$name"
}
-Copy-Payload (Join-Path $resolvedRoot 'third_party_local/nvidia/DLSS_repo/LICENSE.txt') 'licenses/NVIDIA_RTX_SDK_LICENSE.txt'
-Copy-Payload (Join-Path $resolvedRoot 'third_party_local/nvidia/RTX_Video_SDK_1.1.0/NVIDIA_RTX_Video_SDK_License.pdf') 'licenses/NVIDIA_RTX_VIDEO_SDK_LICENSE.pdf'
-Copy-Payload (Join-Path $resolvedRoot 'third_party_local/nvidia/Optical_Flow_SDK_5.0.7/LicenseAgreement.pdf') 'licenses/NVIDIA_OPTICAL_FLOW_SDK_LICENSE.pdf'
+Copy-Payload (Join-Path $resolvedDependencies 'third_party_local/nvidia/DLSS_repo/LICENSE.txt') 'licenses/NVIDIA_RTX_SDK_LICENSE.txt'
+Copy-Payload (Join-Path $resolvedDependencies 'third_party_local/nvidia/RTX_Video_SDK_1.1.0/NVIDIA_RTX_Video_SDK_License.pdf') 'licenses/NVIDIA_RTX_VIDEO_SDK_LICENSE.pdf'
+Copy-Payload (Join-Path $resolvedDependencies 'third_party_local/nvidia/Optical_Flow_SDK_5.0.7/LicenseAgreement.pdf') 'licenses/NVIDIA_OPTICAL_FLOW_SDK_LICENSE.pdf'
if ([version]$Version -ge [version]'1.3.1') {
# MIT licence of the FidelityFX SDK that ships the AMD runtime above.
- $amdLicense = Join-Path $resolvedRoot 'third_party_local/amd/FidelityFX-SDK-2.3.0/docs/license.md'
+ $amdLicense = Join-Path $resolvedDependencies 'third_party_local/amd/FidelityFX-SDK-2.3.0/docs/license.md'
if (-not (Test-Path -LiteralPath $amdLicense -PathType Leaf)) {
- $amdLicense = Join-Path $resolvedRoot 'third_party_local/amd/FidelityFX-SDK-2.3.0/Kits/FidelityFX/docs/license.md'
+ $amdLicense = Join-Path $resolvedDependencies 'third_party_local/amd/FidelityFX-SDK-2.3.0/Kits/FidelityFX/docs/license.md'
}
if (Test-Path -LiteralPath $amdLicense -PathType Leaf) {
Copy-Payload $amdLicense 'licenses/AMD-FIDELITYFX-LICENSE.txt'
@@ -147,15 +155,20 @@ if ([version]$Version -ge [version]'1.3.1') {
throw 'AMD FidelityFX licence text not found in the vendored SDK'
}
}
-Copy-Payload (Join-Path $resolvedRoot 'third_party_local/intel/xess-3.0.2/LICENSE.txt') 'licenses/INTEL_XESS_LICENSE.txt'
-Copy-Payload (Join-Path $resolvedRoot 'third_party_local/intel/xess-3.0.2/third-party-programs.txt') 'licenses/INTEL_THIRD_PARTY_PROGRAMS.txt'
-Copy-Payload (Join-Path $resolvedRoot 'third_party_local/amd/FidelityFX-SDK/LICENSE.txt') 'licenses/AMD_FIDELITYFX_LICENSE.txt'
-foreach ($item in $runtimeFiles) { Copy-Payload (Join-Path $resolvedRoot $item.Source) "$($item.Folder)/$($item.Name)" }
+Copy-Payload (Join-Path $resolvedDependencies 'third_party_local/intel/xess-3.0.2/LICENSE.txt') 'licenses/INTEL_XESS_LICENSE.txt'
+Copy-Payload (Join-Path $resolvedDependencies 'third_party_local/intel/xess-3.0.2/third-party-programs.txt') 'licenses/INTEL_THIRD_PARTY_PROGRAMS.txt'
+Copy-Payload (Join-Path $resolvedDependencies 'third_party_local/amd/FidelityFX-SDK/LICENSE.txt') 'licenses/AMD_FIDELITYFX_LICENSE.txt'
+foreach ($item in $runtimeFiles) { Copy-Payload (Join-Path $resolvedDependencies $item.Source) "$($item.Folder)/$($item.Name)" }
+if ($LocalVideoHdr) {
+ Copy-Payload (Join-Path $resolvedRoot 'docs/LOCAL_HDR_FSR41_TEST_2026-09-18.md') 'LOCAL_TEST.md'
+ Copy-Payload (Join-Path $resolvedRoot 'scripts/fsr41/README.md') 'docs/FSR41_EXPERIMENT.md'
+ Copy-Payload (Join-Path $resolvedRoot 'scripts/fsr41/LICENSE.txt') 'licenses/FSR41-PROVIDER-LICENSE.txt'
+}
$manifestFolders = @('runtime/experimental','runtime_local/intel/experimental')
if ([version]$Version -ge [version]'1.3.1') { $manifestFolders += 'runtime_local/amd/fidelityfx' }
foreach ($folder in $manifestFolders) {
$relative = "$folder/release-runtime-manifest.json"
- [ordered]@{schema=1;package="Veyra $Version";mode='user-authorized-runtime-pack';enforcedAtRuntime=$false;warning='Community experimental integration; not vendor certification or endorsement.';files=@($records | Where-Object {$_.path.StartsWith("$folder/")})} | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath (Join-Path $stage $relative) -Encoding UTF8
+ [ordered]@{schema=1;package="Veyra $Version$Label";mode=$(if($LocalVideoHdr){'local-evaluation-only'}else{'user-authorized-runtime-pack'});enforcedAtRuntime=$false;warning='Community experimental integration; not vendor certification or endorsement.';files=@($records | Where-Object {$_.path.StartsWith("$folder/")})} | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath (Join-Path $stage $relative) -Encoding UTF8
$allowed.Add($relative)
}
$payload = @(Get-ChildItem -LiteralPath $stage -Recurse -File)
diff --git a/src/gfx/FsrSrBackend.cpp b/src/gfx/FsrSrBackend.cpp
index 3e57ed2b..026e071d 100644
--- a/src/gfx/FsrSrBackend.cpp
+++ b/src/gfx/FsrSrBackend.cpp
@@ -1,6 +1,7 @@
#include "veyra/gfx/FsrSrBackend.h"
#include "veyra/Log.h"
+#include "veyra/FileIdentity.h"
#include "veyra/RuntimePaths.h"
#include <filesystem>
@@ -21,6 +22,7 @@ FfxApiSurfaceFormat surfaceFormatFromDxgi(DXGI_FORMAT format) {
switch (format) {
case DXGI_FORMAT_R8G8B8A8_UNORM: return FFX_API_SURFACE_FORMAT_R8G8B8A8_UNORM;
case DXGI_FORMAT_R16G16B16A16_FLOAT: return FFX_API_SURFACE_FORMAT_R16G16B16A16_FLOAT;
+ case DXGI_FORMAT_R11G11B10_FLOAT: return FFX_API_SURFACE_FORMAT_R11G11B10_FLOAT;
case DXGI_FORMAT_R16G16_FLOAT: return FFX_API_SURFACE_FORMAT_R16G16_FLOAT;
case DXGI_FORMAT_R32_FLOAT: return FFX_API_SURFACE_FORMAT_R32_FLOAT;
default: return FFX_API_SURFACE_FORMAT_UNKNOWN;
@@ -64,8 +66,8 @@ const char* returnName(ffxReturnCode_t code) {
void fsrMessage(uint32_t type, const wchar_t* message) {
if (message == nullptr) return;
const int length = WideCharToMultiByte(CP_UTF8, 0, message, -1, nullptr, 0, nullptr, nullptr);
- std::string text(size_t(length > 0 ? length - 1 : 0), '\0');
- if (length > 1) WideCharToMultiByte(CP_UTF8, 0, message, -1, text.data(), length, nullptr, nullptr);
+ std::string text(size_t(length > 0 ? length : 0), '\0');
+ if (length > 0) { WideCharToMultiByte(CP_UTF8, 0, message, -1, text.data(), length, nullptr, nullptr); text.pop_back(); }
if (type == FFX_API_MESSAGE_TYPE_ERROR) log::error("fsr-sr", text);
else log::warn("fsr-sr", text);
}
@@ -91,8 +93,12 @@ struct FsrSrBackend::Impl {
uint64_t evaluateCount = 0;
uint64_t failureCount = 0;
std::string providerVersion;
+ bool experimental411 = false;
#ifdef VEYRA_HAS_FSR
HMODULE loader = nullptr;
+ HMODULE provider = nullptr;
+ using SetSlot = uint32_t (__cdecl*)(ffxContext*, uint32_t, uint32_t);
+ SetSlot setSlot = nullptr;
ffxFunctions functions{};
ffxContext context = nullptr;
uint32_t maxRenderWidth = 0, maxRenderHeight = 0;
@@ -110,25 +116,47 @@ bool FsrSrBackend::initialize(ID3D12Device* device, uint32_t maxRenderWidth, uin
auto& p = *p_;
if (p.available) return true;
const auto root = runtime::localDataDirectory() / "amd" / "fidelityfx";
- const auto loaderPath = std::filesystem::absolute(root / "amd_fidelityfx_loader_dx12.dll");
+ auto loaderPath = std::filesystem::absolute(root / "amd_fidelityfx_loader_dx12.dll");
+ wchar_t experimentalPath[32768]{};
+ const auto pathLength = GetEnvironmentVariableW(L"VEYRA_FSR41_PROVIDER", experimentalPath, 32768);
+ p.experimental411 = pathLength != 0;
+ if (p.experimental411) {
+ if (pathLength >= 32768 || !std::filesystem::path(experimentalPath).is_absolute() || hdr) {
+ log::error("fsr-sr", "experimental 4.1.1 requires an absolute provider path and SDR input");
+ return false;
+ }
+ loaderPath = experimentalPath;
+ log::warn("fsr-sr", std::format("EXPERIMENTAL FSR 4.1.1 INT8 requested: {}; zero jitter, estimated flow, constant depth", loaderPath.string()));
+ }
const auto providerPath = std::filesystem::absolute(root / "amd_fidelityfx_upscaler_dx12.dll");
if (!std::filesystem::exists(loaderPath)) {
log::warn("fsr-sr", std::format("loader missing at {}", loaderPath.string()));
return false;
}
- DirectoryGuard guard(root);
+ if (p.experimental411) {
+ FileIdentity identity; IdentityError error{};
+ computeFileIdentity(loaderPath.wstring(), identity, error);
+ log::info("fsr-sr", std::format("experimental provider identity sha256={} bytes={} signatureValid={} trust=0x{:08X} identityStatus={}",
+ identity.sha256Upper, identity.sizeBytes, identity.signatureValid, identity.winTrustError, identityErrorString(error)));
+ }
+ std::unique_ptr<DirectoryGuard> guard;
+ if (!p.experimental411) guard = std::make_unique<DirectoryGuard>(root);
p.loader = LoadLibraryExW(loaderPath.c_str(), nullptr,
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32);
if (p.loader == nullptr) {
log::error("fsr-sr", std::format("loader load failed win32={}", GetLastError()));
return false;
}
- if (std::filesystem::exists(providerPath) &&
- LoadLibraryExW(providerPath.c_str(), nullptr,
- LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32) == nullptr) {
+ if (!p.experimental411 && std::filesystem::exists(providerPath) &&
+ (p.provider = LoadLibraryExW(providerPath.c_str(), nullptr,
+ LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32)) == nullptr) {
log::warn("fsr-sr", std::format("provider preload failed win32={}", GetLastError()));
}
ffxLoadFunctions(&p.functions, p.loader);
+ if (p.experimental411) {
+ p.setSlot = reinterpret_cast<Impl::SetSlot>(GetProcAddress(p.loader, "veyraFsr411SetSlot"));
+ if (!p.setSlot) { log::error("fsr-sr", "experimental provider lacks caller-slot/reset ABI 1"); return false; }
+ }
if (p.functions.CreateContext == nullptr || p.functions.DestroyContext == nullptr ||
p.functions.Dispatch == nullptr || p.functions.Query == nullptr) {
log::error("fsr-sr", "loader is missing the FidelityFX API entry points");
@@ -155,6 +183,12 @@ bool FsrSrBackend::initialize(ID3D12Device* device, uint32_t maxRenderWidth, uin
}
log::info("fsr-sr", std::format("providers count={} selected={}", capacity,
p.providerVersion.empty() ? "none" : p.providerVersion));
+ constexpr uint64_t researchId = (0xF5A5CA1Eull << 32) | (4ull << 22) | (1ull << 12) | 1;
+ if (p.experimental411 && (listResult != FFX_API_RETURN_OK || capacity != 1 || ids[0] != researchId ||
+ p.providerVersion != "4.1.1-int8-reimpl-tu117")) {
+ log::error("fsr-sr", "experimental provider identity query mismatch; no implicit FSR3 fallback");
+ return false;
+ }
}
ffxCreateBackendDX12Desc backendDesc{};
@@ -166,7 +200,7 @@ bool FsrSrBackend::initialize(ID3D12Device* device, uint32_t maxRenderWidth, uin
ffxCreateContextDescUpscale upscaleDesc{};
upscaleDesc.header.type = FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE;
upscaleDesc.header.pNext = &backendDesc.header;
- backendDesc.header.pNext = &versionDesc.header;
+ backendDesc.header.pNext = p.experimental411 ? nullptr : &versionDesc.header;
upscaleDesc.flags = hdr ? FFX_UPSCALE_ENABLE_HIGH_DYNAMIC_RANGE : 0u;
upscaleDesc.maxRenderSize = {maxRenderWidth, maxRenderHeight};
upscaleDesc.maxUpscaleSize = {maxUpscaleWidth, maxUpscaleHeight};
@@ -201,7 +235,8 @@ bool FsrSrBackend::initialize(ID3D12Device* device, uint32_t maxRenderWidth, uin
bool FsrSrBackend::evaluate(ID3D12GraphicsCommandList* list, ID3D12Resource* color, ID3D12Resource* motion,
ID3D12Resource* depth, ID3D12Resource* output, uint32_t renderWidth, uint32_t renderHeight,
- uint32_t upscaleWidth, uint32_t upscaleHeight, bool reset, float frameTimeMs) {
+ uint32_t upscaleWidth, uint32_t upscaleHeight, bool reset, float frameTimeMs,
+ uint32_t commandSlot) {
#ifdef VEYRA_HAS_FSR
auto& p = *p_;
if (!p.available || list == nullptr || color == nullptr || motion == nullptr || depth == nullptr ||
@@ -243,6 +278,11 @@ bool FsrSrBackend::evaluate(ID3D12GraphicsCommandList* list, ID3D12Resource* col
dispatch.cameraFovAngleVertical = 1.0f;
dispatch.viewSpaceToMetersFactor = 0.0f;
dispatch.flags = 0;
+ if (p.experimental411 && (commandSlot >= 6 || !p.setSlot(&p.context, commandSlot, 1))) {
+ log::error("fsr-sr", "experimental dispatch requires a caller-owned, fence-retired command slot (0..5)");
+ ++p.failureCount;
+ return false;
+ }
const auto result = p.functions.Dispatch(&p.context, &dispatch.header);
if (result != FFX_API_RETURN_OK) {
log::warn("fsr-sr", std::format("dispatch result={} render={}x{} upscale={}x{} reset={}", returnName(result),
@@ -254,7 +294,7 @@ bool FsrSrBackend::evaluate(ID3D12GraphicsCommandList* list, ID3D12Resource* col
return true;
#else
(void)list; (void)color; (void)motion; (void)depth; (void)output; (void)renderWidth; (void)renderHeight;
- (void)upscaleWidth; (void)upscaleHeight; (void)reset; (void)frameTimeMs;
+ (void)upscaleWidth; (void)upscaleHeight; (void)reset; (void)frameTimeMs; (void)commandSlot;
return false;
#endif
}
@@ -272,11 +312,14 @@ void FsrSrBackend::release() {
FreeLibrary(p.loader);
p.loader = nullptr;
}
+ if (p.provider) { FreeLibrary(p.provider); p.provider = nullptr; }
+ p.setSlot = nullptr;
p.available = false;
#endif
}
bool FsrSrBackend::created() const { return p_->available; }
+bool FsrSrBackend::experimental411() const { return p_->experimental411; }
uint64_t FsrSrBackend::evaluateCount() const { return p_->evaluateCount; }
uint64_t FsrSrBackend::failureCount() const { return p_->failureCount; }
const char* FsrSrBackend::providerVersion() const { return p_->providerVersion.c_str(); }
diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cpp
index 109b312b..cb0bada2 100644
--- a/src/pipeline/EnhanceGraph.cpp
+++ b/src/pipeline/EnhanceGraph.cpp
@@ -385,7 +385,7 @@ bool EnhanceGraph::createResources()
if(srEnabled_&&desc_.videoSrQuality==engine::kVideoSrFsr){
fsrSrDepth_=makeTexture(context_.device(),srcW_,srcH_,DXGI_FORMAT_R32_FLOAT,false);
if(!fsrSrDepth_)return false;
- fsrSrDepthPitch_=size_t(srcW_)*sizeof(float);
+ fsrSrDepthPitch_=(size_t(srcW_)*sizeof(float)+255)&~size_t(255);
upFsrSrDepth_=makeUploadBuffer(context_.device(),fsrSrDepthPitch_*srcH_);
if(!upFsrSrDepth_)return false;
}
@@ -790,6 +790,7 @@ HMODULE module = fgCompatibility_ ? fgCompatibility_->provider() : nullptr;
bool EnhanceGraph::initFsrSr()
{
+ fsrSrResetPending_=true;
if (!fsrSrRequested()) return true;
if (desc_.noFeatures) {
veyra::log::warn("fsr-sr", "feature-disabled configuration: AMD FSR upscaling skipped");
@@ -813,6 +814,12 @@ bool EnhanceGraph::initFsrSr()
failedBackend_=engine::FailedBackend::None;
return true;
}
+ if(fsrSrBackend_->experimental411()){
+ if(ring_.slotCount()>6){veyra::log::error("fsr-sr","experimental provider supports at most six caller command slots");return false;}
+ fsr41Input_=makeTexture(context_.device(),srcW_,srcH_,DXGI_FORMAT_R11G11B10_FLOAT,true);
+ fsr41Output_=makeTexture(context_.device(),workW_,workH_,DXGI_FORMAT_R11G11B10_FLOAT,true);
+ if(!fsr41Input_||!fsr41Output_)return false;
+ }
failedBackend_=engine::FailedBackend::None;
veyra::log::info("fsr-sr", std::format("selected render={}x{} output={}x{} provider={}",srcW_,srcH_,workW_,workH_,
fsrSrBackend_->providerVersion()));
@@ -1089,7 +1096,7 @@ bool EnhanceGraph::createComputePasses()
if((desc_.rgbInput||desc_.yuy2Input||desc_.packedInput)&&(!rgbPass_.loadShader(rgbShader,cs)||!rgbPass_.create(context_.device(),cs,12,1,1,8+kColorGradeConstantCount,4)))return false;
if (!encPass_.loadShader("ParityEncode.dxil", cs) || !encPass_.create(context_.device(), cs, 8, 1, 1)) return false;
if (!decPass_.loadShader("ParityDecode.dxil", cs) || !decPass_.create(context_.device(), cs, 8)) return false;
- if (!blitPass_.loadShader("ScaleBlit.dxil", cs) || !blitPass_.create(context_.device(), cs, 21, 1, 1)) return false;
+ if (!blitPass_.loadShader("ScaleBlit.dxil", cs) || !blitPass_.create(context_.device(), cs, 23, 1, 1)) return false;
// Nv12Upload stays: frame-time CopyTextureRegion is poisoned by the
// injected layer (SEH in NGX evaluate, r33-final3 evidence); the compute
// upload is the proven frame-path ingestion on this system.
@@ -1186,6 +1193,8 @@ bool EnhanceGraph::createViews()
if (viewsTex) stagedSrv(residualRgba_.Get(),DXGI_FORMAT_R16G16B16A16_FLOAT,blitPass_,18);
if(videoHdrInput_&&viewsUav)makeUav(context_.device(),videoHdrInput_.Get(),DXGI_FORMAT_R8G8B8A8_UNORM,cpu(blitPass_,19));
if(videoHdrOutput_&&viewsTex)stagedSrv(videoHdrOutput_.Get(),DXGI_FORMAT_R16G16B16A16_FLOAT,blitPass_,20);
+ if(fsr41Input_&&viewsUav)makeUav(context_.device(),fsr41Input_.Get(),DXGI_FORMAT_R11G11B10_FLOAT,cpu(blitPass_,21));
+ if(fsr41Output_&&viewsTex)stagedSrv(fsr41Output_.Get(),DXGI_FORMAT_R11G11B10_FLOAT,blitPass_,22);
if (viewsTex) stagedSrv(srcRgba_.Get(), DXGI_FORMAT_R16G16B16A16_FLOAT, blitPass_, 0);
// Colour-grade tables: four SRVs at the extra table's fixed register base.
if(colorActive_){
@@ -1629,6 +1638,9 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
out.batch.batchId=realFrameIndex_+1;out.batch.identity={epoch_,desc_.settingsRevision,sourceFrameId};
out.batch.a100ns=static_cast<int64_t>(std::llround(prevPtsMs_*10000));
out.batch.b100ns=static_cast<int64_t>(std::llround(ptsMs*10000));gpuTimer_.identity(out.batch.identity);
+ // A reset frame can have no flow and skip FSR. Retain the reset until an
+ // actual dispatch, including gaps caused by failed motion estimation.
+ if(reset||!haveFlow)fsrSrResetPending_=true;
auto runSr=[&]()->bool{
if(srEnabled_&&fsrSrEnabled()&&haveFlow){
// AMD FSR upscaling: FidelityFX effect, render-extent color + guidance
@@ -1640,13 +1652,33 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
tracker_.transition(list,srcRgba_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
tracker_.transition(list,flowTex_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
tracker_.transition(list,fsrSrDepth_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
- tracker_.transition(list,workRgba_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
- if(!fsrSrBackend_->evaluate(list,srcRgba_.Get(),flowTex_.Get(),fsrSrDepth_.Get(),workRgba_.Get(),
- srcW_,srcH_,workW_,workH_,reset,float(deltaMs))){
+ auto* fsrColor=desc_.nrBeforeSr?residualRgba_.Get():srcRgba_.Get();
+ tracker_.transition(list,fsrColor,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ auto* fsrOutput=workRgba_.Get();
+ if(fsr41Input_){
+ tracker_.transition(list,fsr41Input_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
+ const float c[8]={uintBits(srcW_),uintBits(srcH_),uintBits(srcW_),uintBits(srcH_),0,0,0,0};
+ blitPass_.bind(list,c,gpuHandleOf(blitPass_,desc_.nrBeforeSr?18:0).ptr,gpuHandleOf(blitPass_,21).ptr);
+ list->Dispatch((srcW_+15)/16,(srcH_+15)/16,1);tracker_.uavBarrier(list,fsr41Input_.Get());
+ tracker_.transition(list,fsr41Input_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ fsrColor=fsr41Input_.Get();fsrOutput=fsr41Output_.Get();
+ }
+ tracker_.transition(list,fsrOutput,D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
+ if(!fsrSrBackend_->evaluate(list,fsrColor,flowTex_.Get(),fsrSrDepth_.Get(),fsrOutput,
+ srcW_,srcH_,workW_,workH_,fsrSrResetPending_,float(deltaMs),slot)){
failedBackend_=engine::FailedBackend::Sr;
return false;
}
+ fsrSrResetPending_=false;
++metrics_.srEvaluateCount;gpuTimer_.mark(list,GpuStage::Sr,true);
+ if(fsr41Output_){
+ tracker_.uavBarrier(list,fsr41Output_.Get());
+ tracker_.transition(list,fsr41Output_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ tracker_.transition(list,workRgba_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
+ const float c[8]={uintBits(workW_),uintBits(workH_),uintBits(workW_),uintBits(workH_),0,0,0,0};
+ blitPass_.bind(list,c,gpuHandleOf(blitPass_,22).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);
} else if(srEnabled_&&videoSrBackend_){
@@ -2053,6 +2085,7 @@ void EnhanceGraph::shutdown()
for(auto& motion:presentMotion_)motion.Reset();
if(fsrSrBackend_){fsrSrBackend_->release();fsrSrBackend_.reset();}
fsrSrDepth_.Reset();
+ fsr41Input_.Reset();fsr41Output_.Reset();
upFsrSrDepth_.Reset();
if (fgBackend_) fgBackend_->release();
if(videoSrBackend_){videoSrBackend_->release();videoSrBackend_.reset();}
diff --git a/tests/integration/Fsr41VideoTests.cpp b/tests/integration/Fsr41VideoTests.cpp
new file mode 100644
index 00000000..76692567
--- /dev/null
+++ b/tests/integration/Fsr41VideoTests.cpp
@@ -0,0 +1,105 @@
+#include "veyra/pipeline/EnhanceGraph.h"
+#include "veyra/RuntimePaths.h"
+#include "veyra/gfx/D3D12DeviceContext.h"
+#include "veyra/gfx/CommandSlotRing.h"
+#include "veyra/sink/ImageExportSink.h"
+#include "veyra/source/MediaFileSource.h"
+#include <algorithm>
+#include <chrono>
+#include <iostream>
+#include <d3d12sdklayers.h>
+extern "C" {
+#include <libavutil/frame.h>
+}
+using namespace veyra;
+
+// This probe exercises the product graph. Readback is diagnostic only, at the
+// end of each sequence; the intervening frames use the normal six-slot queue.
+int wmain(int argc, wchar_t** argv) {
+ if(argc<2){std::cerr<<"usage: fsr41_tests <absolute-provider|baseline|fsr3> [frames=90] [width=1280] [height=720] [output-width=1920] [output-height=1080]\n";return 1;}
+ const bool baseline=std::wstring(argv[1])==L"baseline", fsr3=std::wstring(argv[1])==L"fsr3";
+ SetEnvironmentVariableW(L"VEYRA_FSR41_PROVIDER",baseline||fsr3?nullptr:argv[1]);
+ const unsigned frames=argc>2?unsigned(_wtoi(argv[2])):90;
+ unsigned w=argc>3?unsigned(_wtoi(argv[3])):1280,h=argc>4?unsigned(_wtoi(argv[4])):720;
+ const bool media=argc>7;
+ source::MediaFileSource source;
+ if(media){source::SourceOpenDesc od;od.path=argv[7];od.preferHardwareDecode=false;
+ if(!source.open(od))return 2;w=source.info().width;h=source.info().height;}
+ const unsigned ow=argc>5?unsigned(_wtoi(argv[5])):1920,oh=argc>6?unsigned(_wtoi(argv[6])):1080;
+ if(frames<12||frames>30000||!w||!h||w>3840||h>2160||ow<w||oh<h||ow>3840||oh>2160)return 1;
+ CoInitializeEx(nullptr,COINIT_MULTITHREADED);
+ const auto initBegin=std::chrono::steady_clock::now();
+ gfx::D3D12DeviceContext ctx; gfx::CommandSlotRing ring; Status status; gfx::DeviceContextDesc dd;
+ dd.enableDebugLayer=GetEnvironmentVariableW(L"VEYRA_FSR_TEST_DEBUG",nullptr,0)!=0;
+ if(!ctx.initialize(dd,status)||!ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),6,status))return 2;
+ pipeline::EnhanceGraph graph(ctx,ring);pipeline::EnhanceGraphDesc gd;
+ gd.sourceWidth=w;gd.sourceHeight=h;gd.workWidth=gd.nrWidth=ow;gd.workHeight=gd.nrHeight=oh;
+ gd.rgbInput=!media;gd.enableNr=gd.enableFg=false;gd.enableSr=!baseline;
+ gd.enableNvofStandalone=true;gd.videoSrQuality=engine::kVideoSrFsr;
+ gd.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();
+ if(!graph.initialize(gd)||!graph.createViews()||(!baseline&&!graph.fsrSrEnabled()))return 3;
+ const auto initSeconds=std::chrono::duration<double>(std::chrono::steady_clock::now()-initBegin).count();
+ uint64_t budget=0,initialMemory=0,finalMemory=0;
+ ctx.videoMemoryInfo(budget,initialMemory);
+ AVFrame* frame=av_frame_alloc();frame->format=AV_PIX_FMT_BGRA;frame->width=int(w);frame->height=int(h);
+ frame->color_range=AVCOL_RANGE_JPEG;frame->color_primaries=AVCOL_PRI_BT709;frame->color_trc=AVCOL_TRC_IEC61966_2_1;
+ if(av_frame_get_buffer(frame,32)<0)return 4;
+ const auto begin=std::chrono::steady_clock::now();
+ bool ok=true;unsigned processed=0;pipeline::EnhanceGraph::FrameOutputs out;
+ for(unsigned n=0;n<frames&&ok;++n){
+ if(std::chrono::steady_clock::now()-begin>std::chrono::seconds(240)){ok=false;break;}
+ if(media){
+ pipeline::FramePacket packet;const AVFrame* decoded=nullptr;
+ if(source.read(packet,&decoded)!=source::SourceReadStatus::Frame){ok=false;break;}
+ ok=graph.process(decoded,packet.pts.toDouble()*1000,n%37==0,out,n+1,&packet.colorInfo);++processed;
+ continue;
+ }
+ // A translated checker and gradient expose black output, stale history,
+ // wrong transfer and shifted geometry; resets occur while work is queued.
+ for(unsigned y=0;y<h;++y)for(unsigned x=0;x<w;++x){
+ auto* p=frame->data[0]+size_t(y)*frame->linesize[0]+x*4;
+ const unsigned xx=(x+n*2)%w;
+ const uint8_t v=uint8_t((((xx/64+y/64)&1)?140:30)+xx*70/w);
+ p[0]=v;p[1]=v;p[2]=v;p[3]=255;
+ }
+ ok=graph.process(frame,n*1000.0/30,n%37==0,out,n+1);++processed;
+ }
+ ok=ring.waitIdle()&&ok;
+ sink::RgbaImage image;
+ if(ok)ok=sink::readRgba8(ctx,ring,graph.videoFrameResource(out.videoSlot),image);
+ double mean=0,mae=0;unsigned lo=255,hi=0;
+ if(ok){
+ for(unsigned y=0;y<oh;++y)for(unsigned x=0;x<ow;++x){
+ const auto value=image.pixels[(size_t(y)*ow+x)*4];mean+=value;lo=std::min(lo,unsigned(value));hi=std::max(hi,unsigned(value));
+ const unsigned sx=std::min(w-1,unsigned((x+.5)*w/ow)),sy=std::min(h-1,unsigned((y+.5)*h/oh));
+ if(!media)mae+=std::abs(int(value)-int(frame->data[0][size_t(sy)*frame->linesize[0]+sx*4]));
+ }
+ mean/=double(ow)*oh;mae/=double(ow)*oh;
+ ok=media?(hi>lo):(mean>30&&mean<225&&hi-lo>50&&mae<30);
+ sink::saveImage(L"fsr-frame.png",image);
+ }
+ const auto& times=ring.gpuCommandTimesMs();
+ auto sorted=times;std::sort(sorted.begin(),sorted.end());
+ double avg=0;for(auto t:times)avg+=t;if(!times.empty())avg/=times.size();
+ const auto srCount=graph.metrics().srEvaluateCount;
+ unsigned debugErrors=0;
+ gfx::ComPtr<ID3D12InfoQueue> messages;
+ if(SUCCEEDED(ctx.device()->QueryInterface(IID_PPV_ARGS(&messages)))){
+ for(UINT64 i=0;i<messages->GetNumStoredMessages();++i){
+ SIZE_T size=0;messages->GetMessage(i,nullptr,&size);std::vector<uint8_t> storage(size);
+ auto* message=reinterpret_cast<D3D12_MESSAGE*>(storage.data());
+ if(SUCCEEDED(messages->GetMessage(i,message,&size))&&message->Severity<=D3D12_MESSAGE_SEVERITY_ERROR){
+ ++debugErrors;std::cerr<<"D3D12_ERROR "<<message->pDescription<<std::endl;
+ }
+ }
+ }
+ ctx.videoMemoryInfo(budget,finalMemory);
+ ok=ok&&(baseline||srCount>frames/2)&&SUCCEEDED(ctx.device()->GetDeviceRemovedReason());
+ ok=ok&&debugErrors==0;
+ std::cout<<"FSR_VIDEO pass="<<ok<<" media="<<media<<" frames="<<processed<<" sr="<<srCount<<" mean="<<mean<<" min="<<lo<<" max="<<hi<<" referenceMAE="<<(media?-1:mae)
+ <<" commandGpuAvgMs="<<avg<<" commandGpuP95Ms="<<(sorted.empty()?0:sorted[size_t((sorted.size()-1)*.95)])
+ <<" seconds="<<std::chrono::duration<double>(std::chrono::steady_clock::now()-begin).count()
+ <<" initSeconds="<<initSeconds<<" initialMemoryMiB="<<initialMemory/1048576<<" finalMemoryMiB="<<finalMemory/1048576
+ <<" debugEnabled="<<ctx.debugLayerEnabled()<<" debugErrors="<<debugErrors<<std::endl;
+ ring.drainQueue();graph.shutdown();av_frame_free(&frame);ring.shutdown();ctx.shutdown();CoUninitialize();return ok?0:5;
+}