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++
Complete native NVIDIA low latency modes and frame generation markers
Veyra Goal Agent4edcb49f2fd2
diff --git a/AGENTS.md b/AGENTS.mdindex 3ceb6517..c741feef 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -1,5 +1,7 @@# Veyra Agent 工作规则+> **2026-10-28/29英伟达低延迟任务**:当前隔离分支`codex/nvidia-low-latency-20261028`,基线main4351bbd;用户授权完善Reflex并改为“英伟达低延迟:关/开/开+增强”。直接NVAPI,源帧Sleep与生成帧带外队列标记分开;当前本机DLSS/VFG/FSR原生路径验证,XeSS保持提供方调度并显示不生效。真实证据、失败修正和硬件边界见`docs/NVIDIA_LOW_LATENCY_2026-10-28.md`与`reports/nvidia-low-latency-20261028/FINAL.json`。不合并main、不push/Release,不改真实配置、驱动、SDK/模型/DLL;使用私有测试配置。+> **2026-10-28后续(用户选择)**:同分支新增“超分后缩回到”超采样选项:单次RTX视频超分到目标尺寸,再线性光精确缩回`srOutput`,NR/补帧/显示按缩回尺寸运行;双重开启时不用、保留选择。复用`srOutput`字段与`SrResolve`,导出协议14,超采样图同双重图走WDDM预算准入。读`docs/SR_SUPERSAMPLE_2026-10-28.md`及`reports/claude-sr-supersample-20261028/FINAL.json`。用户随后要求直接合并:双重超分、复查修正与超采样已合入本地main(未push/Release),活动树切回main,其余限制同下条。> **2026-10-28最新用户纠偏(覆盖下面同日早期两条)**:当前分支`codex/dual-sr-20261028`,实施真正的“基础SR→降低第一次AI结果→第二次SR”;双重开关位于基础超分下,展开独立第二设置,默认关闭。普通8K保持原规则,撤回强制4K参数修正/拦截;新双重图按WDDM预算拒绝不足的分配,不偷偷缩小尺寸。当前双重仅RTX视频超分,两次真实Evaluate;本机SDK共享Feature,不宣称两个独立SDK实例。实际验证与限制读`docs/DUAL_SR_PLAN_2026-10-28.md`及`reports/dual-sr-20261028/FINAL.json`。不重跑原8K最终输出+NR+VFG危险组合,根因未证实;不改真实配置、不合并main、不push/Release。diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.mdindex 62a93e13..5f04692a 100644--- a/THIRD_PARTY_NOTICES.md+++ b/THIRD_PARTY_NOTICES.md@@ -733,12 +733,17 @@ Source: https://github.com/NVIDIA/nvapi/tree/87dca625e83fd89a983e19b904e5f3a580d(`nvapi.h`, `nvapi_interface.h`, `nvapi_lite_common.h`), MIT.`include/veyra/gfx/ReflexSession.h` contains minimal renamed ABI declarations forSetSleepMode v1 and SetLatencyMarker v1, and QueryInterface IDs for initialization,-unloading, sleep and markers. Adaptations: independent RAII device lifetime,+sleep and markers. Adaptations: independent RAII device lifetime,absolute system-driver loading, return-code logging, successful call counts andexplicit disable. No complete SDK header or NVIDIA runtime is committed or bundled.The driver is supplied by Windows/NVIDIA. Frame markers delimit Veyra enhancementand presentation, not game input or physical display latency. Generated-frame-Reflex integration is not enabled; DLSS retains its selected multiplier.+Reflex integration was initially disabled with generated frames. The 2026-10-28+extension adds Boost, out-of-band marker types and the public+NotifyOutOfBandCommandQueue ID from the same fixed NVAPI source. Source-frame Sleep/markers and out-of-band presentation are separated;+generated frames never create another simulation or Sleep. XeSS keeps its own+presentation owner. NVIDIA Streamline's public `sl.chi/d3d12.cpp` is an API-use+reference only; Streamline is not linked, loaded or bundled.`include/veyra/gfx/NvidiaVrr.h` (2026-10-14) adds, from the same interfacefiles, the QueryInterface IDs of NvAPI_DISP_GetDisplayIdByDisplayName,diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.mdindex 7051b08d..6460d130 100644--- a/docs/CURRENT_STATUS.md+++ b/docs/CURRENT_STATUS.md@@ -2,6 +2,8 @@更新:2026-10-28。这里只描述现在;历史过程见[历史索引](history/INDEX.md)。+2026-10-28/29当前任务:隔离分支`codex/nvidia-low-latency-20261028`完善“英伟达低延迟”三档(关/开/开+增强),基线为下述合并后的main4351bbd。直接NVAPI,生成帧不重复Sleep;DLSS/VFG/FSR与提供方回退、GUI/保存验证见[执行记录](NVIDIA_LOW_LATENCY_2026-10-28.md)。尚未合并main或发布,正式版仍2.1.1。+## 正式版与开发基线- 正式版 **2.1.1**:`v2.1.1` / `v2.1.1-sources` → `2fecacf`,已完整进入main。正式包在`E:/项目/Veyra/releases/release-2.1.1-final-20261027`。diff --git a/docs/NVIDIA_LOW_LATENCY_2026-10-28.md b/docs/NVIDIA_LOW_LATENCY_2026-10-28.mdnew file mode 100644index 00000000..54c9e507--- /dev/null+++ b/docs/NVIDIA_LOW_LATENCY_2026-10-28.md@@ -0,0 +1,43 @@+# 英伟达低延迟:执行与验收++用户授权:完善已有Reflex接入,名称改为“英伟达低延迟”,三档“关 / 开 / 开+增强”。本地分支`codex/nvidia-low-latency-20261028`,main基线4351bbd,存档`checkpoint/pre-nvidia-low-latency-20261028`。不合并main、不push/Release;私有配置和本地文件测试,不改驱动/SDK/运行库或真实配置。++实施合同:保留通用低排队能力;NVIDIA控件三档分别不调用、原生低延迟、原生低延迟+Boost。配置保留显式三档,旧lowQueue=true迁移为开,旧关闭维持关闭。不能用实际回退状态覆盖用户保存的选择。非NVIDIA及提供方独占呈现不伪装为Reflex已启用。++源帧Sleep在选择输入前,每个实际处理源帧最多一次;等待/过滤输入复用准备ID。模拟/提交标记围绕输入和增强提交,真实Present正常标记;生成帧使用out-of-band标记,不重复Sleep/模拟标记。直接DXGI下验证DLSS/VFG与增强档;XeSS保留自己的低延迟调度,不套第二个节拍器。返回值失败时停用原生调用并显示回退,关闭、图重建、源切换、退出清除低延迟/Boost。++直接使用NVAPI,不引入Streamline。ABI沿用NVIDIA/nvapi固定87dca625e83fd89a983e19b904e5f3a580da90d2的MIT公共接口;参考NVIDIA公开Streamline D3D12 `setLatencyMarker` 的IUnknown队列目标用法,仅作为契约参考,不接入其运行库。[Reflex入口](https://developer.nvidia.com/performance-rendering-tools/reflex)、[NVAPI](https://github.com/NVIDIA/nvapi/tree/87dca625e83fd89a983e19b904e5f3a580da90d2)、[D3D12参考](https://github.com/NVIDIA-RTX/Streamline/blob/main/source/platforms/sl.chi/d3d12.cpp)。++验证:产品/相关目标构建;三档状态/持久化/迁移/无效值/关闭与失败回退;真实GPU文件在无补帧、DLSS及VFG下开关/增强、暂停恢复/seek/切源;原生API与生成帧标记成功、正常速度与完整退出。以软件排队/驱动接口证据报告,不宣称已测量点击到光子或采集卡固有延迟。每测试≤300秒、构建并发2/≤900秒,产物统一E盘对应nvidia-low-latency-20261028任务目录,复用既有构建与一份运行目录。++## 实际实现++- PresentationSettings新增独立三档字段,沿用通用低队列布尔字段。NVIDIA选择开/增强时启用低队列,关时两者停用;其他显卡保留旧通用低队列控件。已有lowQueue=true仅在NVIDIA上迁移为开,不自动开启Boost;非法保存值回退关。+- 全局JSON presentation.nvidiaLowLatency持久化,不混入画质预设。列表/节点共用NvidiaLowLatencyEditor。状态取实际有效设置;驱动失败及XeSS呈现所有权有明确说明,用户选择仍保存。+- NvAPI_D3D_SetSleepMode设置low=1、boost=0/1、minimumIntervalUs=0,不叠加原生限帧。System32 nvapi64.dll保持进程生命周期固定,设备关闭前撤销模式,保留旧驱动回调安全规则。+- 输入前Sleep并分配单调源ID,等待/丢弃输入复用准备ID;暂停丢弃未消费准备ID,避免把暂停时间算入下一帧准备。模拟结束/渲染开始在增强提交前,正常渲染结束与真实Present分别标记。+- 独立呈现队列NotifyOutOfBandCommandQueue=RENDER_PRESENT;复制工作用带外9/10标记,生成Present用11/12,真实Present仍4/5。使用公开SetLatencyMarker的队列IUnknown目标,每个源帧只Sleep一次,生成帧无额外Sleep/模拟编号。支持直接DXGI的DLSS、VFG和FSR;XeSS保留提供方所有权与XeLL,不强叠第二个调度器。+- 驱动调用失败立即停止原生路径,保留低队列并更新实际状态;撤销失败不能伪装已关闭。失效的旧模式/图的在途ID不再向新模式报告。++## 实测与失败记录++本轮跨至洛杉矶2026-10-29凌晨。真实GPU为本机RTX5070;输入为私有1080p30文件。没有占用采集卡,也没有进行RTX30/40持卡、真实VRR/光学延迟或长时稳定性认证。++- 产品及相关目标构建退出0,主要批次73.8/72.1秒、增量9.1/14.8/15.7秒和测试目标4.1秒,MSVC/Ninja并发2;命令为现有tmp/claude-sr-stage-20261028/build/build.py指定目标。准确命令与日志路径见WORKLOG和任务回执。+- RepairContract 293项0失败,含关时零调用、真实三档参数、6X只Sleep一次、带外标记、无效值、错误回退、撤销失败重试与旧ID隔离。故障路径为注入API单元验证,不冒充真实驱动故障实测。+- GPU:关、开、开+增强的无补帧路径;开+DLSS2X;增强+DLSS6X/VFG2X/FSR2X;增强+NR/SR/DLSS2X;XeSS提供方回退;暂停保留Boost/关闭/seek/恢复/三档切换/resize/源替换/退出。最终结果按FINAL.json列出的实际回执判定。+- 一个DLSS2X回执:162次成功Sleep、160张真实Present、159张生成Present、956个带外标记,撤销状态0。说明Sleep跟随源帧而非所有显示提交,不代表屏幕实际显示了319张不同图像或实测了点击到光子。+- 三档实际GUI、旧true迁移、列表/节点共享、关闭保留VFG、Boost重启恢复通过;无QML错误,原配置SHA未改。截图tests/nvidia-low-latency-20261028/controls.png为真实QML控件;原生视频子窗口不在该QML抓图内。+- QtQuick117通过/0失败/1既有跳过;i18n2704条、缺失0、占位符0。状态变化额外进入UI快照比较,不改既有刷新频率。++必须保留的失败与处理:++1. 首版使用NvAPI_D3D12_SetAsyncFrameMarker,队列通知及模式启用成功,但第一次带外标记返回-1;清零内部Present字段后仍失败。两轮日志在native-dlss-1-2、native-dlss-zero-1-2和对应gpu控制台;产品当场回退,没有假报成功。最终移除该调用与多余ABI,改为NVIDIA公开D3D12实现使用的SetLatencyMarker(queue);同样的9–12标记实际返回0,之后矩阵通过。没有忽略失败码或改SDK/驱动。+2. 首次GUI脚本向addEffect传入无效短名fg,列表三档与VFG已通过,节点夹具失败。改成现有正式键vfg-fg,用新的profile-ui-retry复验通过,原失败JSON/日志保留。+3. NR+SR+DLSS冷启动的首帧等待超过夹具原15秒界限,之后组合以正常速度真实出帧、原生模式/NR/SR/FG均通过,整体仍按失败保存。仅此新增组合的测试等待改为30秒,不改产品超时或旧guard,另目录复验;该时间包含模型初始化,不能冒充Reflex提高/降低延迟的证据。++## 交付与保护++分支本地提交、main保持4351bbd,不push/Release。复用tests/claude-sr-stage-20261028/app,以新文件替换EXE/QML,不写穿供体硬链接;97个运行组件与正式供体及其1730文件manifest复核。独立交互入口tests/nvidia-low-latency-20261028/启动英伟达低延迟测试.cmd,不使用原用户配置。++reports/logs/tests/tmp对应任务目录保留必要回执、原失败证据和脚本;收尾仅清本轮唯一数字TEMP目录中的重建缓存,实际逻辑删除量记录FINAL,不将逻辑字节冒充物理净回收。原8K NR/VFG整机卡死组合未复测,Lecram继续暂停。diff --git a/docs/README.md b/docs/README.mdindex 8930e263..a01f1c4e 100644--- a/docs/README.md+++ b/docs/README.md@@ -2,6 +2,8 @@日常只从这些入口开始:+当前任务:[英伟达低延迟三档](NVIDIA_LOW_LATENCY_2026-10-28.md)(独立分支,未发布)。+1. [当前项目状态](CURRENT_STATUS.md):正式版、活动工作、暂停项、现场问题及验收边界。2. [开发与验证](DEVELOPMENT.md):唯一施工树、构建、回归、运行供体和路径规则。3. [当前工作日志](WORKLOG.md):正在进行的实际结果与续接信息。diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 48a91214..f2607088 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -121,3 +121,27 @@ A/B(GTA VI原生4K两帧,全部质量4,完整表见DUAL_SR_PLAN“复查用户明确要求“直接合并到Main即可”,覆盖此前各段“不合并main”。在`codex/dual-sr-20261028`把复查修正与超采样选项提交为一个提交,再以合并提交并入本地`main`(原`7b0b64b`,是该分支祖先,无分叉),沿用以往“Merge … for local integration”的做法;仓库没有启用的git钩子。活动树随后切回`main`,内容与已测试的工作区一致,无需重编。并入内容:claude/sr-stage-20261028(cf84762)、codex/sr-stage-freeze-20261028(67d0294)、codex/dual-sr-20261028(e61e497)及本次提交。独立`claude/capture-fps-audio-20261027`未并入;施工分支保留未删。未push、未Release,正式版仍2.1.1,运行目录与真实配置不变。提交与合并哈希、合并后检查见reports/claude-sr-supersample-20261028/FINAL.json。++## 2026-10-28/29 英伟达低延迟三档与Reflex补帧接入++用户要求完善NVIDIA低延迟并命名“英伟达低延迟”,提供关/开/开+增强。基线main4351bbd,隔离分支`codex/nvidia-low-latency-20261028`,存档`checkpoint/pre-nvidia-low-latency-20261028`。本轮不合并main、不push/Release。单Agent,复用既有构建和一份测试运行目录,所有新增证据/临时数据在E盘。++完成:独立三档配置和旧lowQueue迁移(旧开启仅迁移到开,不自动Boost;非法值关);列表/节点共享控件;实际驱动状态、错误回退、XeSS提供方所有权说明及重启持久化。直接NVAPI原生SetSleepMode区分Boost,interval=0不另加限帧。源输入前Sleep并复用等待ID,增强提交后renderEnd;独立呈现队列注册带外工作,复制9/10和生成Present11/12使用公开SetLatencyMarker(queue),真实Present4/5正常标记。生成帧不增加Sleep/模拟ID。暂停、模式切换、图重建和切源清理准备ID;关闭撤销Boost,失败不能假报成功。XeSS沿用自身XeLL调度。未引入Streamline或改动驱动、SDK/模型/运行DLL。++主要命令(均在活动源码树执行):++- `python -X utf8 -B E:/项目/Veyra/tmp/claude-sr-stage-20261028/build/build.py veyra_qml_ui veyra_presentation_pacing_tests veyra_repair_contract_tests veyra_ui_i18n_tests veyra_qml_quick_tests`;后续按变更仅重建相关目标,并发2/单次≤900秒。主要批次73.8/72.1秒,最终产品增量15.7秒、测试增量4.1秒退出0;原始MSVC/Ninja日志保留`logs/claude-sr-stage-20261028/build-20261028*.log`及`build-20261029-001739.log`/`build-20261029-002204.log`,不把既有编译警告写成零警告。+- `python -X utf8 -B E:/项目/Veyra/tmp/claude-sr-stage-20261028/stage_app.py`:以unlink后写新文件更新EXE/QML,不写穿供体硬链接。+- `python -X utf8 -B E:/项目/Veyra/reports/nvidia-low-latency-20261028/run.py cpu|qml`;GPU用`gpu <档位> <倍率> <场景> [后缀]`,档位-1关/1开/2增强。场景native-plain、native-dlss-queue、native-dlss、native-vfg、native-fsr、native-xess、native-effects、native-lifecycle。最终组合及生命周期分别`gpu 2 2 native-effects final`/`gpu 2 2 native-lifecycle final`。每测试≤300秒。+- `python -X utf8 -B E:/项目/Veyra/reports/nvidia-low-latency-20261028/ui.py --retry`及`--retry --verify`:真实GUI/驱动、旧设置迁移与Boost重启恢复;`python -X utf8 -B scripts/i18n/extract.py --check`、`git diff --check`。+- `python -X utf8 -B E:/项目/Veyra/reports/nvidia-low-latency-20261028/finalize.py`:交互入口启动、源QML/翻译与EXE身份、供体与运行组件全核验。++结果:RepairContract293项0失败,QtQuick117通过/0失败/1既有跳过,i18n2704条缺失/占位符错误0;10个最终GPU用例退出0。真实RTX5070文件1080p30测试包括关/开/增强、DLSS2X/6X、VFG2X、FSR2X、XeSS提供方回退;最终NR+SR+DLSS组合21.03秒、生命周期20.94秒通过,组合源速0.988793、测量期间149处理帧。列表/节点/关后VFG继续/保存恢复真实GUI通过,无QML错误。162成功Sleep对应160真实/159生成Present为软件和驱动接口计数,不能冒充物理显示帧或延迟收益。++失败如实保留:初始AsyncFrameMarker返回-1(清内部字段仍失败),当场回退;改用NVIDIA公开queue目标SetLatencyMarker后9–12返回0,原两次engine.log保留。GUI初始夹具误用fg键,改现有vfg-fg后新配置复验通过。组合首次15秒首帧夹具超时、之后真实处理成功但整体仍记失败;只把该新增组合夹具等待改30秒后另目录通过,不修改产品或历史guard。清理脚本首版Split-Path参数集合不兼容、尚未删除即退出,改用IO.Directory.GetParent后通过。++保护及空间:EXE构建/运行SHA一致;QML/翻译全一致;97个运行组件与正式供体一致,正式供体1730个manifest文件全核验。GUI与最终交互启动前后真实配置SHA一致。只清本轮19个数字TEMP子目录,删除逻辑46,093,122字节,先核对绝对路径、父链/子项无reparse和进程占用;脚本、原始失败日志、配置、交互入口及运行目录保留。未测本轮净物理空间变化,收尾剩余任务逻辑字节见FINAL。++入口`E:/项目/Veyra/tests/nvidia-low-latency-20261028/启动英伟达低延迟测试.cmd`使用私有interactive-profile,初始关闭、不自动开媒体;启动冒烟退出0。运行目录仍`tests/claude-sr-stage-20261028/app`。回执/脚本`reports/nvidia-low-latency-20261028`,日志`logs/nvidia-low-latency-20261028`,截图`tests/nvidia-low-latency-20261028/controls.png`,执行细节`docs/NVIDIA_LOW_LATENCY_2026-10-28.md`。++未测30/40系持卡、采集卡、真实VRR/物理屏幕端延迟与长时稳定性;不重跑原8K最终输出+NR+VFG整机卡死组合。主线仍4351bbd,正式版仍2.1.1;本分支本地提交哈希与干净状态写入FINAL,不push/Release。Lecram继续暂停。diff --git a/i18n/catalog.json b/i18n/catalog.jsonindex e5546a92..c28d6e1c 100644--- a/i18n/catalog.json+++ b/i18n/catalog.json@@ -112,13 +112,6 @@"en": " · decode ","ja": " · デコード "},- {- "zh": " + NVIDIA Reflex(实验)",- "src": "src/engine/VideoPresenter.cpp",- "zh-TW": " + NVIDIA Reflex(實驗)",- "en": " + NVIDIA Reflex (experimental)",- "ja": " + NVIDIA Reflex(実験的)"- },{"zh": " / 4 个区域","src": "qml/SavePresetDialog.qml",@@ -1974,27 +1967,6 @@"en": "RX 9000 · lmxxf (experimental)","ja": "RX 9000 · lmxxf(実験)"},- {- "zh": "Reflex 调用及驱动撤销失败;请关闭视频后重试",- "src": "src/engine/EngineController.cpp",- "zh-TW": "Reflex 調用及驅動撤銷失敗;請關閉影片後重試",- "en": "Reflex call and driver rollback failed; close the video and try again",- "ja": "Reflex の呼び出しとドライバー設定の取り消しに失敗しました。動画を閉じて再試行してください"- },- {- "zh": "Reflex 调用失败,当前使用低排队;详见日志",- "src": "src/engine/EngineController.cpp",- "zh-TW": "Reflex 調用失敗,當前使用低排隊;詳見日誌",- "en": "Reflex call failed; using the low queue instead. See the log",- "ja": "Reflex の呼び出しに失敗したため、低キューを使用中です。ログを確認してください"- },- {- "zh": "Reflex 驱动状态撤销失败;低延迟队列已停用 · ",- "src": "src/engine/VideoPresenter.cpp",- "zh-TW": "Reflex 驅動狀態撤銷失敗;低延遲佇列已停用 · ",- "en": "Reflex driver state could not be rolled back; low-latency queue disabled · ",- "ja": "Reflex のドライバー状態を取り消せませんでした。低遅延キューを無効にしました · "- },{"zh": "SDK 提交","src": "src/ui/bridge/Playback.cpp",@@ -2360,11 +2332,11 @@"ja": "XeSS はエンコード可能な補間テクスチャを公開していません。書き出しには FSR、DLSS または VFG を選択してください。"},{- "zh": "XeSS 提供方自行调度:低延迟队列与输出上限不生效 · ",+ "zh": "XeSS 提供方自行调度:英伟达低延迟与输出上限不生效,选择已保留 · ","src": "src/engine/VideoPresenter.cpp",- "zh-TW": "XeSS 提供方自行調度:低延遲佇列與輸出上限不生效 · ",- "en": "The XeSS provider schedules itself: low-latency queue and output cap do not apply · ",- "ja": "XeSS は独自にスケジュールします:低遅延キューと出力上限は効きません · "+ "zh-TW": "XeSS 提供方自行調度:NVIDIA 低延遲與輸出上限不生效,選擇已保留 · ",+ "en": "XeSS owns scheduling: NVIDIA Low Latency and output cap are inactive; selections retained · ",+ "ja": "XeSS がスケジュールを管理:NVIDIA 低遅延と出力制限は無効です。選択は保持されます · "},{"zh": "XeSS 未启用:运行时或设备不兼容;当前为普通呈现",@@ -3515,11 +3487,11 @@"ja": "低遅延キュー · 現在無効"},{- "zh": "低延迟队列:只保留一帧在处理",+ "zh": "低延迟队列:已开启","src": "src/engine/VideoPresenter.cpp",- "zh-TW": "低延遲佇列:只保留一幀在處理",- "en": "Low-latency queue: one frame in flight",- "ja": "低遅延キュー:処理中は 1 フレームのみ"+ "zh-TW": "低延遲佇列:已開啟",+ "en": "Low queue latency: on",+ "ja": "低遅延キュー:オン"},{"zh": "低延迟顺序,仅预览、全层同步",@@ -3964,7 +3936,7 @@},{"zh": "关",- "src": "qml/ProDisplayPanel.qml",+ "src": "qml/NvidiaLowLatencyEditor.qml","zh-TW": "關","en": "Off","ja": "オフ"@@ -4271,6 +4243,20 @@"en": "Reduce motion","ja": "アニメーションを減らす"},+ {+ "zh": "减少处理排队",+ "src": "qml/NodePage.qml",+ "zh-TW": "減少處理排隊",+ "en": "Reduce processing queue depth",+ "ja": "処理の待ち行列を減らす"+ },+ {+ "zh": "减少处理排队;增强档提高 GPU 频率,可能增加功耗。",+ "src": "qml/NvidiaLowLatencyEditor.qml",+ "zh-TW": "減少處理排隊;增強模式提高 GPU 時脈,可能增加功耗。",+ "en": "Reduce processing queue depth. Boost requests higher GPU clocks and may increase power use.",+ "ja": "処理の待ち行列を減らします。ブーストは GPU クロックを上げ、消費電力が増える場合があります。"+ },{"zh": "减少暗部被进一步压黑,保留提亮细节","src": "qml/NrLayerEditor.qml",@@ -5160,20 +5146,6 @@"en": "Save as","ja": "名前を付けて保存"},- {- "zh": "只保留一帧在处理,未补帧时加 NVIDIA Reflex;垂直同步本身已不排队",- "src": "qml/ProPage.qml",- "zh-TW": "只保留一幀在處理,未補幀時加 NVIDIA Reflex;垂直同步本身已不排隊",- "en": "Keeps one frame in flight and adds NVIDIA Reflex without frame generation; VSync itself no longer queues",- "ja": "処理中のフレームを 1 枚に保ち、フレーム生成なしでは NVIDIA Reflex を追加;垂直同期自体はもうキューを溜めない"- },- {- "zh": "只保留一帧在处理,未补帧时加 Reflex",- "src": "qml/NodePage.qml",- "zh-TW": "只保留一幀在處理,未補幀時加 Reflex",- "en": "One frame in flight; adds Reflex without frame generation",- "ja": "処理中は 1 フレームのみ、フレーム生成なしでは Reflex を追加"- },{"zh": "只列出当前分辨率和帧率下的像素格式","src": "qml/CaptureSourceDialog.qml",@@ -7906,7 +7878,7 @@},{"zh": "开",- "src": "qml/ProPage.qml",+ "src": "qml/NvidiaLowLatencyEditor.qml","zh-TW": "開","en": "On","ja": "オン"@@ -8023,6 +7995,13 @@"en": "Power on","ja": "電源オン"},+ {+ "zh": "开+增强",+ "src": "qml/NvidiaLowLatencyEditor.qml",+ "zh-TW": "開+增強",+ "en": "On + Boost",+ "ja": "オン+ブースト"+ },{"zh": "引擎异常,请查看诊断","src": "src/engine/EngineController.cpp",@@ -8947,6 +8926,13 @@"en": "Available subtitles appear once a video is open","ja": "動画を開くと使える字幕が表示されます"},+ {+ "zh": "打开视频后生效",+ "src": "qml/NvidiaLowLatencyEditor.qml",+ "zh-TW": "開啟影片後生效",+ "en": "Applies when a video is opened",+ "ja": "動画を開くと適用されます"+ },{"zh": "打开视频或图片","src": "src/ui/bridge/Playback.cpp",@@ -14464,6 +14450,69 @@"en": "Node preset: ","ja": "ノードのプリセット:"},+ {+ "zh": "英伟达低延迟",+ "src": "qml/NvidiaLowLatencyEditor.qml",+ "zh-TW": "NVIDIA 低延遲",+ "en": "NVIDIA Low Latency",+ "ja": "NVIDIA 低遅延"+ },+ {+ "zh": "英伟达低延迟不可用,当前使用低排队;详见日志",+ "src": "src/engine/VideoPresenter.cpp",+ "zh-TW": "NVIDIA 低延遲無法使用,目前使用低排隊;詳見記錄",+ "en": "NVIDIA Low Latency unavailable; using low queue depth. See logs.",+ "ja": "NVIDIA 低遅延は利用できません。低遅延キューを使用中です。ログをご確認ください。"+ },+ {+ "zh": "英伟达低延迟撤销失败;请关闭视频后重试 · ",+ "src": "src/engine/VideoPresenter.cpp",+ "zh-TW": "NVIDIA 低延遲停用失敗;請關閉影片後重試 · ",+ "en": "Could not disable NVIDIA Low Latency; close the video and retry · ",+ "ja": "NVIDIA 低遅延を無効にできません。動画を閉じて再試行してください · "+ },+ {+ "zh": "英伟达低延迟调用及撤销失败;请关闭视频后重试",+ "src": "src/engine/EngineController.cpp",+ "zh-TW": "NVIDIA 低延遲呼叫及停用失敗;請關閉影片後重試",+ "en": "NVIDIA Low Latency call and disable failed; close the video and retry",+ "ja": "NVIDIA 低遅延の呼び出しと無効化に失敗しました。動画を閉じて再試行してください"+ },+ {+ "zh": "英伟达低延迟调用失败,当前使用低排队;详见日志",+ "src": "src/engine/EngineController.cpp",+ "zh-TW": "NVIDIA 低延遲呼叫失敗,目前使用低排隊;詳見記錄",+ "en": "NVIDIA Low Latency call failed; using low queue depth. See logs.",+ "ja": "NVIDIA 低遅延の呼び出しに失敗しました。低遅延キューを使用中です。ログをご確認ください。"+ },+ {+ "zh": "英伟达低延迟需要 NVIDIA 显卡,当前使用低排队",+ "src": "src/engine/VideoPresenter.cpp",+ "zh-TW": "NVIDIA 低延遲需要 NVIDIA 顯示卡,目前使用低排隊",+ "en": "NVIDIA Low Latency requires an NVIDIA GPU; using low queue depth",+ "ja": "NVIDIA 低遅延には NVIDIA GPU が必要です。低遅延キューを使用中です"+ },+ {+ "zh": "英伟达低延迟:关 · ",+ "src": "src/engine/VideoPresenter.cpp",+ "zh-TW": "NVIDIA 低延遲:關 · ",+ "en": "NVIDIA Low Latency: Off · ",+ "ja": "NVIDIA 低遅延:オフ · "+ },+ {+ "zh": "英伟达低延迟:开(已启用)",+ "src": "src/engine/VideoPresenter.cpp",+ "zh-TW": "NVIDIA 低延遲:開(已啟用)",+ "en": "NVIDIA Low Latency: On (active)",+ "ja": "NVIDIA 低遅延:オン(有効)"+ },+ {+ "zh": "英伟达低延迟:开+增强(已启用)",+ "src": "src/engine/VideoPresenter.cpp",+ "zh-TW": "NVIDIA 低延遲:開+增強(已啟用)",+ "en": "NVIDIA Low Latency: On + Boost (active)",+ "ja": "NVIDIA 低遅延:オン+ブースト(有効)"+ },{"zh": "范围 0.25~4.00 倍,保持原有音调","src": "qml/PlaybackRateDialog.qml",@@ -17474,6 +17523,13 @@"en": "Requires an NVIDIA RTX GPU and the NVOF driver","ja": "NVIDIA RTX GPU と NVOF ドライバーが必要です"},+ {+ "zh": "需要 NVIDIA 显卡",+ "src": "qml/NvidiaLowLatencyEditor.qml",+ "zh-TW": "需要 NVIDIA 顯示卡",+ "en": "Requires an NVIDIA GPU",+ "ja": "NVIDIA GPU が必要です"+ },{"zh": "需要 PIN","src": "qml/CaptureSourceDialog.qml",@@ -18706,13 +18762,6 @@"en": " (NGX 0x{:08X}, driver {}); effects that depend on it are off","ja": "(NGX 0x{:08X}、ドライバー {})。依存するエフェクトをオフにしました"},- {- "zh": "(Reflex 初始化失败)",- "src": "src/engine/VideoPresenter.cpp",- "zh-TW": "(Reflex 初始化失敗)",- "en": " (Reflex initialization failed)",- "ja": "(Reflex の初期化に失敗)"- },{"zh": "(SDR 存 PNG,HDR 存 JPEG XR)","src": "qml/SettingsPage.qml",@@ -18790,13 +18839,6 @@"en": " (exit code {} / error {})","ja": "(終了コード {} / エラー {})"},- {- "zh": "(补帧运行,Reflex 不启用)",- "src": "src/engine/VideoPresenter.cpp",- "zh-TW": "(補幀執行,Reflex 不啟用)",- "en": " (frame generation running, Reflex not enabled)",- "ja": "(フレーム生成中のため Reflex は無効)"- },{"zh": ",最忙的引擎类型,全系统),每秒采样;在 设置 → 通用与外观 中更换监控的显卡","src": "qml/ProPerfOrbs.qml",diff --git a/include/veyra/engine/PresentationSettings.h b/include/veyra/engine/PresentationSettings.hindex 1866137f..841a2774 100644--- a/include/veyra/engine/PresentationSettings.h+++ b/include/veyra/engine/PresentationSettings.h@@ -10,9 +10,11 @@ namespace veyra::engine {enum class PacingMode : unsigned { LowQueue, Even, Reflex };enum class DisplaySync : unsigned { Tearing, Vsync, Automatic };enum class OutputRateMode : unsigned { Off, FollowDisplay, Custom };+enum class NvidiaLowLatency : unsigned { Off, On, Boost };+constexpr NvidiaLowLatency savedNvidiaLowLatency(int value){return value>=0&&value<=2?NvidiaLowLatency(value):NvidiaLowLatency::Off;}struct PresentationSettings {- // Low-latency queue: DXGI maximum frame latency 1 instead of 3, plus- // Reflex when frame generation is off. Reduces submit-to-scanout queueing,+ // Low-latency queue: DXGI maximum frame latency 1 instead of 3.+ // Native NVIDIA Reflex is selected separately below. Reduces queueing,// which cannot be measured on this machine - do not claim a figure for it.bool enabled=false;PacingMode mode=PacingMode::LowQueue; // deprecated, see above@@ -25,8 +27,9 @@ struct PresentationSettings {// 可变刷新 switch: where the monitor can run VRR, Automatic presents like// explicit Vsync (G-SYNC/FreeSync + V-SYNC, see presentationVsync below).bool variableRefresh=false;+ NvidiaLowLatency nvidiaLowLatency=NvidiaLowLatency::Off;bool operator==(const PresentationSettings&) const = default;- bool valid()const{return unsigned(mode)<=2&&unsigned(display)<=2&&unsigned(outputRate)<=2&&std::isfinite(customFps)&&customFps>=1.0&&customFps<=1000.0;}+ bool valid()const{return unsigned(mode)<=2&&unsigned(display)<=2&&unsigned(outputRate)<=2&&unsigned(nvidiaLowLatency)<=2&&std::isfinite(customFps)&&customFps>=1.0&&customFps<=1000.0;}};// Automatic never waits for vertical sync and never requests tearing: a// flip-model Present(0, 0) replaces a frame that has not been shown yet at thediff --git a/include/veyra/engine/VideoPresenter.h b/include/veyra/engine/VideoPresenter.hindex 64a225da..08123c08 100644--- a/include/veyra/engine/VideoPresenter.h+++ b/include/veyra/engine/VideoPresenter.h@@ -47,7 +47,9 @@ public:PresentationSettings configurePresentation(gfx::D3D12DeviceContext&,PresentationSettings,bool fg,std::wstring& status);bool presentationReady(){return sink_.presentationReady();}bool waitPresentationReady(unsigned ms){return sink_.waitPresentationReady(ms);}- uint64_t beginReflex(){return reflex_.begin();}+ uint64_t beginReflex(){const auto id=reflexInputFrame_;reflexInputFrame_=0;reflex_.renderStart(id);return id;}+ void endReflex(uint64_t id){reflex_.renderEnd(id);}+ void cancelReflexInput(){if(reflexInputFrame_)reflex_.mark(reflexInputFrame_,1);reflexInputFrame_=0;}void reflexFrame(uint64_t id){reflexFrame_=id;}// True while XeSS owns Present: the low-latency queue and the output// cap cannot reach provider-generated frames, so the UI greys them out.@@ -55,6 +57,7 @@ public:bool reflexActive()const{return reflex_.active();}bool reflexDisablePending()const{return reflex_.disablePending();}+ bool reflexFailed()const{return reflex_.failed();}bool pacingActive()const{return sink_.pacingActive();}uint64_t generation()const{return generation_;}// Explicit integration-test capture only; never called by playback/export.@@ -112,7 +115,7 @@ private:std::chrono::steady_clock::time_point metadataAttempt_{};DXGI_HDR_METADATA_HDR10 lastMetadata_{};gfx::ReflexSession reflex_;- uint64_t reflexFrame_=0,generation_=0;+ uint64_t reflexFrame_=0,reflexInputFrame_=0,generation_=0;bool providerOwnedPresentation_=false;PresentCapture* capture_=nullptr;Microsoft::WRL::ComPtr<ID3D12CommandQueue> presentationQueue_;diff --git a/include/veyra/gfx/ReflexSession.h b/include/veyra/gfx/ReflexSession.hindex 2c3de152..f023a1c9 100644--- a/include/veyra/gfx/ReflexSession.h+++ b/include/veyra/gfx/ReflexSession.h@@ -5,62 +5,115 @@#include <format>#include "veyra/Log.h"namespace veyra::gfx {-// Minimal ABI declarations checked against NVIDIA/nvapi public interfaces.-// Source: NVIDIA/nvapi 87dca625e83fd89a983e19b904e5f3a580da90d2 (MIT).-// Renamed subset and lifecycle integration; see THIRD_PARTY_NOTICES.md.-// No SDK header or runtime is distributed in the source tree.+// Renamed public NVAPI ABI subset: NVIDIA/nvapi+// 87dca625e83fd89a983e19b904e5f3a580da90d2 (MIT), see THIRD_PARTY_NOTICES.+// Owner-thread only. One Sleep per SOURCE input, never per generated Present.class ReflexSession {+public:struct SleepParams {uint32_t version;uint8_t low,boost;uint32_t interval;uint8_t markers,minQueue,reserved[30];};struct MarkerParams {uint32_t version;uint64_t frame;uint32_t type;uint64_t reserved0;uint8_t reserved[56];};static_assert(sizeof(SleepParams)==44&&sizeof(MarkerParams)==88);- using Query=void*(__cdecl*)(uint32_t);- using Init=int(__cdecl*)();using Set=int(__cdecl*)(IUnknown*,SleepParams*);using Sleep=int(__cdecl*)(IUnknown*);using Marker=int(__cdecl*)(IUnknown*,MarkerParams*);- HMODULE module_=nullptr;ID3D12Device* device_=nullptr;- Set set_=nullptr;Sleep sleep_=nullptr;Marker marker_=nullptr;- bool initialized_=false,active_=false,driverEnabled_=false;uint64_t next_=0,sleeps_=0,markers_=0;-public:- ~ReflexSession(){close();} // the module stays pinned, see close()+ using Notify=int(__cdecl*)(ID3D12CommandQueue*,uint32_t);+ // Explicit injection for lifecycle/failed-driver unit tests; production uses System32 NVAPI.+ struct DriverApi {Set set=nullptr;Sleep sleep=nullptr;Marker marker=nullptr;Notify notify=nullptr;};+ ReflexSession()=default;+ explicit ReflexSession(DriverApi api):api_(api),initialized_(true){}+ ReflexSession(const ReflexSession&)=delete;+ ReflexSession& operator=(const ReflexSession&)=delete;+ ~ReflexSession(){close();}bool active()const{return active_;}+ bool boost()const{return active_&&boost_;}bool disablePending()const{return driverEnabled_&&!active_;}- // nvapi64.dll stays loaded and initialized for the life of the process: the driver keeps- // per-device sleep-mode state that is called back when the D3D12 device is finally- // released. NvAPI_Unload + FreeLibrary here (on every re-enable and at shutdown) could- // leave that callback pointing into an unloaded module; a field dump of 2026-10-01- // crashed in D3D12Core on exit, reading code just past the NVIDIA user-mode driver.- void close(){disable();device_=nullptr;driverEnabled_=false;}+ bool failed()const{return failed_;}+ uint64_t sleepCount()const{return sleeps_;}+ uint64_t generatedPresents()const{return generatedPresents_;}+ void close(){+ if(!disable())log::warn("reflex","device close while driver disable failed; device teardown must clear state");+ device_=nullptr;queue_=nullptr;driverEnabled_=false;+ }bool disable(){active_=false;- if(driverEnabled_&&set_){SleepParams p{};p.version=sizeof(p)|(1u<<16);const int r=set_(device_,&p);log::info("reflex",std::format("disable status={} successfulSleeps={} successfulMarkers={}",r,sleeps_,markers_));if(r)return false;driverEnabled_=false;}+ if(driverEnabled_&&api_.set){+ SleepParams p{};p.version=sizeof(p)|(1u<<16);const int r=api_.set(device_,&p);+ log::info("reflex",std::format("disable status={} successfulSleeps={} successfulMarkers={} oobMarkers={} realPresents={} generatedPresents={}",r,sleeps_,markers_,oobMarkers_,realPresents_,generatedPresents_));+ if(r){failed_=true;return false;}driverEnabled_=false;+ }return true;}- bool enable(ID3D12Device* device){- if(active_&&device_==device)return true;+ bool enable(ID3D12Device* device,bool boost=false,bool generated=false,ID3D12CommandQueue* queue=nullptr){+ if(active_&&device_==device&&boost_==boost&&generated_==generated&&queue_==queue)return true;if(!disable())return false;- close();device_=device;- if(!initialized_){- if(!module_){- wchar_t system[MAX_PATH]{};GetSystemDirectoryW(system,MAX_PATH);- const std::wstring path=std::wstring(system)+L"\\nvapi64.dll";- module_=LoadLibraryExW(path.c_str(),nullptr,LOAD_LIBRARY_SEARCH_SYSTEM32);- HMODULE pinned=nullptr; // never unloaded, see close()- if(module_)GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_PIN,reinterpret_cast<LPCWSTR>(module_),&pinned);- }- auto query=module_?reinterpret_cast<Query>(GetProcAddress(module_,"nvapi_QueryInterface")):nullptr;- if(!query)return false;- auto init=reinterpret_cast<Init>(query(0x0150E828));- set_=reinterpret_cast<Set>(query(0xac1ca9e0));sleep_=reinterpret_cast<Sleep>(query(0x852cd1d2));marker_=reinterpret_cast<Marker>(query(0xd9984c05));- if(!init||!set_||!sleep_||!marker_)return false;- const int initialized=init();initialized_=initialized==0;- if(!initialized_){log::warn("reflex",std::format("initialize status={}",initialized));return false;}+ device_=device;queue_=queue;failed_=false;queueMarkers_=false;boost_=boost;generated_=generated;+ if(!load()||!api_.set||!api_.sleep||!api_.marker){log::warn("reflex","required system-driver low-latency interfaces unavailable");return false;}+ if(generated&&(!api_.notify||!queue)){+ log::warn("reflex","frame generation needs out-of-band notification and an owned presentation queue");return false;+ }+ if(queue&&api_.notify){+ const int r=api_.notify(queue,3); // OUT_OF_BAND_RENDER_PRESENT+ log::info("reflex",std::format("present queue out-of-band status={}",r));+ if(r)return false;queueMarkers_=true;}- SleepParams p{};p.version=sizeof(p)|(1u<<16);p.low=1;p.markers=1;- const int result=set_(device_,&p);log::info("reflex",std::format("enable status={} intervalUs=0 boost=0",result));- sleeps_=markers_=0;return active_=driverEnabled_=result==0;+ SleepParams p{};p.version=sizeof(p)|(1u<<16);p.low=1;p.boost=boost;p.markers=1;+ const int r=api_.set(device_,&p);+ log::info("reflex",std::format("enable status={} intervalUs=0 boost={} frameGeneration={} queueMarkers={}",r,boost,generated,queueMarkers_));+ sleeps_=markers_=oobMarkers_=realPresents_=generatedPresents_=0;firstFrame_=next_+1;+ return active_=driverEnabled_=r==0;+ }+ void mark(uint64_t frame,uint32_t type){+ if(!eligible(frame))return;+ MarkerParams p{};p.version=sizeof(p)|(1u<<16);p.frame=frame;p.type=type;+ const int r=api_.marker(device_,&p);+ if(r)fail("marker",r);else{++markers_;if(frame<firstFrame_+2)log::info("reflex-marker",std::format("source={} type={} status=0",frame,type));}+ }+ uint64_t begin(){+ if(!active_)return 0;+ const int r=api_.sleep(device_);if(r){fail("sleep",r);return 0;}+ ++sleeps_;const auto frame=++next_;mark(frame,0);return active_?frame:0;+ }+ void renderStart(uint64_t frame){mark(frame,1);mark(frame,2);}+ void renderEnd(uint64_t frame){if(queueMarkers_)mark(frame,3);}+ void blitStart(uint64_t frame){if(eligible(frame))++presentId_;if(queueMarkers_)queueMark(frame,9);}+ void blitEnd(uint64_t frame){if(queueMarkers_)queueMark(frame,10);}+ void presentStart(uint64_t frame,bool generated){+ if(!eligible(frame))return;+ if(generated)queueMark(frame,11);+ else{if(!queueMarkers_)mark(frame,3);mark(frame,4);}+ }+ void presentEnd(uint64_t frame,bool generated){+ if(!eligible(frame))return;+ if(generated){queueMark(frame,12);if(active_)++generatedPresents_;}+ else{mark(frame,5);if(active_)++realPresents_;}+ }+private:+ bool eligible(uint64_t frame)const{return active_&&frame>=firstFrame_&&frame<=next_;}+ void fail(const char* op,int result){log::warn("reflex",std::format("{} status={}; low latency disabled",op,result));failed_=true;disable();}+ void queueMark(uint64_t frame,uint32_t type){+ if(!eligible(frame)||!queueMarkers_)return;+ // Matches NVIDIA Streamline sl.chi/d3d12.cpp::setLatencyMarker:+ // the public IUnknown target is the out-of-band command queue.+ MarkerParams p{};p.version=sizeof(p)|(1u<<16);p.frame=frame;p.type=type;+ const int r=api_.marker(queue_,&p);if(r)fail("queue-marker",r);else{++oobMarkers_;if(frame<firstFrame_+2)log::info("reflex-oob",std::format("source={} present={} type={} status=0",frame,presentId_,type));}+ }+ bool load(){+ if(initialized_)return true;+ // Keep NVAPI initialized/pinned through D3D12 device teardown. Unloading+ // it before the device has caused driver callbacks into unloaded code.+ wchar_t system[MAX_PATH]{};GetSystemDirectoryW(system,MAX_PATH);+ const std::wstring path=std::wstring(system)+L"\\nvapi64.dll";+ if(!module_)module_=LoadLibraryExW(path.c_str(),nullptr,LOAD_LIBRARY_SEARCH_SYSTEM32);+ HMODULE pinned=nullptr;+ if(module_)GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS|GET_MODULE_HANDLE_EX_FLAG_PIN,reinterpret_cast<LPCWSTR>(module_),&pinned);+ using Query=void*(__cdecl*)(uint32_t);using Init=int(__cdecl*)();+ auto query=module_?reinterpret_cast<Query>(GetProcAddress(module_,"nvapi_QueryInterface")):nullptr;if(!query)return false;+ auto init=reinterpret_cast<Init>(query(0x0150E828));+ api_={reinterpret_cast<Set>(query(0xac1ca9e0)),reinterpret_cast<Sleep>(query(0x852cd1d2)),reinterpret_cast<Marker>(query(0xd9984c05)),reinterpret_cast<Notify>(query(0x03d6e8cb))};+ if(!init)return false;const int r=init();initialized_=r==0;if(r)log::warn("reflex",std::format("initialize status={}",r));return initialized_;}- void mark(uint64_t frame,uint32_t type){if(!active_||!frame)return;MarkerParams p{};p.version=sizeof(p)|(1u<<16);p.frame=frame;p.type=type;const int r=marker_(device_,&p);if(r){log::warn("reflex",std::format("marker frame={} type={} status={}",frame,type,r));disable();}else ++markers_;}- uint64_t begin(){if(!active_)return 0;const int r=sleep_(device_);if(r){log::warn("reflex",std::format("sleep status={}",r));disable();return 0;}++sleeps_;const auto frame=++next_;mark(frame,0);mark(frame,1);mark(frame,2);return frame;}+ DriverApi api_{};HMODULE module_=nullptr;ID3D12Device* device_=nullptr;ID3D12CommandQueue* queue_=nullptr;+ bool initialized_=false,active_=false,driverEnabled_=false,boost_=false,generated_=false,queueMarkers_=false,failed_=false;+ uint64_t next_=0,firstFrame_=1,presentId_=0,sleeps_=0,markers_=0,oobMarkers_=0,realPresents_=0,generatedPresents_=0;};}diff --git a/include/veyra/ui/QmlPlayerBridge.h b/include/veyra/ui/QmlPlayerBridge.hindex 39273ffd..da37b493 100644--- a/include/veyra/ui/QmlPlayerBridge.h+++ b/include/veyra/ui/QmlPlayerBridge.h@@ -79,6 +79,8 @@ class QmlPlayerBridge : public QObject {Q_PROPERTY(QVariantList fgMultiplierChoices READ fgMultiplierChoices NOTIFY fgChoicesChanged)Q_PROPERTY(bool fgStrict READ fgStrict WRITE setFgStrict NOTIFY settingsChanged)Q_PROPERTY(bool fgLowQueue READ fgLowQueue WRITE setFgLowQueue NOTIFY settingsChanged)+ Q_PROPERTY(int nvidiaLowLatency READ nvidiaLowLatency WRITE setNvidiaLowLatency NOTIFY presentationChanged)+ Q_PROPERTY(bool nvidiaLowLatencyAvailable READ nvidiaLowLatencyAvailable NOTIFY effectCapabilitiesChanged)// --- colour settings ---------------------------------------------------Q_PROPERTY(double colorExposure READ colorExposure WRITE setColorExposure NOTIFY settingsChanged)@@ -664,6 +666,9 @@ public:bool fgStrict() const;void setFgStrict(bool value);bool fgLowQueue() const;+ int nvidiaLowLatency() const;+ void setNvidiaLowLatency(int value);+ bool nvidiaLowLatencyAvailable() const;void setFgLowQueue(bool value);double colorExposure() const;diff --git a/qml/Veyra/NodePage.qml b/qml/Veyra/NodePage.qmlindex 4bc2c9a0..d5d52c0c 100644--- a/qml/Veyra/NodePage.qml+++ b/qml/Veyra/NodePage.qml@@ -1659,9 +1659,11 @@ VPage {hint: qsTr("帧同步 · 默认关闭")VSwitch { checked: veyra.fgStrict; onToggled: checked => veyra.fgStrict = checked }}+ NvidiaLowLatencyEditor { namePrefix: "node" }VRow {+ visible: !veyra.nvidiaLowLatencyAvailablelabel: qsTr("低延迟队列")- hint: qsTr("只保留一帧在处理,未补帧时加 Reflex")+ hint: qsTr("减少处理排队")VSwitch { checked: veyra.fgLowQueue; onToggled: checked => veyra.fgLowQueue = checked }}}diff --git a/qml/Veyra/NvidiaLowLatencyEditor.qml b/qml/Veyra/NvidiaLowLatencyEditor.qmlnew file mode 100644index 00000000..1c150d96--- /dev/null+++ b/qml/Veyra/NvidiaLowLatencyEditor.qml@@ -0,0 +1,28 @@+import QtQuick+import QtQuick.Layouts+ColumnLayout {+ id: root+ property string namePrefix: "list"+ readonly property bool available: veyra.nvidiaLowLatencyAvailable === true+ Layout.fillWidth: true+ spacing: 4+ VRow {+ label: qsTr("英伟达低延迟")+ hintBelow: true+ hint: root.available ? qsTr("减少处理排队;增强档提高 GPU 频率,可能增加功耗。") : qsTr("需要 NVIDIA 显卡")+ VSeg {+ objectName: root.namePrefix+"-nvidia-low-latency"+ enabled: root.available+ opacity: enabled ? 1 : 0.4+ options: [{id:"0",label:qsTr("关")},{id:"1",label:qsTr("开")},{id:"2",label:qsTr("开+增强")}]+ current: String(veyra.nvidiaLowLatency ?? 0)+ onPicked: id => veyra.nvidiaLowLatency=Number(id)+ }+ }+ Text {+ Layout.fillWidth: true+ text: veyra.running ? veyra.presentationStatus : qsTr("打开视频后生效")+ color: Theme.t3; font.family: Theme.fontUi; font.pixelSize: 11+ wrapMode: Text.WordWrap+ }+}diff --git a/qml/Veyra/ProPage.qml b/qml/Veyra/ProPage.qmlindex eef7a9c3..6e702c4a 100644--- a/qml/Veyra/ProPage.qml+++ b/qml/Veyra/ProPage.qml@@ -1806,9 +1806,11 @@ VPage {}}}+ NvidiaLowLatencyEditor { namePrefix: "list" }VRow {+ visible: !veyra.nvidiaLowLatencyAvailablelabel: qsTr("低延迟队列")- hint: qsTr("只保留一帧在处理,未补帧时加 NVIDIA Reflex;垂直同步本身已不排队")+ hint: qsTr("减少处理排队")VSwitch {objectName: "list-low-queue"checked: veyra.fgLowQueuediff --git a/scripts/acceptance/nvidia-low-latency-ui.qml b/scripts/acceptance/nvidia-low-latency-ui.qmlnew file mode 100644index 00000000..5fc36375--- /dev/null+++ b/scripts/acceptance/nvidia-low-latency-ui.qml@@ -0,0 +1,72 @@+import QtQuick+Item {+ id: test+ property string media: ""+ property bool verifyOnly: false+ function find(name){let hit=null;const walk=x=>{if(hit)return;if(x.objectName===name){hit=x;return}for(const c of x.children)walk(c)};walk(test.parent.parent);return hit}+ Timer {+ interval:500;running:media.length>0;repeat:true+ property int step:0+ property int ticks:0+ property int total:0+ function next(n){step=n;ticks=0}+ function check(ok,label){if(!ok)throw new Error(label);veyra.logUi("nvidia-ll-test","PASS "+label)}+ function settled(){return ticks>=8&&veyra.running&&!veyra.applying}+ function finish(){veyra.logUi("nvidia-ll-test","NVIDIA_LL_UI_PASS");console.log("NVIDIA_LL_UI_PASS");Qt.quit()}+ onTriggered:{try{+ ++ticks;if(++total>180)throw new Error("bounded UI step="+step)+ if(step===0){+ if(ticks<4)return+ check(veyra.nvidiaLowLatencyAvailable,"NVIDIA device exposes the three-state control")+ if(test.verifyOnly){check(veyra.nvidiaLowLatency===2,"Boost choice restores after restart");finish();return}+ check(veyra.nvidiaLowLatency===1,"legacy lowQueue=true migrates to On, never Boost")+ veyra.muted=true;veyra.nrEnabled=false;veyra.srEnabled=false;veyra.fgEnabled=false+ veyra.openPath(test.media);next(1);return+ }+ if(step===1){+ if(!settled())return+ check(veyra.presentationStatus.includes("英伟达低延迟:开(已启用)"),"On is confirmed by the running native driver state")+ const c=find("list-nvidia-low-latency");check(c!==null,"list control exists")+ let p=c;while(p){if(p.tab!==undefined)p.tab="fg";p=p.parent}+ c.picked("2");next(2);return+ }+ if(step===2){+ if(!settled())return+ check(veyra.nvidiaLowLatency===2&&veyra.presentationStatus.includes("开+增强(已启用)"),"Boost changes the actual native mode")+ veyra.fgBackendName="vfg";veyra.fgMultiplier=2;veyra.fgEnabled=true;next(3);return+ }+ if(step===3){+ if(!settled())return+ check(veyra.fgActive&&veyra.presentationStatus.includes("开+增强(已启用)"),"Boost remains active with real VFG generation")+ const c=find("list-nvidia-low-latency");let p=c.parent+ while(p){if(p.contentY!==undefined&&p.contentItem){p.contentY=Math.max(0,Math.min(p.contentHeight-p.height,c.mapToItem(p.contentItem,0,0).y-30));break}p=p.parent}+ next(31);return+ }+ if(step===31){+ if(ticks<3)return+ test.parent.parent.grabToImage(r=>r.saveToFile("E:/项目/Veyra/tests/nvidia-low-latency-20261028/controls.png"))+ next(32);return+ }+ if(step===32){+ if(ticks<3)return+ find("list-nvidia-low-latency").picked("0");next(4);return+ }+ if(step===4){+ if(!settled())return+ check(veyra.nvidiaLowLatency===0&&veyra.fgActive&&veyra.presentationStatus.includes("英伟达低延迟:关"),"Off revokes native latency while retaining frame generation")+ veyra.nodeMode=1;check(veyra.addEffect("vfg-fg")>=0,"create frame-generation node for the node control");veyra.navigate("node");next(5);return+ }+ if(step===5){+ if(!settled())return+ check(find("node-nvidia-low-latency")!==null,"node control uses the same three states")+ find("node-nvidia-low-latency").picked("1");next(6);return+ }+ if(step===6){+ if(!settled())return+ check(veyra.nvidiaLowLatency===1&&veyra.presentationStatus.includes("英伟达低延迟:开(已启用)"),"node On applies the same global native setting")+ veyra.nvidiaLowLatency=2;next(7);return+ }+ if(step===7){if(!settled())return;check(veyra.nvidiaLowLatency===2,"save Boost for a separate restart check");finish()}+ }catch(e){veyra.logUi("nvidia-ll-test","NVIDIA_LL_UI_FAIL "+e.message);console.log("NVIDIA_LL_UI_FAIL "+e.message);Qt.quit()}}+ }+}diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cppindex ab664cb0..accc0150 100644--- a/src/engine/EngineController.cpp+++ b/src/engine/EngineController.cpp@@ -1337,8 +1337,9 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sif(revision==pacingRevision&&presenterGeneration==presenter.generation()&&!vrrChanged&&!capRefreshChanged){// Reflex dropped out at runtime: the queue-depth part of the// low-latency setting stays, so only the status line changes.- if(presentationEffective.enabled&&!presenter.reflexActive()&&presenter.reflexDisablePending()){- std::lock_guard lock(mutex_);snapshot_.presentationEffective=presentationEffective;snapshot_.presentationStatus=presenter.reflexDisablePending()?L"Reflex 调用及驱动撤销失败;请关闭视频后重试":L"Reflex 调用失败,当前使用低排队;详见日志";+ if(presentationEffective.nvidiaLowLatency!=NvidiaLowLatency::Off&&!presenter.reflexActive()&&presenter.reflexFailed()){+ presentationEffective.nvidiaLowLatency=NvidiaLowLatency::Off;+ std::lock_guard lock(mutex_);snapshot_.presentationEffective=presentationEffective;snapshot_.presentationStatus=presenter.reflexDisablePending()?L"英伟达低延迟调用及撤销失败;请关闭视频后重试":L"英伟达低延迟调用失败,当前使用低排队;详见日志";}if(presentationPaced&&!presenter.pacingActive()){// The sink already stopped waiting; reconfiguring would arm it again.@@ -1347,7 +1348,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s}return;}- if(isImage)requested.enabled=false;+ if(isImage){requested.enabled=false;requested.nvidiaLowLatency=NvidiaLowLatency::Off;}std::wstring message;presentationEffective=presenter.configurePresentation(ctx,requested,options.fg,message);presentationPaced=presenter.pacingActive()&&!legacyVsyncQueue;@@ -1798,6 +1799,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sif(xb)xb->videoReset();#endif}+ presenter.cancelReflexInput();if(audioStarted)audioPipe.setPaused(true);wasPaused=true;const bool referencesValid=hasOutput&&out.batch.count&&out.batch.frames[out.batch.count-1].lease&&out.batch.frames[out.batch.count-1].lease->referencesValid;if(hasOutput&&!presenter.present(ctx,ring,*graph,out.videoSlot,false,referencesValid,comparisonMode_,comparisonBase_,comparisonSplit_,out.batch.identity,previewView(),-1,true)){if(recoverXessPresentation())continue;status(L"画面呈现失败",true);break;}@@ -2344,6 +2346,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sbool processed=false;{processWaitBase=ring.cpuWaitCount();processWaitMsBase=ring.cpuWaitMilliseconds();processSubmitBase=ring.submitCount();processed=!injectedReject&&graph->process(frame,pts,historyReset,out,pkt.sequence,&pkt.colorInfo,&pkt.hardwareSurface,comparisonMode_!=0,admitFg,previewFgMultiplier,(paused_||isImage)&&transaction);+ presenter.endReflex(currentReflexFrame);processSlotWaitMs=ring.cpuWaitMilliseconds()-processWaitMsBase;}loopTrace.mark("graphSubmit");diff --git a/src/engine/VideoPresenter.cpp b/src/engine/VideoPresenter.cppindex 7ea1a13e..3e1c748f 100644--- a/src/engine/VideoPresenter.cpp+++ b/src/engine/VideoPresenter.cpp@@ -6,6 +6,7 @@#include "veyra/sink/ImageExportSink.h"namespace veyra::engine {bool VideoPresenter::beginSourceInput(){+ if(!reflexInputFrame_&&reflex_.active())reflexInputFrame_=reflex_.begin();auto* xess=sink_.xess();if(!xess)return true;// Waiting/filtered inputs keep the same preparation ID. Do not sleep again// until one accepted source has been submitted to the enhancement graph.@@ -123,7 +124,7 @@ bool VideoPresenter::prepareGraphChange(){// Retain metadataSent_: a new graph disabling metadata must clear the// hint that is still attached to the retained DXGI chain.metadataDirty_=true;metadataAttempt_={};sourceMetadata_={};- reflex_.close();reflexFrame_=0;+ reflex_.close();reflexFrame_=reflexInputFrame_=0;return true;}bool VideoPresenter::refresh(ID3D12Device* device){@@ -159,6 +160,7 @@ bool VideoPresenter::refresh(ID3D12Device* device){return true;}bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing& sharedRing,pipeline::EnhanceGraph& graph,unsigned slot,bool generated,bool referencesValid,int comparison,bool baseReference,float split,pipeline::FrameIdentity identity,PreviewView view,int64_t sourcePts100ns,bool retainUnchanged) {+ const auto reflexFrame=reflexFrame_;reflexFrame_=0;auto& ring=presentationQueue_?presentationRing_:sharedRing;auto* fence=presentationFence_?presentationFence_.Get():ctx.fence();const auto presentStart=std::chrono::steady_clock::now();@@ -242,6 +244,7 @@ bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing&if(FAILED(hr)){veyra::log::error("present",std::format("producer handoff wait hr=0x{:X}",unsigned(hr)));return false;}}Status st=Status::Ok;uint32_t commandSlot=0;auto* list=ring.acquireNext(commandSlot,st);if(!list)return false;+ reflex_.blitStart(reflexFrame);gpuTimer_.frame(identity.sourceFrameId?identity:pipeline::FrameIdentity{0,0,submittedCount()+1},fence);gpuTimer_.mark(list,diagnostics::GpuStage::Blit);uint32_t backBufferIndex=0;auto* source=generated?graph.generatedFrameResource(slot):graph.videoFrameResource(slot);auto* bb=sink_.currentBackBuffer(&backBufferIndex);if(!bb)return false;@@ -424,6 +427,7 @@ bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing&gpuTimer_.mark(list,diagnostics::GpuStage::Blit,true);gpuTimer_.resolve(list);if(!ring.submitAndSignal(commandSlot))return false;gpuTimer_.submitted(ring.lastSignaledValue());+ reflex_.blitEnd(reflexFrame);if(captureRecorded){captureRecorded=false;capture_->submitted(fence,ring.lastSignaledValue());}if(probeIssued){probePending_=true;probeFenceValue_=ring.lastSignaledValue();}// Custom: collect the previous probe as soon as the GPU reports it complete.@@ -432,9 +436,9 @@ bool VideoPresenter::present(gfx::D3D12DeviceContext& ctx,gfx::CommandSlotRing&publishLiveCoverage(hdrCurve,identity);lastBuffer_=backBufferIndex;hasPresented_=true;if(presentationQueue_)graph.presentationSubmitted(slot,fence,ring.lastSignaledValue());const auto dxgiStart=std::chrono::steady_clock::now();- reflex_.mark(reflexFrame_,3);reflex_.mark(reflexFrame_,4);+ reflex_.presentStart(reflexFrame,generated);const bool presented=sink_.present(st);- reflex_.mark(reflexFrame_,5);reflexFrame_=0;+ reflex_.presentEnd(reflexFrame,generated);const auto presentEnd=std::chrono::steady_clock::now();const auto ms=[](auto d){return std::chrono::duration<double,std::milli>(d).count();};const bool slow=ms(presentEnd-presentStart)>=80.0;@@ -500,7 +504,7 @@ void VideoPresenter::close(){refreshMonitor_=nullptr;refreshHz_=0;vrr_={};refreshQueried_=false;vrrSync_=false;displayStateSerial_=0;vrrConfirmAt_.reset();retainedFrame_.reset();xessInputId_=0;xessWork_={};xessWorkPosition_=0;- reflex_.close();reflexFrame_=0;+ reflex_.close();reflexFrame_=reflexInputFrame_=0;if(presentationRing_.initialized())presentationRing_.drainQueue();hasPresented_=false;gpuTimer_.close();compositeTarget_.Reset();copyBeforePresent_=copyEligible_=false;rtvs_.Reset();probeStats_.Reset();probeReadback_.Reset();probeCpuViews_.Reset();probePass_={};probePending_=false;probeFailed_=false;probeNext_={};probeCurve_={};probeIdentity_={};liveCoverage_={};pass_={};sink_.shutdown();@@ -551,6 +555,7 @@ double VideoPresenter::displayRefreshHz(){return refreshHz_;}PresentationSettings VideoPresenter::configurePresentation(gfx::D3D12DeviceContext& ctx,PresentationSettings requested,bool fg,std::wstring& status){+ if(requested.nvidiaLowLatency!=NvidiaLowLatency::Off)requested.enabled=true;bool wanted=requested.hdrFgCompatibility&©Eligible_;wchar_t copyOverride[4]{};if(GetEnvironmentVariableW(L"VEYRA_TEST_HDR_PRESENT_COPY",copyOverride,4)&©Override[1]==L'\0'){@@ -573,7 +578,7 @@ PresentationSettings VideoPresenter::configurePresentation(gfx::D3D12DeviceConteveyra::log::info("present-copy",std::format("requested={} eligible={} enabled={} (user preference; switch drains once)",requested.hdrFgCompatibility,copyEligible_,copyBeforePresent_));}}- const bool reflexDisabled=reflex_.disable();reflexFrame_=0;+ const bool reflexDisabled=reflex_.disable();reflexFrame_=reflexInputFrame_=0;const bool followDisplay=requested.outputRate==OutputRateMode::FollowDisplay;if(followDisplay){const double hz=displayRefreshHz();@@ -604,15 +609,16 @@ PresentationSettings VideoPresenter::configurePresentation(gfx::D3D12DeviceConteconst bool vsync=presentationVsync(requested),tearing=presentationTearing(requested);providerOwnedPresentation_=xessActive();const std::wstring sync=vrrSync_?(gfx::vrrLevel(vrr_)>=4?L"显示同步:自动 + 可变刷新 · 屏幕跟着画面刷新,不撕裂":L"显示同步:自动 + 可变刷新 · 已请求,等待驱动确认"):requested.display==DisplaySync::Automatic?L"显示同步:自动 · 不撕裂,也不等待垂直同步(延迟最低)":vsync?L"显示同步:垂直同步":L"显示同步:允许撕裂";- if(!reflexDisabled){effective.enabled=false;sink_.configurePacing(false,vsync,tearing);status=L"Reflex 驱动状态撤销失败;低延迟队列已停用 · "+sync;return effective;}+ if(!reflexDisabled){effective.enabled=false;effective.nvidiaLowLatency=NvidiaLowLatency::Off;sink_.configurePacing(false,vsync,tearing);status=L"英伟达低延迟撤销失败;请关闭视频后重试 · "+sync;return effective;}if(xessActive()){// The provider owns Present for its generated frames, so neither the// latency waiter nor an output cap can reach them. Only the DXGI VSync// bit still applies (XeSS accepts it on the proxy chain).effective.enabled=false;+ effective.nvidiaLowLatency=NvidiaLowLatency::Off;providerOwnedPresentation_=true;sink_.configurePacing(false,vsync,tearing);- status=L"XeSS 提供方自行调度:低延迟队列与输出上限不生效 · "+sync;+ status=L"XeSS 提供方自行调度:英伟达低延迟与输出上限不生效,选择已保留 · "+sync;return effective;}providerOwnedPresentation_=false;@@ -633,14 +639,15 @@ PresentationSettings VideoPresenter::configurePresentation(gfx::D3D12DeviceConteif(followDisplay)cap=std::format(L"输出上限:跟随显示器 {:.0f} Hz",requested.customFps);else if(requested.outputRate==OutputRateMode::Custom)cap=std::format(L"输出上限:{:.3f} FPS",requested.customFps);else cap=L"输出上限:关闭";- if(!requested.enabled){status=queue+sync;if(effective.outputRate==OutputRateMode::Custom)status+=L" · "+cap;status+=capNotice;return effective;}- // Low-latency queue: one source frame in flight (the next input is read- // after the previous one was presented), plus Reflex when frame generation- // is off (generated outputs would need separately validated markers).- std::wstring latency=L"低延迟队列:只保留一帧在处理";- if(fg)latency+=L"(补帧运行,Reflex 不启用)";- else if(reflex_.enable(ctx.device()))latency+=L" + NVIDIA Reflex(实验)";- else latency+=L"(Reflex 初始化失败)";+ if(!requested.enabled){status=(ctx.adapter().isNvidia?std::wstring(L"英伟达低延迟:关 · "):std::wstring())+queue+sync;if(effective.outputRate==OutputRateMode::Custom)status+=L" · "+cap;status+=capNotice;return effective;}+ // Source cadence owns Sleep. Generated/copy work on the presentation queue+ // carries out-of-band markers, never another source-frame Sleep.+ std::wstring latency=L"低延迟队列:已开启";+ if(requested.nvidiaLowLatency!=NvidiaLowLatency::Off){+ if(ctx.adapter().isNvidia&&reflex_.enable(ctx.device(),requested.nvidiaLowLatency==NvidiaLowLatency::Boost,fg,presentationQueue_.Get()))+ latency=requested.nvidiaLowLatency==NvidiaLowLatency::Boost?L"英伟达低延迟:开+增强(已启用)":L"英伟达低延迟:开(已启用)";+ else{effective.nvidiaLowLatency=NvidiaLowLatency::Off;latency=ctx.adapter().isNvidia?L"英伟达低延迟不可用,当前使用低排队;详见日志":L"英伟达低延迟需要 NVIDIA 显卡,当前使用低排队";}+ }status=latency+L" · "+cap+L" · "+queue+sync;return effective;}diff --git a/src/ui/PlayerUiFacade.cpp b/src/ui/PlayerUiFacade.cppindex cc20c93d..2d61ffc7 100644--- a/src/ui/PlayerUiFacade.cpp+++ b/src/ui/PlayerUiFacade.cpp@@ -46,6 +46,8 @@ bool sameNetwork(const veyra::media::NetworkStats& a, const veyra::media::Networ// makes the UI repaint.bool sameSnapshot(const veyra::engine::PlayerSnapshot& a, const veyra::engine::PlayerSnapshot& b) {return sameNetwork(a.network, b.network) &&+ a.presentationStatus==b.presentationStatus&&a.presentationEffective==b.presentationEffective&&+ a.presentationRevision==b.presentationRevision&&a.presentationProviderOwned==b.presentationProviderOwned&&a.transport == b.transport && a.sessionId == b.sessionId && a.position == b.position &&a.duration == b.duration && a.frames == b.frames && a.generated == b.generated &&a.status == b.status && a.savedFramePath == b.savedFramePath && a.backendWarning == b.backendWarning && a.sourceNotice == b.sourceNotice &&diff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cppindex 0a3af697..10d7fdc9 100644--- a/src/ui/QmlPlayerBridge.cpp+++ b/src/ui/QmlPlayerBridge.cpp@@ -287,6 +287,8 @@ QmlPlayerBridge::QmlPlayerBridge(engine::EngineController& engine, std::filesystpr.hdrFgCompatibility = impl_->prefBool("hdrFgCompatibility", false);if (!saved.isEmpty()) {pr.enabled = saved.value(QStringLiteral("lowQueue")).toBool();+ pr.nvidiaLowLatency=engine::savedNvidiaLowLatency(saved.value(QStringLiteral("nvidiaLowLatency"),pr.enabled&&primaryGpuVendor()==0x10de?1:0).toInt());+ if(pr.nvidiaLowLatency!=engine::NvidiaLowLatency::Off)pr.enabled=true;pr.display = static_cast<engine::DisplaySync>(std::clamp(saved.value(QStringLiteral("display")).toInt(), 0, 2));pr.outputRate = static_cast<engine::OutputRateMode>(std::clamp(saved.value(QStringLiteral("outputRate")).toInt(), 0, 2));pr.customFps = std::clamp(saved.value(QStringLiteral("customFps"), 60.0).toDouble(), 1.0, 1000.0);diff --git a/src/ui/bridge/FrameGeneration.cpp b/src/ui/bridge/FrameGeneration.cppindex f3e2fcd7..ce24bc3a 100644--- a/src/ui/bridge/FrameGeneration.cpp+++ b/src/ui/bridge/FrameGeneration.cpp@@ -163,8 +163,17 @@ bool QmlPlayerBridge::fgLowQueue() const { return impl_->presentation.enabled; }void QmlPlayerBridge::setFgLowQueue(bool value) {if (impl_->presentation.enabled == value) return;impl_->presentation.enabled = value;+ if(nvidiaLowLatencyAvailable())impl_->presentation.nvidiaLowLatency=value?engine::NvidiaLowLatency::On:engine::NvidiaLowLatency::Off;applyPresentation();}+int QmlPlayerBridge::nvidiaLowLatency()const{return int(impl_->presentation.nvidiaLowLatency);}+bool QmlPlayerBridge::nvidiaLowLatencyAvailable()const{return primaryGpuVendor()==0x10de;}+void QmlPlayerBridge::setNvidiaLowLatency(int value){+ if(value<0||value>2||(!nvidiaLowLatencyAvailable()&&value!=0))return;+ auto& p=impl_->presentation;+ if(int(p.nvidiaLowLatency)==value&&p.enabled==(value!=0))return;+ p.nvidiaLowLatency=engine::NvidiaLowLatency(value);p.enabled=value!=0;applyPresentation();+}// --- design gap A1-A5: flow, cadence, presentation ----------------------------int QmlPlayerBridge::hdrOutputMode()const{return int(settings().hdrOutputMode);}@@ -336,10 +345,10 @@ void QmlPlayerBridge::applyPresentation() {if (!p.valid()) return;impl_->engine.requestPresentation(p);impl_->prefs[QStringLiteral("presentation")] = QVariantMap{- {"lowQueue", p.enabled}, {"display", int(p.display)}, {"outputRate", int(p.outputRate)}, {"customFps", p.customFps}, {"vrr", p.variableRefresh}};+ {"lowQueue", p.enabled}, {"nvidiaLowLatency",int(p.nvidiaLowLatency)}, {"display", int(p.display)}, {"outputRate", int(p.outputRate)}, {"customFps", p.customFps}, {"vrr", p.variableRefresh}};if (!impl_->savePrefs()) veyra::log::warn("ui-prefs", "presentation settings not saved");- veyra::log::info("ui-presentation", std::format("lowQueue={} display={} outputRate={} customFps={:.3f} variableRefresh={}",- p.enabled, int(p.display), int(p.outputRate), p.customFps, p.variableRefresh));+ veyra::log::info("ui-presentation", std::format("lowQueue={} nvidiaLowLatency={} display={} outputRate={} customFps={:.3f} variableRefresh={}",+ p.enabled, int(p.nvidiaLowLatency), int(p.display), int(p.outputRate), p.customFps, p.variableRefresh));emit presentationChanged();emit settingsChanged();emit perfChanged();diff --git a/tests/integration/PresentationPacingTests.cpp b/tests/integration/PresentationPacingTests.cppindex dde510be..b484a475 100644--- a/tests/integration/PresentationPacingTests.cpp+++ b/tests/integration/PresentationPacingTests.cpp@@ -32,7 +32,7 @@ int wmain(int argc,wchar_t** argv){if(mode< -1||mode>2||display<0||display>2)return 2;const std::wstring scenario=argc>7?argv[7]:L"";const bool screen=scenario==L"screen-xess"||scenario==L"screen-dlss";- const bool xess=scenario==L"xess"||scenario==L"screen-xess";+ const bool xess=scenario==L"xess"||scenario==L"screen-xess"||scenario==L"native-xess";if(scenario==L"legacy"){if(mode!=-1)return 2;SetEnvironmentVariableW(L"VEYRA_TEST_LEGACY_SWAPCHAIN",L"1");}std::filesystem::path dir=argv[2];std::filesystem::create_directories(dir);SetEnvironmentVariableW(L"VEYRA_VERBOSE_FRAME_LOGS",screen?L"0":L"1");@@ -79,14 +79,18 @@ int wmain(int argc,wchar_t** argv){{EngineController engine;engine.setVolume(0,true);PresentationSettings p{mode>=0,PacingMode(std::max(0,mode)),DisplaySync(display)};engine.requestPresentation(p);+ const bool native=scenario.starts_with(L"native-");+ if(native){p.nvidiaLowLatency=mode<0?NvidiaLowLatency::Off:mode==2?NvidiaLowLatency::Boost:NvidiaLowLatency::On;engine.requestPresentation(p);}EnhancementSettings effects;effects.multiplier=unsigned(multiplier);if(xess)effects.frameGenerationBackend=FrameGenerationBackend::XeSS;- if(scenario==L"effects"){effects.nr=true;effects.sr=true;effects.srTarget=veyra::pipeline::SrTarget::Qhd;}+ if(scenario==L"native-vfg")effects.frameGenerationBackend=FrameGenerationBackend::Vfg;+ if(scenario==L"native-fsr")effects.frameGenerationBackend=FrameGenerationBackend::Fsr;+ if(scenario==L"effects"||scenario==L"native-effects"){effects.nr=true;effects.sr=true;effects.srTarget=veyra::pipeline::SrTarget::Qhd;}if(physical){effects.nr=true;effects.sr=false;}auto options=PlayerOptions::from(effects);options.captureReplayForTest=scenario==L"replay";engine.open(window,sourcePath,options);auto pump=[] {MSG msg;while(PeekMessageW(&msg,nullptr,0,0,PM_REMOVE)){TranslateMessage(&msg);DispatchMessageW(&msg);}};auto wait=[&](auto predicate,int ms=15000){auto end=Clock::now()+std::chrono::milliseconds(ms);while(Clock::now()<end){pump();auto s=engine.snapshot();if(s.failed)return false;if(predicate(s))return true;std::this_thread::sleep_for(std::chrono::milliseconds(2));}return false;};- check(wait([](auto& s){return s.frames>10;}),"first frames");+ check(wait([](auto& s){return s.frames>10;},scenario==L"native-effects"?30000:15000),"first frames");if(physical){const auto warm=Clock::now();check(wait([&](auto& s){return Clock::now()-warm>=std::chrono::seconds(10)&&s.nrActive&&s.fgActive;},20000),"ten second warmup with NR and DLSS active");}std::ofstream samples(dir/L"snapshots.csv");samples<<"wall,position,frames,generated,lateMs,queueReadyMs,presentMs,skipped,effective,mode,sync,revision\n";const auto start=Clock::now();auto last=engine.snapshot();const auto first=last;@@ -105,10 +109,9 @@ int wmain(int argc,wchar_t** argv){std::cout<<"mediaSpeed="<<speed<<" processedDelta="<<last.frames-first.frames<<std::endl;check(!last.failed&&last.frames>first.frames+10&&speed>.8&&speed<1.2,"sustained playback at media speed");if(multiplier>1)check(last.fgActive&&last.generated>first.generated,"real provider generated frames during measurement");- if(scenario==L"effects")check(last.nrActive&&last.srActive&&last.nrEvaluated>first.nrEvaluated,"NR and SR remain active with pacing");+ if(scenario==L"effects"||scenario==L"native-effects")check(last.nrActive&&last.srActive&&last.nrEvaluated>first.nrEvaluated,"NR and SR remain active with pacing");if(mode>=0&&!xess)check(last.presentationEffective.enabled,"optional pacing active");- if(mode==2&&multiplier==1)check(last.presentationEffective.mode==PacingMode::Reflex,"native Reflex active");- if(mode==2&&multiplier>1&&!xess)check(last.presentationEffective.mode==PacingMode::LowQueue,"Reflex with FG explicitly falls back to low queue");+ if(native&&mode>=0&&!xess)check(last.presentationEffective.nvidiaLowLatency==p.nvidiaLowLatency,"requested native NVIDIA low latency mode actually active with or without FG");if(mode>=0&&xess)check(!last.presentationEffective.enabled&&last.fgActive,"provider remains pacing owner");if(screen){for(unsigned cycle=0;cycle<3;++cycle){@@ -129,6 +132,24 @@ int wmain(int argc,wchar_t** argv){SetWindowPos(window,nullptr,30,30,960,600,SWP_NOZORDER);p.enabled=false;engine.requestPresentation(p);check(wait([](auto& s){return !s.presentationEffective.enabled;}),"off after resize");const auto before=engine.snapshot().frames;check(wait([&](auto& s){return s.frames>before+10;}),"off keeps playing");}+ if(scenario==L"native-lifecycle"){+ const auto beforePause=engine.snapshot().frames;+ engine.pause(true);check(wait([](auto& s){return s.transport==TransportState::Paused;}),"pause with Boost retained");+ Sleep(150);engine.pause(false);check(wait([&](auto& s){return s.frames>beforePause+8&&s.presentationEffective.nvidiaLowLatency==NvidiaLowLatency::Boost;}),"resume native Boost without a stale prepared input");+ engine.pause(true);check(wait([](auto& s){return s.transport==TransportState::Paused;}),"native pause");+ p.enabled=false;p.nvidiaLowLatency=NvidiaLowLatency::Off;engine.requestPresentation(p);+ check(wait([](auto& s){return s.presentationEffective.nvidiaLowLatency==NvidiaLowLatency::Off&&!s.presentationEffective.enabled;}),"disable native latency and Boost while paused");+ engine.seek(5);const auto seek=engine.snapshot().seekRequested;check(wait([&](auto& s){return s.seekPresented>=seek;}),"native paused seek");+ engine.pause(false);check(wait([](auto& s){return s.position>5.3;}),"native resume");+ for(auto setting:{NvidiaLowLatency::On,NvidiaLowLatency::Boost,NvidiaLowLatency::Off,NvidiaLowLatency::Boost}){+ const auto before=engine.snapshot().frames;p.enabled=setting!=NvidiaLowLatency::Off;p.nvidiaLowLatency=setting;engine.requestPresentation(p);+ check(wait([&](auto& s){return s.frames>before+12&&s.presentationEffective.nvidiaLowLatency==setting;}),"native live mode transition retains playback");+ }+ SetWindowPos(window,nullptr,30,30,960,600,SWP_NOZORDER);+ const auto before=engine.snapshot().frames;check(wait([&](auto& s){return s.frames>before+20&&s.presentationEffective.nvidiaLowLatency==NvidiaLowLatency::Boost;}),"native Boost survives resize");+ const auto session=engine.snapshot().sessionId;engine.open(window,sourcePath,options);+ check(wait([&](auto& s){return s.sessionId!=session&&s.frames>12&&s.presentationEffective.nvidiaLowLatency==NvidiaLowLatency::Boost;}),"source replacement restores requested Boost on the new device");+ }if(scenario==L"overload"){SetEnvironmentVariableW(L"VEYRA_TEST_VIDEO_WORK_MS",L"80");auto before=engine.snapshot();const auto begin=Clock::now();diff --git a/tests/unit/NvidiaLowLatencyTests.h b/tests/unit/NvidiaLowLatencyTests.hnew file mode 100644index 00000000..bad3b966--- /dev/null+++ b/tests/unit/NvidiaLowLatencyTests.h@@ -0,0 +1,45 @@+#pragma once+#include "veyra/gfx/ReflexSession.h"+#include <vector>+namespace nvidia_latency_test {+using R=veyra::gfx::ReflexSession;+struct Event {uint64_t frame;uint32_t type;uint64_t present;bool async;};+inline std::vector<R::SleepParams> modes;+inline std::vector<Event> events;+inline int sleeps=0;inline bool failSleep=false,failQueue=false,failDisable=false;+inline int __cdecl set(IUnknown*,R::SleepParams* p){if(!p->low&&failDisable)return -1;modes.push_back(*p);return 0;}+inline int __cdecl sleep(IUnknown*){++sleeps;return failSleep?-1:0;}+inline int __cdecl marker(IUnknown* target,R::MarkerParams* p){const bool queue=target==reinterpret_cast<IUnknown*>(uintptr_t(2));events.push_back({p->frame,p->type,0,queue});return queue&&failQueue?-1:0;}+inline int __cdecl notify(ID3D12CommandQueue*,uint32_t type){return type==3?0:-1;}+template<class Check>void run(Check check){+ using namespace veyra::engine;+ PresentationSettings p;check(p.valid()&&p.nvidiaLowLatency==NvidiaLowLatency::Off,"NVIDIA low latency defaults off");+ p.nvidiaLowLatency=NvidiaLowLatency(3);check(!p.valid(),"invalid NVIDIA low latency mode rejected");+ check(savedNvidiaLowLatency(-1)==NvidiaLowLatency::Off&&savedNvidiaLowLatency(99)==NvidiaLowLatency::Off&&savedNvidiaLowLatency(2)==NvidiaLowLatency::Boost,"invalid saved mode falls back to off rather than accidentally enabling Boost");+ modes.clear();events.clear();sleeps=0;failSleep=failQueue=failDisable=false;+ auto* device=reinterpret_cast<ID3D12Device*>(uintptr_t(1));auto* queue=reinterpret_cast<ID3D12CommandQueue*>(uintptr_t(2));+ R r({set,sleep,marker,notify});+ check(r.begin()==0&&modes.empty()&&events.empty(),"off makes no driver calls");+ check(r.enable(device)&&modes.back().low&&!modes.back().boost&&!modes.back().interval,"on requests native low latency without Boost or frame cap");+ const auto id=r.begin();check(id&&events.size()==1&&events[0].type==0,"input starts with simulation marker only");+ r.renderStart(id);r.renderEnd(id);r.blitStart(id);r.blitEnd(id);r.presentStart(id,false);r.presentEnd(id,false);+ check(events.size()==6&&events[1].type==1&&events[2].type==2&&events[3].type==3&&events[4].type==4&&events[5].type==5,"legacy driver source markers follow actual processing and Present boundaries");+ check(r.enable(device,true,true,queue)&&modes.back().boost&&r.boost(),"Boost plus FG enables native Boost and out-of-band queue tracking");+ const auto next=r.begin();r.renderStart(next);r.renderEnd(next);+ for(unsigned i=0;i<5;++i){r.blitStart(next);r.blitEnd(next);r.presentStart(next,true);r.presentEnd(next,true);}+ r.blitStart(next);r.blitEnd(next);r.presentStart(next,false);r.presentEnd(next,false);+ check(sleeps==2&&r.sleepCount()==1&&r.generatedPresents()==5,"6X presentation sleeps once for the source, never for five generated frames");+ bool valid=true;unsigned generated=0;+ for(const auto& e:events)if(e.async){if(e.present||e.frame!=next)valid=false;if(e.type==11)++generated;}+ check(valid&&generated==5,"out-of-band markers retain source ID and leave driver-internal Present fields zero");+ check(r.disable()&&!r.active()&&!modes.back().low&&!modes.back().boost,"off revokes low latency and Boost together");+ const auto count=events.size();r.presentStart(next,true);r.begin();check(events.size()==count&&sleeps==2,"disabled mode stops periodic Sleep and markers");+ check(r.enable(device,false,true,queue),"re-enable after off");const auto stale=events.size();r.mark(next,4);check(events.size()==stale,"stale in-flight marker IDs ignored after a mode change");+ failSleep=true;check(r.begin()==0&&!r.active()&&r.failed()&&!r.disablePending(),"Sleep failure disables driver mode and reports fallback");failSleep=false;+ check(r.enable(device,true,true,queue),"retry native mode after failure");const auto failed=r.begin();failQueue=true;r.blitStart(failed);check(!r.active()&&r.failed(),"out-of-band marker failure stops native mode");failQueue=false;+ check(r.enable(device),"enable before disable failure");failDisable=true;+ check(!r.disable()&&r.disablePending()&&!r.enable(device,true),"failed disable is not reported as off or re-enabled over pending state");+ failDisable=false;check(r.disable()&&!r.disablePending(),"failed disable can be retried cleanly");+ R old({set,sleep,marker,nullptr});check(!old.enable(device,false,true,queue)&&!old.active(),"FG does not masquerade as enabled on a driver without out-of-band queue notification");+}+}diff --git a/tests/unit/RepairContractTests.cpp b/tests/unit/RepairContractTests.cppindex 1bb1e627..6d4b1d77 100644--- a/tests/unit/RepairContractTests.cpp+++ b/tests/unit/RepairContractTests.cpp@@ -38,9 +38,11 @@ int thunkReplacementFunction(int value) { ++thunkHookCalls; return thunkOriginal#include "veyra/engine/PresentationSettings.h"#include "veyra/engine/PresentationGeometry.h"#include "veyra/gfx/NvidiaVrr.h"+#include "NvidiaLowLatencyTests.h"int main(){using namespace veyra;int failures=0,checks=0;auto check=[&](bool ok,const char* name){++checks;if(!ok)++failures;std::cout<<(ok?"PASS ":"FAIL ")<<name<<'\n';};+ nvidia_latency_test::run(check);{gfx::VrrState state;state.known=state.capsKnown=true;state.supportsVrr=state.currentlyCapable=true;