Skip to content

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

C++

feat: package Veyra runtime pack

Veyra Goal Agent181a047269a7
diff --git a/AGENTS.md b/AGENTS.md
index 927993c9..82c77239 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -3,6 +3,7 @@
> 2026-09-07 新用户决定:默认明确标注的实时档(4K输入可用1080内部处理),保留原生4K可选;视频导出仍原生4K。不得要求以本机原生4K NR达到60fps作为本次默认档门槛,也不得把实时档冒充native4K。最终统一软件短测为 `scripts/gates/delivery.ps1`(phase5–7本次合同的合并检查),实卡仍由用户验收。其他安全/许可规则不变。
> 2026-09-06 用户授权接管修订:当前推进、五分钟短测与用户实卡验收以 `docs/ACTIVE_DELIVERY_PLAN.md` 为准,取代下文旧的严格串行施工/30分钟测试/未接设备阻塞全部交付规则。历史记录不是当前通过证明。
+> 2026-09-09 用户发布决策:Veyra 采用“完整开箱即用的实验 Runtime Pack”发布策略。用户明确接受该 Pack 可能被 GitHub 下架或被权利方要求移除的风险,并授权将经过身份校验的指定实验运行时作为 **GitHub Release 资产** 随 Veyra 用户包分发。该例外不允许把 NVIDIA SDK、运行时、模型、头文件、样例或压缩包提交进源码仓库、Git LFS、Git 历史或 C++ 源文件;不允许修改、重签名、伪装或从游戏/驱动缓存提取二进制。详情以“Release Runtime Pack 规则”为准。
本文件对在本目录工作的所有 Agent 生效。不要只扫标题;开工前必须完整阅读:
@@ -59,6 +60,18 @@ renodx-dlss5-1.addon64
```
如果 hash 不同,不要“先试试看”;记录实际值并询问用户。
+## Release Runtime Pack 规则(2026-09-09 用户授权)
+
+这是一项面向用户体验的、明确标记为实验性的发布决策,不是 NVIDIA 官方合作、官方支持或通用再分发授权。
+
+- **源码与 Release 必须物理分离。** 所有 NVIDIA SDK/runtime、模型、头文件、`.lib`、样例、SDK ZIP、驱动文件和本机抓帧必须保持在 gitignore 的本地目录;不得提交、vendoring、Git LFS、嵌入资源、编码为 base64 或以任何方式混入源码/提交历史。
+- **仅 Release 资产可带二进制。** 用户批准的完整包可从本机受控 staging 目录复制已批准运行时;每个文件必须在 `release-runtime-manifest.json` 中列明文件名、来源类别、版本、大小、SHA-256、签名状态、实验标记及是否可卸载。未列明的 NVIDIA 文件一律拒绝打包。
+- **当前 DLSSNR 许可范围。** 仅允许身份与本规则上方完全一致的 `nvngx_dlssnr.dll`(310.8.0.0、指定 SHA-256、NVIDIA 签名有效)进入 `runtime/experimental/`。哈希、版本、签名或来源不一致时停止打包并询问用户;不得联网搜寻“更新偷跑版”。
+- **不得篡改或隐藏。** 禁止 patch、重签名、修改 PE、伪装为 Veyra 文件、嵌进资源、从游戏安装目录/驱动缓存复制,或借助 RenoDX/ReShade 注入路径实现发布包。实验 Runtime Pack 必须以清晰目录、版本与哈希呈现。
+- **运行时保护。** Veyra 启动时校验 manifest、SHA-256、签名和 GPU/驱动兼容性;校验或初始化失败时只禁用对应增强功能,基础播放器、采集和导出仍可启动。不得静默下载未知二进制,也不得把失败伪装为增强已生效。
+- **发布说明。** Release Notes、README、软件内组件页必须写明“实验运行时 / community experimental”,不得宣称 NVIDIA 官方合作、认证、支持或完整官方 DLSS 5 集成;同时保留 Veyra 自身版本、runtime 版本、哈希和卸载说明。
+- **范围最小化。** 用户包只包含运行所需 DLL/模型与适用许可证、notice、manifest;绝不包含 SDK 开发文件、样例、私有测试媒体、日志、PDB、LIB 或游戏文件。官方 SDK 中明确可集成分发的组件仍须逐项保留其许可证与来源记录。
+- **人工发布。** 任何 push、GitHub Release、Runtime Pack 上传、替换或删除都必须由用户在当前对话明确授权;无人值守 Goal 仍禁止发布。若平台或权利方要求移除,先移除/下架 Runtime Pack,再保留不含该 Pack 的 Veyra 基础包。
## 阶段门禁
@@ -107,10 +120,10 @@ Phase 0–4 的历史 checkpoint 只能证明各基础 harness 当时通过,
- Magpie 是 GPLv3。闭源 Veyra 不得复制其源码或做机械改名;只可把其公开行为当作黑盒/接口参考后独立实现。若要直接复用,先让用户明确接受 GPLv3 以及对应源码义务。
- `video2dlssnr` 当前仓库未提供许可证;不得复制代码。`DLSS5-Feeder`、`dlss5-infinity-studio` 和 `dlss5-visual-enhancer` 只能按各自许可证与第三方 notices 取用;默认只借鉴公开行为与架构,任何代码复用都要在 `THIRD_PARTY_NOTICES` 逐项归因。
-- NVIDIA SDK/runtime 和当前 DLSSNR 文件的分发权不能假定。默认只做本机研发,`runtime_local/`、`third_party_local/`、抓帧和 SDK 压缩包必须 gitignore。
-- NVIDIA Video Codec SDK 头文件/sample 同样需要单独接受 EULA;系统 `nvEncodeAPI64.dll` 不复制进安装包。没有完成第三方分发审计前,“首发产品完成”不等于“获准公开捆绑发布”。
-- 不得上传、发布、打包或向第三方发送项目中的两个二进制。
-- 任何准备公开发布、签名安装包或 CI 上传 artifact 的动作,都必须先停下并让用户确认许可证与分发来源。
+- NVIDIA SDK/runtime 的分发权不得想当然地扩大。除“Release Runtime Pack 规则”列出的、用户明确批准并完成身份校验的 Release 资产外,默认只做本机研发;`runtime_local/`、`third_party_local/`、抓帧和 SDK 压缩包必须 gitignore。
+- NVIDIA Video Codec SDK 头文件/sample 同样需要单独接受 EULA;系统 `nvEncodeAPI64.dll` 不复制进用户包。没有完成第三方分发审计前,不得把产品宣传为 NVIDIA 官方认证、合作或支持。
+- 已批准的 Runtime Pack 例外只适用于 GitHub Release 用户包,不适用于源码仓库、Git 历史、CI artifact、第三方镜像或私下发送未经 manifest 校验的二进制。
+- 任何 Runtime Pack 的新增文件、版本替换、push、GitHub Release、上传或删除都必须先在当前对话得到用户明确授权,并报告来源、SHA-256、签名状态、许可证文件和包内扫描结果。
## 每次交付必须报告
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cd15488c..fee6ecf7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.24)
-project(veyra VERSION 0.1.0 LANGUAGES CXX)
+project(veyra VERSION 0.0.1 LANGUAGES CXX)
# ---------------------------------------------------------------------------
# Veyra cache variables and feature switches (Playbook section 5.1).
@@ -9,6 +9,12 @@ project(veyra VERSION 0.1.0 LANGUAGES CXX)
# ---------------------------------------------------------------------------
set(VEYRA_DLSS_SDK_ROOT "" CACHE PATH "NVIDIA DLSS SDK root")
set(VEYRA_NVOF_SDK_ROOT "" CACHE PATH "NVIDIA Optical Flow SDK root")
+if(NOT VEYRA_NVOF_SDK_ROOT)
+ set(VEYRA_NVOF_CANDIDATE "${CMAKE_CURRENT_SOURCE_DIR}/third_party_local/nvidia/Optical_Flow_SDK_5.0.7")
+ if(EXISTS "${VEYRA_NVOF_CANDIDATE}/NvOFInterface/nvOpticalFlowCommon.h")
+ set(VEYRA_NVOF_SDK_ROOT "${VEYRA_NVOF_CANDIDATE}")
+ endif()
+endif()
set(VEYRA_RUNTIME_ROOT "" CACHE PATH "Local NVIDIA runtime root")
set(VEYRA_FFMPEG_ROOT "" CACHE PATH "vcpkg-installed x64-windows root with FFmpeg (player deps)")
set(VEYRA_CLIP_TOOLS_ROOT "" CACHE PATH "vcpkg-installed x64-windows root with openh264-enabled FFmpeg (clip tooling only)")
@@ -35,6 +41,7 @@ add_library(veyra_base STATIC
src/base/Log.cpp
src/base/NgxResult.cpp
src/base/FileIdentity.cpp
+ src/base/RuntimePaths.cpp
)
veyra_apply_warnings(veyra_base)
target_compile_options(veyra_base PUBLIC /utf-8)
@@ -71,10 +78,17 @@ add_library(veyra_ngx STATIC
src/ngx/DlssSrBackend.cpp
src/ngx/VideoSrBackend.cpp
src/ngx/DlssFgBackend.cpp
+ src/ngx/FrucBackend.cpp
)
veyra_apply_warnings(veyra_ngx)
target_compile_features(veyra_ngx PUBLIC cxx_std_20)
- target_link_libraries(veyra_ngx PUBLIC veyra_base veyra_gfx)
+ target_link_libraries(veyra_ngx PUBLIC veyra_base veyra_gfx d3d11)
+ add_executable(veyra_fruc_worker src/ngx/FrucWorker.cpp)
+ veyra_apply_warnings(veyra_fruc_worker)
+ target_compile_features(veyra_fruc_worker PRIVATE cxx_std_20)
+ target_link_libraries(veyra_fruc_worker PRIVATE veyra_base d3d11 dxgi)
+ target_include_directories(veyra_fruc_worker PRIVATE "${VEYRA_NVOF_SDK_ROOT}/NvOFFRUC/Interface" "${VEYRA_NVOF_SDK_ROOT}/NvOFFRUC/NvOFFRUCSample/cudart_header")
+ add_dependencies(veyra_ngx veyra_fruc_worker)
target_include_directories(veyra_ngx PUBLIC
"${VEYRA_DLSS_SDK_ROOT}/include")
# NVIDIA ships the static core shim as MT-Release; the _dbg variants match
@@ -267,12 +281,6 @@ endif()
# NVOF probe tool (phase5 gate expects veyra_nvof_probe.exe).
set(VEYRA_NVOF_SDK_ROOT "" CACHE PATH "NVIDIA Optical Flow SDK root")
-if(NOT VEYRA_NVOF_SDK_ROOT)
- set(VEYRA_NVOF_CANDIDATE "${CMAKE_CURRENT_SOURCE_DIR}/third_party_local/nvidia/Optical_Flow_SDK_5.0.7")
- if(EXISTS "${VEYRA_NVOF_CANDIDATE}/NvOFInterface/nvOpticalFlowCommon.h")
- set(VEYRA_NVOF_SDK_ROOT "${VEYRA_NVOF_CANDIDATE}")
- endif()
-endif()
if(VEYRA_NVOF_SDK_ROOT AND EXISTS "${VEYRA_NVOF_SDK_ROOT}/NvOFInterface/nvOpticalFlowCommon.h")
# Reusable NVOF D3D12 session (Phase 6 motion guidance for DLSSG).
add_library(veyra_nvof STATIC src/ngx/NvOfSession.cpp)
@@ -432,6 +440,11 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avform
target_include_directories(veyra_repair_parameter_tests PRIVATE ${FFMPEG_INCLUDE_DIRS})
target_compile_definitions(veyra_repair_parameter_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN VEYRA_PROJECT_ROOT="${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(veyra_repair_parameter_tests PRIVATE veyra_pipeline veyra_sinks veyra_nvof)
+ add_executable(veyra_fruc_tests tests/integration/FrucTests.cpp)
+ target_include_directories(veyra_fruc_tests PRIVATE ${FFMPEG_INCLUDE_DIRS})
+ target_compile_features(veyra_fruc_tests PRIVATE cxx_std_20)
+ target_compile_definitions(veyra_fruc_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN VEYRA_PROJECT_ROOT="${CMAKE_CURRENT_SOURCE_DIR}")
+ target_link_libraries(veyra_fruc_tests PRIVATE veyra_pipeline veyra_sinks veyra_nvof)
add_executable(veyra_repair_fg_tests tests/integration/RepairFgTests.cpp)
add_executable(veyra_motion_validation_tests tests/integration/MotionValidationTests.cpp)
add_executable(veyra_depth_response_tests tests/integration/DepthResponseTests.cpp)
diff --git a/README.md b/README.md
index 3958b715..2c199927 100644
--- a/README.md
+++ b/README.md
@@ -1,140 +1,108 @@
-# Veyra DLSS Video Player
+# Veyra
-**面向 Windows 的本地视频增强播放器:视频观看、采集卡输入、图片与视频导出,共用一套 D3D12 增强管线。**
+Windows 本地视频播放器与画面增强工作台。它把视频播放、采集卡预览、图片增强和视频导出放进同一个原生应用:日常模式专注看画面,专业模式集中放增强、补帧、对比、诊断和导出工具。
-Veyra 使用 C++20 / Win32 原生界面,直接调用 NVIDIA NGX。日常模式把空间留给画面,专业模式展开精细参数、对比、性能信息与导出工具。控制区使用真实桌面毛玻璃,视频区域保持不透明,未打开媒体时为纯黑。
+Veyra is a native Windows video player and image-enhancement workspace. It combines local playback, capture-card preview, image enhancement, and video export in one application. Daily mode is built for watching; Professional mode exposes enhancement, frame generation, comparison, diagnostics, and export tools.
-> **当前为实验开发版,状态:Phase 7 / needs_review。** 此仓库提供源码存档,不包含可直接运行的安装包、NVIDIA 专有运行时、SDK、个人媒体或本机测试日志。部分 UI 与 GPU 路径已经本机实测;整体交付门禁、当前版本实卡体验和长期稳定性仍有待完成。
+> 这是 `0.0.1` 的早期实验版本。便携包包含经哈希和签名校验的 Runtime Pack,让兼容 RTX 环境可直接启用对应增强;其中 NR、FRUC 和 DLSSG 属于社区实验运行时,不代表 NVIDIA 官方合作、认证或支持。This is an early experimental build. The portable package includes a hash- and signature-verified Runtime Pack so compatible RTX systems can enable its available enhancements directly. NR, FRUC, and DLSSG are community-experimental runtimes and do not imply NVIDIA endorsement, certification, or support.
-## 主要功能
+## 功能 / Features
-| 方向 | 当前实现 |
-| --- | --- |
-| 日常观看 | 默认日常模式;底栏直接提供打开、采集、最近文件、增强、SR、播放、音量、字幕与全屏等常用操作,窄窗口保留图标入口。 |
-| 专业工作台 | 240 毫秒展开 / 收起动画;保留同一播放会话;集中管理增强、补帧、预设、原图对比与导出。 |
-| 原生界面 | Windows Desktop Acrylic 透出窗口下方的模糊颜色;统一圆角选择器、Lucide 图标、视频全屏与自动隐藏控制条。系统不支持材质时回退。 |
-| 媒体输入 | H.264 / HEVC 视频、PNG / JPEG 图片;DirectShow / UVC 采集设备;当前范围为最高 3840×2160 的 SDR。 |
-| 图像增强 | DLSS SR、实验 Feature 18 NR、NVOF 光流与置信度门控;实时 NR 与原生 NR 档位;参数应用失败时回滚。 |
-| 补帧 | DLSSG 2X 路径;另有实验性 3X / 4X 设置。倍率不等于实际显示帧率,也不代表所有组合均能实时运行。 |
-| 对比与诊断 | 同一源帧原图 / 增强对比、分屏拖动、实际处理尺寸与阶段耗时、可预览的脱敏诊断。 |
-| 图片导出 | 增强 PNG / JPEG,支持保存当前真实源帧。 |
-| 视频导出 | 独立后台作业,冻结启动时的设置;D3D12 NVENC 编码 H.264 / HEVC MP4,支持暂停、取消和优先观看。 |
-| 音频与字幕 | 应用独立音量、静音、外部 SRT;导出保留第一条兼容 MP4 的音轨,不兼容时明确拒绝。 |
-
-操作说明见 [使用指南](docs/USER_GUIDE.md)。最新界面变更见 [底栏与选择器交付报告](docs/UI_CONTROLS_V4_DELIVERY_2026-09-08.md)。
-
-## 分辨率与性能
-
-- **实时 NR 档**:保留源画面 / SR 底图,NR 在约 1080p 内部尺寸处理,再由 GPU 将增强变化回填到底图。它不是原生 4K NR。
-- **原生 NR 档**:按工作画面尺寸执行 NR,成本更高;不承诺本机原生 4K NR 达到 60 fps。
-- **SR 4K**:按原比例放大到 3840×2160 范围,尺寸取偶数。例如 16:9 为 3840×2160,4:3 为 2880×2160;达到边界时跳过 SR。
-- **视频导出**:不沿用实时档的内部降分辨率策略;4K 输入使用原生 4K NR。后台观看与导出共享 GPU,可能争用资源。
-
-补帧需要等待后续源帧,不能消除采集卡固有延迟。历史短测中 SR 4K + 4X 组合仍出现明显落后,不能把功能调用成功写成 4K60 实时通过。
+- 默认日常模式:大画面、底部播放控制、打开媒体、采集卡、音量、字幕和全屏。
+- 专业模式:带展开动画的参数工作台;同一播放会话不中断。
+- H.264 / HEVC 视频、PNG / JPEG 图片、DirectShow / UVC 采集设备。
+- 可选 DLSS SR、RTX Video SR、实验性 NR、NVOF 运动置信度,以及 DLSS / FRUC 补帧后端。
+- 原图与增强结果的即时对比、分屏拖动、专业模式内的画面缩放和性能诊断。
+- PNG / JPEG 图片导出,D3D12 NVENC H.264 / HEVC 视频导出。
+- Windows 11 Desktop Acrylic 控制面板;视频区域保持不透明,未打开媒体时为纯黑。
-## 架构
+- Daily mode by default: a large picture area with playback, media opening, capture, volume, subtitles, and fullscreen controls.
+- Professional mode: an expanding settings workspace without interrupting the current session.
+- H.264 / HEVC video, PNG / JPEG images, and DirectShow / UVC capture devices.
+- Optional DLSS SR, RTX Video SR, experimental NR, NVOF motion confidence, plus DLSS and FRUC frame-generation backends.
+- Same-frame comparison, split view, preview zoom in Professional mode, and performance diagnostics.
+- PNG / JPEG image export and D3D12 NVENC H.264 / HEVC video export.
+- Windows 11 Desktop Acrylic for controls; the video area stays opaque and is pure black with no media open.
-```text
-视频 / 图片 / 采集卡
- │
- FrameSource
- │
- EnhanceGraph
- 统一颜色处理 → SR(可选)→ NR(可选)→ DLSSG(可选)
- NVOF 光流 + 置信度门控
- │
- FrameSink
- ┌────┼────────────┐
- 屏幕呈现 PNG / JPEG D3D12 NVENC → MP4
-```
+## 使用方法 / How to use
-播放器、采集与导出复用产品库。字幕与播放器叠加层在补帧之后合成。产品不依赖 ReShade,也不加载 RenoDX add-on;当前 NR 适配器为本机实验 Feature 18 路径,不代表获得通用官方 DLSS 5 接口或分发授权。
+### 免安装包 / Portable package
-## 构建与运行
+1. 下载并解压 `Veyra-0.0.1-win64-portable.zip`。
+2. 双击 `Veyra.exe`。
+3. 在日常模式点击“打开视频 / 图片”或“采集”,然后播放、暂停、调节音量或进入全屏。
+4. 点击“切换专业模式”展开完整面板。这里可以选择增强、超分、补帧、预设、对比和导出。
-### 环境与本地依赖
+压缩包中的 `runtime_local/nvidia` 包含版本固定的 Runtime Pack。软件会读取 `release-runtime-manifest.json`,校验 DLL 哈希和签名;校验、驱动或硬件不兼容时自动关闭对应增强,基础播放器、采集与导出仍可启动。不要自行替换其中的 DLL,也不要从游戏目录、驱动缓存或未知来源复制文件。
-- Windows x64,Visual Studio 2022 C++ 工具链,CMake 3.24+、Ninja,以及带 `dxc.exe` 的 Windows SDK。
-- 兼容所用 NGX / NVOF / NVENC 路径的 NVIDIA GPU 与驱动。已有本机测试使用 RTX 5070;没有据此验证所有 RTX 型号。桌面毛玻璃使用 Windows 11 Desktop Acrylic。
-- 下列依赖须按各自来源与许可自行准备,源码仓库不会自动下载实验运行时。
-
-| 依赖 | 当前构建约定 |
-| --- | --- |
-| NVIDIA DLSS SDK 310.7.0 | `third_party_local/nvidia/DLSS_SDK_310.7.0/`,包含头文件与 x64 NGX 库。 |
-| NVIDIA Optical Flow SDK 5.0.7 | `third_party_local/nvidia/Optical_Flow_SDK_5.0.7/`。 |
-| NVENC API 头文件 | `third_party_local/nvidia/nv-codec-headers/include/`;固定来源见 [第三方说明](THIRD_PARTY_NOTICES.md)。 |
-| NVIDIA 运行时 | `runtime_local/nvidia/`;实验 NR 仅使用 [项目规则](AGENTS.md) 中固定身份的本地文件。仓库不提供或代寻该文件。 |
-| FFmpeg 开发依赖 | 构建脚本当前自动检测 `C:/veyra-deps/installed/x64-windows/`,含头文件、库及 `share/ffmpeg/FindFFMPEG.cmake`。 |
-| 测试工具 | 部分检查需要 PATH 中的 `ffmpeg` / `ffprobe`,以及本地合成媒体;测试工具依赖与产品依赖分开。 |
+1. Download and extract `Veyra-0.0.1-win64-portable.zip`.
+2. Run `Veyra.exe`.
+3. In Daily mode, choose Open Video / Image or Capture, then play, pause, adjust volume, or enter fullscreen.
+4. Select Switch to Professional Mode to expand the complete workspace. This is where enhancement, super resolution, frame generation, presets, comparison, and export are configured.
-没有完整依赖时,部分 CMake 目标不会生成;仅克隆源码或编译基础测试不等于得到完整播放器。`build.ps1` 仍包含本机依赖目录约定,尚未提供一键依赖安装器。运行时 / shader 路径在构建时绑定,移动目录后应重新配置与构建。
+The package includes a version-pinned Runtime Pack in `runtime_local/nvidia`. The release builder generates `release-runtime-manifest.json` and verifies DLL hashes and signatures; NR and FRUC also validate their pinned identities at startup. If driver, hardware, or initialization compatibility fails, Veyra disables only the affected enhancement while the player, capture, and export paths remain available. Do not replace these DLLs or copy files from games, driver caches, or unknown sources.
-### 构建
+### 从源码构建 / Build from source
-在 PowerShell 中执行:
+准备 Windows x64、Visual Studio 2022 C++ 工具链、CMake 3.24+、Ninja 和 Windows SDK。NVIDIA 与 FFmpeg 依赖请按各自许可准备在本地,仓库不会自动下载它们。
```powershell
git clone https://github.com/Likely7/Veyra-DLSS-Video-Player.git
Set-Location Veyra-DLSS-Video-Player
-
-# 先按上表准备本地依赖,再构建。
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\scripts\build.ps1 -Root . -Preset x64-release
-
-# 构建成功且运行依赖就绪后启动。
.\Veyra.cmd
```
-输出程序为 `out/build/x64-release/veyra.exe`。如需自定义依赖根目录,可在 x64 开发者环境中直接使用 CMake 的 `VEYRA_DLSS_SDK_ROOT`、`VEYRA_NVOF_SDK_ROOT`、`VEYRA_FFMPEG_ROOT` 等缓存项;具体目标条件见 [CMakeLists.txt](CMakeLists.txt)。
-
-## 验证状态
+Prepare Windows x64, the Visual Studio 2022 C++ toolchain, CMake 3.24+, Ninja, and the Windows SDK. Supply NVIDIA and FFmpeg dependencies locally under their own licenses; this repository does not download them automatically.
-**截至 2026-09-08:UI v4 已完成限定范围验证,整体仍需验收。** 最新报告记录了实际构建、EXE 身份、NVIDIA Create / Evaluate 返回值、失败与修复,不以旧阶段通过记录代替当前产品状态。
+## 技术路线 / Technical approach
-- 最终 UI v4 程序:布局 / 状态与 14 场景弹层检查通过;40 次模式切换检查通过;NR / SR 开关等原生运行检查通过。
-- 最后一次 12 DIP 排版微调前:完整 UI 15 命令与图片 / 视频 / 导出 11 命令检查通过。报告明确区分这两个构建,未把上一构建的全套结果标成最终构建结果。
-- 既有统一 `delivery` 门禁仍有失败:旧断言要求 23 帧,当前 CFR 尾部保持策略输出 24 帧。尚未解决该门禁差异;专项通过不等于 Phase 7 通过。
-- 当前版本实卡体验、长期稳定性、多屏物理 DPI 与部分真实 IME 场景尚未完成验收。历史实卡吞吐测试不替代当前版本体验确认。
+三个输入入口共享同一条 GPU 图,不复制三套增强逻辑:
-在本地依赖与相应测试素材就绪后,可分别运行:
-
-```powershell
-# 底栏、布局、图标身份与原生弹层专项。
-powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\scripts\acceptance\ui-controls-v4.ps1 -Root .
+```text
+视频 / 图片 / 采集卡
+ → 颜色与时间戳解析
+ → SR(可选)
+ → NR(可选)
+ → 帧生成(可选)
+ → 呈现、图片导出或 NVENC 视频导出
+```
-# 完整双模式专项;需要脚本指定的本地合成媒体。
-powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\scripts\acceptance\ui-dual-mode.ps1 -Root . -Case all
+The three input modes use one shared GPU graph rather than three separate enhancement implementations:
-# 统一软件交付门禁;当前已知失败如上,不标记为全绿。
-powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\scripts\gates\delivery.ps1 -Root .
+```text
+Video / image / capture card
+ → color and timestamp handling
+ → optional SR
+ → optional NR
+ → optional frame generation
+ → presentation, image export, or NVENC video export
```
-**每次测试调用最多 300 秒,累计测试时间不设“一轮五分钟”限制。** 原始日志、截图和测试媒体保留在本机,不随源码上传;文档中的历史 `logs/` 路径不是 GitHub 可下载附件。此次 README / 源码存档不新增 GPU 性能结论,也未验证全新机器的一键构建。
+- Veyra uses C++20, Win32, D3D12, FFmpeg, and Windows media APIs.
+- SR is performed before NR; frame generation is performed after NR. Player subtitles and OSD are composed after frame generation.
+- Capture uses a latest-frame mailbox to limit latency. Frame generation requires the next real source frame; it cannot remove a capture card's inherent delay.
+- Realtime NR can use an explicitly labelled 1080p-class internal working size for 4K input. Native 4K NR remains available but costs substantially more GPU time. Export retains its native-size path.
+- HDMI and ordinary video do not contain game-engine depth, motion vectors, exposure, or HUD-free color. Veyra estimates only what can be derived from pixels and does not claim game-native equivalence.
-## 已知边界
+## 当前边界 / Current limits
-- 当前面向 SDR;HDR、AV1 / ProRes 导出、VFR 原样输出与厂商私有采集 SDK 不在已交付范围。
-- Depth provider 尚未实现,当前使用 NVOF motion + confidence;估算输入不等同游戏引擎原生 depth / motion。
-- 部分 NR 参数属于实验项,不能保证对所有素材有效;画质没有被证明等同或优于官方游戏实现及其他产品。
-- 外部 SRT 可显示;内嵌字幕解码、多音轨选择、音频转码和字幕烧录导出尚未提供。
-- 3X / 4X 为实验性扩展;有界短测不证明完整组合的长期稳定或实际屏幕扫描帧率。
-- NVIDIA 运行时、SDK、FFmpeg 配置与成品分发仍需独立审计,目前没有可公开捆绑分发的安装包。
+- SDR is the supported delivery path. HDR, AV1 / ProRes export, and VFR-preserving export are not part of this version.
+- Depth is not a shipped default provider. Current motion guidance uses NVOF confidence handling where available.
+- 3X and 4X frame generation are experimental. A selected multiplier does not guarantee that every source-frame pair produces a valid generated frame or that every configuration runs in real time.
+- Actual scanout latency, long-term stability, capture audio behavior, and every GPU / driver combination require further real-device validation.
+- No NVIDIA runtime, SDK archive, headers, libraries, models, or samples are in this Git repository. The user-authorized Release Runtime Pack is a separate Release-only payload and remains experimental.
-## 项目导航
+## 项目结构 / Project layout
-| 路径 | 内容 |
+| Path | Purpose |
| --- | --- |
-| [apps/veyra](apps/veyra/) | Win32 应用与双模式界面。 |
-| [include/veyra](include/veyra/) / [src](src/) | 共享引擎、媒体源、NGX、光流与输出实现。 |
-| [shaders](shaders/) | 颜色、缩放、光流与增强合成 shader。 |
-| [tests](tests/) / [scripts](scripts/) | 单元 / 集成检查、构建与验收入口。 |
-| [使用指南](docs/USER_GUIDE.md) | 播放、采集、增强、字幕与导出操作。 |
-| [最新 UI 交付](docs/UI_CONTROLS_V4_DELIVERY_2026-09-08.md) / [复核记录](docs/REVIEW_UI_CONTROLS_V4_2026-09-08.md) | 最新限定范围变更、真实验证与剩余问题。 |
-| [当前交付计划](docs/ACTIVE_DELIVERY_PLAN.md) / [工作日志](docs/WORKLOG.md) | 当前合同与按时间保留的开发记录;旧条目不代表最新状态。 |
-| [施工手册](VEYRA_AGENT_EXECUTION_PLAYBOOK_V1.md) / [产品规范](VEYRA_PRODUCT_SPEC_V1.md) / [项目规则](AGENTS.md) | 技术边界与开发约束。 |
-| [竞品审计](docs/COMPETITOR_AUDIT_2026-09-03.md) / [状态](loop/STATE.json) / [证据](loop/EVIDENCE.md) / [施工记录](loop/JOURNAL.md) | 可追溯的历史事实与恢复资料;历史阶段标签不覆盖本文的当前验证状态。 |
-
-## 许可证与存档范围
+| `apps/veyra` | Win32 application and the two-mode interface |
+| `include/veyra`, `src` | Shared engine, media, GPU, enhancement, and export code |
+| `shaders` | GPU shader sources and build rules |
+| `tests`, `scripts` | Tests, build commands, and local acceptance helpers |
+| `docs` | User guide, architecture notes, work log, and implementation plans |
-保留此 GitHub 仓库初始化时已有的 [GNU GPL v3 许可证](LICENSE)。Lucide / Feather 图标的 ISC / MIT 通知随素材保留,来源和其他依赖说明见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。仓库许可证不改变外部 NVIDIA 组件或其他依赖自身的许可条件。
+## 许可 / License
-本次公开存档包含当前源码、shader、许可允许保留的图标、构建 / 测试脚本与开发文档。完整本地开发历史另行保留;含旧测试视频或本地依赖记录的历史提交不推送。`runtime_local/`、`third_party_local/`、构建产物、个人配置、原始诊断与测试媒体均不包含在本次上传中。
+The repository keeps its existing [GNU GPL v3 license](LICENSE). Third-party notices are in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). This repository license does not grant rights to redistribute NVIDIA SDKs, runtimes, drivers, or other external components.
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md
index ddd9eb41..b8b64874 100644
--- a/THIRD_PARTY_NOTICES.md
+++ b/THIRD_PARTY_NOTICES.md
@@ -20,4 +20,8 @@ Source: https://github.com/lucide-icons/lucide/tree/a537cb6eb323b885f4c60baf3cec
## RTX Video SDK 1.1 local VSR adapter
-User-provided official SDK from https://developer.nvidia.com/rtx-video-sdk/getting-started, kept under ignored third_party_local/nvidia/RTX_Video_SDK_1.1.0. Its NVIDIA RTX SDK license remains applicable. VideoSrBackend is independently authored against the documented VSR parameter ABI; no SDK sample implementation or proprietary header is copied into the repository. Local nvngx_vsr.dll is excluded from Git and distribution. This addition does not authorize packaging or redistributing NVIDIA runtimes.
+User-provided official SDK from https://developer.nvidia.com/rtx-video-sdk/getting-started, kept under ignored third_party_local/nvidia/RTX_Video_SDK_1.1.0. Its NVIDIA RTX SDK license remains applicable. VideoSrBackend is independently authored against the documented VSR parameter ABI; no SDK sample implementation or proprietary header is copied into the repository. Local nvngx_vsr.dll remains excluded from Git. Under the user-authorized 2026-09-09 Release Runtime Pack policy, its pinned signed release copy may be included only as a Release asset alongside the applicable SDK license and manifest; it is never committed to source control.
+
+## NVIDIA FRUC local adapter
+
+Local Optical Flow SDK5.0.7 NvOFFRUC interface and CUDA declarations are consumed from ignored third_party_local, under the NVIDIA SDK terms. FrucBackend/FrucWorker are independently authored code; no sample or competitor implementation is copied. The locally provided signed NvOFFRUC.dll is never committed to Git. Under the user-authorized 2026-09-09 Release Runtime Pack policy, only its pinned signed release copy may be included as an experimental Release asset with a manifest and the applicable license. Veyra relies on the user-installed NVIDIA driver for nvcuda.dll; it does not copy that driver DLL. The build-produced veyra_fruc_worker.exe is Veyra code, not a renamed proprietary binary. FRUC SDK guide: https://docs.nvidia.com/video-technologies/optical-flow-sdk/nvfruc-programming-guide/index.html . These additions do not grant NVIDIA runtime distribution rights.
diff --git a/apps/veyra/SettingsWindow.cpp b/apps/veyra/SettingsWindow.cpp
index b3252d0c..a17bbd14 100644
--- a/apps/veyra/SettingsWindow.cpp
+++ b/apps/veyra/SettingsWindow.cpp
@@ -1,6 +1,7 @@
#include "SettingsWindow.h"
#include "ui/Theme.h"
#include "veyra/engine/PresetStore.h"
+#include "veyra/RuntimePaths.h"
#include <filesystem>
#include <sstream>
#include <iomanip>
@@ -9,7 +10,7 @@ namespace veyra::ui {
namespace {
HWND window=nullptr,body=nullptr;engine::EngineController* controller=nullptr;HFONT font=nullptr;
std::function<bool(engine::EnhancementSettings)> apply;
-engine::PresetStore store(std::filesystem::path(VEYRA_PROJECT_ROOT)/"runtime_local/user-presets.v1");bool loaded=false,dirty=false,populating=false,enhancementEnabled=true;int page=0,scroll=0,contentHeight=0;uint64_t displayedRevision=0;engine::EnhancementSettings configuredSettings;
+engine::PresetStore store(runtime::localDataDirectory()/"user-presets.v1");bool loaded=false,dirty=false,populating=false,enhancementEnabled=true;int page=0,scroll=0,contentHeight=0;uint64_t displayedRevision=0;engine::EnhancementSettings configuredSettings;
struct Item{HWND h;int page,x,y,w,height;};std::vector<Item> items;
HWND item(int id){for(auto& entry:items)if(GetDlgCtrlID(entry.h)==id)return entry.h;return nullptr;}
LRESULT send(int id,UINT message,WPARAM w=0,LPARAM l=0){return SendMessageW(item(id),message,w,l);}
@@ -38,7 +39,7 @@ void syncProtection(const engine::ProtectionSettings& protection){
putText(206,(L"NR保护区域 · "+std::to_wstring(count)+L"/4").c_str());
}
void selectDiscrete(int group,int value){for(int j=0;j<(group==0?3:2);++j){auto h=item(700+group*10+j);if(j==value)SetPropW(h,L"veyra.selected",HANDLE(1));else RemovePropW(h,L"veyra.selected");InvalidateRect(h,nullptr,FALSE);}}
-void populate(engine::EnhancementSettings s){populating=true;float v[]={s.model.intensity,s.model.tone,s.model.structure,s.model.skin,float(s.model.style),float(s.model.autoMask),float(s.model.uiCorrection),s.residual.total,s.residual.darken,s.residual.brighten,s.residual.color,s.residual.luminance};for(int i=0;i<12;++i){std::wostringstream o;o<<std::setprecision(7)<<v[i];if(i>=4&&i<=6){selectDiscrete(i-4,int(v[i]));continue;}if(GetFocus()!=item(100+i))putText(100+i,o.str().c_str());send(600+i,TBM_SETPOS,TRUE,LPARAM(v[i]*100));}syncProtection(s.protection);check(200,enhancementEnabled&&s.nr?BST_CHECKED:BST_UNCHECKED);check(201,enhancementEnabled&&s.sr?BST_CHECKED:BST_UNCHECKED);send(207,CB_SETCURSEL,s.videoSrQuality,0);send(202,CB_SETCURSEL,s.multiplier-1,0);send(203,CB_SETCURSEL,int(s.nrPolicy),0);send(204,CB_SETCURSEL,int(s.flow),0);send(205,CB_SETCURSEL,int(s.content),0);displayedRevision=s.revision;populating=false;dirty=false;}
+void populate(engine::EnhancementSettings s){populating=true;float v[]={s.model.intensity,s.model.tone,s.model.structure,s.model.skin,float(s.model.style),float(s.model.autoMask),float(s.model.uiCorrection),s.residual.total,s.residual.darken,s.residual.brighten,s.residual.color,s.residual.luminance};for(int i=0;i<12;++i){std::wostringstream o;o<<std::setprecision(7)<<v[i];if(i>=4&&i<=6){selectDiscrete(i-4,int(v[i]));continue;}if(GetFocus()!=item(100+i))putText(100+i,o.str().c_str());send(600+i,TBM_SETPOS,TRUE,LPARAM(v[i]*100));}syncProtection(s.protection);check(200,enhancementEnabled&&s.nr?BST_CHECKED:BST_UNCHECKED);check(201,enhancementEnabled&&s.sr?BST_CHECKED:BST_UNCHECKED);send(207,CB_SETCURSEL,s.videoSrQuality,0);send(202,CB_SETCURSEL,s.multiplier-1,0);send(208,CB_SETCURSEL,int(s.frameGenerationBackend),0);send(203,CB_SETCURSEL,int(s.nrPolicy),0);send(204,CB_SETCURSEL,int(s.flow),0);send(205,CB_SETCURSEL,int(s.content),0);displayedRevision=s.revision;populating=false;dirty=false;}
bool read(engine::EnhancementSettings& s,bool allPages=false){s=enhancementEnabled?controller->snapshot().desired:configuredSettings;float v[12]{};for(int i=0;i<12;++i){if(i>=4&&i<=6){v[i]=float(i==4?s.model.style:i==5?s.model.autoMask:s.model.uiCorrection);continue;}wchar_t b[64]{};GetWindowTextW(item(100+i),b,64);wchar_t* end=nullptr;v[i]=wcstof(b,&end);if(end==b||*end||!std::isfinite(v[i])){message(L"请输入完整的有限数值;未提交设置");return false;}}
for(int i=4;i<7;++i)if(v[i]!=std::floor(v[i])||v[i]<0||v[i]>(i==4?2:1)){message(L"风格/遮罩/UI修正必须为整数");return false;}
s.model={v[0],v[1],v[2],v[3],int(v[4]),int(v[5]),int(v[6])};s.residual={v[7],v[8],v[9],v[10],v[11]};if(enhancementEnabled){s.nr=checked(200)==BST_CHECKED;s.sr=checked(201)==BST_CHECKED;}s.videoSrQuality=uint32_t(send(207,CB_GETCURSEL,0,0));if(allPages)s.multiplier=uint32_t(send(202,CB_GETCURSEL,0,0)+1);s.nrPolicy=static_cast<pipeline::NrSizePolicy>(send(203,CB_GETCURSEL,0,0));if(allPages){s.flow=static_cast<engine::FlowQuality>(send(204,CB_GETCURSEL,0,0));s.content=static_cast<engine::ContentRate>(send(205,CB_GETCURSEL,0,0));}if(!s.validate().empty()){message(L"参数越界,未提交。悬停数值框查看允许范围。");return false;}return true;}
@@ -57,6 +58,7 @@ bool liveField(int id){
case 203:s.nrPolicy=static_cast<pipeline::NrSizePolicy>(send(id,CB_GETCURSEL));break;
case 204:s.flow=static_cast<engine::FlowQuality>(send(id,CB_GETCURSEL));break;
case 205:s.content=static_cast<engine::ContentRate>(send(id,CB_GETCURSEL));break;
+ case 208:s.frameGenerationBackend=static_cast<engine::FrameGenerationBackend>(send(id,CB_GETCURSEL));break;
case 207:s.videoSrQuality=uint32_t(send(id,CB_GETCURSEL));break;
case 700:case 701:case 702:s.model.style=id-700;break;
case 710:case 711:s.model.autoMask=id-710;break;
@@ -107,10 +109,10 @@ case WM_CREATE:{window=h;font=makeFont(h);items.clear();
add(L"STATIC",L"肤质 / 风格 / 遮罩 / UI键为本地实验参数。未验证的效果不会标成可用能力。",1102,0,0,12,956,-1,70);
button(L"还原默认",211,-1,12,86);
add(L"STATIC",L"补帧与运动估算",1103,0,1,12,12,-1,30);
- combo(202,1,52,{L"关闭补帧",L"DLSSG 2X",L"DLSSG 3X · 需硬件支持",L"DLSSG 4X · 需硬件支持"});
- combo(204,1,104,{L"光流 · 性能",L"光流 · 平衡",L"光流 · 质量"});
+ combo(202,1,52,{L"关闭补帧",L"2X · 一张中间帧",L"3X · 两张中间帧",L"4X · 三张中间帧"});
+ combo(204,1,104,{L"NR / DLSS光流 · 性能",L"NR / DLSS光流 · 平衡",L"NR / DLSS光流 · 质量"});
combo(205,1,156,{L"采用源时间戳",L"自动识别内容节奏",L"识别30fps内容节奏",L"识别50fps内容节奏",L"识别60fps内容节奏"});
- add(L"STATIC",L"运动为估算输入。倍率不代表实际显示帧率。比较时只展示真实帧;采集补帧需要等待下一张源帧。",1104,0,1,12,210,-1,100);
+ add(L"STATIC",L"FRUC倍率越高,耗时越多。光流档位用于NR/DLSS;FRUC内部自动控制。补帧需等待下一张源帧,倍率不等于实测显示帧率。",1104,0,1,12,210,-1,100);
add(L"STATIC",L"用户预设",1105,0,2,12,12,-1,30);combo(300,2,56,{});add(L"EDIT",L"新预设",301,ES_AUTOHSCROLL|WS_TABSTOP,2,12,108,-1,36);send(301,EM_SETLIMITTEXT,48,0);
const wchar_t* names[]={L"载入所选预设",L"新建内建默认预设",L"保存当前参数为新预设",L"重命名所选",L"删除所选",L"设为启动增强默认"};for(int i=0;i<6;++i)button(names[i],310+i,2,12,164+i*44);
@@ -128,6 +130,8 @@ case WM_CREATE:{window=h;font=makeFont(h);items.clear();
add(L"STATIC",L"最多4区,左键拖框,Esc取消。仅抑制NR变化;不保护SR或补帧。可随预设保存;换源清空。",1109,0,0,12,232,-1,82);
for(auto& entry:items)if(entry.page==0&&entry.y>=104)entry.y+=48;
combo(207,0,100,{L"DLSS SR",L"RTX 视频超分 · 低",L"RTX 视频超分 · 中",L"RTX 视频超分 · 高",L"RTX 视频超分 · 最高"});
+ for(auto& entry:items)if(entry.page==1)entry.y+=48;
+ combo(208,1,8,{L"DLSS 帧生成",L"NVIDIA FRUC · 视频补帧"});
loadStore();refreshPresets();populate(controller->snapshot().desired);message(store.error());SetTimer(h,1,250,nullptr);arrange();return 0;}
case WM_SIZE:arrange();return 0;
case WM_ERASEBKGND:return 1;
@@ -135,7 +139,7 @@ case WM_PAINT:{PaintBuffer paint(h);fillSurface(paint.dc,paint.rect,h);return 0;
case WM_VSCROLL:{switch(LOWORD(wp)){case SB_LINEUP:scroll-=40;break;case SB_LINEDOWN:scroll+=40;break;case SB_PAGEUP:scroll-=240;break;case SB_PAGEDOWN:scroll+=240;break;case SB_THUMBTRACK:{SCROLLINFO si{sizeof(si),SIF_TRACKPOS};GetScrollInfo(h,SB_VERT,&si);scroll=si.nTrackPos;break;}}arrange();return 0;}
case WM_MOUSEWHEEL:scroll-=GET_WHEEL_DELTA_WPARAM(wp)/WHEEL_DELTA*90;arrange();return 0;
case WM_CTLCOLORSTATIC:case WM_CTLCOLOREDIT:case WM_CTLCOLORLISTBOX:case WM_CTLCOLORBTN:return colors(msg,wp,lp);
-case WM_COMMAND:{const int id=LOWORD(wp);if(!populating&&((id>=202&&id<=205||id==207)&&HIWORD(wp)==CBN_SELCHANGE||(id>=700&&id<=721)&&HIWORD(wp)==BN_CLICKED)){liveField(id);return 0;}if((id==206||id==213||id==214)&&HIWORD(wp)==BN_CLICKED){const auto accepted=SendMessageW(GetParent(h),WM_APP+45,id,checked(206));message(accepted?(id==213?L"请在画面中左键拖动框选;Esc取消。":L"已请求更新NR保护区域。"):L"未能操作:请先打开画面,或清除已满的4个区域。");return 0;}if((id==200||id==201)&&HIWORD(wp)==BN_CLICKED){const bool accepted=SendMessageW(GetParent(h),WM_APP+44,id,checked(id))!=0;message(accepted?L"已请求开关;确认帧边界结果后生效。":L"总增强正在切换,请待当前事务完成。");return 0;}if(HIWORD(wp)==EN_SETFOCUS){for(auto& item:items)if(GetDlgCtrlID(item.h)==id&&item.page==page){RECT r{};GetClientRect(h,&r);int height=MulDiv(r.bottom,96,GetDpiForWindow(h))-128;if(item.y<scroll)scroll=item.y;if(item.y+item.height>scroll+height)scroll=item.y+item.height-height;arrange();break;}}if(!populating&&id>=100&&id<=111&&HIWORD(wp)==EN_CHANGE){liveField(id);return 0;}
+case WM_COMMAND:{const int id=LOWORD(wp);if(!populating&&((id>=202&&id<=205||id==207||id==208)&&HIWORD(wp)==CBN_SELCHANGE||(id>=700&&id<=721)&&HIWORD(wp)==BN_CLICKED)){liveField(id);return 0;}if((id==206||id==213||id==214)&&HIWORD(wp)==BN_CLICKED){const auto accepted=SendMessageW(GetParent(h),WM_APP+45,id,checked(206));message(accepted?(id==213?L"请在画面中左键拖动框选;Esc取消。":L"已请求更新NR保护区域。"):L"未能操作:请先打开画面,或清除已满的4个区域。");return 0;}if((id==200||id==201)&&HIWORD(wp)==BN_CLICKED){const bool accepted=SendMessageW(GetParent(h),WM_APP+44,id,checked(id))!=0;message(accepted?L"已请求开关;确认帧边界结果后生效。":L"总增强正在切换,请待当前事务完成。");return 0;}if(HIWORD(wp)==EN_SETFOCUS){for(auto& item:items)if(GetDlgCtrlID(item.h)==id&&item.page==page){RECT r{};GetClientRect(h,&r);int height=MulDiv(r.bottom,96,GetDpiForWindow(h))-128;if(item.y<scroll)scroll=item.y;if(item.y+item.height>scroll+height)scroll=item.y+item.height-height;arrange();break;}}if(!populating&&id>=100&&id<=111&&HIWORD(wp)==EN_CHANGE){liveField(id);return 0;}
if(!populating&&id>=100&&id<=111&&HIWORD(wp)==EN_KILLFOCUS){populate(enhancementEnabled?controller->snapshot().desired:configuredSettings);return 0;}
engine::EnhancementSettings s;wchar_t name[128]{};GetWindowTextW(item(301),name,128);const auto index=size_t(send(300,CB_GETCURSEL,0,0));bool ok=true;
if(id==211){SetFocus(body);s={};if(submit(s)){populate(s);message(L"已还原内建默认;用户预设保留");}}
diff --git a/apps/veyra/TelemetryWindow.cpp b/apps/veyra/TelemetryWindow.cpp
index ba8d88f7..48b4a053 100644
--- a/apps/veyra/TelemetryWindow.cpp
+++ b/apps/veyra/TelemetryWindow.cpp
@@ -1,5 +1,6 @@
#include "TelemetryWindow.h"
#include "veyra/Log.h"
+#include "veyra/RuntimePaths.h"
#include <shellapi.h>
#include <filesystem>
#include "ui/Theme.h"
@@ -29,7 +30,7 @@ case WM_CTLCOLORSTATIC:case WM_CTLCOLOREDIT:case WM_CTLCOLORLISTBOX:case WM_CTLC
case WM_TIMER:refresh();return 0;
case WM_COMMAND:if(LOWORD(w)==6){SendMessageW(GetParent(h),WM_APP+43,0,0);}else if(LOWORD(w)==3){preview=wide(Logger::instance().diagnosticReport());SetDlgItemTextW(h,2,preview.c_str());}else if(LOWORD(w)==4&&!preview.empty()){
if(OpenClipboard(h)){HGLOBAL data=GlobalAlloc(GMEM_MOVEABLE,(preview.size()+1)*sizeof(wchar_t));if(data){if(void* p=GlobalLock(data)){memcpy(p,preview.c_str(),(preview.size()+1)*sizeof(wchar_t));GlobalUnlock(data);EmptyClipboard();if(!SetClipboardData(CF_UNICODETEXT,data))GlobalFree(data);}else GlobalFree(data);}CloseClipboard();}
-}else if(LOWORD(w)==5)ShellExecuteW(h,L"open",(std::filesystem::path(VEYRA_PROJECT_ROOT)/"logs").c_str(),nullptr,nullptr,SW_SHOW);return 0;
+}else if(LOWORD(w)==5)ShellExecuteW(h,L"open",runtime::logsDirectory().c_str(),nullptr,nullptr,SW_SHOW);return 0;
case WM_CLOSE:DestroyWindow(h);return 0;case WM_DESTROY:KillTimer(h,1);DeleteObject(font);window=nullptr;return 0;}return DefWindowProcW(h,m,w,l);}
}
diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cpp
index a9c9c128..00f88097 100644
--- a/apps/veyra/ui/AppShell.cpp
+++ b/apps/veyra/ui/AppShell.cpp
@@ -26,6 +26,7 @@
#include "veyra/engine/VideoExportJob.h"
#include "veyra/source/CaptureCardSource.h"
#include "veyra/Log.h"
+#include "veyra/RuntimePaths.h"
#include "veyra/engine/Subtitles.h"
namespace {
constexpr DWORD ShellStyle=WS_POPUP|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_SYSMENU|WS_CLIPCHILDREN;
@@ -33,7 +34,7 @@ enum {Open=101,Play,Stop,Save,Nr,Sr,Fg,Seek,Info,Capture,Export,Realtime,Recent,
veyra::engine::EngineController engine;
veyra::engine::ExportJobManager exportJob;
veyra::ui::UiSessionState uiState;
-veyra::ui::UiPreferenceStore preferences(std::filesystem::path(VEYRA_PROJECT_ROOT)/"runtime_local");veyra::ui::UiPreferences uiPreferences;
+veyra::ui::UiPreferenceStore preferences(veyra::runtime::localDataDirectory());veyra::ui::UiPreferences uiPreferences;
HWND inspector=nullptr,metricLabel=nullptr,tooltips=nullptr,diagnosticPanel=nullptr;bool showDiagnostics=false,inspectorResizing=false;int proposedInspectorWidth=320;bool preferWatching=true,jobPaused=false;int subtitlePixels=22;
veyra::engine::EnhancementSettings lastSuccessful,jobExpected;bool haveSuccessful=false;uint64_t masterPendingRevision=0,masterPendingSession=0;bool masterPreviousEnabled=true;
std::wstring smokeView;bool smokeViewApplied=false;
@@ -118,7 +119,7 @@ std::wstring fileDialog(bool save){std::vector<wchar_t> name(32768);OPENFILENAME
ofn.lpstrFilter=save?L"PNG图片\0*.png\0JPEG图片\0*.jpg\0":L"视频 / 图片\0*.mp4;*.mkv;*.mov;*.avi;*.ts;*.png;*.jpg;*.jpeg\0所有文件\0*.*\0";
ofn.Flags=OFN_EXPLORER|OFN_NOCHANGEDIR|OFN_PATHMUSTEXIST|(save?OFN_OVERWRITEPROMPT:OFN_FILEMUSTEXIST);ofn.lpstrDefExt=save?L"png":nullptr;
return (save?GetSaveFileNameW(&ofn):GetOpenFileNameW(&ofn))?name.data():L"";}
-void openFile(const std::wstring& file){if(file.empty())return;cancelProtection();auto openOptions=options();if(file!=currentFile){openOptions.settings.protection={};uiState.configured.protection={};}auto ext=std::filesystem::path(file).extension().wstring();for(auto& c:ext)c=towlower(c);if((ext==L".png"||ext==L".jpg"||ext==L".jpeg")&&uiState.mode==veyra::ui::Mode::Daily)switchMode();engine.previewView({});currentFile=file;subtitles=veyra::engine::loadSrt(std::filesystem::path(file).replace_extension(L".srt").wstring());paused=false;SetWindowTextW(GetDlgItem(mainWindow,Play),L"暂停");engine.open(video,file,openOptions);SetWindowTextW(mainWindow,(L"Veyra — "+std::filesystem::path(file).filename().wstring()).c_str());if(smokeSeconds<=0)WritePrivateProfileStringW(L"Player",L"最近打开",file.c_str(),(std::filesystem::path(VEYRA_PROJECT_ROOT)/"runtime_local/veyra.ini").wstring().c_str());}
+void openFile(const std::wstring& file){if(file.empty())return;cancelProtection();auto openOptions=options();if(file!=currentFile){openOptions.settings.protection={};uiState.configured.protection={};}auto ext=std::filesystem::path(file).extension().wstring();for(auto& c:ext)c=towlower(c);if((ext==L".png"||ext==L".jpg"||ext==L".jpeg")&&uiState.mode==veyra::ui::Mode::Daily)switchMode();engine.previewView({});currentFile=file;subtitles=veyra::engine::loadSrt(std::filesystem::path(file).replace_extension(L".srt").wstring());paused=false;SetWindowTextW(GetDlgItem(mainWindow,Play),L"暂停");engine.open(video,file,openOptions);SetWindowTextW(mainWindow,(L"Veyra — "+std::filesystem::path(file).filename().wstring()).c_str());if(smokeSeconds<=0)WritePrivateProfileStringW(L"Player",L"最近打开",file.c_str(),(veyra::runtime::localDataDirectory()/"veyra.ini").wstring().c_str());}
HWND control(const wchar_t* cls,const wchar_t* label,int id,DWORD style,int x,int y,int w,int h){auto hwnd=CreateWindowExW(0,cls,label,WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|style|(_wcsicmp(cls,L"STATIC")?WS_TABSTOP:0),x,y,w,h,mainWindow,reinterpret_cast<HMENU>(INT_PTR(id)),GetModuleHandleW(nullptr),nullptr);SendMessageW(hwnd,WM_SETFONT,reinterpret_cast<WPARAM>(font),TRUE);veyra::ui::themeControl(hwnd);if(id>=Open&&id<=Fullscreen&&id!=Seek)toolbar.push_back({hwnd,w});return hwnd;}
void refreshDailyPresets(){auto h=GetDlgItem(mainWindow,DailyPreset);if(!h)return;SendMessageW(h,CB_RESETCONTENT,0,0);SendMessageW(h,CB_ADDSTRING,0,LPARAM(L"当前自定义设置"));for(auto& name:veyra::ui::presetNames())SendMessageW(h,CB_ADDSTRING,0,LPARAM(name.c_str()));SendMessageW(h,CB_SETCURSEL,0,0);}
void selectInspector(int page){uiState.inspector=page;veyra::ui::settingsPage(page);for(int i=0;i<4;++i)veyra::ui::selected(GetDlgItem(mainWindow,TabEnhance+i),i==page);}
@@ -279,7 +280,7 @@ case Mute:{auto s=engine.snapshot();engine.setVolume(s.volume,!s.muted);break;}
case Subtitle:if(lp)subtitleMenu();else{uiState.subtitles=!uiState.subtitles;layout();}break;
case SubtitleLoad:{std::vector<wchar_t> name(32768);OPENFILENAMEW d{sizeof(d)};d.hwndOwner=hwnd;d.lpstrFile=name.data();d.nMaxFile=32768;d.lpstrFilter=L"SubRip 字幕\0*.srt\0";d.Flags=OFN_FILEMUSTEXIST|OFN_NOCHANGEDIR;if(GetOpenFileNameW(&d)){subtitles=veyra::engine::loadSrt(name.data());uiState.subtitles=true;layout();}break;}
case SubtitleSize:subtitlePixels=subtitlePixels==22?28:subtitlePixels==28?34:22;break;
-case Recent:{std::vector<wchar_t> recent(32768);GetPrivateProfileStringW(L"Player",L"最近打开",L"",recent.data(),32768,(std::filesystem::path(VEYRA_PROJECT_ROOT)/"runtime_local/veyra.ini").wstring().c_str());openFile(recent.data());break;}
+case Recent:{std::vector<wchar_t> recent(32768);GetPrivateProfileStringW(L"Player",L"最近打开",L"",recent.data(),32768,(veyra::runtime::localDataDirectory()/"veyra.ini").wstring().c_str());openFile(recent.data());break;}
case Play:{auto s=engine.snapshot();if(s.capture||s.image||s.transport==veyra::engine::TransportState::Opening||s.transport==veyra::engine::TransportState::Stopping)break;if(!currentFile.empty()&&(!s.running||s.transport==veyra::engine::TransportState::Ended)){openFile(currentFile);break;}paused=s.transport==veyra::engine::TransportState::Playing;engine.pause(paused);SetWindowTextW(GetDlgItem(hwnd,Play),paused?L"播放":L"暂停");break;}
case Stop:engine.stop();break;
case Save:{auto name=fileDialog(true);if(!name.empty())engine.saveFrame(name);break;}
@@ -401,10 +402,10 @@ int runVeyraApp(HINSTANCE instance,int show){
Gdiplus::GdiplusStartupInput graphicsInput;ULONG_PTR graphicsToken=0;Gdiplus::GdiplusStartup(&graphicsToken,&graphicsInput,nullptr);struct GraphicsCleanup{ULONG_PTR token;~GraphicsCleanup(){Gdiplus::GdiplusShutdown(token);}} graphicsCleanup{graphicsToken};
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);INITCOMMONCONTROLSEX controls{sizeof(controls),ICC_BAR_CLASSES};InitCommonControlsEx(&controls);
CoInitializeEx(nullptr,COINIT_APARTMENTTHREADED);
-std::filesystem::create_directories(std::filesystem::path(VEYRA_PROJECT_ROOT)/"logs");wchar_t logOverride[32768]{};GetEnvironmentVariableW(L"VEYRA_LOG_FILE",logOverride,32768);veyra::Logger::instance().openFile(logOverride[0]?std::wstring(logOverride):(std::filesystem::path(VEYRA_PROJECT_ROOT)/"logs/veyra-app.log").wstring());
+std::filesystem::create_directories(veyra::runtime::logsDirectory());wchar_t logOverride[32768]{};GetEnvironmentVariableW(L"VEYRA_LOG_FILE",logOverride,32768);veyra::Logger::instance().openFile(logOverride[0]?std::wstring(logOverride):(veyra::runtime::logsDirectory()/"veyra-app.log").wstring());
initialOptions=veyra::engine::PlayerOptions::from(veyra::ui::defaultSettings());
-int argc=0;auto argv=CommandLineToArgvW(GetCommandLineW(),&argc);for(int i=1;i<argc;++i){const std::wstring arg=argv[i];if(arg==L"--export-worker"&&i+1<argc)workerMapping=reinterpret_cast<HANDLE>(_wcstoui64(argv[++i],nullptr,10));else if(arg==L"--smoke-view"&&i+1<argc)smokeView=argv[++i];else if(arg==L"--smoke-repair-ui")smokeRepair=true;else if(arg==L"--smoke-repair-ui-reject")smokeRepair=smokeRepairReject=true;else if(arg==L"--smoke-hover")smokeZoom=smokeHover=true;else if(arg==L"--smoke-protection")smokeProtection=true;else if(arg==L"--smoke-zoom")smokeZoom=true;else if(arg==L"--smoke-empty")smokeEmpty=true;else if(arg==L"--smoke-dual")smokeDual=true;else if(arg==L"--smoke-dual-pause"){smokeDual=smokeDualPause=true;}else if(arg==L"--smoke-master-reject")smokeMaster=smokeMasterReject=true;else if(arg==L"--smoke-master")smokeMaster=true;else if(arg==L"--smoke-audio")smokeAudio=true;else if(arg==L"--smoke-job-cancel")smokeJobCancel=true;else if(arg==L"--smoke-job-exit")smokeJobExit=true;else if(arg==L"--smoke-job")smokeJob=true;else if(arg==L"--smoke-dual-export"&&i+1<argc)smokeDualOutput=argv[++i];else if(arg==L"--smoke-seconds"&&i+1<argc)smokeSeconds=std::clamp(_wtoi(argv[++i]),1,240);else if(arg==L"--export-out"&&i+1<argc)exportOutput=argv[++i];else if(arg==L"--max-frames"&&i+1<argc)exportFrames=std::max(1,_wtoi(argv[++i]));else if(arg==L"--cancel-after-ms"&&i+1<argc)cancelAfterMs=std::clamp(_wtoi(argv[++i]),1,240000);else if(arg==L"--hevc")exportHevc=true;else if(arg==L"--smoke-rollback-flow"){smokeRollback=true;smokeRollbackFlow=true;}else if(arg==L"--smoke-rollback")smokeRollback=true;else if(arg==L"--smoke-ui")smokeUi=true;else if(arg==L"--no-fg")initialOptions.fg=false;else if(arg==L"--smoke-settings")smokeSettings=true;else if(arg==L"--smoke-controls")smokeControls=true;else if(arg==L"--smoke-save"&&i+1<argc)smokeSave=argv[++i];else if(arg==L"--native")initialOptions.realtime=false;else if(arg==L"--realtime")initialOptions.realtime=true;else if(arg==L"--fg")initialOptions.fg=true;else if(arg==L"--fg-multiplier"&&i+1<argc){initialOptions.fgMultiplier=std::clamp(_wtoi(argv[++i]),2,4);initialOptions.fg=true;}else if(arg==L"--video-sr"&&i+1<argc){initialOptions.settings.videoSrQuality=std::clamp(_wtoi(argv[++i]),1,4);initialOptions.sr=true;}else if(arg==L"--sr")initialOptions.sr=true;else if(arg==L"--no-nr")initialOptions.nr=false;else if(arg==L"--nr")initialOptions.nr=true;else if(arg==L"--no-sr")initialOptions.sr=false;else autoInput=arg;}LocalFree(argv);
+int argc=0;auto argv=CommandLineToArgvW(GetCommandLineW(),&argc);for(int i=1;i<argc;++i){const std::wstring arg=argv[i];if(arg==L"--export-worker"&&i+1<argc)workerMapping=reinterpret_cast<HANDLE>(_wcstoui64(argv[++i],nullptr,10));else if(arg==L"--smoke-view"&&i+1<argc)smokeView=argv[++i];else if(arg==L"--smoke-repair-ui")smokeRepair=true;else if(arg==L"--smoke-repair-ui-reject")smokeRepair=smokeRepairReject=true;else if(arg==L"--smoke-hover")smokeZoom=smokeHover=true;else if(arg==L"--smoke-protection")smokeProtection=true;else if(arg==L"--smoke-zoom")smokeZoom=true;else if(arg==L"--smoke-empty")smokeEmpty=true;else if(arg==L"--smoke-dual")smokeDual=true;else if(arg==L"--smoke-dual-pause"){smokeDual=smokeDualPause=true;}else if(arg==L"--smoke-master-reject")smokeMaster=smokeMasterReject=true;else if(arg==L"--smoke-master")smokeMaster=true;else if(arg==L"--smoke-audio")smokeAudio=true;else if(arg==L"--smoke-job-cancel")smokeJobCancel=true;else if(arg==L"--smoke-job-exit")smokeJobExit=true;else if(arg==L"--smoke-job")smokeJob=true;else if(arg==L"--smoke-dual-export"&&i+1<argc)smokeDualOutput=argv[++i];else if(arg==L"--smoke-seconds"&&i+1<argc)smokeSeconds=std::clamp(_wtoi(argv[++i]),1,240);else if(arg==L"--export-out"&&i+1<argc)exportOutput=argv[++i];else if(arg==L"--max-frames"&&i+1<argc)exportFrames=std::max(1,_wtoi(argv[++i]));else if(arg==L"--cancel-after-ms"&&i+1<argc)cancelAfterMs=std::clamp(_wtoi(argv[++i]),1,240000);else if(arg==L"--hevc")exportHevc=true;else if(arg==L"--smoke-rollback-flow"){smokeRollback=true;smokeRollbackFlow=true;}else if(arg==L"--smoke-rollback")smokeRollback=true;else if(arg==L"--smoke-ui")smokeUi=true;else if(arg==L"--no-fg")initialOptions.fg=false;else if(arg==L"--smoke-settings")smokeSettings=true;else if(arg==L"--smoke-controls")smokeControls=true;else if(arg==L"--smoke-save"&&i+1<argc)smokeSave=argv[++i];else if(arg==L"--native")initialOptions.realtime=false;else if(arg==L"--realtime")initialOptions.realtime=true;else if(arg==L"--fg")initialOptions.fg=true;else if(arg==L"--fg-multiplier"&&i+1<argc){initialOptions.fgMultiplier=std::clamp(_wtoi(argv[++i]),2,4);initialOptions.fg=true;}else if(arg==L"--fruc"){initialOptions.settings.frameGenerationBackend=veyra::engine::FrameGenerationBackend::Fruc;initialOptions.fg=true;}else if(arg==L"--video-sr"&&i+1<argc){initialOptions.settings.videoSrQuality=std::clamp(_wtoi(argv[++i]),1,4);initialOptions.sr=true;}else if(arg==L"--sr")initialOptions.sr=true;else if(arg==L"--no-nr")initialOptions.nr=false;else if(arg==L"--nr")initialOptions.nr=true;else if(arg==L"--no-sr")initialOptions.sr=false;else autoInput=arg;}LocalFree(argv);
if(workerMapping){const int code=veyra::engine::runExportWorker(workerMapping);CoUninitialize();return code;}
if(smokeSeconds<=0&&exportOutput.empty()){uiPreferences=preferences.load();initialOptions=veyra::engine::PlayerOptions::from(preferences.startup(initialOptions.snapshot()));engine.setVolume(uiPreferences.volume,uiPreferences.muted);uiState.subtitles=uiPreferences.subtitles;subtitlePixels=uiPreferences.subtitleSize;}
engine.requestSettings(initialOptions.snapshot());
diff --git a/docs/FRUC_INTEGRATION_2026-09-09.md b/docs/FRUC_INTEGRATION_2026-09-09.md
new file mode 100644
index 00000000..450c6622
--- /dev/null
+++ b/docs/FRUC_INTEGRATION_2026-09-09.md
@@ -0,0 +1,58 @@
+# FRUC 与高帧率接入 — 2026-09-09(Cycle87–88)
+
+## 当前范围
+
+本机可选实验后端。专业模式 → 补帧 → 选择「NVIDIA FRUC · 视频补帧」,下方选择关闭 / 2X / 3X / 4X;实时应用。DLSS后端保留,默认仍为DLSS;还原默认关闭补帧。后端随预设保存,预设schema4兼容旧1–3,旧版默认DLSS。只选FRUC但关闭补帧不启动辅助进程,也不要求FRUC DLL可用。
+
+共享顺序为 source → SR(DLSS或RTX Video)→ NR → FG(DLSS或FRUC)→ 呈现/导出。三入口仍使用同一EnhanceGraph,没有复制NR/颜色/指导实现。光流档位配置NR/DLSS共享NVOF,不配置FRUC内部算法;FRUC公开接口没有同等质量滑条。
+
+## 1000fps 的准确含义
+
+呈现原本没有60fps硬锁,Present采用非vsync路径;发现并放宽的是采集间隔估计和CFR导出准入中的120fps政策上限,现在允许到1000fps(1ms源帧间隔)。PTS连续性/VFR拒绝等完整性判断保留。显示器刷新率、解码、GPU预算、驱动呈现和编码器支持仍分别限制实际吞吐。
+
+实际 `app-1000fps.log`:256×144、1000fps、2秒合成H.264,关闭NR/SR/FG,完整处理2000源帧,processedFps=999.34,failed=false,source读取与处理未锁60。不是4K千帧、开启增强千帧或屏幕物理显示1000幅/秒的证明。1080p/4K普通视频仍走当前软件解码,没有借本次改动宣称NVDEC已接入。
+
+## 官方接口与实现
+
+依据NVIDIA [FRUC guide](https://docs.nvidia.com/video-technologies/optical-flow-sdk/nvfruc-programming-guide/index.html) 与用户本机Optical Flow SDK5.0.7头文件独立实现,没有复制其他项目/SDK sample实现。
+
+- 接口输入当前帧并缓存上一帧,指定任意两帧间目标时间戳;同实例禁止把同一输入重复调用来伪造多倍补帧。
+- SDK没有2X/3X/4X枚举。Veyra用1/2/3个独立FRUC实例,分别算1/2,1/3+2/3,1/4+2/4+3/4位置。每个实例每个源帧只调用一次,生成帧不递归当源帧。
+- 仍必须等B到达才能在A/B之间补帧。源15fps的一帧lookahead约66.7ms,不能拿9ms阶段耗时冒充端到端延迟。
+- Windows接口D3D11。父进程D3D12共享RGBA8纹理/共享fence,子进程同adapter LUID的D3D11打开它们。输入copy → fence signal → FRUC依次wait/signal → 父D3D12 queue wait → output copy。正常路径没有GPU→CPU像素回读。
+- `veyra_fruc_worker.exe`为本项目源码构建的隐藏辅助进程;只继承白名单内存映射/event/纹理/fence句柄。共享内存只含控制参数/状态/重复标志,无像素。Job Object限定子进程寿命,退出时只终止本次拥有的worker。
+- IPC等待的是CPU API返回/提交确认(10秒故障上限),GPU完成靠共享fence。FRUC SDK本身可能阻塞CPU,此路径不宣称SDK是完全异步的。
+- 每个FRUC实例创建后记录SDK留下的CUDA上下文,调用前切换,之后恢复;直接省略上下文切换会出现result16。
+- SDK重复回退标志映射GenerationValidity::Disabled,不计为有效生成帧。导出沿用原有明确hold计数;不把hold写成真实补帧。
+
+本地DLL身份:`NvOFFRUC.dll` SHA256 `5A0B6701D30709E25E7E5B92CA46B18AAB1459160CECD4F629872369D85C8B0A`,783416bytes,Valid NVIDIA签名。仅从忽略的本机SDK绝对路径加载,不复制/上传/分发;CUDA使用System32绝对路径。依赖协议和分发权仍需审计。
+
+## 重建失败证据与处理
+
+尝试同进程方式时,首次2/3/4倍生成能成功,但销毁后重新注册返回4(InvalidHandle);先创建替代实例再销毁旧实例会在下一次warp出现0xC0000005。正常上下文恢复、逆序销毁、保持模块驻留未解决重复注册失败。没有继续用同一失败指纹无限尝试,没有修改或替换SDK DLL。
+
+最终改为每次完整重置启动干净worker进程,保留GPU共享纹理。测试覆盖连续3次reset且每次reset后再次process,不止检查seed帧。`bSkipWarp`只承诺更新状态并跳过warp,没有证据证明其清除全部光流历史,本轮不将它冒充完整reset。
+
+代价:seek、scene-cut、capture-drop、参数历史reset会有worker重建成本。尤其当高倍率超过源帧预算、采集持续掉帧时,可能反复重建并恶化卡顿。这是本轮已知实卡风险,未宣称可用于任意4K/60卡的稳定4X。后续优化应先对比重置后下一对像素与fresh worker一致性,再决定可否轻量reseeding,不能直接去掉reset门槛。
+
+## 实际测试(Maker)
+
+命令均单次≤300秒;本轮常见8–60秒上限,无实卡占用。
+
+- 构建:`powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/build.ps1 -Root <project> -Preset x64-release`;最终源码候选 `logs/video-sdk-trial-20260909/build-fruc-lazy.log`。
+- CPU:`veyra_live_timing_tests.exe`16项、`veyra_repair_contract_tests.exe`27项、`veyra_repair_preset_tests.exe <独立临时文件>`全部通过。首次preset漏传路径exit2为调用错误,补传独立路径后通过。
+- GPU像素/PTS:`veyra_fruc_tests.exe 2|3|4 logs/video-sdk-trial-20260909/pan.nv12`,已知8pixel/帧平移6源帧,分别5/10/15有效生成帧;最大RGB8 MAE约0.00008 / 0.29943 / 0.14638,均优于保持上一帧;各子帧PTS误差≤1个100ns tick;连续3次reset后无跨epoch生成,下一次process成功。日志 `fruc-worker2/3/4.stdout.log`。这里只证明构造平移样本,不能推断遮挡/字幕/自然场景总体画质。
+- 真播放器known-pan15:2X为60源+59生成;3X为59源+116生成;4X为57源+168生成,各failed=false。日志 `app-knownpan2/3/4.log`。FRUC阶段区间中位数约9.22 / 18.36 / 27.13ms,P95约11.69 / 22.86 / 33.92ms;这是GPU时间戳包住共享队列等待/IPC提交的阶段区间,非纯CUDA核耗时、非端到端延迟。
+- 正常testsrc2并非每帧满足SDK质量门槛:`app-fruc4-controls.log` 和 `app-fruc2-srnr.log` 成功执行但generated=0(repeat回退),如实保留。这说明打开倍率不保证每对源帧都有有效生成,不能只看API成功码。
+- SR→NR→FRUC:`app-fruc2-srnr.log` 实际执行VSR、NR和FRUC,87个NR帧,无失败;该样本重复回退不作为生成画质通过证据。
+- UI实时切换:`python scripts/acceptance/ui-fruc-switch.py`;2→3→4→DLSS→FRUC→关闭→2→还原默认通过,未更改用户启动偏好。Maker日志 `logs/fruc-switch-ae7549842be3415b937af9e0ac6a307d.log`(最终lazy创建变更后需独立重跑)。
+- NVENC D3D12导出:`veyra.exe --export-out <新文件> --max-frames 12 --no-nr --no-sr --fruc --fg-multiplier 2|3|4 <known-pan15.mp4>`。分别12源+11生成+1尾部hold=24帧/30fps,12+22+2=36帧/45fps,12+33+3=48帧/60fps;ffprobe均1920×1080、0.8s。日志 `export-fruc2/3/4.log`、`.ffprobe.json`。该素材无音轨,本轮FRUC导出不单独声称测过有声源;已有统一gate继续验证既有完整性,不加重检查。
+
+## 尚待/限制
+
+独立只读复核与preflight/phase7结果见下方追加记录。整体Phase7仍in_progress;自然视频主观质量、实卡FRUC延迟/掉帧、4K高倍率持续性能和长时间稳定仍未验收。NR表盘依旧仅NR阶段,旧统计窗口混合配置问题不在本次修复中。不得公开打包专有runtime。
+
+
+## 独立检查与用户反馈补充
+
+独立review_fruc已报告CPU16+27项/preset、实际2/3/4pixel/PTS/连续reset、UI全后端切换和自有worker进程故障测试通过,无新增已确认P0/P1/P2消息。preflight69 PASS;其实际phase7日志 `logs/video-sdk-trial-20260909/review-fruc-gate-phase7.log` 为73 PASS,delivery `logs/delivery/1c195ef6d3684879b220fc8c13439e83/result.json`。Reviewer随后额度耗尽,未返回最终整体结论;因此记录为independent_checks_passed / final_verdict_unavailable,不伪造最终Reviewer PASS。用户随后明确“我已经测试没问题”,记录用户本次体验通过,不外推其未说明的配置与长期稳定性。程序SHA256 BD76BA1F3D66DF30286E450AD1742E773F48989B5815C175BDC0A297ABF4E94D;workerSHA256 B6F267C3B1C73DE0CB99C4BAD4B5DA9355C42DF7E7F37F21C9891B02B80412A3。
diff --git a/docs/RELEASE_NOTES_0.0.1.md b/docs/RELEASE_NOTES_0.0.1.md
new file mode 100644
index 00000000..628ac4d5
--- /dev/null
+++ b/docs/RELEASE_NOTES_0.0.1.md
@@ -0,0 +1,32 @@
+# Veyra 0.0.1
+
+首个公开源码与免安装实验版。
+
+## 本版本包含
+
+- 日常观看模式与可展开的专业工作台。
+- 视频、图片和采集设备入口。
+- 播放、音量、字幕、全屏、最近文件和专业模式对比工具。
+- 可选的增强、超分、补帧、图片导出和视频导出工作流。
+- 运行目录自定位:便携版从 `Veyra.exe` 所在目录读取 shader、设置、日志与运行时,不再依赖开发机绝对路径。
+- 用户授权的 Runtime Pack:固定版本的 DLSS SR、DLSSG、DLSSNR、RTX Video VSR 与 FRUC 运行时,随包提供哈希、签名状态和许可证文件。
+
+## 使用
+
+解压后运行 `Veyra.exe`。Release 构建会校验 `runtime_local/nvidia/release-runtime-manifest.json` 中列出的运行时哈希和签名;NR 与 FRUC 在启动时还会校验固定身份。兼容的 RTX 环境可直接启用相应功能。校验、驱动、硬件或初始化失败时,只关闭受影响的增强,播放器、采集与导出仍可启动。
+
+NR、DLSSG 和 FRUC 是社区实验运行时,不代表 NVIDIA 官方合作、认证或支持。请不要替换包内 DLL,也不要从游戏目录、驱动缓存或未知来源复制文件。
+
+## 已知限制
+
+- 这是实验版本,未宣称全部 GPU、驱动、采集卡或高倍率补帧组合已完成长期验证。
+- HDR、AV1 / ProRes 导出和 VFR 原样输出不在本版本范围。
+- 3X / 4X 补帧为实验功能;所选倍率不保证每对输入帧都能生成有效画面。
+- 没有测量物理屏幕扫描延迟;采集卡、音频和长时间稳定性仍需真实设备验证。
+- Runtime Pack 是独立的 Release 载荷;若平台或权利方要求移除,Veyra 基础包仍可独立发布和运行。
+
+## English summary
+
+This is Veyra's first public source snapshot and portable experimental build. Extract the archive and run `Veyra.exe`. The user-authorized Runtime Pack contains version-pinned DLSS SR, DLSSG, DLSSNR, RTX Video VSR, and FRUC components with a manifest, hashes, signature states, and license files. The release builder validates the listed runtime files, while NR and FRUC validate their pinned identities at startup. Veyra keeps player, capture, and export available when a component cannot run.
+
+NR, DLSSG, and FRUC are community-experimental runtimes. They do not imply NVIDIA endorsement, certification, partnership, or support. This release does not claim universal GPU, capture-device, high-multiplier frame-generation, HDR, AV1/ProRes, VFR, physical-latency, or long-duration validation.
diff --git a/docs/USER_GUIDE.md b/docs/USER_GUIDE.md
index 9702ee68..d21b6f66 100644
--- a/docs/USER_GUIDE.md
+++ b/docs/USER_GUIDE.md
@@ -69,4 +69,4 @@
## 2026-09-09 当前交接
-最新交接见 [HANDOFF_2026-09-09.md](HANDOFF_2026-09-09.md)。RTX Video SR已接入共享管线;FRUC仅做过独立试验,产品补帧仍为DLSSG。NR表盘只表示NR阶段GPU耗时,不是采集到屏幕总延迟,统计窗口混合旧配置的问题尚待处理。USB3Video实卡已实测1080p60与4K18;设备未公开1440p格式,不人为伪造模式。
+最新交接见 [HANDOFF_2026-09-09.md](HANDOFF_2026-09-09.md)。RTX Video SR已接入共享管线;专业模式补帧页现可切换DLSS或NVIDIA FRUC,选择关闭/2X/3X/4X,均实时应用;详见[FRUC接入记录](FRUC_INTEGRATION_2026-09-09.md)。FRUC更高倍率开销更高,SDK可能退回原帧;跳转/切镜/采集掉帧会重建并可能短暂卡顿。播放器时间戳支持到1000fps,实际吞吐取决于尺寸/处理链/硬件;已测256×144无增强约999fps,不是4K千帧保证。NR表盘只表示NR阶段GPU耗时,不是采集到屏幕总延迟,统计窗口混合旧配置的问题尚待处理。USB3Video实卡已实测1080p60与4K18;设备未公开1440p格式,不人为伪造模式。
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index bb298197..5254787b 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -1293,3 +1293,32 @@ Cycle86 safety stop: build passed (logs/video-sdk-trial-20260909/build-cycle86.l
EXE SHA256: `3BD470D51AD43F7C461F23AB6F9F9B7234DC6F33D84C9DDEB35A463663264E2C`。构建日志 `logs/video-sdk-trial-20260909/build-cycle86.log`;独立review前后跟踪指纹 `9d45fe7ff6b19a67b3a42db2215928b1aecf5b4f`不变,之后仅更新交接记录。单次测试均不足300秒。Cycle86修复可交本机实测;整体Phase7优化仍in_progress,既有统计窗口/间歇时序/实卡体验/长期稳定风险未宣称消失。下一任务见HANDOFF优先处理配置相关统计窗口。
本地Git checkpoint包括Cycles78–86已核对源码、使用指南、交接报告与授权的GOAL_PROMPT删除;不包含runtime/SDK/个人媒体,不push。实际提交ID以本次 `git log -1` 为准,避免在commit内容中制造自指hash。
+
+
+## Cycle87–88 FRUC/high-FPS candidate
+
+User requested1000fps support andFRUC2/3/4. Source timing admission120→1000, exact timestamp validation retained. OptionalFRUC behind sharedgraph, UI/preset/export propagated, DLSS retained. Same-process multiinstance required per-instanceCUDAcontext; destroy/recreate repeatedlyRegister4/warpSEH, so stopped that approach and isolated runtime in hidden ownedworker with GPUsharedtextures/fence. No normal pixelreadback. Fullreset freshworker is correct in triple-reset tests but has startupcost/capture-drop feedbackrisk. Maker pixel/PTS2/3/4PASS; playbackknownpan有效5/10/15子帧与实际播放计数、NVENC24/36/48frame输出、1000fps2000frames/999.34processedfps及UI切换PASS. Specificcommands/logs/failures in docs/FRUC_INTEGRATION_2026-09-09.md. 最终lazy创建候选等待独立review/preflight/phase7;整体Phase7未完成,不push。
+
+
+## 独立检查与用户反馈补充
+
+独立review_fruc已报告CPU16+27项/preset、实际2/3/4pixel/PTS/连续reset、UI全后端切换和自有worker进程故障测试通过,无新增已确认P0/P1/P2消息。preflight69 PASS;其实际phase7日志 `logs/video-sdk-trial-20260909/review-fruc-gate-phase7.log` 为73 PASS,delivery `logs/delivery/1c195ef6d3684879b220fc8c13439e83/result.json`。Reviewer随后额度耗尽,未返回最终整体结论;因此记录为independent_checks_passed / final_verdict_unavailable,不伪造最终Reviewer PASS。用户随后明确“我已经测试没问题”,记录用户本次体验通过,不外推其未说明的配置与长期稳定性。程序SHA256 BD76BA1F3D66DF30286E450AD1742E773F48989B5815C175BDC0A297ABF4E94D;workerSHA256 B6F267C3B1C73DE0CB99C4BAD4B5DA9355C42DF7E7F37F21C9891B02B80412A3。
+
+
+## 用户新请求:GitHub性能归因
+
+已固定7个仓库head,只读源码/官方文档+既有GPU日志;报告docs/GITHUB_PERFORMANCE_AUDIT_2026-09-09.md。确认原生4KNR硬预算与软件同步/日志/重置/统计问题并存,不提供未测占比。未运行竞品、未改runtime/产品代码、未占实卡。下一条任务:配置revision隔离统计,再同源逐项A/B定位等待与计算;不先建议换卡。
+
+## 2026-09-09 竞品对照改进方案(仅文档)
+
+用户暂停间歇卡顿现场追查,要求先对照已有竞品写改进方案。新增 docs/COMPETITOR_IMPROVEMENT_PLAN_2026-09-09.md,按固定 GitHub 审计、当前 controller/FRUC 源码、旧质量方案及已完成专项整理。先统计/日志/有界调度与 reset,再做 CUDA FRUC、硬解和拷贝消减实验;深度/缓存不加入默认路径。明确每项证据、动作、验收与回退,保留导出完整性检查和单次 300 秒约定。最新自然日志未包含用户所述卡顿的处理证据,不给周期性卡顿下确定归因。同步 HANDOFF 索引和 STATE 文档条目,未改产品代码/依赖/默认设置或保护门禁。未运行新的构建/GPU/实卡测试,未推进 Phase 7 或补造 Reviewer 结论。
+
+## 2026-09-09 0.0.1 发布候选(尚未提交或上传)
+
+按用户请求完成 README 中英文重写、0.0.1 release notes、可复现便携包脚本,以及运行目录自定位。应用从 EXE 所在目录查找 shader、日志、设置和可选本地运行时;源码开发目录仍兼容。Release build 命令 `powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/build.ps1 -Root <project> -Preset x64-release` 通过。最终 ZIP `out/releases/Veyra-0.0.1-win64-portable.zip` SHA256 `906964FC80BA74F5A8407AE8E4FD9890485962539FD59FAF7764CF74799D0095`;从新解压目录以 `--smoke-empty --smoke-seconds 3 --no-nr --no-sr --no-fg` 实际启动退出码 0。包内未发现 NVIDIA、CUDA、NVENC、PDB 或 LIB;包含 Veyra EXE、自建 worker、shader、FFmpeg shared DLL、FFmpeg copyright、项目 LICENSE/notice 和空的 runtime_local/nvidia 说明。README 是控制面文件,preflight 因其固定 hash 变更而失败,未私自更新控制清单。公开上传仍等待许可证/来源确认及远端 main 分支整合;未创建 commit、tag、release 或 push。
+
+## 2026-09-09 Runtime Pack 发布策略(用户明确授权)
+
+用户选择完整开箱即用的实验 Runtime Pack,并明确接受该 Pack 可能被 GitHub 下架或被权利方要求移除的风险。`AGENTS.md` 已锁定源码/Release 物理隔离:NVIDIA 二进制、SDK、头文件、库、样例和压缩包不得进入 Git、LFS、源码或资源;仅经 manifest 白名单、固定 SHA-256、有效 NVIDIA Authenticode 签名和适用许可证检查的用户包 Release 资产可携带运行时。不得篡改/重签名/隐藏、不得从游戏或驱动缓存提取,且不得宣称 NVIDIA 官方支持。
+
+`FrucWorker` 改为从 EXE 相对的 `runtime_local/nvidia/NvOFFRUC.dll` 加载,移除开发机绝对路径。`scripts/package-portable.ps1` 以显式 allowlist 打包 `nvngx_dlss.dll`、`nvngx_dlssg.dll`、`nvngx_dlssnr.dll`、`nvngx_vsr.dll`、`NvOFFRUC.dll`,生成 `release-runtime-manifest.json`,附带 RTX / Optical Flow 许可证并排除 SDK 开发文件。Release 构建通过;最新 ZIP SHA256 `C3BA5C6E138557D3F4A208737CCC2542CE5687DA1BA7F0AD534F009DA4AE1E6F`。独立解压后五个 DLL 的 SHA-256 均匹配 manifest、Authenticode 均为 Valid,包内未发现 PDB/LIB/头文件/样例/SDK 目录;`veyra.exe --smoke-empty --smoke-seconds 3 --no-nr --no-sr --no-fg` 退出码 0。尚未 commit、push、tag 或创建 GitHub Release;README 控制面 hash 漂移仍未自行重基线。
diff --git a/include/veyra/RuntimePaths.h b/include/veyra/RuntimePaths.h
new file mode 100644
index 00000000..9a28174a
--- /dev/null
+++ b/include/veyra/RuntimePaths.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include <filesystem>
+
+namespace veyra::runtime {
+
+std::filesystem::path applicationRoot();
+std::filesystem::path shaderDirectory();
+std::filesystem::path localRuntimeDirectory();
+std::filesystem::path localDataDirectory();
+std::filesystem::path logsDirectory();
+
+} // namespace veyra::runtime
diff --git a/include/veyra/engine/CfrTimeline.h b/include/veyra/engine/CfrTimeline.h
index 7d2bd643..b453fe66 100644
--- a/include/veyra/engine/CfrTimeline.h
+++ b/include/veyra/engine/CfrTimeline.h
@@ -13,7 +13,7 @@ public:
CfrTimeline(int num, int den, double quantum, double origin)
: num_(num), den_(den), quantum_(quantum), origin_(origin), low_(-quantum/2), high_(quantum/2) {}
bool valid() const {
- return num_ > 0 && den_ > 0 && fps() <= 120 && fps() >= 1 &&
+ return num_ > 0 && den_ > 0 && fps() <= 1000 && fps() >= 1 &&
std::isfinite(origin_) && std::isfinite(quantum_) && quantum_ > 0 && quantum_ <= 1.0 / fps() + 1e-12;
}
double fps() const { return double(num_) / den_; }
diff --git a/include/veyra/engine/EnhancementSettings.h b/include/veyra/engine/EnhancementSettings.h
index bd8fde39..a8c8b59c 100644
--- a/include/veyra/engine/EnhancementSettings.h
+++ b/include/veyra/engine/EnhancementSettings.h
@@ -5,6 +5,7 @@
#include <string>
#include "veyra/pipeline/ResolutionPlan.h"
namespace veyra::engine {
+enum class FrameGenerationBackend { Dlss, Fruc };
enum class FlowQuality { Performance, Balanced, Quality };
enum class ContentRate { Transport, Auto, Fps30, Fps50, Fps60 };
struct NrSettings {
@@ -41,6 +42,7 @@ struct EnhancementSettings {
bool nr=true,sr=false;
uint32_t videoSrQuality=0; // 0 DLSS SR; 1–4 RTX Video SR
uint32_t multiplier=1;
+ FrameGenerationBackend frameGenerationBackend=FrameGenerationBackend::Dlss;
pipeline::NrSizePolicy nrPolicy=pipeline::NrSizePolicy::Realtime;
FlowQuality flow=FlowQuality::Balanced;
ContentRate content=ContentRate::Transport;
@@ -53,6 +55,7 @@ struct EnhancementSettings {
if(model.skin!=-1&&!range(model.skin,2))return "skin parameter out of range";
if(model.style<0||model.style>2||model.autoMask<0||model.autoMask>1||model.uiCorrection<0||model.uiCorrection>1)return "invalid experimental parameter";
for(float v:{residual.total,residual.darken,residual.brighten,residual.color,residual.luminance})if(!range(v,2))return "residual parameter out of range";
+ if(frameGenerationBackend!=FrameGenerationBackend::Dlss&&frameGenerationBackend!=FrameGenerationBackend::Fruc)return "invalid frame generation backend";
if(videoSrQuality>4)return "invalid video SR quality";
if(multiplier<1||multiplier>4)return "unsupported multiplier";
if(nrPolicy!=pipeline::NrSizePolicy::Realtime&&nrPolicy!=pipeline::NrSizePolicy::Native)return "invalid NR size policy";
diff --git a/include/veyra/engine/LivePresentationTiming.h b/include/veyra/engine/LivePresentationTiming.h
index 3a6272bd..67b26786 100644
--- a/include/veyra/engine/LivePresentationTiming.h
+++ b/include/veyra/engine/LivePresentationTiming.h
@@ -5,8 +5,8 @@
namespace veyra::engine {
inline int64_t liveSourceInterval100ns(pipeline::Rational duration,double nominalFps){
- if(!duration.isUnknown()&&duration.den>0&&duration.num>0)return int64_t(std::clamp(static_cast<long double>(duration.num)*10000000.L/duration.den,83333.L,1000000.L)+.5L);
- if(std::isfinite(nominalFps)&&nominalFps>=10&&nominalFps<=120)return int64_t(std::llround(10000000.0/nominalFps));
+ if(!duration.isUnknown()&&duration.den>0&&duration.num>0)return int64_t(std::clamp(static_cast<long double>(duration.num)*10000000.L/duration.den,10000.L,1000000.L)+.5L);
+ if(std::isfinite(nominalFps)&&nominalFps>=10&&nominalFps<=1000)return int64_t(std::llround(10000000.0/nominalFps));
return 200000; // documented last-resort 50 Hz estimate, never a measured duration
}
// Live capture never waits on an absolute source PTS. Once B is available,
diff --git a/include/veyra/ngx/FrucBackend.h b/include/veyra/ngx/FrucBackend.h
new file mode 100644
index 00000000..bf9ec0da
--- /dev/null
+++ b/include/veyra/ngx/FrucBackend.h
@@ -0,0 +1,20 @@
+#pragma once
+#include <d3d12.h>
+#include <memory>
+#include <array>
+namespace veyra::gfx {class D3D12DeviceContext;}
+namespace veyra::ngx {
+// Independent adapter to locally installed NvOFFRUC, with GPU-only shared RGBA8
+// surfaces. Each fractional timestamp has its own temporal FRUC instance.
+class FrucBackend {
+public:
+ FrucBackend();~FrucBackend();
+ bool initialize(gfx::D3D12DeviceContext&,unsigned width,unsigned height,unsigned multiplier);
+ bool reset(); // caller drains graph consumers before resetting history
+ void recordInput(ID3D12GraphicsCommandList*,ID3D12Resource*,unsigned parity);
+ bool execute(unsigned parity,double previousMs,double currentMs,std::array<bool,3>& repeated);
+ void recordOutput(ID3D12GraphicsCommandList*,ID3D12Resource*,unsigned subframe);
+private:
+ struct Impl;std::unique_ptr<Impl> p_;
+};
+}
diff --git a/include/veyra/ngx/FrucWorkerProtocol.h b/include/veyra/ngx/FrucWorkerProtocol.h
new file mode 100644
index 00000000..65560d7e
--- /dev/null
+++ b/include/veyra/ngx/FrucWorkerProtocol.h
@@ -0,0 +1,16 @@
+#pragma once
+#include <windows.h>
+#include <cstdint>
+namespace veyra::ngx {
+// Control messages only; pixel buffers and completion dependencies stay on GPU.
+struct FrucWorkerMessage {
+ uint32_t version=1,width=0,height=0,multiplier=2;
+ LUID adapter{};
+ uint64_t textures[5]{},fence=0,request=0,response=0;
+ uint64_t inputFence=0,outputFence=0;
+ double previousMs=0,currentMs=0;
+ uint32_t parity=0,command=0,result=1,seh=0;
+ bool repeated[3]{};
+ wchar_t logPath[1024]{};
+};
+}
diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.h
index a9fc24f5..ece84f90 100644
--- a/include/veyra/pipeline/EnhanceGraph.h
+++ b/include/veyra/pipeline/EnhanceGraph.h
@@ -44,6 +44,7 @@ class NgxCoreHost;
class DlssSrBackend;
class VideoSrBackend;
class DlssFgBackend;
+class FrucBackend;
class DlssNrRuntimeAdapter;
class NvOfSession;
}
@@ -68,6 +69,7 @@ struct EnhanceGraphDesc {
bool stillImage = false; // no temporal motion/FG history for a single image
uint32_t nrWidth=0,nrHeight=0; // zero preserves legacy native working extent
uint32_t fgMultiplier=2;
+ engine::FrameGenerationBackend frameGenerationBackend=engine::FrameGenerationBackend::Dlss;
uint64_t settingsRevision=1;
engine::FlowQuality flowQuality=engine::FlowQuality::Balanced;
engine::ContentRate contentRate=engine::ContentRate::Transport;
@@ -259,6 +261,8 @@ private:
std::unique_ptr<ngx::DlssSrBackend> srBackend_;
std::unique_ptr<ngx::VideoSrBackend> videoSrBackend_;
std::unique_ptr<ngx::DlssFgBackend> fgBackend_;
+ std::unique_ptr<ngx::FrucBackend> frucBackend_;
+ std::array<bool,6> frucRepeated_{};
NVSDK_NGX_Parameter* ngxParams_ = nullptr;
NVSDK_NGX_Handle* nrHandle_ = nullptr;
uint64_t nrResult_ = 0;
diff --git a/include/veyra/pipeline/GpuPassUtils.h b/include/veyra/pipeline/GpuPassUtils.h
index c9a5f7ec..04cf99c3 100644
--- a/include/veyra/pipeline/GpuPassUtils.h
+++ b/include/veyra/pipeline/GpuPassUtils.h
@@ -17,10 +17,7 @@
#include <vector>
#include "veyra/Log.h"
-
-#ifndef VEYRA_SHADER_DIR
-#error "VEYRA_SHADER_DIR must be defined by the build system"
-#endif
+#include "veyra/RuntimePaths.h"
namespace veyra::pipeline {
@@ -110,7 +107,7 @@ struct ComputePass {
bool loadShader(const char* name, std::vector<uint8_t>& bytes) const
{
- const std::string path = std::string(VEYRA_SHADER_DIR "/") + name;
+ const std::string path = (runtime::shaderDirectory() / name).string();
HANDLE f = CreateFileA(path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (f == INVALID_HANDLE_VALUE) {
@@ -191,7 +188,7 @@ struct ComputePass {
inline bool loadShaderBytes(const char* name, std::vector<uint8_t>& bytes)
{
- const std::string path = std::string(VEYRA_SHADER_DIR "/") + name;
+ const std::string path = (runtime::shaderDirectory() / name).string();
HANDLE f = CreateFileA(path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (f == INVALID_HANDLE_VALUE) {
diff --git a/scripts/acceptance/ui-fruc-switch.py b/scripts/acceptance/ui-fruc-switch.py
new file mode 100644
index 00000000..33c56d6f
--- /dev/null
+++ b/scripts/acceptance/ui-fruc-switch.py
@@ -0,0 +1,50 @@
+# Regression: live per-field settings, wheel safety, discrete buttons, reset. Own app; 30-second app deadline.
+import ctypes as c,ctypes.wintypes as w,subprocess,os,time,pathlib,json,uuid
+r=pathlib.Path.cwd();u=c.WinDLL('user32');u.GetWindowThreadProcessId.argtypes=[w.HWND,c.POINTER(w.DWORD)];u.GetDlgCtrlID.argtypes=[w.HWND];u.GetParent.argtypes=[w.HWND];u.GetParent.restype=w.HWND
+u.SendMessageTimeoutW.argtypes=[w.HWND,w.UINT,w.WPARAM,w.LPARAM,w.UINT,w.UINT,c.POINTER(c.c_size_t)];u.SendMessageTimeoutW.restype=w.LPARAM
+cb=c.WINFUNCTYPE(w.BOOL,w.HWND,w.LPARAM);u.EnumWindows.argtypes=[cb,w.LPARAM];u.EnumChildWindows.argtypes=[w.HWND,cb,w.LPARAM]
+def send(h,m,a=0,b=0):
+ result=c.c_size_t();assert u.SendMessageTimeoutW(h,m,a,b,2,1500,c.byref(result));return result.value
+log=r/('logs/fruc-switch-'+uuid.uuid4().hex+'.log');env=os.environ.copy();env['PATH']=r'C:\veyra-deps\installed\x64-windows\bin;'+env['PATH'];env['VEYRA_LOG_FILE']=str(log)
+p=subprocess.Popen([str(r/'out/build/x64-release/veyra.exe'),'--smoke-seconds','24','--no-nr','--no-sr','--fruc','--fg-multiplier','2',str(r/'logs/video-sdk-trial-20260909/known-pan15.mp4')],env=env)
+try:
+ start=time.monotonic();time.sleep(3);controls={}
+ @cb
+ def child(h,l):
+ ident=u.GetDlgCtrlID(h)
+ if ident in [202,208,211]:controls[ident]=h
+ return True
+ @cb
+ def top(h,l):
+ pid=w.DWORD();u.GetWindowThreadProcessId(h,c.byref(pid))
+ if pid.value==p.pid:u.EnumChildWindows(h,child,0)
+ return True
+ u.EnumWindows(top,0);assert len(controls)==3,controls
+ def select(ident,index):
+ h=controls[ident];send(h,0x14e,index);send(u.GetParent(h),0x111,ident|(1<<16),h)
+ def click(ident):
+ h=controls[ident];send(u.GetParent(h),0x111,ident,h)
+ def textOf(ident):
+ buf=c.create_unicode_buffer(100);send(controls[ident],13,100,c.addressof(buf));return buf.value
+ def change(ident,index,token):
+ old=log.read_text(encoding='utf-8',errors='replace').count(token)
+ select(ident,index);deadline=time.monotonic()+6
+ while time.monotonic()<deadline:
+ data=log.read_text(encoding='utf-8',errors='replace')
+ if data.count(token)>old:return
+ assert p.poll() is None,'app exited early'
+ time.sleep(.05)
+ raise AssertionError('not applied: '+token)
+ change(202,2,'backend=FRUC multiplier=3')
+ change(202,3,'backend=FRUC multiplier=4')
+ change(208,0,'backend=DLSS multiplier=4')
+ change(208,1,'backend=FRUC multiplier=4')
+ change(202,0,'backend=FRUC multiplier=1')
+ change(202,1,'backend=FRUC multiplier=2')
+ click(211)
+ code=p.wait(timeout=max(1,35-(time.monotonic()-start)));data=log.read_text()
+ ok=code==0 and 'failed=false' in data and 'backend=DLSS multiplier=1' in data
+ print(json.dumps({'exit':code,'switch_2_3_4_dlss_fruc_off_on_reset':ok,'log':str(log)}));assert ok
+
+finally:
+ if p.poll() is None:p.kill();p.wait()
diff --git a/scripts/package-portable.ps1 b/scripts/package-portable.ps1
new file mode 100644
index 00000000..ca3aef79
--- /dev/null
+++ b/scripts/package-portable.ps1
@@ -0,0 +1,70 @@
+param(
+ [Parameter(Mandatory = $true)][string]$Root,
+ [Parameter(Mandatory = $true)][string]$Version,
+ [Parameter(Mandatory = $true)][string]$OutputDirectory
+)
+
+$ErrorActionPreference = 'Stop'
+$resolvedRoot = [IO.Path]::GetFullPath($Root)
+$resolvedOutput = [IO.Path]::GetFullPath($OutputDirectory)
+$bin = Join-Path $resolvedRoot 'out/build/x64-release'
+$stage = Join-Path $resolvedOutput ("Veyra-" + $Version + "-win64-portable")
+$archive = $stage + '.zip'
+$runtimeStage = Join-Path $stage 'runtime_local/nvidia'
+$licensesStage = Join-Path $stage 'licenses'
+
+$applicationFiles = @('veyra.exe', 'veyra_fruc_worker.exe', 'avcodec-63.dll', 'avformat-63.dll', 'avutil-61.dll', 'swresample-7.dll', 'swscale-10.dll')
+foreach ($file in $applicationFiles) {
+ if (-not (Test-Path -LiteralPath (Join-Path $bin $file))) { throw "Missing Release file: $file" }
+}
+
+# Explicit user-authorized Runtime Pack allowlist. No wildcards are permitted.
+$runtimeFiles = @(
+ @{ Name = 'nvngx_dlss.dll'; Source = (Join-Path $resolvedRoot 'runtime_local/nvidia/nvngx_dlss.dll'); Sha256 = 'BE6E434A94CA32499515EB62CA0E6C274526055D568D0426E4C652DCDFB6EE6E'; Classification = 'official-sdk-runtime'; Experimental = $false },
+ @{ Name = 'nvngx_dlssg.dll'; Source = (Join-Path $resolvedRoot 'runtime_local/nvidia/nvngx_dlssg.dll'); Sha256 = '135EAF0733C1E37381A8C28ABCF7A862404A54132B81787C04E35D09EFC5E36F'; Classification = 'community-experimental-runtime'; Experimental = $true },
+ @{ Name = 'nvngx_dlssnr.dll'; Source = (Join-Path $resolvedRoot 'runtime_local/nvidia/nvngx_dlssnr.dll'); Sha256 = 'E16BCF15E16E13F527491CDF7845B2FE6521A738D8F7C9C721866A8496E1FC8E'; Classification = 'community-experimental-runtime'; Experimental = $true },
+ @{ Name = 'nvngx_vsr.dll'; Source = (Join-Path $resolvedRoot 'runtime_local/nvidia/nvngx_vsr.dll'); Sha256 = 'C3D88EEA5FF7A548EDEFA66414CF6E77464D0947277C904F324DD23ABF58A1ED'; Classification = 'official-rtx-video-sdk-runtime'; Experimental = $false },
+ @{ Name = 'NvOFFRUC.dll'; Source = (Join-Path $resolvedRoot 'third_party_local/nvidia/Optical_Flow_SDK_5.0.7/NvOFFRUC/NvOFFRUCSample/bin/win64/NvOFFRUC.dll'); Sha256 = '5A0B6701D30709E25E7E5B92CA46B18AAB1459160CECD4F629872369D85C8B0A'; Classification = 'community-experimental-runtime'; Experimental = $true }
+)
+foreach ($item in $runtimeFiles) {
+ if (-not (Test-Path -LiteralPath $item.Source)) { throw "Missing approved runtime: $($item.Name)" }
+ if ((Get-FileHash -Algorithm SHA256 -LiteralPath $item.Source).Hash.ToUpperInvariant() -ne $item.Sha256) { throw "Runtime hash mismatch for $($item.Name)" }
+ if ((Get-AuthenticodeSignature -LiteralPath $item.Source).Status -ne 'Valid') { throw "Runtime signature is not Valid for $($item.Name)" }
+}
+
+if (Test-Path -LiteralPath $stage) { Remove-Item -LiteralPath $stage -Recurse -Force }
+if (Test-Path -LiteralPath $archive) { Remove-Item -LiteralPath $archive -Force }
+New-Item -ItemType Directory -Path $runtimeStage -Force | Out-Null
+New-Item -ItemType Directory -Path $licensesStage -Force | Out-Null
+New-Item -ItemType Directory -Path (Join-Path $stage 'runtime_local/config') -Force | Out-Null
+
+foreach ($file in $applicationFiles) { Copy-Item -LiteralPath (Join-Path $bin $file) -Destination $stage }
+Copy-Item -LiteralPath (Join-Path $resolvedRoot 'LICENSE') -Destination $stage
+Copy-Item -LiteralPath (Join-Path $resolvedRoot 'THIRD_PARTY_NOTICES.md') -Destination $stage
+Copy-Item -LiteralPath (Join-Path $resolvedRoot 'docs/RELEASE_NOTES_0.0.1.md') -Destination (Join-Path $stage 'RELEASE_NOTES.md')
+Copy-Item -LiteralPath 'C:/veyra-deps/installed/x64-windows/share/ffmpeg/copyright' -Destination (Join-Path $stage 'FFMPEG-COPYRIGHT.txt')
+Copy-Item -LiteralPath (Join-Path $bin 'shaders') -Destination (Join-Path $stage 'shaders') -Recurse
+Copy-Item -LiteralPath (Join-Path $resolvedRoot 'runtime_local/config/ngx-local.json') -Destination (Join-Path $stage 'runtime_local/config/ngx-local.json')
+Copy-Item -LiteralPath (Join-Path $resolvedRoot 'third_party_local/nvidia/DLSS_repo/LICENSE.txt') -Destination (Join-Path $licensesStage 'NVIDIA_RTX_SDK_LICENSE.txt')
+Copy-Item -LiteralPath (Join-Path $resolvedRoot 'third_party_local/nvidia/RTX_Video_SDK_1.1.0/NVIDIA_RTX_Video_SDK_License.pdf') -Destination (Join-Path $licensesStage 'NVIDIA_RTX_VIDEO_SDK_LICENSE.pdf')
+Copy-Item -LiteralPath (Join-Path $resolvedRoot 'third_party_local/nvidia/Optical_Flow_SDK_5.0.7/LicenseAgreement.pdf') -Destination (Join-Path $licensesStage 'NVIDIA_OPTICAL_FLOW_SDK_LICENSE.pdf')
+
+$manifestFiles = foreach ($item in $runtimeFiles) {
+ Copy-Item -LiteralPath $item.Source -Destination (Join-Path $runtimeStage $item.Name)
+ $file = Get-Item -LiteralPath $item.Source
+ $signature = Get-AuthenticodeSignature -LiteralPath $item.Source
+ $version = [Diagnostics.FileVersionInfo]::GetVersionInfo($item.Source).FileVersion
+ [ordered]@{ name = $item.Name; size = $file.Length; sha256 = $item.Sha256; fileVersion = $version; authenticode = $signature.Status.ToString(); signer = if ($signature.SignerCertificate) { $signature.SignerCertificate.Subject } else { $null }; classification = $item.Classification; experimental = $item.Experimental }
+}
+[ordered]@{ schema = 1; package = "Veyra $Version"; mode = 'user-authorized-runtime-pack'; warning = 'Experimental runtime components are not an NVIDIA official endorsement or support statement.'; files = @($manifestFiles) } | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath (Join-Path $runtimeStage 'release-runtime-manifest.json') -Encoding UTF8
+
+@'
+This directory contains the Veyra experimental Runtime Pack selected by the
+publisher. It is not source code and must not be copied into the Veyra Git
+repository. The package checks release-runtime-manifest.json before enabling
+NVIDIA-backed enhancement features.
+'@ | Set-Content -LiteralPath (Join-Path $runtimeStage 'README.txt') -Encoding UTF8
+
+Compress-Archive -LiteralPath $stage -DestinationPath $archive -CompressionLevel Optimal
+Get-ChildItem -LiteralPath $stage -Recurse -File | Get-FileHash -Algorithm SHA256 | Select-Object Path, Hash | ConvertTo-Json | Set-Content -LiteralPath ($archive + '.sha256.json') -Encoding UTF8
+Get-FileHash -LiteralPath $archive -Algorithm SHA256 | Format-List
diff --git a/src/base/RuntimePaths.cpp b/src/base/RuntimePaths.cpp
new file mode 100644
index 00000000..89e9941a
--- /dev/null
+++ b/src/base/RuntimePaths.cpp
@@ -0,0 +1,39 @@
+#include "veyra/RuntimePaths.h"
+
+#include <windows.h>
+
+namespace veyra::runtime {
+namespace {
+std::filesystem::path executableDirectory()
+{
+ wchar_t path[32768]{};
+ const DWORD length = GetModuleFileNameW(nullptr, path, static_cast<DWORD>(std::size(path)));
+ if (length == 0 || length >= std::size(path)) return std::filesystem::current_path();
+ return std::filesystem::path(path).parent_path();
+}
+}
+
+std::filesystem::path applicationRoot()
+{
+ auto candidate = executableDirectory();
+ for (unsigned depth = 0; depth != 6; ++depth) {
+ if (std::filesystem::exists(candidate / "runtime_local")) return candidate;
+ const auto parent = candidate.parent_path();
+ if (parent.empty() || parent == candidate) break;
+ candidate = parent;
+ }
+ return executableDirectory();
+}
+
+std::filesystem::path shaderDirectory()
+{
+ const auto besideExecutable = executableDirectory() / "shaders";
+ if (std::filesystem::exists(besideExecutable)) return besideExecutable;
+ return applicationRoot() / "shaders";
+}
+
+std::filesystem::path localRuntimeDirectory() { return applicationRoot() / "runtime_local" / "nvidia"; }
+std::filesystem::path localDataDirectory() { return applicationRoot() / "runtime_local"; }
+std::filesystem::path logsDirectory() { return applicationRoot() / "logs"; }
+
+} // namespace veyra::runtime
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index f8dd2f90..02064582 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -11,6 +11,7 @@
#include "veyra/sink/ImageExportSink.h"
#include "veyra/gfx/D3D12DeviceContext.h"
#include "veyra/gfx/CommandSlotRing.h"
+#include "veyra/RuntimePaths.h"
#include <chrono>
#include <filesystem>
#include <format>
@@ -94,9 +95,9 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options){
pipeline::EnhanceGraphDesc gd;gd.sourceWidth=width;gd.sourceHeight=height;gd.rgbInput=isImage||isCapture;gd.stillImage=isImage;
const auto resolution=pipeline::ResolutionPlan::make({width,height},options.sr,options.realtime?pipeline::NrSizePolicy::Realtime:pipeline::NrSizePolicy::Native,isImage,1);
gd.workWidth=resolution.base.width;gd.workHeight=resolution.base.height;gd.nrWidth=resolution.nr.width;gd.nrHeight=resolution.nr.height;
- gd.enableSr=resolution.srApplied;gd.videoSrQuality=options.settings.videoSrQuality;gd.enableNr=options.nr;gd.enableFg=options.fg;gd.fgMultiplier=options.fgMultiplier;gd.enableNvofStandalone=options.nr;
+ gd.enableSr=resolution.srApplied;gd.videoSrQuality=options.settings.videoSrQuality;gd.enableNr=options.nr;gd.enableFg=options.fg;gd.fgMultiplier=options.fgMultiplier;gd.frameGenerationBackend=options.settings.frameGenerationBackend;gd.enableNvofStandalone=options.nr;
gd.noFeatures=false;gd.model=options.settings.model;gd.residual=options.settings.residual;gd.protection=options.settings.protection;gd.settingsRevision=options.settings.revision;gd.flowQuality=options.settings.flow;gd.contentRate=options.settings.content;
- gd.runtimeAbsPath=std::filesystem::path(VEYRA_PROJECT_ROOT).wstring()+L"\\runtime_local\\nvidia";
+ gd.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();
if(!graph.initialize(gd)||!presenter.open(ctx,window,graph)||!graph.createViews()){status(L"增强初始化失败,请核对本地运行时",true);break;}
if(isCapture&&!captureSource.start()){status(L"无法启动采集,请查看诊断",true);break;}
{std::lock_guard lock(mutex_);snapshot_.duration=duration;snapshot_.running=true;snapshot_.transport=TransportState::Playing;snapshot_.image=isImage;snapshot_.capture=isCapture;snapshot_.applied=options.snapshot();snapshot_.desired=desired_;}
@@ -122,9 +123,9 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options){
auto next=PlayerOptions::from(requested);auto nextDesc=gd;
const auto plan=pipeline::ResolutionPlan::make({width,height},next.sr,requested.nrPolicy,isImage,requested.revision);
nextDesc.workWidth=plan.base.width;nextDesc.workHeight=plan.base.height;nextDesc.nrWidth=plan.nr.width;nextDesc.nrHeight=plan.nr.height;
- nextDesc.enableSr=plan.srApplied;nextDesc.videoSrQuality=next.settings.videoSrQuality;nextDesc.enableNr=next.nr;nextDesc.enableFg=next.fg;nextDesc.fgMultiplier=next.fgMultiplier;nextDesc.enableNvofStandalone=next.nr;
+ nextDesc.enableSr=plan.srApplied;nextDesc.videoSrQuality=next.settings.videoSrQuality;nextDesc.enableNr=next.nr;nextDesc.enableFg=next.fg;nextDesc.fgMultiplier=next.fgMultiplier;nextDesc.frameGenerationBackend=next.settings.frameGenerationBackend;nextDesc.enableNvofStandalone=next.nr;
nextDesc.model=requested.model;nextDesc.residual=requested.residual;nextDesc.protection=requested.protection;nextDesc.settingsRevision=requested.revision;nextDesc.flowQuality=requested.flow;nextDesc.contentRate=requested.content;
- const bool rebuild=gd.videoSrQuality!=nextDesc.videoSrQuality||gd.flowQuality!=nextDesc.flowQuality||gd.workWidth!=nextDesc.workWidth||gd.workHeight!=nextDesc.workHeight||gd.nrWidth!=nextDesc.nrWidth||gd.nrHeight!=nextDesc.nrHeight;
+ const bool rebuild=gd.frameGenerationBackend!=nextDesc.frameGenerationBackend||(nextDesc.frameGenerationBackend==FrameGenerationBackend::Fruc&&(gd.fgMultiplier!=nextDesc.fgMultiplier||gd.enableFg!=nextDesc.enableFg))||gd.videoSrQuality!=nextDesc.videoSrQuality||gd.flowQuality!=nextDesc.flowQuality||gd.workWidth!=nextDesc.workWidth||gd.workHeight!=nextDesc.workHeight||gd.nrWidth!=nextDesc.nrWidth||gd.nrHeight!=nextDesc.nrHeight;
bool accepted=ring.drainQueue();out={};hasOutput=false;
if(accepted&&rebuild){presenter.close();graph.shutdown();accepted=graph.initialize(nextDesc)&&presenter.open(ctx,window,graph)&&graph.createViews();
if(!accepted){presenter.close();graph.shutdown();if(!graph.initialize(gd)||!presenter.open(ctx,window,graph)||!graph.createViews()){status(L"设置失败且旧资源恢复失败,已停止",true);break;}}
@@ -167,7 +168,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options){
}else{status(L"参数回滚失败,已停止",true);break;}
}else{status(L"增强执行失败;请查看日志",true);break;}
}
- if(transaction){std::lock_guard lock(mutex_);snapshot_.applied=options.snapshot();snapshot_.applying=desired_.revision!=options.settings.revision;snapshot_.status=std::format(L"输入 {}×{} / 底图 {}×{} / NR {}×{} / 光流 {}×{} / FG与输出 {}×{} | {}",width,height,gd.workWidth,gd.workHeight,gd.nrWidth,gd.nrHeight,width,height,gd.workWidth,gd.workHeight,gd.nrWidth<gd.workWidth?L"实时NR变化回填":L"原生NR(性能成本较高)");veyra::log::info("settings",std::format("Applied revision={} sourcePtsMs={} (source kept open)",options.settings.revision,pts));}
+ if(transaction){std::lock_guard lock(mutex_);snapshot_.applied=options.snapshot();snapshot_.applying=desired_.revision!=options.settings.revision;snapshot_.status=std::format(L"输入 {}×{} / 底图 {}×{} / NR {}×{} / 光流 {}×{} / FG与输出 {}×{} | {}",width,height,gd.workWidth,gd.workHeight,gd.nrWidth,gd.nrHeight,width,height,gd.workWidth,gd.workHeight,gd.nrWidth<gd.workWidth?L"实时NR变化回填":L"原生NR(性能成本较高)");veyra::log::info("settings",std::format("Applied revision={} sourcePtsMs={} backend={} multiplier={} (source kept open)",options.settings.revision,pts,options.settings.frameGenerationBackend==FrameGenerationBackend::Fruc?"FRUC":"DLSS",options.snapshot().multiplier));}
veyra::log::info("source-identity",std::format("source={} totalRead={} graphProcessed={} cached={} revision={} nvofStandalone={}",pkt.sequence,sourceFrames,frames+1,rereadCached,options.settings.revision,gd.enableNvofStandalone));
reset=false;hasOutput=true;
const auto processDone=Clock::now();processTimes.add(elapsedMs(processStart));
diff --git a/src/engine/EngineControllerImage.cpp b/src/engine/EngineControllerImage.cpp
index cf85036c..97b5da91 100644
--- a/src/engine/EngineControllerImage.cpp
+++ b/src/engine/EngineControllerImage.cpp
@@ -2,6 +2,7 @@
#include "veyra/engine/TiledImageProcessor.h"
#include "veyra/engine/VideoPresenter.h"
#include "veyra/gfx/CommandSlotRing.h"
+#include "veyra/RuntimePaths.h"
#include <filesystem>
#include <format>
extern "C" {
@@ -45,7 +46,7 @@ void EngineController::runLargeImage(HWND window,const sink::RgbaImage& original
if(requested.revision!=applied.revision){
pipeline::EnhanceGraphDesc desc;desc.enableNr=requested.nr;desc.noFeatures=!requested.nr;
desc.model=requested.model;desc.residual=requested.residual;desc.protection=requested.protection;desc.settingsRevision=requested.revision;
- desc.runtimeAbsPath=(std::filesystem::path(VEYRA_PROJECT_ROOT)/"runtime_local/nvidia").wstring();
+ desc.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();
sink::RgbaImage candidate;TiledImageProcessor::Stats stats;
status(L"正在分块增强大图,保留完整输出尺寸…");
bool processed=false;
diff --git a/src/engine/ExportJobManager.cpp b/src/engine/ExportJobManager.cpp
index 3105e66b..29f20b24 100644
--- a/src/engine/ExportJobManager.cpp
+++ b/src/engine/ExportJobManager.cpp
@@ -1,6 +1,7 @@
#include "veyra/engine/ExportJobManager.h"
#include "veyra/engine/VideoExportJob.h"
#include "veyra/Log.h"
+#include "veyra/RuntimePaths.h"
#include <filesystem>
#include <format>
#include <chrono>
@@ -68,7 +69,7 @@ ExportJobSnapshot ExportJobManager::poll(){
int runExportWorker(HANDLE mapping){
auto s=static_cast<Shared*>(MapViewOfFile(mapping,FILE_MAP_ALL_ACCESS,0,0,sizeof(Shared)));if(!s)return 1;
if(s->signature!=magic||s->version!=1||s->bytes!=sizeof(Shared)||!s->settings.validate().empty()||s->input[32767]||s->output[32767]){UnmapViewOfFile(s);CloseHandle(mapping);return 1;}
- Logger::instance().openFile((std::filesystem::path(VEYRA_PROJECT_ROOT)/"logs"/std::format("export-worker-{}.log",GetCurrentProcessId())).wstring());
+ Logger::instance().openFile((runtime::logsDirectory()/std::format("export-worker-{}.log",GetCurrentProcessId())).wstring());
const auto settings=s->settings;log::info("export-frozen",std::format("revision={} nr={} sr={} multiplier={} intensity={} tone={} structure={} skin={} style={} autoMask={} ui={} total={} darken={} brighten={} color={} luminance={} flow={} content={} nativeNR=true",settings.revision,settings.nr,settings.sr,settings.multiplier,settings.model.intensity,settings.model.tone,settings.model.structure,settings.model.skin,settings.model.style,settings.model.autoMask,settings.model.uiCorrection,settings.residual.total,settings.residual.darken,settings.residual.brighten,settings.residual.color,settings.residual.luminance,int(settings.flow),int(settings.content)));std::atomic<bool> cancel=false,done=false;
std::thread monitor([&]{while(!done){if(InterlockedCompareExchange(&s->cancel,0,0))cancel=true;std::this_thread::sleep_for(std::chrono::milliseconds(10));}});
auto frameBoundary=[&]{
diff --git a/src/engine/PresetStore.cpp b/src/engine/PresetStore.cpp
index 42a231d7..e07f1635 100644
--- a/src/engine/PresetStore.cpp
+++ b/src/engine/PresetStore.cpp
@@ -13,17 +13,18 @@ bool nameOk(const std::wstring& s){return !s.empty()&&s.size()<=48&&s.front()!=L
std::wstring trim(std::wstring s){auto a=s.find_first_not_of(L" \t\r\n");if(a==s.npos)return {};auto b=s.find_last_not_of(L" \t\r\n");return s.substr(a,b-a+1);}
}
std::string PresetStore::serialize()const{
- std::ostringstream o;o.imbue(std::locale::classic());o<<std::setprecision(std::numeric_limits<float>::max_digits10)<<"VEYRA_PRESETS 3\n"<<std::quoted(utf8(default_))<<' '<<entries_.size()<<'\n';
- for(auto& p:entries_){const auto& s=p.settings;const auto& m=s.model;const auto& r=s.residual;o<<std::quoted(utf8(p.name))<<' '<<m.intensity<<' '<<m.tone<<' '<<m.structure<<' '<<m.skin<<' '<<m.style<<' '<<m.autoMask<<' '<<m.uiCorrection<<' '<<r.total<<' '<<r.darken<<' '<<r.brighten<<' '<<r.color<<' '<<r.luminance<<' '<<s.nr<<' '<<s.sr<<' '<<s.multiplier<<' '<<int(s.nrPolicy)<<' '<<int(s.flow)<<' '<<int(s.content)<<' '<<s.protection.enabled<<' '<<s.protection.featherPixels;for(auto q:s.protection.regions)o<<' '<<q.left<<' '<<q.top<<' '<<q.right<<' '<<q.bottom;o<<' '<<s.videoSrQuality<<'\n';}return o.str();
+ std::ostringstream o;o.imbue(std::locale::classic());o<<std::setprecision(std::numeric_limits<float>::max_digits10)<<"VEYRA_PRESETS 4\n"<<std::quoted(utf8(default_))<<' '<<entries_.size()<<'\n';
+ for(auto& p:entries_){const auto& s=p.settings;const auto& m=s.model;const auto& r=s.residual;o<<std::quoted(utf8(p.name))<<' '<<m.intensity<<' '<<m.tone<<' '<<m.structure<<' '<<m.skin<<' '<<m.style<<' '<<m.autoMask<<' '<<m.uiCorrection<<' '<<r.total<<' '<<r.darken<<' '<<r.brighten<<' '<<r.color<<' '<<r.luminance<<' '<<s.nr<<' '<<s.sr<<' '<<s.multiplier<<' '<<int(s.nrPolicy)<<' '<<int(s.flow)<<' '<<int(s.content)<<' '<<s.protection.enabled<<' '<<s.protection.featherPixels;for(auto q:s.protection.regions)o<<' '<<q.left<<' '<<q.top<<' '<<q.right<<' '<<q.bottom;o<<' '<<s.videoSrQuality<<' '<<int(s.frameGenerationBackend)<<'\n';}return o.str();
}
bool PresetStore::parse(const std::string& data,std::vector<UserPreset>& out,std::wstring& def){
if(data.size()>65536)return false;std::istringstream in(data);in.imbue(std::locale::classic());std::string magic,d;int version=0;size_t count=0;
- if(!(in>>magic>>version)||magic!="VEYRA_PRESETS"||(version!=1&&version!=2&&version!=3)||!(in>>std::quoted(d)>>count)||count>64)return false;def=wide(d);if(!d.empty()&&def.empty())return false;
+ if(!(in>>magic>>version)||magic!="VEYRA_PRESETS"||(version!=1&&version!=2&&version!=3&&version!=4)||!(in>>std::quoted(d)>>count)||count>64)return false;def=wide(d);if(!d.empty()&&def.empty())return false;
for(size_t i=0;i<count;++i){UserPreset p;std::string n;int policy,flow,content,nr,sr;auto& s=p.settings;auto& m=s.model;auto& r=s.residual;
if(!(in>>std::quoted(n)>>m.intensity>>m.tone>>m.structure>>m.skin>>m.style>>m.autoMask>>m.uiCorrection>>r.total>>r.darken>>r.brighten>>r.color>>r.luminance>>nr>>sr>>s.multiplier>>policy>>flow>>content))return false;
if(version>=2){int enabled;if(!(in>>enabled>>s.protection.featherPixels)||enabled<0||enabled>1)return false;s.protection.enabled=enabled!=0;
for(auto& q:s.protection.regions)if(!(in>>q.left>>q.top>>q.right>>q.bottom))return false;}
if(version>=3&&!(in>>s.videoSrQuality))return false;
+ if(version>=4){int backend;if(!(in>>backend)||backend<0||backend>1)return false;s.frameGenerationBackend=static_cast<FrameGenerationBackend>(backend);}
p.name=wide(n);if(!nameOk(p.name)||std::any_of(out.begin(),out.end(),[&](auto& a){return a.name==p.name;})||nr<0||nr>1||sr<0||sr>1)return false;
s.nr=nr;s.sr=sr;s.nrPolicy=static_cast<pipeline::NrSizePolicy>(policy);s.flow=static_cast<FlowQuality>(flow);s.content=static_cast<ContentRate>(content);
if(!s.validate().empty())return false;out.push_back(std::move(p));
diff --git a/src/engine/VideoExportJob.cpp b/src/engine/VideoExportJob.cpp
index 81bc3274..d7f9a898 100644
--- a/src/engine/VideoExportJob.cpp
+++ b/src/engine/VideoExportJob.cpp
@@ -6,6 +6,7 @@
#include "veyra/sink/NvencD3D12Encoder.h"
#include "veyra/gfx/D3D12DeviceContext.h"
#include "veyra/gfx/CommandSlotRing.h"
+#include "veyra/RuntimePaths.h"
#include <filesystem>
#include <format>
#include <thread>
@@ -41,7 +42,7 @@ bool exportVideo(const std::wstring& input,const std::wstring& output,PlayerOpti
const AVRational rate=av_mul_q({rateNum,rateDen},{int(options.fg?options.fgMultiplier:1),1});
veyra::log::info("export-timeline",std::format("CFR declared={}/{} candidate={}/{} timestampQuantum={} sampled={} output={}/{} (timestamp-consistent candidate, quantized short clips may be ambiguous; every PTS validated)",info.nominalRateNum,info.nominalRateDen,rateNum,rateDen,info.timestampQuantum,samples.size(),rate.num,rate.den));
const auto resolution=pipeline::ResolutionPlan::make({info.width,info.height},options.sr,pipeline::NrSizePolicy::Native,true,options.settings.revision);
- pipeline::EnhanceGraphDesc gd;gd.sourceWidth=info.width;gd.sourceHeight=info.height;gd.workWidth=resolution.base.width;gd.workHeight=resolution.base.height;gd.enableSr=resolution.srApplied;gd.videoSrQuality=options.settings.videoSrQuality;gd.enableNr=options.nr;gd.enableFg=options.fg;gd.fgMultiplier=options.fgMultiplier;gd.enableNvofStandalone=options.nr;gd.model=options.settings.model;gd.residual=options.settings.residual;gd.protection=options.settings.protection;gd.settingsRevision=options.settings.revision;gd.flowQuality=options.settings.flow;gd.contentRate=options.settings.content;gd.runtimeAbsPath=(std::filesystem::path(VEYRA_PROJECT_ROOT)/"runtime_local/nvidia").wstring();
+ pipeline::EnhanceGraphDesc gd;gd.sourceWidth=info.width;gd.sourceHeight=info.height;gd.workWidth=resolution.base.width;gd.workHeight=resolution.base.height;gd.enableSr=resolution.srApplied;gd.videoSrQuality=options.settings.videoSrQuality;gd.enableNr=options.nr;gd.enableFg=options.fg;gd.fgMultiplier=options.fgMultiplier;gd.frameGenerationBackend=options.settings.frameGenerationBackend;gd.enableNvofStandalone=options.nr;gd.model=options.settings.model;gd.residual=options.settings.residual;gd.protection=options.settings.protection;gd.settingsRevision=options.settings.revision;gd.flowQuality=options.settings.flow;gd.contentRate=options.settings.content;gd.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();
if(!graph.initialize(gd)||!graph.createViews())break;
if(avformat_alloc_output_context2(&mux,nullptr,"mp4",utf8(partial).c_str())<0||!mux)break;
videoStream=avformat_new_stream(mux,nullptr);if(!videoStream)break;videoStream->time_base={rate.den,rate.num};videoStream->avg_frame_rate=rate;
diff --git a/src/ngx/FrucBackend.cpp b/src/ngx/FrucBackend.cpp
new file mode 100644
index 00000000..2c370c25
--- /dev/null
+++ b/src/ngx/FrucBackend.cpp
@@ -0,0 +1,150 @@
+#include "veyra/ngx/FrucBackend.h"
+#include "veyra/ngx/FrucWorkerProtocol.h"
+#include "veyra/gfx/D3D12DeviceContext.h"
+#include "veyra/Log.h"
+#include <wrl/client.h>
+#include <filesystem>
+#include <format>
+#include <vector>
+namespace veyra::ngx {
+using Microsoft::WRL::ComPtr;
+namespace {
+bool hrOk(HRESULT hr,const char* op) {
+ if(FAILED(hr))log::error("fruc-ipc",std::format("{} hr=0x{:X}",op,unsigned(hr)));
+ return SUCCEEDED(hr);
+}
+void barrier(ID3D12GraphicsCommandList* list,ID3D12Resource* resource,D3D12_RESOURCE_STATES before,D3D12_RESOURCE_STATES after) {
+ D3D12_RESOURCE_BARRIER b{};b.Type=D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
+ b.Transition={resource,D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,before,after};list->ResourceBarrier(1,&b);
+}
+struct Handle {
+ HANDLE value=nullptr;
+ ~Handle(){if(value)CloseHandle(value);}
+ void close(){if(value)CloseHandle(value);value=nullptr;}
+};
+}
+struct FrucBackend::Impl {
+ gfx::D3D12DeviceContext* ctx=nullptr;
+ unsigned width=0,height=0,count=0;uint64_t serial=0;
+ ComPtr<ID3D12Resource> shared[5];ComPtr<ID3D12Fence> fence;
+ Handle textures[5],fenceHandle,mapping,request,response,process,job;
+ FrucWorkerMessage* message=nullptr;
+ ~Impl() {
+ stop();if(message)UnmapViewOfFile(message);
+ }
+ void stop() {
+ if(!process.value)return;
+ message->command=2;SetEvent(request.value);
+ if(WaitForSingleObject(process.value,3000)!=WAIT_OBJECT_0) {
+ // Only this owned worker is terminated; no user processes are touched.
+ TerminateJobObject(job.value,1);WaitForSingleObject(process.value,1000);
+ }
+ process.close();job.close();
+ }
+ bool acknowledge(DWORD timeout) {
+ HANDLE events[]{response.value,process.value};
+ const auto result=WaitForMultipleObjects(2,events,FALSE,timeout);
+ if(result!=WAIT_OBJECT_0) {
+ DWORD exitCode=0;GetExitCodeProcess(process.value,&exitCode);
+ log::error("fruc-ipc",std::format("worker wait={} exit={}",result,exitCode));return false;
+ }
+ if(message->result||message->seh) {
+ log::error("fruc-ipc",std::format("worker result={} seh={}",message->result,message->seh));return false;
+ }
+ return true;
+ }
+ bool start() {
+ SECURITY_ATTRIBUTES security{sizeof(security),nullptr,TRUE};
+ if(!mapping.value) {
+ mapping.value=CreateFileMappingW(INVALID_HANDLE_VALUE,&security,PAGE_READWRITE,0,sizeof(FrucWorkerMessage),nullptr);
+ if(!mapping.value)return false;
+ message=static_cast<FrucWorkerMessage*>(MapViewOfFile(mapping.value,FILE_MAP_ALL_ACCESS,0,0,sizeof(FrucWorkerMessage)));
+ if(!message)return false;
+ request.value=CreateEventW(&security,FALSE,FALSE,nullptr);response.value=CreateEventW(&security,FALSE,FALSE,nullptr);
+ if(!request.value||!response.value)return false;
+ }
+ ResetEvent(request.value);ResetEvent(response.value);
+ *message=FrucWorkerMessage{};
+ message->width=width;message->height=height;message->multiplier=count+1;message->adapter=ctx->device()->GetAdapterLuid();
+ message->fence=reinterpret_cast<uint64_t>(fenceHandle.value);
+ message->request=reinterpret_cast<uint64_t>(request.value);message->response=reinterpret_cast<uint64_t>(response.value);
+ std::vector<HANDLE> inherited{mapping.value,request.value,response.value,fenceHandle.value};
+ for(unsigned j=0;j<count+2;++j){message->textures[j]=reinterpret_cast<uint64_t>(textures[j].value);inherited.push_back(textures[j].value);}
+ wchar_t exePath[32768]{};if(!GetModuleFileNameW(nullptr,exePath,32768))return false;
+ const auto executable=std::filesystem::path(exePath).parent_path()/L"veyra_fruc_worker.exe";
+ // Unique worker log survives worker crashes and reset/reopen cycles.
+ wchar_t existingLog[1024]{};GetEnvironmentVariableW(L"VEYRA_LOG_FILE",existingLog,1024);
+ auto logPath=(existingLog[0]?std::filesystem::path(existingLog).parent_path():std::filesystem::path(L"logs"))/
+ std::format(L"fruc-worker-{}-{}.log",GetCurrentProcessId(),GetTickCount64());
+ const auto absoluteLog=std::filesystem::absolute(logPath).wstring();
+ if(absoluteLog.size()>=std::size(message->logPath))return false;
+ wcscpy_s(message->logPath,absoluteLog.c_str());
+ SIZE_T bytes=0;InitializeProcThreadAttributeList(nullptr,1,0,&bytes);
+ std::vector<unsigned char> storage(bytes);auto* attributes=reinterpret_cast<LPPROC_THREAD_ATTRIBUTE_LIST>(storage.data());
+ if(!InitializeProcThreadAttributeList(attributes,1,0,&bytes))return false;
+ struct AttributesCleanup{LPPROC_THREAD_ATTRIBUTE_LIST list;~AttributesCleanup(){DeleteProcThreadAttributeList(list);}}cleanup{attributes};
+ if(!UpdateProcThreadAttribute(attributes,0,PROC_THREAD_ATTRIBUTE_HANDLE_LIST,inherited.data(),inherited.size()*sizeof(HANDLE),nullptr,nullptr))return false;
+ job.value=CreateJobObjectW(nullptr,nullptr);JOBOBJECT_EXTENDED_LIMIT_INFORMATION limits{};
+ limits.BasicLimitInformation.LimitFlags=JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
+ if(!job.value||!SetInformationJobObject(job.value,JobObjectExtendedLimitInformation,&limits,sizeof(limits)))return false;
+ STARTUPINFOEXW startup{};startup.StartupInfo.cb=sizeof(startup);startup.lpAttributeList=attributes;
+ PROCESS_INFORMATION pi{};auto command=std::format(L"\"{}\" {}",executable.wstring(),reinterpret_cast<uint64_t>(mapping.value));
+ if(!CreateProcessW(executable.c_str(),command.data(),nullptr,nullptr,TRUE,CREATE_NO_WINDOW|CREATE_SUSPENDED|EXTENDED_STARTUPINFO_PRESENT,nullptr,nullptr,&startup.StartupInfo,&pi)) {
+ log::error("fruc-ipc",std::format("CreateProcess error={}",GetLastError()));return false;
+ }
+ process.value=pi.hProcess;Handle thread;thread.value=pi.hThread;
+ if(!AssignProcessToJobObject(job.value,process.value)) {TerminateProcess(process.value,1);return false;}
+ if(ResumeThread(thread.value)==DWORD(-1))return false;
+ log::info("fruc-ipc",std::format("worker pid={} streams={} extent={}x{}",pi.dwProcessId,count,width,height));
+ return acknowledge(15000);
+ }
+};
+FrucBackend::FrucBackend():p_(std::make_unique<Impl>()){}
+FrucBackend::~FrucBackend()=default;
+bool FrucBackend::initialize(gfx::D3D12DeviceContext& ctx,unsigned width,unsigned height,unsigned multiplier) {
+ if(p_->ctx||!width||!height||multiplier<2||multiplier>4)return false;
+ auto& p=*p_;p.ctx=&ctx;p.width=width;p.height=height;p.count=multiplier-1;
+ SECURITY_ATTRIBUTES security{sizeof(security),nullptr,TRUE};
+ if(!hrOk(ctx.device()->CreateFence(0,D3D12_FENCE_FLAG_SHARED,IID_PPV_ARGS(&p.fence)),"CreateFence")||
+ !hrOk(ctx.device()->CreateSharedHandle(p.fence.Get(),&security,GENERIC_ALL,nullptr,&p.fenceHandle.value),"ShareFence"))return false;
+ D3D12_HEAP_PROPERTIES heap{};heap.Type=D3D12_HEAP_TYPE_DEFAULT;
+ D3D12_RESOURCE_DESC desc{};desc.Dimension=D3D12_RESOURCE_DIMENSION_TEXTURE2D;desc.Width=width;desc.Height=height;
+ desc.DepthOrArraySize=1;desc.MipLevels=1;desc.SampleDesc.Count=1;desc.Format=DXGI_FORMAT_R8G8B8A8_UNORM;
+ desc.Flags=D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS|D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
+ for(unsigned j=0;j<p.count+2;++j) {
+ if(!hrOk(ctx.device()->CreateCommittedResource(&heap,D3D12_HEAP_FLAG_SHARED,&desc,D3D12_RESOURCE_STATE_COMMON,nullptr,IID_PPV_ARGS(&p.shared[j])),"SharedTexture")||
+ !hrOk(ctx.device()->CreateSharedHandle(p.shared[j].Get(),&security,GENERIC_ALL,nullptr,&p.textures[j].value),"ShareTexture"))return false;
+ }
+ return p.start();
+}
+bool FrucBackend::reset() {
+ // Fresh process avoids the pinned FRUC runtime's invalid-handle/SEH after
+ // destruction/recreation. Resources stay on GPU; caller drains consumers.
+ p_->stop();return p_->start();
+}
+void FrucBackend::recordInput(ID3D12GraphicsCommandList* list,ID3D12Resource* input,unsigned parity) {
+ auto target=p_->shared[parity].Get();
+ barrier(list,input,D3D12_RESOURCE_STATE_COMMON,D3D12_RESOURCE_STATE_COPY_SOURCE);
+ barrier(list,target,D3D12_RESOURCE_STATE_COMMON,D3D12_RESOURCE_STATE_COPY_DEST);list->CopyResource(target,input);
+ barrier(list,target,D3D12_RESOURCE_STATE_COPY_DEST,D3D12_RESOURCE_STATE_COMMON);
+ barrier(list,input,D3D12_RESOURCE_STATE_COPY_SOURCE,D3D12_RESOURCE_STATE_COMMON);
+}
+bool FrucBackend::execute(unsigned parity,double previousMs,double currentMs,std::array<bool,3>& repeated) {
+ auto& p=*p_;auto& m=*p.message;
+ m.command=1;m.result=1;m.seh=0;m.parity=parity;m.previousMs=previousMs;m.currentMs=currentMs;
+ m.inputFence=++p.serial;
+ if(!hrOk(p.ctx->directQueue()->Signal(p.fence.Get(),m.inputFence),"InputSignal")||!SetEvent(p.request.value))return false;
+ // Wait for CPU API submission/results, not for GPU completion. CUDA/FRUC's
+ // internal CPU blocking is unchanged; all pixel synchronization is GPU-side.
+ if(!p.acknowledge(10000))return false;
+ p.serial=m.outputFence;for(unsigned j=0;j<p.count;++j)repeated[j]=m.repeated[j];
+ return hrOk(p.ctx->directQueue()->Wait(p.fence.Get(),m.outputFence),"OutputQueueWait");
+}
+void FrucBackend::recordOutput(ID3D12GraphicsCommandList* list,ID3D12Resource* target,unsigned subframe) {
+ auto input=p_->shared[subframe+1].Get();
+ barrier(list,input,D3D12_RESOURCE_STATE_COMMON,D3D12_RESOURCE_STATE_COPY_SOURCE);
+ barrier(list,target,D3D12_RESOURCE_STATE_COMMON,D3D12_RESOURCE_STATE_COPY_DEST);list->CopyResource(target,input);
+ barrier(list,target,D3D12_RESOURCE_STATE_COPY_DEST,D3D12_RESOURCE_STATE_COMMON);
+ barrier(list,input,D3D12_RESOURCE_STATE_COPY_SOURCE,D3D12_RESOURCE_STATE_COMMON);
+}
+}
diff --git a/src/ngx/FrucWorker.cpp b/src/ngx/FrucWorker.cpp
new file mode 100644
index 00000000..02c4fc3a
--- /dev/null
+++ b/src/ngx/FrucWorker.cpp
@@ -0,0 +1,176 @@
+#include "veyra/ngx/FrucWorkerProtocol.h"
+
+#include "veyra/FileIdentity.h"
+#include "veyra/Log.h"
+#include "veyra/RuntimePaths.h"
+#include <d3d11_4.h>
+#include <dxgi1_4.h>
+#include <wrl/client.h>
+#include <filesystem>
+#include <format>
+#include <mutex>
+#pragma warning(push,0)
+#include <NvOFFRUC.h>
+#include <cuda.h>
+#pragma warning(pop)
+namespace veyra::ngx {
+using Microsoft::WRL::ComPtr;
+namespace {
+bool hrOk(HRESULT hr,const char* op){log::info("fruc",std::format("{} hr=0x{:X}",op,unsigned(hr)));return SUCCEEDED(hr);}
+template<class Fn, class... Args>
+NvOFFRUC_STATUS callSafe(unsigned& seh, Fn fn, Args... args) {
+ __try { return fn(args...); }
+ __except(EXCEPTION_EXECUTE_HANDLER) { seh=GetExceptionCode(); return NvOFFRUC_ERR_GENERIC; }
+}
+template<class Fn, class... Args>
+bool checkedCall(const char* operation, Fn fn, Args... args) {
+ unsigned seh=0;
+ const auto result=callSafe(seh,fn,args...);
+ log::info("fruc",std::format("{} result={} seh={}",operation,int(result),seh));
+ return result==NvOFFRUC_SUCCESS && !seh;
+}
+bool cudaOk(CUresult result,const char* op) {
+ if(result!=CUDA_SUCCESS)log::error("fruc",std::format("{} cudaResult={}",op,int(result)));
+ return result==CUDA_SUCCESS;
+}
+
+}
+struct WorkerKernel {
+ using GetContext = CUresult (CUDAAPI*)(CUcontext*);
+ using SetContext = CUresult (CUDAAPI*)(CUcontext);
+ HMODULE cuda=nullptr; GetContext getContext=nullptr; SetContext setContext=nullptr;
+ CUcontext streamContext[3]={};
+ HMODULE lib=nullptr;unsigned width=0,height=0,count=0;uint64_t serial=0;
+ ComPtr<ID3D11Device> device;ComPtr<ID3D11Device5> device5;
+ ComPtr<ID3D11DeviceContext> context;
+ ComPtr<ID3D11Fence> fence11;
+ ComPtr<ID3D11Texture2D> tex[5];
+ NvOFFRUCHandle handles[3]={};bool registered[3]={};
+ PtrToFuncNvOFFRUCCreate create=nullptr;PtrToFuncNvOFFRUCDestroy destroy=nullptr;
+ PtrToFuncNvOFFRUCRegisterResource reg=nullptr;PtrToFuncNvOFFRUCUnregisterResource unreg=nullptr;PtrToFuncNvOFFRUCProcess process=nullptr;
+ struct ContextScope {
+ WorkerKernel& owner;
+ CUcontext saved=nullptr;
+ bool valid=false;
+ explicit ContextScope(WorkerKernel& p):owner(p) {
+ valid=p.getContext && cudaOk(p.getContext(&saved),"GetContext");
+ }
+ ~ContextScope() { if(valid)cudaOk(owner.setContext(saved),"RestoreContext"); }
+ };
+ void release() {
+ ContextScope scope(*this);
+ for(unsigned index=3;index>0;--index) {
+ const unsigned j=index-1;
+ if(!handles[j])continue;
+ if(scope.saved==streamContext[j])scope.saved=nullptr;
+ if(setContext&&streamContext[j])cudaOk(setContext(streamContext[j]),"ReleaseContext");
+ if(registered[j]) {
+ NvOFFRUC_UNREGISTER_RESOURCE_PARAM r{};
+ r.uiCount=3;r.pArrResource[0]=tex[0].Get();r.pArrResource[1]=tex[1].Get();r.pArrResource[2]=tex[2+j].Get();
+ checkedCall("Unregister",unreg,handles[j],&r);
+ registered[j]=false;
+ }
+ checkedCall("Destroy",destroy,handles[j]);
+ handles[j]=nullptr;streamContext[j]=nullptr;
+ }
+ }
+ ~WorkerKernel() {
+ release();
+ for(auto& t:tex)t.Reset();
+ fence11.Reset();context.Reset();device5.Reset();device.Reset();
+ if(lib)FreeLibrary(lib);
+ if(cuda)FreeLibrary(cuda);
+ }
+ bool initialize(FrucWorkerMessage&);
+ bool execute(FrucWorkerMessage&);
+ bool createStreams() {
+ ContextScope scope(*this);
+ if(!scope.valid)return false;
+ for(unsigned j=0;j<count;++j) {
+ NvOFFRUC_CREATE_PARAM c{};
+ c.uiWidth=width;c.uiHeight=height;c.pDevice=device.Get();
+ c.eResourceType=DirectX11Resource;c.eSurfaceFormat=ARGBSurface;c.eCUDAResourceType=CudaResourceTypeUndefined;
+ if(!checkedCall("Create",create,&c,&handles[j])||!handles[j])return false;
+ // This local runtime leaves each newly created stream's CUDA context
+ // current. Preserve it and explicitly bind it for subsequent calls.
+ if(!cudaOk(getContext(&streamContext[j]),"StreamContext")||!streamContext[j])return false;
+ log::info("fruc",std::format("Context stream={} ptr={}",j,static_cast<void*>(streamContext[j])));
+ NvOFFRUC_REGISTER_RESOURCE_PARAM r{};
+ r.uiCount=3;r.pD3D11FenceObj=fence11.Get();
+ r.pArrResource[0]=tex[0].Get();r.pArrResource[1]=tex[1].Get();r.pArrResource[2]=tex[j+2].Get();
+ if(!checkedCall("Register",reg,handles[j],&r))return false;
+ registered[j]=true;
+ if(!cudaOk(setContext(scope.saved),"RestoreAfterCreate"))return false;
+ }
+ return true;
+ }
+};
+bool WorkerKernel::initialize(FrucWorkerMessage& info) {
+ auto& p=*this;const auto w=info.width,h=info.height;p.width=w;p.height=h;p.count=info.multiplier-1;
+ const std::wstring path=(runtime::localRuntimeDirectory()/L"NvOFFRUC.dll").make_preferred().wstring();FileIdentity identity;IdentityError error;
+ if(!computeFileIdentity(path,identity,error)||!identity.signatureValid||!identity.signerIsNvidia||identity.sha256Upper!="5A0B6701D30709E25E7E5B92CA46B18AAB1459160CECD4F629872369D85C8B0A"){log::error("fruc","local runtime identity mismatch or unavailable");return false;}
+ log::info("fruc",std::format("runtime sha256={} extent={}x{} instances={}",identity.sha256Upper,w,h,p.count));
+ p.lib=LoadLibraryExW(path.c_str(),nullptr,LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR|LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);if(!p.lib){log::error("fruc",std::format("LoadLibrary error={}",GetLastError()));return false;}
+ p.create=reinterpret_cast<PtrToFuncNvOFFRUCCreate>(GetProcAddress(p.lib,CreateProcName));p.destroy=reinterpret_cast<PtrToFuncNvOFFRUCDestroy>(GetProcAddress(p.lib,DestroyProcName));p.reg=reinterpret_cast<PtrToFuncNvOFFRUCRegisterResource>(GetProcAddress(p.lib,RegisterResourceProcName));p.unreg=reinterpret_cast<PtrToFuncNvOFFRUCUnregisterResource>(GetProcAddress(p.lib,UnregisterResourceProcName));p.process=reinterpret_cast<PtrToFuncNvOFFRUCProcess>(GetProcAddress(p.lib,ProcessProcName));if(!p.create||!p.destroy||!p.reg||!p.unreg||!p.process)return false;
+ wchar_t systemDir[MAX_PATH]{};if(!GetSystemDirectoryW(systemDir,MAX_PATH))return false;
+ const auto cudaPath=std::filesystem::path(systemDir)/L"nvcuda.dll";
+ p.cuda=LoadLibraryExW(cudaPath.c_str(),nullptr,LOAD_LIBRARY_SEARCH_SYSTEM32);if(!p.cuda)return false;
+ p.getContext=reinterpret_cast<WorkerKernel::GetContext>(GetProcAddress(p.cuda,"cuCtxGetCurrent"));
+ p.setContext=reinterpret_cast<WorkerKernel::SetContext>(GetProcAddress(p.cuda,"cuCtxSetCurrent"));if(!p.getContext||!p.setContext)return false;
+ using InitCuda=CUresult(CUDAAPI*)(unsigned);auto initCuda=reinterpret_cast<InitCuda>(GetProcAddress(p.cuda,"cuInit"));if(!initCuda||!cudaOk(initCuda(0),"InitCuda"))return false;
+ ComPtr<IDXGIFactory4> factory;ComPtr<IDXGIAdapter> adapter;if(!hrOk(CreateDXGIFactory1(IID_PPV_ARGS(&factory)),"Factory")||!hrOk(factory->EnumAdapterByLuid(info.adapter,IID_PPV_ARGS(&adapter)),"SameAdapter"))return false;
+ if(!hrOk(D3D11CreateDevice(adapter.Get(),D3D_DRIVER_TYPE_UNKNOWN,nullptr,0,nullptr,0,D3D11_SDK_VERSION,&p.device,nullptr,&p.context),"D3D11Device")||!hrOk(p.device.As(&p.device5),"Device5"))return false;
+
+ if(!hrOk(device5->OpenSharedFence(reinterpret_cast<HANDLE>(info.fence),IID_PPV_ARGS(&fence11)),"OpenFence"))return false;
+ for(unsigned j=0;j<count+2;++j)
+ if(!hrOk(device5->OpenSharedResource1(reinterpret_cast<HANDLE>(info.textures[j]),IID_PPV_ARGS(&tex[j])),"OpenTexture"))return false;
+ return createStreams();
+}
+bool WorkerKernel::execute(FrucWorkerMessage& info) {
+ ContextScope scope(*this);if(!scope.valid)return false;
+ auto wait=info.inputFence;
+ for(unsigned j=0;j<count;++j) {
+ if(!cudaOk(setContext(streamContext[j]),"ProcessContext"))return false;
+ NvOFFRUC_PROCESS_IN_PARAMS in{};NvOFFRUC_PROCESS_OUT_PARAMS out{};
+ in.stFrameDataInput.pFrame=tex[info.parity].Get();in.stFrameDataInput.nTimeStamp=info.currentMs;
+ in.uSyncWait.FenceWaitValue.uiFenceValueToWaitOn=wait;
+ out.stFrameDataOutput.pFrame=tex[j+2].Get();
+ out.stFrameDataOutput.nTimeStamp=info.previousMs+(info.currentMs-info.previousMs)*double(j+1)/(count+1);
+ out.stFrameDataOutput.bHasFrameRepetitionOccurred=&info.repeated[j];
+ out.uSyncSignal.FenceSignalValue.uiFenceValueToSignalOn=++wait;
+ unsigned seh=0;auto result=callSafe(seh,process,handles[j],&in,&out);
+ info.result=uint32_t(result);info.seh=seh;
+ log::info("fruc",std::format("Process inputMs={} outputMs={} sub={} result={} seh={} repeated={}",info.currentMs,out.stFrameDataOutput.nTimeStamp,j+1,int(result),seh,info.repeated[j]));
+ if(result!=NvOFFRUC_SUCCESS||seh)return false;
+ }
+ info.outputFence=wait;return true;
+}
+} // namespace veyra::ngx
+int wmain(int argc,wchar_t** argv) {
+ using namespace veyra;using namespace veyra::ngx;
+ if(argc!=2)return 2;
+ auto mapping=reinterpret_cast<HANDLE>(_wcstoui64(argv[1],nullptr,10));
+ auto* info=static_cast<FrucWorkerMessage*>(MapViewOfFile(mapping,FILE_MAP_ALL_ACCESS,0,0,sizeof(FrucWorkerMessage)));
+ if(!info||info->version!=1||info->multiplier<2||info->multiplier>4||!info->width||!info->height)return 2;
+ Logger::instance().setConsoleEnabled(false);
+ if(!Logger::instance().openFile(info->logPath))return 2;
+ const auto response=reinterpret_cast<HANDLE>(info->response),request=reinterpret_cast<HANDLE>(info->request);
+ int exitCode=0;
+ {
+ WorkerKernel kernel;
+ bool ready=kernel.initialize(*info);info->result=ready?0:1;
+ if(!SetEvent(response))return 2;
+ if(ready)for(;;) {
+ if(WaitForSingleObject(request,INFINITE)!=WAIT_OBJECT_0){exitCode=2;break;}
+ if(info->command==2)break;
+ if(info->command!=1||info->parity>1){exitCode=2;break;}
+ info->result=1;info->seh=0;
+ const bool ok=kernel.execute(*info);
+ if(!ok&&info->result==0)info->result=1;
+ if(!SetEvent(response)){exitCode=2;break;}
+ if(!ok){exitCode=1;break;}
+ }
+ else exitCode=1;
+ }
+ Logger::instance().flush();UnmapViewOfFile(info);CloseHandle(mapping);return exitCode;
+}
diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cpp
index 990ebeaf..f782229a 100644
--- a/src/pipeline/EnhanceGraph.cpp
+++ b/src/pipeline/EnhanceGraph.cpp
@@ -20,6 +20,7 @@
#include "veyra/gfx/CommandSlotRing.h"
#include "veyra/gfx/D3D12DeviceContext.h"
#include "veyra/ngx/DlssFgBackend.h"
+#include "veyra/ngx/FrucBackend.h"
#include "veyra/ngx/DlssNrParameters.h"
#include "veyra/ngx/DlssNrRuntimeAdapter.h"
#include "veyra/ngx/DlssSrBackend.h"
@@ -343,7 +344,7 @@ bool EnhanceGraph::initNgxFeatures()
fgCapsAvailable_ = false;
fgMultiFrameMax_ = 0;
- if (!desc_.stillImage) {
+ if (!desc_.stillImage && desc_.frameGenerationBackend==engine::FrameGenerationBackend::Dlss) {
fgBackend_ = std::make_unique<ngx::DlssFgBackend>();
ngx::DlssFgBackend::Capability fgCaps{};
const bool fgAvailable = fgBackend_->queryCapability(*coreHost_, fgCaps, st);
@@ -358,6 +359,13 @@ bool EnhanceGraph::initNgxFeatures()
fgCaps.available, fgCaps.multiFrameCountMax));
}
+ if(!desc_.stillImage&&desc_.frameGenerationBackend==engine::FrameGenerationBackend::Fruc){
+ if(desc_.enableFg){
+ frucBackend_=std::make_unique<ngx::FrucBackend>();
+ if(!frucBackend_->initialize(context_,workW_,workH_,std::max(2u,desc_.fgMultiplier)))return false;
+ }
+ fgCapsAvailable_=true;fgMultiFrameMax_=3;
+ }
nrAdapter_ = std::make_unique<ngx::DlssNrRuntimeAdapter>();
if (!nrAdapter_->load(desc_.runtimeAbsPath.c_str(), st) ||
!nrAdapter_->installCallerCompatibility(st) ||
@@ -418,7 +426,7 @@ bool EnhanceGraph::initNgxFeatures()
// FG create + warm-up evaluate BEFORE descriptor views (the runtime
// allocates internals at the first evaluate and would fail after views
// exist on this system).
- if (!desc_.stillImage) {
+ if (!desc_.stillImage && desc_.frameGenerationBackend==engine::FrameGenerationBackend::Dlss) {
ngx::DlssFgBackend::CreateDesc fd{};
fd.width = workW_; fd.height = workH_;
fd.renderWidth = workW_; fd.renderHeight = workH_;
@@ -841,7 +849,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
// Guidance from original source-space color before SR/NR. Queue waits are GPU-side.
bool haveFlow = false;
- const bool runMotion = nvofStandalone_ || fgEnabled_ || (srEnabled_ && !desc_.videoSrQuality);
+ const bool runMotion = nvofStandalone_ || (fgEnabled_&&!frucBackend_) || (srEnabled_ && !desc_.videoSrQuality);
if (runMotion && nvof_ && nvof_->initialized()) {
const float dims[8] = {uintBits(nvofW_),uintBits(nvofH_),uintBits(nvofW_),uintBits(nvofH_),0,0,0,0};
if (prevValid_) {
@@ -1060,6 +1068,24 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
if(!fgEnabled_)gpuTimer_.submitted(ring_.lastSignaledValue());
out.videoFenceValue = ring_.lastSignaledValue();
+ if(fgEnabled_&&frucBackend_){
+ if(reset&&realFrameIndex_>0&&(!ring_.drainQueue()||!frucBackend_->reset()))return false;
+ auto* flist=ring_.acquireNext(slot,st);if(!flist)return false;
+ gpuTimer_.mark(flist,GpuStage::FgBatch);
+ frucBackend_->recordInput(flist,videoFrame_[parity].Get(),parity);
+ if(!ring_.submitAndSignal(slot))return false;
+ std::array<bool,3> repeats{};
+ if(!frucBackend_->execute(parity,prevValid_&&!reset?prevPtsMs_:ptsMs,ptsMs,repeats))return false;
+ flist=ring_.acquireNext(slot,st);if(!flist)return false;
+ for(uint32_t sub=1;sub<desc_.fgMultiplier;++sub){const unsigned generatedSlot=parity+(sub-1)*2;frucBackend_->recordOutput(flist,genFrame_[generatedSlot].Get(),sub);frucRepeated_[generatedSlot]=repeats[sub-1];}
+ gpuTimer_.mark(flist,GpuStage::FgBatch,true);gpuTimer_.resolve(flist);
+ if(!ring_.submitAndSignal(slot))return false;gpuTimer_.submitted(ring_.lastSignaledValue());
+ out.genFenceValue=ring_.lastSignaledValue();out.genSlot=parity;out.hasGenerated=prevValid_&&!reset;
+ if(out.hasGenerated)for(uint32_t sub=1;sub<desc_.fgMultiplier;++sub){const unsigned generatedSlot=parity+(sub-1)*2;++metrics_.fgSubmittedCandidates;
+ BatchFrame f;f.identity=out.batch.identity;f.kind=FrameKind::Generated;f.validity=GenerationValidity::Pending;f.subframe=sub;f.pts100ns=FrameBatch::interpolate(out.batch.a100ns,out.batch.b100ns,sub,desc_.fgMultiplier);
+ f.lease=std::make_shared<FrameLease>();f.lease->texture=genFrame_[generatedSlot];f.lease->slot=generatedSlot;f.lease->readyFence=out.genFenceValue;generatedLeases_[generatedSlot]=f.lease;out.batch.append(std::move(f));}
+ }
+
// FG reads enhanced SDR color, not the pre-NR guidance input.
if (fgEnabled_ && fgBackend_ && fgBackend_->created()) {
for(uint32_t sub=1;sub<desc_.fgMultiplier;++sub){
@@ -1131,11 +1157,14 @@ bool EnhanceGraph::resolveGeneration(FrameOutputs& out)
for(uint32_t i=0;i<out.batch.count;++i){
auto& frame=out.batch.frames[i];if(frame.kind!=FrameKind::Generated)continue;
if(frame.validity!=GenerationValidity::Pending){anyValid|=frame.validity==GenerationValidity::Valid;continue;}
- void* data=nullptr;D3D12_RANGE range{0,4};
- HRESULT hr=fgDisableReadback_[frame.lease->slot]->Map(0,&range,&data);
- if(FAILED(hr)){frame.validity=GenerationValidity::Failed;out.hasGenerated=false;veyra::log::error("fg-status",std::format("Map hr=0x{:X}",unsigned(hr)));return true;}
- const uint32_t disabled=*static_cast<uint8_t*>(data); // SDK writes the first byte only
- D3D12_RANGE written{0,0};fgDisableReadback_[frame.lease->slot]->Unmap(0,&written);
+ uint32_t disabled=frucRepeated_[frame.lease->slot];
+ if(!frucBackend_){
+ void* data=nullptr;D3D12_RANGE range{0,4};
+ HRESULT hr=fgDisableReadback_[frame.lease->slot]->Map(0,&range,&data);
+ if(FAILED(hr)){frame.validity=GenerationValidity::Failed;out.hasGenerated=false;veyra::log::error("fg-status",std::format("Map hr=0x{:X}",unsigned(hr)));return true;}
+ disabled=*static_cast<uint8_t*>(data);
+ D3D12_RANGE written{0,0};fgDisableReadback_[frame.lease->slot]->Unmap(0,&written);
+ }
const bool rejected=disabled||out.contentDuplicate;
frame.validity=rejected?GenerationValidity::Disabled:GenerationValidity::Valid;
anyValid|=!rejected;if(rejected)++metrics_.fgDisabledFrames;else ++metrics_.fgGeneratedFrames;
@@ -1145,7 +1174,7 @@ bool EnhanceGraph::resolveGeneration(FrameOutputs& out)
}
bool EnhanceGraph::applySettings(const engine::EnhancementSettings& s){
- if(s.videoSrQuality!=desc_.videoSrQuality||!s.validate().empty()||(s.multiplier>1&&(!fgCapsAvailable_||s.multiplier-1>uint32_t(fgMultiFrameMax_))))return false;
+ if((s.frameGenerationBackend==engine::FrameGenerationBackend::Fruc&&s.multiplier>1&&!frucBackend_)||s.frameGenerationBackend!=desc_.frameGenerationBackend||(frucBackend_&&s.multiplier>1&&s.multiplier!=desc_.fgMultiplier)||s.videoSrQuality!=desc_.videoSrQuality||!s.validate().empty()||(s.multiplier>1&&(!fgCapsAvailable_||s.multiplier-1>uint32_t(fgMultiFrameMax_))))return false;
desc_.contentRate=s.content;desc_.model=s.model;desc_.residual=s.residual;desc_.protection=s.protection;desc_.settingsRevision=s.revision;
desc_.fgMultiplier=std::max(2u,s.multiplier);desc_.enableNvofStandalone=s.nr&&!desc_.stillImage;nvofStandalone_=desc_.enableNvofStandalone;
setNrEnabled(s.nr);setFgEnabled(s.multiplier>1);
@@ -1166,7 +1195,7 @@ ID3D12Fence* EnhanceGraph::contextFence()const{return context_.fence();}
uint32_t EnhanceGraph::actualFlowPerf()const{return nvof_?nvof_->caps().actualPerfLevel:0;}
bool EnhanceGraph::fgCreated() const
{
- return fgBackend_ && fgBackend_->created();
+ return frucBackend_ || (fgBackend_ && fgBackend_->created());
}
uint64_t EnhanceGraph::lastNvofSignal() const
@@ -1211,6 +1240,7 @@ void EnhanceGraph::shutdown()
(void)nrAdapter_->snippetReleaseFeature(nrHandle_, rr, rs);
nrHandle_ = nullptr;
}
+ frucBackend_.reset();
if (fgBackend_) fgBackend_->release();
if(videoSrBackend_){videoSrBackend_->release();videoSrBackend_.reset();}
if (srBackend_) srBackend_->release();
diff --git a/tests/integration/FrucTests.cpp b/tests/integration/FrucTests.cpp
new file mode 100644
index 00000000..97efbb53
--- /dev/null
+++ b/tests/integration/FrucTests.cpp
@@ -0,0 +1,39 @@
+// Diagnostic pixel readback only. Known 8-pixel pan provides exact fractional GT.
+#include "veyra/pipeline/EnhanceGraph.h"
+#include "veyra/gfx/D3D12DeviceContext.h"
+#include "veyra/gfx/CommandSlotRing.h"
+#include "veyra/sink/ImageExportSink.h"
+#include <filesystem>
+#include <fstream>
+#include <iostream>
+#include <cmath>
+extern "C" {
+#include <libavutil/frame.h>
+#include <libavutil/pixfmt.h>
+}
+int main(int argc,char** argv){using namespace veyra;if(argc<3)return 2;const unsigned mult=unsigned(std::stoi(argv[1]));if(mult<2||mult>4)return 2;
+ constexpr unsigned W=1920,H=1080;std::vector<unsigned char> base(W*H);std::ifstream input(argv[2],std::ios::binary);if(!input.read(reinterpret_cast<char*>(base.data()),base.size()))return 2;
+ CoInitializeEx(nullptr,COINIT_MULTITHREADED);gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;pipeline::EnhanceGraph graph(ctx,ring);Status st;
+ gfx::DeviceContextDesc deviceDesc{};bool ok=ctx.initialize(deviceDesc,st)&&ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),6,st);
+ pipeline::EnhanceGraphDesc gd;gd.sourceWidth=gd.workWidth=W;gd.sourceHeight=gd.workHeight=H;gd.rgbInput=true;gd.enableNr=gd.enableSr=false;gd.enableFg=true;gd.fgMultiplier=mult;gd.frameGenerationBackend=engine::FrameGenerationBackend::Fruc;gd.runtimeAbsPath=(std::filesystem::path(VEYRA_PROJECT_ROOT)/"runtime_local/nvidia").wstring();if(ok)ok=graph.initialize(gd)&&graph.createViews();
+ AVFrame* f=av_frame_alloc();f->format=AV_PIX_FMT_RGBA;f->width=W;f->height=H;f->color_range=AVCOL_RANGE_JPEG;ok=ok&&av_frame_get_buffer(f,32)>=0;
+ auto color=[&](int x,unsigned y,unsigned c){const unsigned v=base[size_t(y)*W+std::clamp(x,0,int(W)-1)];return c==0?v:c==1?v/2+32:255-v;};
+ unsigned generated=0;double worst=0;for(unsigned i=0;ok&&i<6;++i){for(unsigned y=0;y<H;++y)for(unsigned x=0;x<W;++x){auto* p=f->data[0]+y*f->linesize[0]+x*4;for(unsigned c=0;c<3;++c)p[c]=static_cast<unsigned char>(color(int(x)-int(i)*8,y,c));p[3]=255;}
+ pipeline::EnhanceGraph::FrameOutputs out;if(!graph.process(f,i*1000.0/15,i==0,out)||!ring.waitIdle()||!graph.resolveGeneration(out)){ok=false;break;}
+ for(unsigned j=0;j<out.batch.count;++j){auto& item=out.batch.frames[j];if(item.kind!=pipeline::FrameKind::Generated)continue;sink::RgbaImage image;if(!sink::readRgba8(ctx,ring,item.lease->texture.Get(),image)){ok=false;break;}
+ double err=0,repeatError=0;size_t samples=0;double shift=(i-1+double(item.subframe)/mult)*8;
+ for(unsigned y=32;y<H-32;++y)for(unsigned x=64;x<W-64;++x)for(unsigned c=0;c<3;++c){double pos=x-shift;int left=int(std::floor(pos));double t=pos-left;double expected=color(left,y,c)*(1-t)+color(left+1,y,c)*t;err+=std::abs(image.pixels[(size_t(y)*W+x)*4+c]-expected);repeatError+=std::abs(double(color(int(x)-int(i-1)*8,y,c))-expected);++samples;}
+ err/=samples;repeatError/=samples;worst=std::max(worst,err);bool pass=item.validity==pipeline::GenerationValidity::Valid&&err<repeatError&&std::llabs(item.pts100ns-std::llround((i-1+double(item.subframe)/mult)*10000000.0/15))<=1;
+ std::cout<<"FRUC_GT frame="<<i<<" sub="<<item.subframe<<" mae="<<err<<" repeatMae="<<repeatError<<" valid="<<pass<<std::endl;ok=ok&&pass;++generated;
+ }
+ }
+ // Explicit discontinuity must reseed, never interpolate across the reset.
+ for(unsigned epoch=1;ok&&epoch<=3;++epoch){
+ pipeline::EnhanceGraph::FrameOutputs out;
+ ok=graph.process(f,epoch*2000.0,true,out)&&ring.waitIdle()&&graph.resolveGeneration(out)&&out.batch.count==1;
+ // A second frame after reseeding must run successfully, even for static input.
+ if(ok)ok=graph.process(f,epoch*2000.0+1000.0/15,false,out)&&ring.waitIdle()&&graph.resolveGeneration(out);
+ }
+ ok=ok&&generated==5*(mult-1);std::cout<<"FRUC_RESULT multiplier="<<mult<<" generated="<<generated<<" worstMae="<<worst<<" pass="<<ok<<std::endl;
+ ring.drainQueue();graph.shutdown();av_frame_free(&f);ring.shutdown();ctx.shutdown();CoUninitialize();return ok?0:1;
+}
diff --git a/tests/unit/LivePresentationTimingTests.cpp b/tests/unit/LivePresentationTimingTests.cpp
index b61f0e51..515ee1fd 100644
--- a/tests/unit/LivePresentationTimingTests.cpp
+++ b/tests/unit/LivePresentationTimingTests.cpp
@@ -12,6 +12,8 @@ int main(){
check(captureDuration(100,166767,true,333333).to100ns()==166667,"sample duration wins over nominal");
check(captureDuration(100,100,false,333333).to100ns()==333333,"missing sample stop uses nominal30fps");
check(captureDuration(100,90,true,0).isUnknown(),"invalid sample and absent nominal stay unknown");
+ check(liveSourceInterval100ns({1,1000},60)==10000,"1000fps packet not clamped to120fps");
+ check(liveSourceInterval100ns({0,1},1000)==10000,"1000fps nominal fallback accepted");
check(liveSourceInterval100ns({0,1},60)==166667,"known zero cannot turn60fps into120fps");
check(liveSourceInterval100ns(captureDuration(0,0,false,333333),60)==333333,"30fps packet retained by scheduler");
check(liveSourceInterval100ns({INT64_MAX,1},60)==1000000,"huge duration clamps before integer conversion");
diff --git a/tests/unit/RepairContractTests.cpp b/tests/unit/RepairContractTests.cpp
index 8ad3c01a..785fa165 100644
--- a/tests/unit/RepairContractTests.cpp
+++ b/tests/unit/RepairContractTests.cpp
@@ -35,6 +35,7 @@ int main(){
cadence.reset();for(int i=0;i<120;++i)cadence.observe(i*20.0,.01,true);check(cadence.measuredRate()==50,"moving 50fps cadence");
cadence.reset();for(int i=0;i<120;++i)cadence.observe(i*1000.0/60,.01,true);check(cadence.measuredRate()==60,"moving 60fps cadence");check(cadence.confirmedRate(engine::ContentRate::Fps60)==60&&cadence.confirmedRate(engine::ContentRate::Fps30)==0&&cadence.conflicts(engine::ContentRate::Fps30),"manual identification target is not a resampling fiction");
check(diagnostics::redact("failure C:\\Users\\private-user\\media file.mp4\nserial=DEVICE123\nuser=private-user").find("private-user")==std::string::npos,"redact Windows paths, usernames and serials");
+ engine::CfrTimeline high(1000,1,.000001,0);bool highOk=true;for(unsigned i=0;i<1000;++i)highOk &= high.accepts(i,i/1000.0);check(highOk&&!high.accepts(1000,1.001),"1000fps preserves exact timestamps and rejects dropped frame");
engine::CfrTimeline cfr(60,1,.001,0);bool quantized=true;
for(unsigned i=0;i<6000;++i)quantized &= cfr.accepts(i,std::round(i*1000.0/60)/1000);
check(quantized,"60fps millisecond quantization does not drift or reject");
diff --git a/tests/unit/RepairPresetTests.cpp b/tests/unit/RepairPresetTests.cpp
index e60b1cdf..7427a810 100644
--- a/tests/unit/RepairPresetTests.cpp
+++ b/tests/unit/RepairPresetTests.cpp
@@ -1,8 +1,9 @@
#include "veyra/engine/PresetStore.h"
#include <iostream>
#include <fstream>
-int main(int argc,char** argv){if(argc!=2)return 2;using namespace veyra::engine;const std::filesystem::path p=argv[1];PresetStore a(p);bool ok=a.load();EnhancementSettings s;s.videoSrQuality=2;s.protection.enabled=true;s.protection.featherPixels=3.5f;s.protection.regions[0]={.1f,.2f,.7f,.8f};s.protection.regions[3]={0,0,1,1};s.model.intensity=.375f;s.model.skin=1.5f;s.residual.darken=1.2f;s.multiplier=4;s.flow=FlowQuality::Quality;s.content=ContentRate::Fps50;s.nrPolicy=veyra::pipeline::NrSizePolicy::Native;
+int main(int argc,char** argv){if(argc!=2)return 2;using namespace veyra::engine;const std::filesystem::path p=argv[1];PresetStore a(p);bool ok=a.load();EnhancementSettings s;s.videoSrQuality=2;s.frameGenerationBackend=FrameGenerationBackend::Fruc;s.protection.enabled=true;s.protection.featherPixels=3.5f;s.protection.regions[0]={.1f,.2f,.7f,.8f};s.protection.regions[3]={0,0,1,1};s.model.intensity=.375f;s.model.skin=1.5f;s.residual.darken=1.2f;s.multiplier=4;s.flow=FlowQuality::Quality;s.content=ContentRate::Fps50;s.nrPolicy=veyra::pipeline::NrSizePolicy::Native;
ok=ok&&a.put(L"test",s)&&a.setDefault(0)&&!a.put(L"test",s);PresetStore b(p);ok=ok&&b.load()&&b.defaultSettings()==s&&b.rename(0,L"renamed")&&b.defaultSettings()==s;
+ auto badBackend=s;badBackend.frameGenerationBackend=static_cast<FrameGenerationBackend>(2);ok=ok&&!b.put(L"invalid backend",badBackend);
auto badSr=s;badSr.videoSrQuality=5;ok=ok&&!b.put(L"invalid video SR",badSr);
auto invalid=s;invalid.model.tone=9;ok=ok&&!b.put(L"bad",invalid)&&b.entries().size()==1&&b.erase(0)&&b.entries().empty();
auto badRegion=s;badRegion.protection.regions[0].left=2;ok=ok&&!b.put(L"invalid region",badRegion);