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

latency-min: FG output hint instead of reduction; 可变刷新 switch

Veyra Goal Agente550f966117c
diff --git a/AGENTS.md b/AGENTS.md
index 222cdf9a..c7b6bd1d 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -4,7 +4,7 @@
> **2026-10-12 用户确认 Claude 内容节奏修复实机通过并授权合并重打 2.0.7**:从 main05bc4b5 隔离合入 claude/cadence-exact-20261012(60a93f3、8d11cad),按 docs/TEST_2.0.7_REFRESH_2026-10-12.md 重新构建、定向回归、本地 main 合并与 NVIDIA/AMD 完整测试包;显示2.0.7-test-r2。保护68旧树/509脏文件及已交付原包,全部研发产物在E盘新任务目录。不改用户正在运行的播放器/配置、UI频率/默认GPU优先级/运行库/模型,无新push/Release/关机或子Agent授权。
-> **2026-10-13/14 极限低延迟(Claude)**:用户要求把显示同步“自动”恢复成游戏同款(不撕裂、不等垂直同步)、“延迟必须要做到极限的低!但不要允许撕裂”,随后“全部做掉!”授权 docs/LATENCY_MIN_PLAN_2026-10-13.md 的 B1–C3。存档 `checkpoint/pre-claude-latency-min-20261013`(main 7571919),分支 `claude/latency-min-20261013`,产物 `{用途}/claude-latency-min-20261013`。已完成:A1/A2 “自动”=`Present(0,0)`+诊断(c1dd0a2);B2 直播补帧输出预算(降到屏幕显示得下的倍数,源占满屏幕时旁路,垂直同步放不下也旁路;f9e6dfc);B3 只有显式垂直同步节流,启用时重置可等待对象、读帧前取容量,自动/撕裂永不等待,“低延迟队列”=一帧在处理+Reflex(ada49ff);B1 XeSS 提交即送显、XeLL 周期对齐(3c2d6ca);C1 NVIDIA VRR 状态检测与状态栏(dca66de、0676c78);C2 实测全屏且控制条隐藏少一个刷新;C3 采集拷贝研究,多线程无效、零拷贝不实施(8182472)。每项有测试开关可退回旧行为。采集卡 10-14 凌晨离线,B1/B3 的采集卡+NR 实测与 PBP 60Hz 光学复测待用户;第二版测试包 tests/claude-latency-min-20261013/Veyra-2.0.7-test-latency-r2-NVIDIA。不改运行库/模型/驱动/用户配置;无 merge/push/Release/子 Agent;测试≤300秒、构建≤900秒。
+> **2026-10-13/14 极限低延迟(Claude)**:用户要求把显示同步“自动”恢复成游戏同款(不撕裂、不等垂直同步)、“延迟必须要做到极限的低!但不要允许撕裂”,随后“全部做掉!”授权 docs/LATENCY_MIN_PLAN_2026-10-13.md 的 B1–C3。存档 `checkpoint/pre-claude-latency-min-20261013`(main 7571919),分支 `claude/latency-min-20261013`,产物 `{用途}/claude-latency-min-20261013`。已完成:A1/A2 “自动”=`Present(0,0)`+诊断(c1dd0a2);B3 只有显式垂直同步节流,启用时重置可等待对象、读帧前取容量,自动/撕裂永不等待,“低延迟队列”=一帧在处理+Reflex(ada49ff);B1 XeSS 提交即送显、XeLL 周期对齐(3c2d6ca);C2 实测全屏且控制条隐藏少一个刷新;C3 采集拷贝研究,多线程无效、零拷贝不实施(8182472)。10-14 用户改动:B2 不再自动降倍数/旁路,改为状态栏与“倍率”下方提示“当前帧率超出屏幕刷新率,建议降至…”;C1 改为“显示”里的“可变刷新”开关(屏幕不支持时灰,开且可用时按 G-SYNC/FreeSync + V-SYNC 呈现,不用撕裂标志);修正垂直同步送显→上屏测量(统计落后时旧帧被算成约 19ms)。T911 10-14 上午恢复,B1/B3 实卡已验证;本机 320Hz 屏驱动报告不支持 VRR,真实 VRR 与 PBP 60Hz 光学复测待用户;测试包 tests/claude-latency-min-20261013/Veyra-2.0.7-test-latency-r3-NVIDIA。不改运行库/模型/驱动/用户配置;无 merge/push/Release/子 Agent;测试≤300秒、构建≤900秒。
> **2026-10-12 内容节奏修正(Claude)**:用户实测 2.0.7:“采集 60→30”被植入内容节奏判断、原始帧率跳动,要求还原为最简单的 60 帧 AABBCCDD→ABCD 稳定隔帧;新“自动识别内容节奏”去重不稳定(VFG 耗时、GPU 占用忽高忽低),游戏运行中出现 6fps,怀疑不是百分百相同的帧也被去掉。追加授权关闭用户正在运行的 Veyra、直接用 T911 实卡(2K60 NV12、游戏 30 帧)测试。存档 `checkpoint/pre-claude-cadence-exact-20261012`(main 05bc4b5)与 `archives/claude-cadence-exact-20261012`,分支 `claude/cadence-exact-20261012`。60→30 恢复 `CaptureHalfRate`(与 85cbd5a 之前相同、不经去重);内容模式整画面逐像素与上一张新画面比较,每个分量都在 ±3 级(8 位刻度)以内才算重复(`PictureCompare.h`,采集回调只在去重开启时比较驱动样本并给帧编画面号);逐字节相同在实卡上从不成立(T911 重复帧 ±1–2 级噪声),该版本已被实卡数据否决。见 docs/CONTENT_CADENCE_EXACT_2026-10-12.md。不改默认设置、NR/SR/FG 模型、运行库;用户设置只读取并复制进测试包;无 merge/push/Release/子 Agent。
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md
index 3a5e3a4a..802ae489 100644
--- a/THIRD_PARTY_NOTICES.md
+++ b/THIRD_PARTY_NOTICES.md
@@ -619,11 +619,13 @@ and presentation, not game input or physical display latency. Generated-frame
Reflex integration is not enabled; DLSS retains its selected multiplier.
`include/veyra/gfx/NvidiaVrr.h` (2026-10-14) adds, from the same interface
-files, the QueryInterface IDs of NvAPI_DISP_GetDisplayIdByDisplayName and
-NvAPI_Disp_GetVRRInfo and a renamed NV_GET_VRR_INFO_V1 layout (checked against
-the local unmodified copy used for the pacing work). It only reads the
-monitor's variable-refresh state for diagnostics; the driver setting is never
-changed. Same loading rules and the same license as above.
+files, the QueryInterface IDs of NvAPI_DISP_GetDisplayIdByDisplayName,
+NvAPI_Disp_GetVRRInfo and NvAPI_DISP_GetMonitorCapabilities and renamed
+NV_GET_VRR_INFO_V1 and NV_MONITOR_CAPABILITIES_V1 (generic capability bits)
+layouts (checked against the commit above). It only reads the monitor's
+variable-refresh support and state, for diagnostics and to enable the 可变刷新
+switch; the driver setting is never changed. Same loading rules and the same
+license as above.
Copyright (c) 2019-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
diff --git a/apps/veyra/ui/LiveStatusHistory.h b/apps/veyra/ui/LiveStatusHistory.h
index 6bf7e7b0..d8b85c19 100644
--- a/apps/veyra/ui/LiveStatusHistory.h
+++ b/apps/veyra/ui/LiveStatusHistory.h
@@ -42,12 +42,6 @@ inline OutputRateAssessment assessOutputRate(const engine::PlayerSnapshot& s,con
result.comparison=context.comparison&&s.applied.multiplier>1;
result.requestedFps=result.contentFps*(result.comparison?1u:s.applied.multiplier);
result.targetFps=result.requestedFps;
- // Live output budget: the engine generates only what the panel can show
- // (1 = generation bypassed), so that is the target, not a shortfall.
- if(!result.comparison&&s.displayFgLimited&&s.displayFgMultiplier>=1){
- result.displayLimited=true;
- result.targetFps=std::min(result.targetFps,result.contentFps*s.displayFgMultiplier);
- }
const auto& effective=s.presentationEffective;
if(effective.outputRate==engine::OutputRateMode::Custom&&effective.customFps>0&&std::isfinite(effective.customFps)){
result.outputLimited=effective.customFps<result.targetFps*.99;
diff --git a/docs/LATENCY_MIN_PLAN_2026-10-13.md b/docs/LATENCY_MIN_PLAN_2026-10-13.md
index 5ee3ab72..b9b06498 100644
--- a/docs/LATENCY_MIN_PLAN_2026-10-13.md
+++ b/docs/LATENCY_MIN_PLAN_2026-10-13.md
@@ -26,9 +26,9 @@
| **A1 “自动”恢复**(本次授权,已实施) | `presentationVsync()` 只对“垂直同步”返回 true;“自动”=`Present(0,0)`,原生和 XeSS 两条路径都生效;状态栏与设置提示改写;“垂直同步”“允许撕裂”不变 | 输出超过刷新率时不再排队(原生实测 7 帧→约 1 帧);不受限时延迟不变 | 320Hz DLSS 6X 场景送显→上屏回到约 2–5ms;2X/4X、XeSS 2X、仅 NR 不变;Present 参数日志 sync=0 flags=0;60Hz PBP 由用户光学复测 |
| **A2 诊断**(随 A1) | 每秒记录 presentsAhead(GetLastPresentCount−已显示 PresentCount);“自动”模式也统计送显→上屏(只按确认上屏的那一帧) | 以后的日志能直接看出是否排队 | 日志字段存在且数值合理 |
| **B1 XeSS“提交即送显”**(已实施) | XeSS 时读帧→处理→立即打标签并 Present,不再由调度器等 GPU 完成后才送;一个 XeLL 周期内完成 睡眠→读输入→提交→送显;XeSS 也遵守“GPU 未完成不读下一帧” | 去掉 CPU 等 GPU 的时间和轮询抖动;XeLL 周期对齐 | 屏幕采集 XeSS 2X:周期错位 922/960→0,回调→送显 P95 3.8→3.0ms;采集卡+NR 实测待设备上线 |
-| **B2 补帧输出预算**(已实施) | 内容帧率×倍数 > 1.02×刷新率时:DLSS/FSR/VFG 自动降到能放下的最大合法倍数;放不下但源比屏幕慢(60fps@100Hz)保留 2X(仍多出画面);源已占满屏幕(≥0.97×刷新,如 60Hz 屏 + 60fps 源)旁路补帧,真帧直接显示、不等插帧;XeSS 只做 SetEnabled(false) 旁路;新决定持续 1.5 秒才生效,状态栏说明原因 | 不浪费 GPU、动作均匀;60Hz+60fps 时延迟等于仅 NR | 实测:DLSS 6X@320Hz→4X,送显→上屏 6.2/8.0→5.0/6.9ms,垂直同步 12.2/18.4→5.7/8.5ms;模拟 60Hz 旁路回调→送显 8.8ms=仅 NR;30fps+2X@60Hz 保持 2X |
+| **B2 补帧输出预算 → 提示**(10-14 用户改为只提示) | 原实施:放不下自动降倍数/源占满屏幕时旁路。用户决定“不要自动降档,做一个提示”:倍数保持用户选择,状态栏与“倍率”下方提示“当前帧率 N fps 超出屏幕刷新率 M Hz,建议降至 KX(或关闭补帧)来获得更好的延迟体验”;规则同原预算(XeSS 也可建议 2–4X),持续 1.5 秒才更新 | 用户自己选择延迟与流畅的取舍 | 实卡:DLSS 6X@320Hz 保持 6X(289 次/秒),提示建议 4X,送显→上屏 4.9/8.9ms(降到 4X 为 5.0/6.9ms);XeSS 模拟 60Hz 提示关闭补帧、XeSS 仍 120/s |
| **B3 “垂直同步”也不排队**(已实施) | 只有显式垂直同步节流:启用时清掉可等待对象积累的计数并放行一帧;直播未补帧时在读采集帧之前取得屏幕容量,每次送显前也取得容量(插帧最多等 ≤2ms 否则让给下一帧);自动/撕裂永不等待;“低延迟队列”=只保留一帧在处理 + 未补帧时 Reflex;XeSS 代理不设最大延迟(Intel:XeLL 以外的延迟手段不受支持) | 垂直同步模式下的排队上限 1 帧 | 回放 6X 超刷新:送显→上屏 18.4→5.8ms;探针源快 5%:7.3→2.5 个刷新;常规配置无回退;采集卡实测待设备上线 |
-| **C1 VRR 研究**(检测已实施) | 用户在驱动开启 G-SYNC/FreeSync 后,实测“自动”是否触发可变刷新;若不触发,评估“垂直同步 + B2 输出预算(输出始终低于最高刷新)”的 VRR 模式(不会撕裂) | 少等 0–1 个刷新(60Hz 平均约 8ms) | 已加 NVAPI 状态检测、日志与状态栏;本机显示器 possible=false 无法实测,需用户在支持的屏幕上开启后对比 |
+| **C1 可变刷新开关**(10-14 实施) | “显示”里加“可变刷新”开关,屏幕不支持(NVAPI 显示器能力 supportVRR=0)时变灰;开且 VRR 可用、显示同步为“自动”时按 G-SYNC/FreeSync + V-SYNC 呈现(B3 一帧队列,不用撕裂标志);状态显示生效与否及原因 | 可变刷新范围内少等 0–1 个刷新(60Hz 平均约 8ms) | 本机屏不支持(开关灰);`VEYRA_TEST_VRR_LEVEL` 模拟验证配置与界面;真实 VRR 需用户在支持的屏幕上验证 |
| **C2 独立翻转确认**(已实测) | 不用管理员:按送显→上屏判断呈现方式 | 明确“全屏更低”的条件 | 真实程序:窗口 4.79ms,全屏且控制条隐藏 1.94ms(独立翻转,少 1 个刷新),控制条显示时 5.17ms(回到合成) |
| **C3 采集拷贝**(研究,未实施) | 回调拷贝已是唯一一次 CPU 拷贝(写入上传缓冲) | 4K NV12 约 1.2–2.1ms(用户日志) | 多线程拷贝无效(单线程已达带宽上限 19–20GB/s);零拷贝需自建分配器,驱动相关且采集卡离线无法验证,记录为后续选项 |
@@ -41,7 +41,7 @@
| 场景 | 关效果 | 仅 NR | NR+2X |
|---|---|---|---|
| 320Hz 日常 | ≈20ms | ≈27ms | ≈37–42ms |
-| 60Hz PBP,60fps 源 | 33ms(实测,相位决定) | ≈33–50ms | A1 后≈45–55ms;B2 后=仅 NR |
+| 60Hz PBP,60fps 源 | 33ms(实测,相位决定) | ≈33–50ms | A1 后≈45–55ms;按提示关闭补帧后=仅 NR |
| 60Hz PBP,30fps 源 | ≈33ms | ≈33–50ms | ≈50–60ms |
60Hz 下处理时间会被刷新量化(同一处理可能落在原本要等的空档里,也可能错过一个刷新)。320Hz 行为推算,最终以用户光学测量为准。
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 39aba417..d787d916 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -9395,3 +9395,17 @@ v2.0.7 ID 410800361,published_at 2026-10-12T16:24:59Z,latest/非草稿/非
C2(无需管理员):DXGI 的 GetFrameStatisticsMedia 在这些交换链上不可用(产品日志 compositionMode=-1),改用“送显→上屏”直接判断。探针 `tmp/claude-latency-min-20261013/dxgi_mode_probe.cpp`(320Hz,源略低于刷新):小弹窗与 1280×720 普通窗口都是约 1.5 个刷新(4.8ms,DWM 合成),无边框全屏约 0.6 个刷新(1.9ms,独立翻转;此时 DXGI 不给刷新计数)。真实程序 `run_app_mode.py`(60fps 文件、无效果、自动):窗口 P50/P95 4.79/5.98ms,全屏且控制条隐藏 1.94/3.24ms,全屏但控制条显示 5.17/6.26ms(控制窗口盖在画面上,回到合成)。结论:全屏且控制条自动隐藏(鼠标静止约 1.6 秒)时少一个刷新,320Hz 约 3ms,60Hz 约 17ms。
C3:采集回调的拷贝已经是唯一一次 CPU 拷贝(邮箱帧就是 D3D12 上传缓冲)。实卡 2K NV12(5.5MB)每帧 0.26–0.31ms;用户 4K 测试日志 4K NV12(12.4MB)1.2–2.1ms、24.9MB 样本 3.8–5.6ms。探针 `upload_copy_probe.cpp`:单线程写入上传缓冲已达 19–20GB/s(4K NV12 冷数据 0.64ms),2–4 线程无改善(内存/写合并带宽受限),因此不做多线程拷贝。彻底去掉这次拷贝需要自建 DirectShow 分配器,把 GPU 可见的缓冲(可用 OpenExistingHeapFromAddress 打开的带缓存系统内存,避免去重比较读写合并内存过慢)交给驱动、样本持有到 GPU 拷贝完成;属于各驱动行为不同的大改动,采集卡离线无法验证,本轮不实施,作为后续选项记录。
+
+## 2026-10-14 极限低延迟:补帧改为提示、可变刷新开关、垂直同步测量修正(Claude)
+
+用户决定:“不要自动降档,做一个提示好了,当前帧率超出屏幕刷新率,建议降至xxx来获得更好的延迟体验”;“可变刷新率做成开关,在显示里面可以开启,如果屏幕不支持显示灰色”。
+
+补帧提示:B2 的自动降倍数与旁路全部撤回(EnhanceGraph 回到 main 版本;读帧门、配对延迟、准入、节奏回到按用户倍数)。`DisplayFgBudget.h` 只算建议 `displayFgSuggestion`:输出放得下不提示;源已占满屏幕(≥0.97×刷新,如 60Hz 屏 + 60fps 源)建议关闭补帧;否则建议放得下的最大可选倍数(DLSS 2/3/4/6、XeSS 2–4、VFG 2–8、FSR 只有 2X);都放不下且源比屏幕慢时,自动模式只在请求高于 2X 时建议 2X,垂直同步建议关闭。新建议持续 1.5 秒才显示,只对直播、非撕裂。状态栏与补帧“倍率”下方(专业页、节点页,黄色)显示“当前帧率 N fps 超出屏幕刷新率 M Hz,建议降至 KX 来获得更好的延迟体验”或“……建议关闭补帧……”。日志 `display-fg-hint`。去掉 `VEYRA_TEST_NO_DISPLAY_FG_BUDGET`(已无行为可对比),保留 `VEYRA_TEST_DISPLAY_HZ`。
+
+可变刷新开关:`NvidiaVrr.h` 增加 NvAPI_DISP_GetMonitorCapabilities(supportVRR / currentlyCapableOfVRR / isTrueGsync),统一等级 `gfx::vrrLevel`:0 无法检测(非 NVIDIA)、1 屏幕不支持(开关变灰)、2 支持但当前不可用(驱动未开等)、3 可用、4 生效中。`PresentationSettings.variableRefresh` 随显示设置保存(prefs `presentation.vrr`)。开关开、等级≥3 且显示同步为“自动”时,呈现按显式垂直同步走:G-SYNC/FreeSync + V-SYNC,沿用 B3 一帧队列;可变刷新范围内屏幕随帧刷新,等待约为 0,不撕裂;Microsoft 文档的撕裂标志方案只留给“允许撕裂”。显示器与驱动状态每 2 秒重读,变化即重配(NVAPI 调用移到快照锁外)。专业页“显示”和节点页输出框加开关与说明(按等级给出原因与操作)。本机 320Hz 屏驱动报告 supportVRR=0,开关为灰;`VEYRA_TEST_VRR_LEVEL=0..4` 可模拟。真实 VRR 是否生效需在支持的屏幕上由用户验证。
+
+测量修正:垂直同步时 `PresentSink::sampleDisplayLatency` 用“每帧至少占一个刷新”的上界给统计落后的旧帧定时。60fps@320Hz 统计晚一帧时,5ms 上屏的帧被算成约 19ms(晚两帧约 31ms)。现在只对连发(相邻送显不超过 1.25 个刷新)的旧帧使用该上界,否则跳过。补帧超刷新时的连发仍计入。
+
+实卡(T911 恢复在线,2K60 NV12 → NR,320Hz):DLSS 6X 不再自动降:289 次/秒送显,提示“建议降至 4X”,送显→上屏 4.9/8.9ms(降到 4X 时为 5.0/6.9ms)。仅 NR:显式垂直同步 4.98/6.42ms(修正后),自动 4.87/6.18ms,回调→送显 P95 9.1 / 9.3ms,即 B3 在 60fps 源下不增加延迟。修正前同一垂直同步 P95 19.3ms,旧队列(`VEYRA_TEST_LEGACY_VSYNC_QUEUE=1`)同样有 19ms 尖刺,确认是测量问题。XeSS 2X+NR(B1 实卡):XeLL 周期错位 0,回调→送显返回 P95 10.0→3.0ms(现在送显先于 GPU 完成,上屏时间仍受 GPU 约 8ms 约束);模拟 60Hz 提示“建议关闭补帧”,XeSS 仍 120/s。可变刷新模拟等级 3:pacing 日志 effective=Vsync、displayQueuePaced=true、vrrSync=true,状态“可变刷新 · 未生效”。截图:显示页开关在真实屏上为灰、模拟可用时可开;补帧页黄色提示正确。
+
+测试:veyra_realtime_preview_tests 0 失败(提示 27 项、防抖 7 项);repair 259/0;ui contract 通过;latency-min-tests display-sync、lifecycle 通过;回放 6X 垂直同步 4/0(送显→上屏 5.69/6.05ms)、屏幕 XeSS 10/0、生命周期 13/0。build.py 现在对改动的 QObject 头重跑 moc(新属性需要新的元对象,只重编旧生成文件不够)。
diff --git a/i18n/catalog.json b/i18n/catalog.json
index 692ce1e9..40fadb5e 100644
--- a/i18n/catalog.json
+++ b/i18n/catalog.json
@@ -15724,27 +15724,6 @@
"en": "Display sync: auto · no tearing and no VSync wait (lowest latency)",
"ja": "表示の同期:自動 · ティアリングなし、垂直同期を待たない(最小遅延)"
},
- {
- "zh": "自动(推荐):不撕裂,也不等待垂直同步,每次刷新显示最新一帧,延迟最低 · 垂直同步:每帧都等刷新,输出帧率超过刷新率时会排队、延迟变大 · 允许撕裂:可能出现撕裂线",
- "src": "qml/ProPage.qml",
- "zh-TW": "自動(推薦):不撕裂,也不等待垂直同步,每次更新顯示最新一幀,延遲最低 · 垂直同步:每幀都等更新,輸出幀率超過更新率時會排隊、延遲變大 · 允許撕裂:可能出現撕裂線",
- "en": "Auto (recommended): no tearing and no VSync wait; each refresh shows the newest frame for the lowest latency · VSync: every frame waits for a refresh and queues up, adding latency, when output exceeds the refresh rate · Allow tearing: tear lines may appear",
- "ja": "自動(推奨):ティアリングなし、垂直同期を待たず、毎回のリフレッシュで最新フレームを表示し遅延が最小 · 垂直同期:全フレームがリフレッシュを待ち、出力がリフレッシュレートを超えるとキューが溜まり遅延が増加 · ティアリングを許可:ティアリングが発生する場合あり"
- },
- {
- "zh": "屏幕 %1 Hz · 内容 %2 fps:补帧已旁路,真帧直接显示(延迟最低)",
- "src": "src/ui/QmlPlayerBridge.cpp",
- "zh-TW": "螢幕 %1 Hz · 內容 %2 fps:補幀已旁路,真幀直接顯示(延遲最低)",
- "en": "%1 Hz display · %2 fps content: frame generation bypassed, real frames shown directly (lowest latency)",
- "ja": "%1 Hz の画面 · コンテンツ %2 fps:フレーム生成をバイパスし、実フレームを直接表示(最小遅延)"
- },
- {
- "zh": "屏幕 %1 Hz 只显示得下 %2X:已从 %3X 降到 %2X",
- "src": "src/ui/QmlPlayerBridge.cpp",
- "zh-TW": "螢幕 %1 Hz 只顯示得下 %2X:已從 %3X 降到 %2X",
- "en": "A %1 Hz display can only show %2X: lowered from %3X to %2X",
- "ja": "%1 Hz の画面で表示できるのは %2X まで:%3X から %2X に下げました"
- },
{
"zh": "只保留一帧在处理,未补帧时加 NVIDIA Reflex;垂直同步本身已不排队",
"src": "qml/ProPage.qml",
@@ -15830,25 +15809,144 @@
"ja": "表示の同期:自動"
},
{
- "zh": "可变刷新生效中",
+ "zh": "无法检测屏幕是否支持(目前只支持 NVIDIA 显卡)",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "無法偵測螢幕是否支援(目前只支援 NVIDIA 顯示卡)",
+ "en": "Cannot detect whether the display supports it (NVIDIA GPUs only for now)",
+ "ja": "ディスプレイの対応を検出できません(現在は NVIDIA GPU のみ)"
+ },
+ {
+ "zh": "当前屏幕不支持可变刷新",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "目前螢幕不支援可變更新",
+ "en": "This display does not support variable refresh",
+ "ja": "このディスプレイは可変リフレッシュに対応していません"
+ },
+ {
+ "zh": "屏幕支持,但驱动未开启:NVIDIA 控制面板 → 设置 G-SYNC",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "螢幕支援,但驅動程式未開啟:NVIDIA 控制面板 → 設定 G-SYNC",
+ "en": "The display supports it, but the driver has it off: NVIDIA Control Panel → Set up G-SYNC",
+ "ja": "ディスプレイは対応していますが、ドライバーで無効です:NVIDIA コントロールパネル → G-SYNC の設定"
+ },
+ {
+ "zh": "屏幕跟着画面刷新:不撕裂,也几乎不用等刷新",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "螢幕跟著畫面更新:不撕裂,也幾乎不用等更新",
+ "en": "The display refreshes when each frame arrives: no tearing and almost no waiting",
+ "ja": "フレームが届いた時点で画面を更新:ティアリングなし、待ち時間もほぼなし"
+ },
+ {
+ "zh": "已开启,屏幕还没进入可变刷新:全屏并隐藏控制栏,或在 NVIDIA 控制面板为窗口模式开启 G-SYNC",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "已開啟,螢幕還沒進入可變更新:全螢幕並隱藏控制列,或在 NVIDIA 控制面板為視窗模式開啟 G-SYNC",
+ "en": "On, but the display is not in variable refresh yet: go fullscreen with the controls hidden, or enable G-SYNC for windowed mode in the NVIDIA Control Panel",
+ "ja": "オンですが、まだ可変リフレッシュになっていません:全画面でコントロールバーを隠すか、NVIDIA コントロールパネルでウィンドウモードの G-SYNC を有効にしてください"
+ },
+ {
+ "zh": "已开启,播放时生效",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "已開啟,播放時生效",
+ "en": "On; applies during playback",
+ "ja": "オン(再生中に有効)"
+ },
+ {
+ "zh": "生效中:屏幕跟着画面刷新",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "生效中:螢幕跟著畫面更新",
+ "en": "Active: the display refreshes with each frame",
+ "ja": "動作中:画面がフレームに合わせて更新"
+ },
+ {
+ "zh": "屏幕正处于可变刷新(驱动已开启)",
"src": "src/ui/QmlPlayerBridge.cpp",
- "zh-TW": "可變更新生效中",
- "en": "Variable refresh active",
- "ja": "可変リフレッシュ動作中"
+ "zh-TW": "螢幕正處於可變更新(驅動程式已開啟)",
+ "en": "The display is in variable refresh (enabled by the driver)",
+ "ja": "ディスプレイは可変リフレッシュ中(ドライバーで有効)"
},
{
- "zh": "可变刷新已开启",
+ "zh": "可变刷新 · 生效中",
"src": "src/ui/QmlPlayerBridge.cpp",
- "zh-TW": "可變更新已開啟",
- "en": "Variable refresh enabled",
- "ja": "可変リフレッシュ有効"
+ "zh-TW": "可變更新 · 生效中",
+ "en": "Variable refresh · active",
+ "ja": "可変リフレッシュ · 動作中"
},
{
- "zh": "屏幕支持可变刷新(未开启)",
+ "zh": "可变刷新 · 未生效",
"src": "src/ui/QmlPlayerBridge.cpp",
- "zh-TW": "螢幕支援可變更新(未開啟)",
- "en": "Display supports variable refresh (off)",
- "ja": "画面は可変リフレッシュに対応(無効)"
+ "zh-TW": "可變更新 · 未生效",
+ "en": "Variable refresh · not active",
+ "ja": "可変リフレッシュ · 未動作"
+ },
+ {
+ "zh": "可变刷新 · 当前屏幕不可用",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "可變更新 · 目前螢幕不可用",
+ "en": "Variable refresh · unavailable on this display",
+ "ja": "可変リフレッシュ · このディスプレイでは使用不可"
+ },
+ {
+ "zh": "屏幕可变刷新生效中",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "螢幕可變更新生效中",
+ "en": "Display variable refresh active",
+ "ja": "ディスプレイの可変リフレッシュ動作中"
+ },
+ {
+ "zh": "当前帧率 %1 fps 超出屏幕刷新率 %2 Hz,建议关闭补帧来获得更好的延迟体验",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "目前幀率 %1 fps 超出螢幕更新率 %2 Hz,建議關閉補幀來獲得更好的延遲體驗",
+ "en": "Current frame rate %1 fps exceeds the %2 Hz refresh rate; turn frame generation off for lower latency",
+ "ja": "現在のフレームレート %1 fps が画面のリフレッシュレート %2 Hz を超えています。遅延を抑えるにはフレーム生成をオフにしてください"
+ },
+ {
+ "zh": "当前帧率 %1 fps 超出屏幕刷新率 %2 Hz,建议降至 %3X 来获得更好的延迟体验",
+ "src": "src/ui/QmlPlayerBridge.cpp",
+ "zh-TW": "目前幀率 %1 fps 超出螢幕更新率 %2 Hz,建議降至 %3X 來獲得更好的延遲體驗",
+ "en": "Current frame rate %1 fps exceeds the %2 Hz refresh rate; lower it to %3X for lower latency",
+ "ja": "現在のフレームレート %1 fps が画面のリフレッシュレート %2 Hz を超えています。遅延を抑えるには %3X に下げてください"
+ },
+ {
+ "zh": "可变刷新",
+ "src": "qml/ProPage.qml",
+ "zh-TW": "可變更新",
+ "en": "Variable refresh",
+ "ja": "可変リフレッシュ"
+ },
+ {
+ "zh": "自动(推荐):不撕裂,也不等待垂直同步,每次刷新显示最新一帧,延迟最低 · 垂直同步:每帧都等到刷新才显示,比自动多等最多一个刷新 · 允许撕裂:可能出现撕裂线",
+ "src": "qml/ProPage.qml",
+ "zh-TW": "自動(推薦):不撕裂,也不等待垂直同步,每次更新顯示最新一幀,延遲最低 · 垂直同步:每幀都等到更新才顯示,比自動多等最多一次更新 · 允許撕裂:可能出現撕裂線",
+ "en": "Auto (recommended): no tearing and no VSync wait; each refresh shows the newest frame for the lowest latency · VSync: every frame waits for a refresh, at most one refresh longer than Auto · Allow tearing: tear lines may appear",
+ "ja": "自動(推奨):ティアリングなし、垂直同期を待たず、毎回のリフレッシュで最新フレームを表示し遅延が最小 · 垂直同期:全フレームがリフレッシュを待って表示され、自動より最大 1 リフレッシュ分長く待つ · ティアリングを許可:ティアリングが発生する場合あり"
+ },
+ {
+ "zh": "显示同步:自动 + 可变刷新",
+ "src": "src/engine/VideoPresenter.cpp",
+ "zh-TW": "顯示同步:自動 + 可變更新",
+ "en": "Display sync: auto + variable refresh",
+ "ja": "表示の同期:自動 + 可変リフレッシュ"
+ },
+ {
+ "zh": "屏幕跟着画面刷新,不撕裂",
+ "src": "src/engine/VideoPresenter.cpp",
+ "zh-TW": "螢幕跟著畫面更新,不撕裂",
+ "en": "the display refreshes with each frame, no tearing",
+ "ja": "画面がフレームに合わせて更新、ティアリングなし"
+ },
+ {
+ "zh": "显示同步:自动 + 可变刷新 · 屏幕跟着画面刷新,不撕裂",
+ "src": "src/engine/VideoPresenter.cpp",
+ "zh-TW": "顯示同步:自動 + 可變更新 · 螢幕跟著畫面更新,不撕裂",
+ "en": "Display sync: auto + variable refresh · the display refreshes with each frame, no tearing",
+ "ja": "表示の同期:自動 + 可変リフレッシュ · 画面がフレームに合わせて更新、ティアリングなし"
+ },
+ {
+ "zh": "可变刷新:超过屏幕最高刷新时只排 1 帧",
+ "src": "src/engine/VideoPresenter.cpp",
+ "zh-TW": "可變更新:超過螢幕最高更新時只排 1 幀",
+ "en": "Variable refresh: at most 1 frame queued above the maximum refresh",
+ "ja": "可変リフレッシュ:最大リフレッシュを超える時だけ 1 フレーム待機"
}
]
}
diff --git a/include/veyra/engine/DisplayFgBudget.h b/include/veyra/engine/DisplayFgBudget.h
index e45b94a2..05adf1c9 100644
--- a/include/veyra/engine/DisplayFgBudget.h
+++ b/include/veyra/engine/DisplayFgBudget.h
@@ -5,59 +5,58 @@
#include <cstdint>
namespace veyra::engine {
-// Live frame-generation output budget (claude/latency-min-20261013 B2).
+// Live frame-generation output hint (claude/latency-min-20261013).
//
// A panel shows at most one new picture per refresh. Generated pictures above
-// that rate are queued (VSync: latency) or replaced before scanout (Automatic:
-// wasted GPU), and every extra multiplier step makes the real frame wait
-// longer: graph FG shows it (M-1)/M of a source interval after it arrived.
-// For live sources (files have no input latency to protect):
-// 1. the output fits the refresh (content x M <= 1.02 x refresh): unchanged;
-// 2. otherwise the largest supported multiplier whose output fits;
-// 3. if none fits but the source is slower than the panel (60 fps on a
-// 100 Hz panel), 2X: Automatic replaces the surplus at each refresh and
-// still shows more distinct pictures per refresh. Under VSync (queued)
-// the surplus would wait in the display queue instead, so bypass;
-// 4. if the source alone already fills the panel (>= 0.97 x refresh, e.g.
-// 60 fps on 60 Hz), bypass generation: no generated picture can add a
-// refresh, and real frames present as soon as they are enhanced instead
-// of waiting half an interval behind a generated one.
-// XeSS changes its interpolation count only through a model switch Intel
-// documents as expensive (shader compilation), so XeSS keeps the requested
-// multiplier and only bypasses (xefgSwapChainSetEnabled): under rule 4, and
-// under VSync whenever its output does not fit.
+// that rate are replaced before scanout (Automatic) or dropped/waited for
+// (VSync), and every extra multiplier step makes the real frame wait longer:
+// graph FG shows it (M-1)/M of a source interval after it arrived. The
+// multiplier stays the user's choice (decision 2026-10-14: no automatic
+// lowering); for live sources the status line suggests a better one:
+// 1. the output fits the refresh (content x M <= 1.02 x refresh): nothing;
+// 2. the source alone already fills the panel (>= 0.97 x refresh, e.g.
+// 60 fps on 60 Hz): turn generation off - no generated picture can add a
+// refresh, and real frames would present without waiting behind one;
+// 3. otherwise the largest selectable lower multiplier whose output fits;
+// 4. if none fits but the source is slower than the panel (60 fps on a
+// 100 Hz panel): Automatic still shows more distinct pictures per refresh
+// with 2X, so suggest 2X only when more was requested; under VSync the
+// surplus waits or is dropped, so suggest turning generation off.
inline constexpr double kDisplayFgFitTolerance=1.02;
inline constexpr double kDisplayFgFillRatio=0.97;
-constexpr bool displayFgMultiplierSupported(FrameGenerationBackend backend,unsigned multiplier){
+// Multipliers the user can pick for the backend (fgMultiplierChoices: XeSS
+// stops at 4X, FSR offers 2X only). Lower values than an accepted request
+// are always within the runtime limits.
+constexpr bool displayFgMultiplierSelectable(FrameGenerationBackend backend,unsigned multiplier){
switch(backend){
case FrameGenerationBackend::Dlss: return multiplier==2||multiplier==3||multiplier==4||multiplier==6;
+ case FrameGenerationBackend::XeSS: return multiplier>=2&&multiplier<=4;
case FrameGenerationBackend::Vfg: return multiplier>=2&&multiplier<=8;
case FrameGenerationBackend::Fsr:
case FrameGenerationBackend::Fsr4: return multiplier==2;
- case FrameGenerationBackend::XeSS: return false; // never reduced, see above
}
return false;
}
-// 0 = bypass generation, otherwise a multiplier in [2, requested].
-// queued: presents above the refresh wait in the display queue (VSync)
-// instead of being replaced (Automatic). Unknown rates keep the request.
-inline unsigned displayFgMultiplier(FrameGenerationBackend backend,unsigned requested,double contentFps,double refreshHz,bool queued=false){
- if(requested<2||!std::isfinite(contentFps)||!std::isfinite(refreshHz)||contentFps<=0||refreshHz<=0)return requested;
- if(contentFps>=refreshHz*kDisplayFgFillRatio)return 0;
- if(contentFps*requested<=refreshHz*kDisplayFgFitTolerance)return requested;
- if(backend==FrameGenerationBackend::XeSS)return queued?0:requested;
+// 0 = no suggestion, 1 = turn generation off, otherwise a lower multiplier.
+// queued: presents above the refresh wait or are dropped (VSync) instead of
+// being replaced (Automatic). Unknown rates suggest nothing.
+inline unsigned displayFgSuggestion(FrameGenerationBackend backend,unsigned requested,double contentFps,double refreshHz,bool queued=false){
+ if(requested<2||!std::isfinite(contentFps)||!std::isfinite(refreshHz)||contentFps<=0||refreshHz<=0)return 0;
+ if(contentFps*requested<=refreshHz*kDisplayFgFitTolerance)return 0;
+ if(contentFps>=refreshHz*kDisplayFgFillRatio)return 1;
for(unsigned m=requested-1;m>=2;--m)
- if(displayFgMultiplierSupported(backend,m)&&contentFps*m<=refreshHz*kDisplayFgFitTolerance)return m;
- return queued?0:2;
+ if(displayFgMultiplierSelectable(backend,m)&&contentFps*m<=refreshHz*kDisplayFgFitTolerance)return m;
+ if(queued)return 1;
+ return requested>2&&displayFgMultiplierSelectable(backend,2)?2:0;
}
-// A changed decision applies only after it held for the whole hold time, so a
+// A changed suggestion shows only after it held for the whole hold time, so a
// content rate wobbling around a boundary (30/40 fps games, the dedup
-// estimate) or a brief refresh change never toggles generation; a candidate
-// that changes again restarts the hold. The first decision after reset()
-// applies at once. Units: 100 ns.
+// estimate) or a brief refresh change never makes the hint flicker; a
+// candidate that changes again restarts the hold. The first decision after
+// reset() applies at once. Units: 100 ns.
class DisplayFgBudgetGate {
public:
explicit DisplayFgBudgetGate(int64_t hold100ns=15000000):hold_(hold100ns){}
diff --git a/include/veyra/engine/EngineController.h b/include/veyra/engine/EngineController.h
index 526cab5a..a89597ed 100644
--- a/include/veyra/engine/EngineController.h
+++ b/include/veyra/engine/EngineController.h
@@ -118,16 +118,18 @@ struct PlayerSnapshot {
double playbackRate=1; // requested file-preview transport rate; separate from measurement
bool fgBudgetLimited=false,xessGenerationSuppressed=false;
unsigned previewFgMultiplier=0;
- // Live FG output budget (DisplayFgBudget.h). displayFgLimited: the panel
- // cannot show the requested multiplier, displayFgMultiplier is the one in
- // use (1 = generation bypassed because the source already fills the
- // panel); refresh and content rate are the inputs of that decision.
- bool displayFgLimited=false;
- unsigned displayFgMultiplier=0;
+ // Live FG output hint (DisplayFgBudget.h), never applied automatically:
+ // 0 = the output fits the panel, 1 = suggest turning generation off,
+ // otherwise the suggested lower multiplier. Refresh and content rate are
+ // the inputs of that suggestion.
+ unsigned displayFgSuggestion=0;
double displayFgRefreshHz=0,displayFgContentFps=0;
- // Variable refresh of the presenting monitor (NVIDIA only): 0 unknown,
- // 1 not possible, 2 possible but off, 3 enabled in the driver, 4 active.
+ // Variable refresh of the presenting monitor (NVIDIA only, gfx::vrrLevel):
+ // 0 unknown, 1 the monitor cannot do VRR, 2 it can but VRR is not possible
+ // now, 3 possible, 4 active. presentationVrrSync: the 可变刷新 switch made
+ // Automatic present like Vsync for it.
unsigned displayVrr=0;
+ bool presentationVrrSync=false;
// Runtime-reported DLSSG MultiFrameCountMax: 1 = 2X only, 5 = 6X.
// 0 = not queried yet (no session). The UI uses this to offer only the
// multipliers the active GPU can actually honour.
diff --git a/include/veyra/engine/PresentationSettings.h b/include/veyra/engine/PresentationSettings.h
index 95187ca5..1866137f 100644
--- a/include/veyra/engine/PresentationSettings.h
+++ b/include/veyra/engine/PresentationSettings.h
@@ -22,6 +22,9 @@ struct PresentationSettings {
bool fullscreen=false; // transient UI state, never persisted as a preference
// Global opt-in compatibility choice; never part of enhancement presets.
bool hdrFgCompatibility=false;
+ // 可变刷新 switch: where the monitor can run VRR, Automatic presents like
+ // explicit Vsync (G-SYNC/FreeSync + V-SYNC, see presentationVsync below).
+ bool variableRefresh=false;
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;}
};
@@ -35,7 +38,12 @@ struct PresentationSettings {
// does not limit. 2.0.6 (ef2069f) had made Automatic identical to Vsync; the
// 4K NR+XeSS capture measured 112 ms on a 60 Hz panel with it.
// Explicit Vsync makes every frame wait for a refresh; only explicit Tearing
-// passes DXGI_PRESENT_ALLOW_TEARING.
+// passes DXGI_PRESENT_ALLOW_TEARING. With the 可变刷新 switch on and VRR
+// possible on the monitor, the presenter reports Automatic as Vsync in its
+// effective settings: inside the VRR range the panel starts a refresh when
+// the frame arrives, so the wait is about zero and nothing tears; above the
+// range the one-deep VSync queue holds (Microsoft documents VRR through the
+// tearing flag, which only explicit Tearing may use).
constexpr bool presentationVsync(const PresentationSettings& s) {
return s.display==DisplaySync::Vsync;
}
diff --git a/include/veyra/engine/VideoPresenter.h b/include/veyra/engine/VideoPresenter.h
index 3d4e5937..a7d08b88 100644
--- a/include/veyra/engine/VideoPresenter.h
+++ b/include/veyra/engine/VideoPresenter.h
@@ -74,6 +74,13 @@ public:
double displayRefreshHz();
// Variable refresh state of that monitor (NVIDIA only), re-read with it.
gfx::VrrState displayVrr()const{return vrr_;}
+ // The 可变刷新 rule: the switch is on, Automatic is selected and VRR is
+ // possible on the monitor, so Automatic presents like explicit Vsync.
+ // vrrSync() is what the last configurePresentation applied.
+ static bool vrrSyncWanted(const PresentationSettings& requested,const gfx::VrrState& vrr){
+ return requested.variableRefresh&&requested.display==DisplaySync::Automatic&&gfx::vrrLevel(vrr)>=3;
+ }
+ bool vrrSync()const{return vrrSync_;}
diagnostics::GpuSample blitTiming(ID3D12Fence* f,uint64_t revision=0,uint64_t epoch=0){gpuTimer_.collect(presentationFence_?presentationFence_.Get():f);if((revision&&gpuTimer_.last().identity.settingsRevision!=revision)||(epoch&&gpuTimer_.last().identity.epoch!=epoch)){diagnostics::GpuSample pending;pending.state=diagnostics::SampleState::Pending;return pending;}return gpuTimer_.last().gpu[size_t(diagnostics::GpuStage::Blit)];}
// Application-side frame-generation timing for present-sink backends
// (XeSS): the copies, barriers and provider prepare work recorded on
@@ -143,7 +150,7 @@ private:
bool xessWasEnabled_=false;
bool xessFailed_=false;
bool xessGenerationSuppressed_=false;
- HMONITOR refreshMonitor_=nullptr;double refreshHz_=0;gfx::VrrState vrr_{};bool refreshQueried_=false;
+ HMONITOR refreshMonitor_=nullptr;double refreshHz_=0;gfx::VrrState vrr_{};bool refreshQueried_=false,vrrSync_=false;
std::chrono::steady_clock::time_point refreshQuery_{};
uint32_t xessInputId_=0;
struct XessWork {pipeline::FrameIdentity identity{};uint32_t id=0;};
diff --git a/include/veyra/gfx/NvidiaVrr.h b/include/veyra/gfx/NvidiaVrr.h
index b5e12005..f1dcd12b 100644
--- a/include/veyra/gfx/NvidiaVrr.h
+++ b/include/veyra/gfx/NvidiaVrr.h
@@ -1,34 +1,67 @@
#pragma once
#include <windows.h>
+#include <algorithm>
#include <cstdint>
+#include <cstdlib>
+#include <cwchar>
#include <mutex>
#include <string>
namespace veyra::gfx {
// Variable refresh (G-SYNC / G-SYNC Compatible) state of the monitor showing
-// a window, for diagnostics and the status line. Veyra never changes it; the
-// user enables it in the NVIDIA Control Panel.
+// a window. Veyra never changes the driver setting; the user enables it in
+// the NVIDIA Control Panel, and the 可变刷新 switch only decides how Veyra
+// presents when it is available (VideoPresenter::configurePresentation).
// Minimal ABI declarations checked against NVIDIA/nvapi public interfaces
-// (nvapi_interface.h function IDs, NV_GET_VRR_INFO_V1 layout), MIT; same
-// source and loading rules as ReflexSession: System32 nvapi64.dll only, pinned
-// for the life of the process. No SDK header or runtime is distributed.
+// (nvapi_interface.h function IDs, NV_GET_VRR_INFO_V1 and
+// NV_MONITOR_CAPABILITIES_V1 layouts), MIT; same source and loading rules as
+// ReflexSession: System32 nvapi64.dll only, pinned for the life of the
+// process. No SDK header or runtime is distributed.
struct VrrState {
bool known=false; // NVIDIA driver answered for this monitor
- bool possible=false; // the display can run VRR with the current mode/connection
- bool requested=false; // VRR is enabled for this display in the driver
- bool enabled=false; // VRR mode is currently active on the display
+ bool possible=false; // VRR mode is possible on the display (bIsVRRPossible)
+ bool requested=false; // VRR mode is requested for the display (bIsVRRRequested)
+ bool enabled=false; // VRR mode is currently active on the display (bIsVRREnabled)
bool indicator=false; // the driver's VRR indicator overlay is on
bool inVrrMode=false; // the display itself reports VRR mode
+ bool capsKnown=false; // generic monitor capabilities answered
+ bool supportsVrr=false; // the monitor supports VRR at all (supportVRR)
+ bool currentlyCapable=false; // ... with the applied display settings
+ bool trueGsync=false; // G-SYNC module, not adaptive sync
+ bool simulated=false; // VEYRA_TEST_VRR_LEVEL override
int status=0; // last NvAPI status (0 = OK)
bool operator==(const VrrState&)const=default;
};
+// 0 unknown (no NVIDIA driver answer), 1 the monitor cannot do VRR, 2 it can
+// but VRR is not possible now (driver setting off, mode or connection),
+// 3 VRR possible/requested but not active, 4 VRR active on the display.
+constexpr unsigned vrrLevel(const VrrState& s){
+ if(!s.known)return 0;
+ if(s.enabled||s.inVrrMode)return 4;
+ if(s.possible||s.requested)return 3;
+ if(s.supportsVrr||s.currentlyCapable)return 2;
+ return 1;
+}
inline VrrState queryVrr(HWND window){
+ // Test hook (VEYRA_TEST_VRR_LEVEL=0..4): this rig's monitor reports no VRR
+ // support, so UI and presentation-rule tests simulate a level.
+ static const int testLevel=[]{wchar_t v[4]{};return GetEnvironmentVariableW(L"VEYRA_TEST_VRR_LEVEL",v,4)?std::clamp(_wtoi(v),0,4):-1;}();
+ if(testLevel>=0){
+ VrrState s;s.simulated=true;s.known=testLevel>0;s.capsKnown=s.known;
+ s.supportsVrr=s.currentlyCapable=testLevel>=2;s.possible=s.requested=testLevel>=3;s.enabled=s.inVrrMode=testLevel>=4;
+ return s;
+ }
struct Info {uint32_t version;uint32_t flags;uint32_t reservedEx[4];};
static_assert(sizeof(Info)==24);
+ // NV_MONITOR_CAPABILITIES_V1: the union starts right after the one-byte
+ // bIsValidInfo; NV_MONITOR_CAPS_VSDB (49 bytes) is its largest member.
+ struct Caps {uint32_t version;uint16_t size;uint32_t infoType;uint32_t connectorType;uint8_t valid;uint8_t data[49];};
+ static_assert(sizeof(Caps)==68);
using Query=void*(__cdecl*)(uint32_t);
using Init=int(__cdecl*)();
using IdByName=int(__cdecl*)(const char*,uint32_t*);
using GetVrr=int(__cdecl*)(uint32_t,Info*);
- static std::once_flag once;static IdByName idByName=nullptr;static GetVrr getVrr=nullptr;static bool ready=false;
+ using GetCaps=int(__cdecl*)(uint32_t,Caps*);
+ static std::once_flag once;static IdByName idByName=nullptr;static GetVrr getVrr=nullptr;static GetCaps getCaps=nullptr;static bool ready=false;
std::call_once(once,[]{
wchar_t system[MAX_PATH]{};GetSystemDirectoryW(system,MAX_PATH);
const std::wstring path=std::wstring(system)+L"\\nvapi64.dll";
@@ -40,6 +73,7 @@ inline VrrState queryVrr(HWND window){
auto init=reinterpret_cast<Init>(query(0x0150E828));
idByName=reinterpret_cast<IdByName>(query(0xAE457190));
getVrr=reinterpret_cast<GetVrr>(query(0xDF8FDA57));
+ getCaps=reinterpret_cast<GetCaps>(query(0x3B05C7E1)); // NvAPI_DISP_GetMonitorCapabilities, optional
ready=init&&idByName&&getVrr&&init()==0;
});
VrrState state;
@@ -57,6 +91,13 @@ inline VrrState queryVrr(HWND window){
state.known=true;
state.enabled=info.flags&1u;state.possible=info.flags&2u;state.requested=info.flags&4u;
state.indicator=info.flags&8u;state.inVrrMode=info.flags&16u;
+ if(getCaps){
+ Caps caps{};caps.version=uint32_t(sizeof(Caps))|(1u<<16);caps.size=uint16_t(sizeof(Caps));caps.infoType=0x1002; // NV_MONITOR_CAPS_TYPE_GENERIC
+ if(getCaps(displayId,&caps)==0&&(caps.valid&1u)){
+ state.capsKnown=true;
+ state.supportsVrr=caps.data[0]&1u;state.trueGsync=caps.data[0]&4u;state.currentlyCapable=caps.data[0]&16u;
+ }
+ }
return state;
}
}
diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.h
index 14e6bc8d..8cd0e00f 100644
--- a/include/veyra/pipeline/EnhanceGraph.h
+++ b/include/veyra/pipeline/EnhanceGraph.h
@@ -468,12 +468,6 @@ public:
// does not travel inside the AVFrame (D3D11VA). It must be provided exactly
// when frame->format == AV_PIX_FMT_D3D11 and is unused otherwise.
bool process(const AVFrame* frame, double ptsMs, bool reset, FrameOutputs& out, uint64_t sourceFrameId = 0, const ColorDescription* color = nullptr, const HardwareSurfaceInput* hardwareSurface = nullptr, bool retainReferences = true, const FgAdmission& admitFg = {}, unsigned previewMultiplier = 0, bool pausedResidualRefresh = false);
- // Live output budget (DisplayFgBudget.h): the source already fills the
- // panel, so frame generation is not run at all - no evaluation, no
- // FG-only motion work (flow, XeSS motion refinement/copy) - and is not
- // counted as a budget rejection. Generation resumes with a history reset.
- void setFgBypass(bool bypass){fgBypass_=bypass;}
- bool fgBypass()const{return fgBypass_;}
bool nextFrameSlotAvailable()const {
const unsigned slot=unsigned(realFrameIndex_%2);
if(presentationFences_[slot]&&presentationFences_[slot]->GetCompletedValue()<presentationValues_[slot])return false;
@@ -872,10 +866,6 @@ private:
double prevPtsMs_ = -1.0;
bool prevValid_ = false;
bool fgHistorySkipped_ = false;
- // fgBypass_: see setFgBypass. flowStale_: motion was skipped for a
- // bypassed frame, so the stored previous flow input is not the previous
- // source; the next motion frame restarts its history.
- bool fgBypass_ = false, flowStale_ = false;
Metrics metrics_{};
std::string mvecSource_ = "nvof";
};
diff --git a/include/veyra/ui/QmlPlayerBridge.h b/include/veyra/ui/QmlPlayerBridge.h
index cf2d0a6d..1bfe2253 100644
--- a/include/veyra/ui/QmlPlayerBridge.h
+++ b/include/veyra/ui/QmlPlayerBridge.h
@@ -320,6 +320,9 @@ class QmlPlayerBridge : public QObject {
Q_PROPERTY(QString runStatus READ runStatus NOTIFY perfChanged)
Q_PROPERTY(QString runStatusLevel READ runStatusLevel NOTIFY perfChanged)
Q_PROPERTY(QString runStatusDetail READ runStatusDetail NOTIFY perfChanged)
+ // Live FG output hint ("当前帧率…超出屏幕刷新率,建议降至…"), empty when the
+ // output fits; a suggestion only, the multiplier is never changed.
+ Q_PROPERTY(QString fgDisplayHint READ fgDisplayHint NOTIFY perfChanged)
Q_PROPERTY(QStringList runOptions READ runOptions NOTIFY perfChanged)
Q_PROPERTY(double effectiveOutputFps READ effectiveOutputFps NOTIFY perfChanged)
// Achieved output rate / effective policy target; -1 while unknown.
@@ -340,6 +343,13 @@ class QmlPlayerBridge : public QObject {
// Presentation: display sync 0 允许撕裂 1 垂直同步 2 自动; output cap 0 关闭
// 1 跟随显示器 2 自定义 (+ fps). Owned by XeSS when presentationOwned.
Q_PROPERTY(int displaySync READ displaySync WRITE setDisplaySync NOTIFY presentationChanged)
+ // 可变刷新 switch (persisted with the presentation settings) and the
+ // presenting monitor's VRR level: 0 unknown, 1 the monitor cannot do VRR
+ // (switch greyed), 2 it can but the driver setting is off, 3 possible,
+ // 4 active; vrrHint explains it beside the switch.
+ Q_PROPERTY(bool variableRefresh READ variableRefresh WRITE setVariableRefresh NOTIFY presentationChanged)
+ Q_PROPERTY(int vrrState READ vrrState NOTIFY perfChanged)
+ Q_PROPERTY(QString vrrHint READ vrrHint NOTIFY perfChanged)
Q_PROPERTY(int outputRateMode READ outputRateMode WRITE setOutputRateMode NOTIFY presentationChanged)
Q_PROPERTY(double outputCustomFps READ outputCustomFps WRITE setOutputCustomFps NOTIFY presentationChanged)
Q_PROPERTY(bool presentationOwned READ presentationOwned NOTIFY snapshotChanged)
@@ -862,6 +872,11 @@ public:
void setContentRate(int value);
int displaySync() const;
void setDisplaySync(int value);
+ bool variableRefresh() const;
+ void setVariableRefresh(bool value);
+ int vrrState() const;
+ QString vrrHint() const;
+ QString fgDisplayHint() const;
Q_INVOKABLE void setPresentationFullscreen(bool value);
bool fullscreenMemorySafe() const;
int outputRateMode() const;
diff --git a/qml/Veyra/NodePage.qml b/qml/Veyra/NodePage.qml
index c31599a6..e2fbfe69 100644
--- a/qml/Veyra/NodePage.qml
+++ b/qml/Veyra/NodePage.qml
@@ -777,6 +777,19 @@ VPage {
current: String(veyra.displaySync)
onPicked: id => veyra.displaySync = Number(id)
}
+ // 可变刷新 (G-SYNC / FreeSync): greyed when the monitor cannot do it.
+ RowLayout {
+ Layout.fillWidth: true
+ enabled: veyra.vrrState >= 2
+ opacity: enabled ? 1 : 0.5
+ NodeLabel { Layout.fillWidth: true; text: qsTr("可变刷新"); wrapMode: Text.WordWrap }
+ VSwitch {
+ objectName: "node-vrr"
+ checked: veyra.variableRefresh
+ onToggled: checked => veyra.variableRefresh = checked
+ }
+ }
+ NodeLabel { Layout.fillWidth: true; text: veyra.vrrHint; wrapMode: Text.WordWrap; opacity: veyra.vrrState >= 2 ? 1 : 0.5 }
NodeLabel { text: qsTr("输出上限") }
VSeg {
objectName: "node-output-rate"
@@ -1525,7 +1538,8 @@ VPage {
}
VRow {
label: qsTr("倍率")
- hint: veyra.fgMaxMultiplier + qsTr("X 为上限")
+ hint: veyra.fgDisplayHint.length > 0 ? veyra.fgDisplayHint : veyra.fgMaxMultiplier + qsTr("X 为上限")
+ hintColor: veyra.fgDisplayHint.length > 0 ? Theme.warn : Theme.t3
VSeg {
objectName: "node-fg-multiplier"
visible: veyra.fgBackendName !== "vfg"
diff --git a/qml/Veyra/ProPage.qml b/qml/Veyra/ProPage.qml
index 0a924d30..b35f60ce 100644
--- a/qml/Veyra/ProPage.qml
+++ b/qml/Veyra/ProPage.qml
@@ -123,7 +123,7 @@ VPage {
spacing: 0
VRow {
label: qsTr("显示同步")
- hint: qsTr("自动(推荐):不撕裂,也不等待垂直同步,每次刷新显示最新一帧,延迟最低 · 垂直同步:每帧都等刷新,输出帧率超过刷新率时会排队、延迟变大 · 允许撕裂:可能出现撕裂线")
+ hint: qsTr("自动(推荐):不撕裂,也不等待垂直同步,每次刷新显示最新一帧,延迟最低 · 垂直同步:每帧都等到刷新才显示,比自动多等最多一个刷新 · 允许撕裂:可能出现撕裂线")
VSeg {
objectName: "presentation-display-sync"
options: [{ id: "0", label: qsTr("允许撕裂") }, { id: "1", label: qsTr("垂直同步") }, { id: "2", label: qsTr("自动") }]
@@ -131,6 +131,18 @@ VPage {
onPicked: id => veyra.displaySync = Number(id)
}
}
+ // 可变刷新 (G-SYNC / FreeSync): greyed when the monitor cannot do it.
+ VRow {
+ label: qsTr("可变刷新")
+ enabled: veyra.vrrState >= 2
+ opacity: enabled ? 1 : 0.5
+ hint: veyra.vrrHint
+ VSwitch {
+ objectName: "presentation-vrr"
+ checked: veyra.variableRefresh
+ onToggled: checked => veyra.variableRefresh = checked
+ }
+ }
VRow {
label: qsTr("输出上限")
enabled: !veyra.presentationOwned
@@ -1722,7 +1734,9 @@ VPage {
}
VRow {
label: qsTr("倍率")
- hint: veyra.fgMaxMultiplier + qsTr("X 为上限")
+ // Live output hint: a suggestion, the multiplier stays as chosen.
+ hint: veyra.fgDisplayHint.length > 0 ? veyra.fgDisplayHint : veyra.fgMaxMultiplier + qsTr("X 为上限")
+ hintColor: veyra.fgDisplayHint.length > 0 ? Theme.warn : Theme.t3
VSeg {
visible: veyra.fgBackendName !== "vfg"
options: veyra.fgMultiplierChoices
diff --git a/qml/Veyra/VRow.qml b/qml/Veyra/VRow.qml
index 8e15b8d3..120f2e78 100644
--- a/qml/Veyra/VRow.qml
+++ b/qml/Veyra/VRow.qml
@@ -5,6 +5,7 @@ Item {
id: row
property string label: ""
property string hint: ""
+ property color hintColor: Theme.t3
property string value: ""
// Narrow panels with a wide control (导出 输出设置): the hint runs under the
// whole row instead of being squeezed beside the control.
@@ -53,7 +54,7 @@ Item {
Text {
visible: row.hint.length > 0 && !row.hintBelow
text: row.hint
- color: Theme.t3
+ color: row.hintColor
font.family: Theme.fontUi
font.pixelSize: 11
wrapMode: Text.Wrap
@@ -82,7 +83,7 @@ Item {
anchors.top: mainRow.bottom
anchors.topMargin: 6
text: row.hint
- color: Theme.t3
+ color: row.hintColor
font.family: Theme.fontUi
font.pixelSize: 11
wrapMode: Text.WordWrap
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index 35dddc50..b9aa2280 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -967,12 +967,9 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
const bool vfgRetainOverload=GetEnvironmentVariableW(L"VEYRA_TEST_VFG_NO_OVERLOAD_ESTIMATE",nullptr,0)==0;
int64_t nextVfgOverloadLog=0;
unsigned previewFgMultiplier=options.fgMultiplier;
- // Live output budget (DisplayFgBudget.h). fgBypassed persists into
- // the next iteration's read gate. VEYRA_TEST_NO_DISPLAY_FG_BUDGET=1
- // restores the unbudgeted multiplier for A/B runs;
+ // Live output hint (DisplayFgBudget.h): a status-line suggestion only.
// VEYRA_TEST_DISPLAY_HZ=<hz> replaces the measured refresh for it.
- DisplayFgBudgetGate displayFgGate;bool fgBypassed=false;unsigned displayFgApplied=0;
- static const bool displayFgBudgetEnabled=GetEnvironmentVariableW(L"VEYRA_TEST_NO_DISPLAY_FG_BUDGET",nullptr,0)==0;
+ DisplayFgBudgetGate displayFgGate;
static const double displayFgTestHz=[]{wchar_t v[16]{};return GetEnvironmentVariableW(L"VEYRA_TEST_DISPLAY_HZ",v,16)?std::clamp(_wtof(v),0.0,1000.0):0.0;}();
LivePairLatency pairLatency;
const bool adaptiveCapturePhase=physicalCapture&&GetEnvironmentVariableW(L"VEYRA_TEST_LEGACY_CAPTURE_PHASE",nullptr,0)==0;
@@ -1161,7 +1158,10 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
auto applyPresentation=[&]{
PresentationSettings requested;uint64_t revision;
{std::lock_guard lock(mutex_);requested=presentation_;revision=presentationRevision_;}
- if(revision==pacingRevision&&presenterGeneration==presenter.generation()){
+ // 可变刷新: the monitor's VRR availability is re-read every 2 s
+ // (window moved, driver setting changed); a change re-applies.
+ const bool vrrChanged=presenter.vrrSync()!=VideoPresenter::vrrSyncWanted(requested,presenter.displayVrr());
+ if(revision==pacingRevision&&presenterGeneration==presenter.generation()&&!vrrChanged){
// 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()){
@@ -1180,7 +1180,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
presentationPaced=presenter.pacingActive()&&!legacyVsyncQueue;
pacingRevision=revision;presenterGeneration=presenter.generation();cadence.reset();
{std::lock_guard lock(mutex_);snapshot_.presentationEffective=presentationEffective;snapshot_.presentationRevision=revision;snapshot_.presentationStatus=message;snapshot_.presentationProviderOwned=presenter.providerOwnedPresentation();}
- veyra::log::info("pacing",std::format("revision={} requested={}/{}/{} effective={}/{}/{} displayQueuePaced={}",revision,requested.enabled,unsigned(requested.mode),unsigned(requested.display),presentationEffective.enabled,unsigned(presentationEffective.mode),unsigned(presentationEffective.display),presentationPaced));
+ veyra::log::info("pacing",std::format("revision={} requested={}/{}/{} effective={}/{}/{} displayQueuePaced={} variableRefresh={} vrrLevel={} vrrSync={}",revision,requested.enabled,unsigned(requested.mode),unsigned(requested.display),presentationEffective.enabled,unsigned(presentationEffective.mode),unsigned(presentationEffective.display),presentationPaced,requested.variableRefresh,gfx::vrrLevel(presenter.displayVrr()),presenter.vrrSync()));
};
auto drainLivePresentation=[&]{cadence.reset();if(liveScheduler){++presentationDrains;liveScheduler->cancel();pollCompletions();pendingCompletions.clear();}pairLatency.reset();};
auto advanceLive=[&]{applyPresentation();if(liveScheduler){pollCompletions();if(stop_||(paused_&&!seekPreviewPending)||seekSeconds_>=0){liveScheduler->cancel();cadence.reset();}else liveScheduler->advance(host100ns());}};
@@ -1566,7 +1566,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
// when a lease frees we consume the newest available sample.
if(liveScheduler&&!transaction){
const auto enhancementPending=[&]{
- const bool fgRunning=options.fg&&!fgBypassed;
+ const bool fgRunning=options.fg;
if(presentationEffective.enabled&&!fgRunning&&(isCapture||!fileAwaitingVideo)&&liveScheduler->occupancy()>=1)return true;
// Explicit VSync, live, no generation: throttle only before the
// read. A frame read while the display queue is full would wait
@@ -1928,39 +1928,29 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
previewFgMultiplier=std::clamp(needed,2u,options.fgMultiplier);
}
}
- // Live output budget: never generate what the panel cannot show
- // (DisplayFgBudget.h). Tearing presents partial frames by the
- // user's choice, so it keeps the request.
+ // Live output hint: the panel cannot show more than one new picture
+ // per refresh, so suggest a multiplier that fits (DisplayFgBudget.h).
+ // The multiplier stays the user's choice (2026-10-14: hint, never
+ // an automatic reduction). Tearing shows partial frames by choice.
{
- const bool budgeted=displayFgBudgetEnabled&&isCapture&&!isImage&&options.fg&&options.fgMultiplier>1&&
+ const bool hinted=isCapture&&!isImage&&options.fg&&options.fgMultiplier>1&&
presentationEffective.display!=DisplaySync::Tearing;
double contentFps=0,refreshHz=0;
- if(budgeted){
+ if(hinted){
// Content rate: 60->30 halves the transport; dedup uses its
- // measured cadence and decides nothing until it has one.
+ // measured cadence and suggests nothing until it has one.
contentFps=dedupActive?contentDedup.contentFps():activeSource->info().averageFps*(halfRate?.5:1.0);
refreshHz=displayFgTestHz>0?displayFgTestHz:presenter.displayRefreshHz();
- if(contentFps>0&&refreshHz>0&&displayFgGate.update(displayFgMultiplier(options.settings.frameGenerationBackend,options.fgMultiplier,contentFps,refreshHz,presentationVsync(presentationEffective)),host100ns())){
- const auto applied=displayFgGate.applied();
- veyra::log::info("display-fg-budget",std::format("revision={} backend={} requested={}X applied={} contentFps={:.3f} refreshHz={:.3f}{} dedup={} halfRate={} display={} (output above the refresh is never shown: lower multiplier, or bypass when the source already fills the panel)",
- options.settings.revision,frameGenerationBackendName(options.settings.frameGenerationBackend),options.fgMultiplier,applied?std::format("{}X",applied):std::string("bypass"),contentFps,refreshHz,displayFgTestHz>0?" (test override)":"",dedupActive,halfRate,unsigned(presentationEffective.display)));
- // The pair-phase model and FG cost predictions describe
- // the previous multiplier.
- if(applied!=displayFgApplied){fgBudget.reset();vfgOverload.reset();pairLatency.reset();}
+ if(contentFps>0&&refreshHz>0&&displayFgGate.update(displayFgSuggestion(options.settings.frameGenerationBackend,options.fgMultiplier,contentFps,refreshHz,presentationVsync(presentationEffective)),host100ns())){
+ const auto hint=displayFgGate.applied();
+ veyra::log::info("display-fg-hint",std::format("revision={} backend={} requested={}X suggestion={} outputFps={:.3f} contentFps={:.3f} refreshHz={:.3f}{} dedup={} halfRate={} display={} (hint only: the multiplier is never changed automatically)",
+ options.settings.revision,frameGenerationBackendName(options.settings.frameGenerationBackend),options.fgMultiplier,hint==0?std::string("none"):hint==1?std::string("off"):std::format("{}X",hint),contentFps*options.fgMultiplier,contentFps,refreshHz,displayFgTestHz>0?" (test override)":"",dedupActive,halfRate,unsigned(presentationEffective.display)));
}
}else displayFgGate.reset();
- const bool budgetValid=budgeted&&displayFgGate.valid();
- displayFgApplied=budgetValid?displayFgGate.applied():0;
- fgBypassed=budgetValid&&displayFgApplied==0;
- if(budgetValid&&displayFgApplied>=2)previewFgMultiplier=std::min(previewFgMultiplier,displayFgApplied);
- graph->setFgBypass(fgBypassed);
- if(graph->xessEnabled())presenter.setXessGenerationSuppressed(fgBypassed);
std::lock_guard lock(mutex_);
- snapshot_.displayFgLimited=budgetValid&&(fgBypassed||displayFgApplied<options.fgMultiplier);
- snapshot_.displayFgMultiplier=!budgetValid?0u:fgBypassed?1u:displayFgApplied;
+ snapshot_.displayFgSuggestion=hinted&&displayFgGate.valid()?displayFgGate.applied():0u;
snapshot_.displayFgRefreshHz=refreshHz;snapshot_.displayFgContentFps=contentFps;
}
- const bool fgActive=options.fg&&!fgBypassed;
{std::lock_guard lock(mutex_);snapshot_.previewFgMultiplier=previewFgMultiplier;}
const auto liveInterval=physicalCapture?
// A span across frames WE skipped is not the source cadence. Using it
@@ -1969,17 +1959,16 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
// at ~10 pairs/s (field log 2026-10-04, 60 -> 22 fps until refocus).
capturePairInterval100ns(pkt.duration,activeSource->info().averageFps,lastProcessedPtsMs,pts,historyReset||gapCandidate):
livePhaseInterval100ns(pkt.duration,activeSource->info().averageFps/(isScreen&&halfRate?2:1),isScreen);
- const auto processingAllowance=isCapture&&fgActive&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)?
+ const auto processingAllowance=isCapture&&options.fg&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)?
fgBudget.processingAllowance(host100ns(),liveInterval):0;
// Present-sink providers own subframe pacing after receiving B.
// Graph FG needs the A/B presentation phase; provider FG does not.
- // A bypassed FG presents real frames as soon as they are ready.
- const auto legacyPairDelay=presentSinkFrameGeneration(options.settings.frameGenerationBackend)||!fgActive?0:liveInterval+processingAllowance;
- const auto pairDelay=adaptiveCapturePhase&&fgActive&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)?
+ const auto legacyPairDelay=presentSinkFrameGeneration(options.settings.frameGenerationBackend)?0:liveInterval+processingAllowance;
+ const auto pairDelay=adaptiveCapturePhase&&options.fg&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)?
pairLatency.select(host100ns(),legacyPairDelay,liveInterval,previewFgMultiplier):legacyPairDelay;
// DLSS can reseed after a skipped pair. XeSS
// owns generation inside its presenter and has no graph admission.
- if(isCapture&&!rereadCached&&fgActive&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)){
+ if(isCapture&&!rereadCached&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)){
const auto presentP95=livePresentGpu.p95();
admitFg=[&,presentP95](const pipeline::FrameBatch& batch,bool warmingHistory){
// Physical capture and PS5 delivery clocks are not
@@ -2205,15 +2194,15 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
std::lock_guard lock(mutex_);snapshot_.captureHalfRate=halfRate;
veyra::log::info("capture-rate",std::format("revision={} requested60To30={} active={} transportFps={} originalPtsPreserved=true",options.settings.revision,options.settings.content==ContentRate::Capture60To30,halfRate,isCapture?activeSource->info().averageFps:0));
}
- const bool pairPacing=pairAnchoredLive&&fgActive;
+ const bool pairPacing=pairAnchoredLive&&options.fg;
if(isCapture&&!rereadCached&&(isStream||pairPacing||!liveTimeline.anchored(out.batch.identity.epoch))){
const auto duration100ns=liveSourceInterval100ns(pkt.duration,activeSource->info().averageFps);
// File replay has no device pacing and still needs its PTS
// clock. Physical capture without FG presents as soon as ready.
- const bool paceSourcePts=fgActive||!physicalCapture;
- if(!liveTimeline.anchored(out.batch.identity.epoch)||(pairPacing&&frames==0))veyra::log::info("capture-timeline",std::format("interval100ns={} packetDurationKnown={} packetDurationPositive={} nominalFps={} FG={} pacing={}",duration100ns,!pkt.duration.isUnknown(),pkt.duration.num>0,activeSource->info().averageFps,fgActive,pairPacing?(isRemote?"decoded-pair":"capture-pair"):paceSourcePts?"source-pts":"capture-ready"));
- if(pairPacing||isStream)liveTimeline.resetPair(out.batch.identity.epoch,out.batch.b100ns,liveInputReady,fgActive?pairDelay:0,paceSourcePts);
- else if(!liveTimeline.anchored(out.batch.identity.epoch))liveTimeline.reset(out.batch.identity.epoch,out.batch.b100ns,liveInputReady,fgActive?duration100ns:0,paceSourcePts);
+ const bool paceSourcePts=options.fg||!physicalCapture;
+ if(!liveTimeline.anchored(out.batch.identity.epoch)||(pairPacing&&frames==0))veyra::log::info("capture-timeline",std::format("interval100ns={} packetDurationKnown={} packetDurationPositive={} nominalFps={} FG={} pacing={}",duration100ns,!pkt.duration.isUnknown(),pkt.duration.num>0,activeSource->info().averageFps,options.fg,pairPacing?(isRemote?"decoded-pair":"capture-pair"):paceSourcePts?"source-pts":"capture-ready"));
+ if(pairPacing||isStream)liveTimeline.resetPair(out.batch.identity.epoch,out.batch.b100ns,liveInputReady,options.fg?pairDelay:0,paceSourcePts);
+ else if(!liveTimeline.anchored(out.batch.identity.epoch))liveTimeline.reset(out.batch.identity.epoch,out.batch.b100ns,liveInputReady,options.fg?duration100ns:0,paceSourcePts);
}
if(!isImage&&!isCapture&&frames==0){anchor=Clock::now();anchorMs=lastAudioClockMs=pts;}
double frameWaitMs=0,framePresentMs=0;
@@ -2534,6 +2523,9 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
loopTrace.mark("flowSnapshot");
measured.sourceFrames=measured.flow.counters.sourceAccepted;measured.validGenerated=measured.flow.counters.fgReadyValid;measured.submitted=measured.flow.counters.realPresented+measured.flow.counters.generatedPresented;measured.expired=measured.flow.counters.generatedExpiredAfterEval;
const double ageP95=liveScheduler?completed.ageP95:captureAges.p95(),waitP95=liveScheduler?completed.waitP95:scheduleWaits.p95(),presentP95=liveScheduler?completed.presentP95:presentTimes.p95();
+ // Refresh and VRR state (NVAPI, every 2 s) are read outside the
+ // snapshot lock.
+ presenter.displayRefreshHz();
++frames;{std::lock_guard lock(mutex_);snapshot_.metrics=measured;snapshot_.colorStatus=graph->videoHdrActive()?L"SDR → RTX Video HDR":options.settings.videoHdr.enabled&&!gd.hdrInput?L"SDR → SDR(HDR显示未启用)":gd.hdrOutput?(graph->hdr10Output()?L"HDR → HDR10 / PQ":L"HDR → scRGB / 浮点"):gd.hdrInput?L"HDR → SDR色调映射":L"SDR → SDR";snapshot_.position=(isCapture||isImage?pts:lastFilePresentedMs)/1000;snapshot_.frames=sourceFrames;snapshot_.generated=graphStats.fgGeneratedFrames;snapshot_.lateMs=lateness;snapshot_.lateP95Ms=presentReturnDeviation.p95();
snapshot_.videoHdrActive=graph->videoHdrActive();
snapshot_.videoHdrStatus=graph->videoHdrActive()?L"预览:SDR 转 HDR 已运行":
@@ -2555,8 +2547,8 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
}
snapshot_.previewSkipped=measured.flow.counters.previewSkippedBeforeGraph;
snapshot_.fgBudgetLimited=measured.flow.lastFgRejected100ns>0&&host100ns()-measured.flow.lastFgRejected100ns<10000000;
- snapshot_.xessGenerationSuppressed=graph->xessEnabled()&&presenter.xessGenerationSuppressed()&&!fgBypassed; // budget bypass is not an overload
- {presenter.displayRefreshHz();const auto vrr=presenter.displayVrr();snapshot_.displayVrr=!vrr.known?0u:vrr.enabled||vrr.inVrrMode?4u:vrr.requested?3u:vrr.possible?2u:1u;}
+ snapshot_.xessGenerationSuppressed=graph->xessEnabled()&&presenter.xessGenerationSuppressed();
+ snapshot_.displayVrr=gfx::vrrLevel(presenter.displayVrr());snapshot_.presentationVrrSync=presenter.vrrSync();
snapshot_.nrActive=graph->nrEnabled()&&graphStats.nrEvaluateCount>0;
snapshot_.nrAutoActive=graph->autoNrPoolReady();
snapshot_.nrAutoPercent=graph->autoNrPoolReady()?AutoNrController::percent(graph->autoNrLevel()):0;
diff --git a/src/engine/VideoPresenter.cpp b/src/engine/VideoPresenter.cpp
index bb03f25b..2db17886 100644
--- a/src/engine/VideoPresenter.cpp
+++ b/src/engine/VideoPresenter.cpp
@@ -31,7 +31,7 @@ bool VideoPresenter::open(gfx::D3D12DeviceContext& ctx,HWND window,pipeline::Enh
veyra::log::warn("present","presentation creation cancelled: target window is no longer available");
return false;
}
- viewWidth_=viewHeight_=0;bufferMonitor_=nullptr;monitorWidth_=monitorHeight_=0;refreshMonitor_=nullptr;refreshHz_=0;refreshQuery_={};vrr_={};refreshQueried_=false;
+ viewWidth_=viewHeight_=0;bufferMonitor_=nullptr;monitorWidth_=monitorHeight_=0;refreshMonitor_=nullptr;refreshHz_=0;refreshQuery_={};vrr_={};refreshQueried_=false;vrrSync_=false;
++generation_;
Status st=Status::Ok;
// Keep one presentation queue for the native chain's lifetime. A later
@@ -413,7 +413,7 @@ bool VideoPresenter::readPresentedFrameForTest(gfx::D3D12DeviceContext& ctx,gfx:
void VideoPresenter::close(){
metadataSent_=false;metadataDirty_=false;lastMetadata_={};sourceMetadata_={};metadataAttempt_={};
hdrPeakMonitor_=nullptr;hdrPeakInfo_={};hdrPeakQuery_={};
- refreshMonitor_=nullptr;refreshHz_=0;refreshQuery_={};vrr_={};refreshQueried_=false;
+ refreshMonitor_=nullptr;refreshHz_=0;refreshQuery_={};vrr_={};refreshQueried_=false;vrrSync_=false;
retainedFrame_.reset();
xessInputId_=0;xessWork_={};xessWorkPosition_=0;
reflex_.close();reflexFrame_=0;
@@ -433,7 +433,7 @@ double VideoPresenter::displayRefreshHz(){
if(refreshMonitor_&&std::abs(hz-refreshHz_)>0.5)veyra::log::info("display-refresh",std::format("monitor refresh={:.3f} Hz (was {:.3f}; window moved or display mode changed)",hz,refreshHz_));
refreshHz_=hz;refreshMonitor_=monitor;refreshQuery_=now;sink_.setDisplayRefreshHz(hz);
const auto vrr=gfx::queryVrr(window_);
- if(!(vrr==vrr_)||!refreshQueried_)veyra::log::info("display-vrr",std::format("known={} possible={} requested={} active={} displayInVrrMode={} indicator={} status={} refreshHz={:.3f} (NVIDIA G-SYNC / G-SYNC Compatible state of the window's monitor; enabled by the user in the NVIDIA Control Panel, never changed by Veyra)",vrr.known,vrr.possible,vrr.requested,vrr.enabled,vrr.inVrrMode,vrr.indicator,vrr.status,hz));
+ if(!(vrr==vrr_)||!refreshQueried_)veyra::log::info("display-vrr",std::format("level={} known={} monitorSupportsVrr={} currentlyCapable={} trueGsync={} capsKnown={} possible={} requested={} active={} displayInVrrMode={} indicator={} simulated={} status={} refreshHz={:.3f} (NVIDIA G-SYNC / G-SYNC Compatible state of the window's monitor; enabled by the user in the NVIDIA Control Panel, never changed by Veyra)",gfx::vrrLevel(vrr),vrr.known,vrr.supportsVrr,vrr.currentlyCapable,vrr.trueGsync,vrr.capsKnown,vrr.possible,vrr.requested,vrr.enabled,vrr.inVrrMode,vrr.indicator,vrr.simulated,vrr.status,hz));
vrr_=vrr;refreshQueried_=true;
}
return refreshHz_;
@@ -477,9 +477,18 @@ PresentationSettings VideoPresenter::configurePresentation(gfx::D3D12DeviceConte
effective.outputRate=OutputRateMode::Off;
capNotice=L" · 此补帧提供方暂不支持独立输出限帧;已保留设置";
}
+ // 可变刷新: with VRR possible on this monitor, Automatic presents like
+ // explicit Vsync - the G-SYNC/FreeSync + V-SYNC combination. Inside the
+ // VRR range the panel starts a refresh when the frame arrives, so the
+ // VSync wait is about zero and nothing tears; above the range the
+ // one-deep VSync queue below holds. Without VRR (switch off, another
+ // monitor, driver setting off) Automatic stays Present(0,0).
+ displayRefreshHz();
+ vrrSync_=vrrSyncWanted(requested,vrr_);
+ if(vrrSync_){requested.display=DisplaySync::Vsync;effective.display=DisplaySync::Vsync;}
const bool vsync=presentationVsync(requested),tearing=presentationTearing(requested);
providerOwnedPresentation_=xessActive();
- const std::wstring sync=requested.display==DisplaySync::Automatic?L"显示同步:自动 · 不撕裂,也不等待垂直同步(延迟最低)":vsync?L"显示同步:垂直同步":L"显示同步:允许撕裂";
+ const std::wstring sync=vrrSync_?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(xessActive()){
// The provider owns Present for its generated frames, so neither the
@@ -504,7 +513,7 @@ PresentationSettings VideoPresenter::configurePresentation(gfx::D3D12DeviceConte
// there would throttle presents to the refresh, the wait they avoid.
const bool paced=vsync&&sink_.configurePacing(true,vsync,tearing);
const bool restored=paced||sink_.configurePacing(false,vsync,tearing);
- const std::wstring queue=paced?L"垂直同步:屏幕队列 1 帧,读帧前等待刷新 · ":vsync?L"垂直同步:屏幕队列控制不可用 · ":restored?L"":L"显示队列恢复失败 · ";
+ const std::wstring queue=paced?(vrrSync_?L"可变刷新:超过屏幕最高刷新时只排 1 帧 · ":L"垂直同步:屏幕队列 1 帧,读帧前等待刷新 · "):vsync?L"垂直同步:屏幕队列控制不可用 · ":restored?L"":L"显示队列恢复失败 · ";
std::wstring cap;
if(followDisplay)cap=std::format(L"输出上限:跟随显示器 {:.0f} Hz",requested.customFps);
else if(requested.outputRate==OutputRateMode::Custom)cap=std::format(L"输出上限:{:.3f} FPS",requested.customFps);
diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cpp
index 85f9446a..ffbb9040 100644
--- a/src/pipeline/EnhanceGraph.cpp
+++ b/src/pipeline/EnhanceGraph.cpp
@@ -411,7 +411,7 @@ bool EnhanceGraph::initialize(const EnhanceGraphDesc& desc)
}
veyra::log::info("graph","diagnostic SR motion override active; no product entry point enables this");
}
- desc_ = desc;lastSourceColor_={};tracker_={};prevValid_=false;fgHistorySkipped_=false;flowStale_=false;cadence_.reset();scene_.reset();sceneLastSourceId_=0;previousLuma_.clear();
+ desc_ = desc;lastSourceColor_={};tracker_={};prevValid_=false;fgHistorySkipped_=false;cadence_.reset();scene_.reset();sceneLastSourceId_=0;previousLuma_.clear();
if(desc.videoSrQuality>engine::kVideoSrFsr){veyra::log::error("graph",std::format("invalid video SR quality value={}",desc.videoSrQuality));return false;}
srcW_ = desc.sourceWidth;
srcH_ = desc.sourceHeight;
@@ -2359,19 +2359,10 @@ 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;
- // A bypassed FG (setFgBypass) consumes no motion: keep flow only for NR/SR.
- const bool fgMotion = !fgBypass_ && desc_.fgUsesFlow() && (presentSinkFg() || fgEnabled_);
- const bool runMotion = nvofStandalone_ || fgMotion || (srEnabled_&&desc_.srUsesFlow()&&(desc_.videoSrQuality==0||desc_.videoSrQuality==engine::kVideoSrFsr));
- const bool motionBackend = gpuDis_ || amdOf_ || (nvof_ && nvof_->initialized());
- // XeSS motion refinement only feeds generation.
- const bool refineFlow = flowRefine_ && !fgBypass_;
- // After skipped motion frames the stored previous flow input is stale.
- const bool flowPrevValid = prevValid_ && !flowStale_;
- if (!runMotion && motionBackend) flowStale_ = true;
- if (runMotion && motionBackend) {
- flowStale_ = false;
+ const bool runMotion = nvofStandalone_ || (presentSinkFg()&&desc_.fgUsesFlow()) || (fgEnabled_&&desc_.fgUsesFlow()) || (srEnabled_&&desc_.srUsesFlow()&&(desc_.videoSrQuality==0||desc_.videoSrQuality==engine::kVideoSrFsr));
+ if (runMotion && (gpuDis_ || amdOf_ || (nvof_ && nvof_->initialized()))) {
const float dims[8] = {uintBits(nvofW_),uintBits(nvofH_),uintBits(nvofW_),uintBits(nvofH_),0,0,0,0};
- if (flowPrevValid) {
+ if (prevValid_) {
tracker_.transition(list,nvofInB_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
tracker_.transition(list,nvofInA_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
blitPass_.bind(list,dims,gpuHandleOf(blitPass_,5).ptr,gpuHandleOf(blitPass_,6).ptr);
@@ -2387,11 +2378,11 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
tracker_.transition(list,nvofInB_.Get(),D3D12_RESOURCE_STATE_COMMON);
if(amdOf_){
gpuTimer_.mark(list,GpuStage::Flow);
- if(!amdOf_->dispatch(list,nvofInB_.Get(),!flowPrevValid))return false;
- ++metrics_.amdOfExecuteCount;haveFlow=flowPrevValid;
- if(!refineFlow||!haveFlow)gpuTimer_.mark(list,GpuStage::Flow,true);
+ if(!amdOf_->dispatch(list,nvofInB_.Get(),!prevValid_))return false;
+ ++metrics_.amdOfExecuteCount;haveFlow=prevValid_;
+ if(!flowRefine_||!haveFlow)gpuTimer_.mark(list,GpuStage::Flow,true);
}
- if(gpuDis_ && flowPrevValid){
+ if(gpuDis_ && prevValid_){
gpuTimer_.mark(list,GpuStage::Flow);
tracker_.transition(list,flowTex_.Get(),D3D12_RESOURCE_STATE_COMMON);
tracker_.transition(list,confTex_.Get(),D3D12_RESOURCE_STATE_COMMON);
@@ -2403,7 +2394,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
++metrics_.gpuDisExecuteCount;haveFlow=true;
gpuTimer_.mark(list,GpuStage::Flow,true);
}
- if (flowPrevValid && !gpuDis_) {
+ if (prevValid_ && !gpuDis_) {
if(!amdOf_){
gpuTimer_.mark(list,GpuStage::Flow);
if(!submitGraph(slot))return false;
@@ -2422,7 +2413,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
if(!waitForFlow())return false;
}
list=ring_.acquireNext(slot,st);if(!list)return false;
- if(!refineFlow||!haveFlow)gpuTimer_.mark(list,GpuStage::Flow,true);
+ if(!flowRefine_||!haveFlow)gpuTimer_.mark(list,GpuStage::Flow,true);
}
if(haveFlow) {
if(amdOf_)tracker_.transition(list,amdOf_->sceneChanges(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
@@ -2437,7 +2428,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
densifyPass_.bind(list,dc,gpuHandleOf(densifyPass_,0).ptr,gpuHandleOf(densifyPass_,5).ptr);
list->Dispatch((nvofW_+15)/16,(nvofH_+15)/16,1);
tracker_.uavBarrier(list,flowTex_.Get());tracker_.uavBarrier(list,confTex_.Get());
- if(refineFlow){
+ if(flowRefine_){
// XeSS motion: per-pixel candidate choice, then disocclusion fill.
tracker_.transition(list,fgFlowRefined_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
if(flowConsistency_)tracker_.transition(list,nvofReverseTex_.Get(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
@@ -2495,7 +2486,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
list->Dispatch((w+15)/16,(h+15)/16,1);tracker_.uavBarrier(list,output);tracker_.transition(list,output,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
};
adapt(nrFlow_.Get(),nrW_,nrH_,1);adapt(baseFlow_.Get(),workW_,workH_,2);
- if(refineFlow){
+ if(flowRefine_){
tracker_.transition(list,fgBaseFlow_.Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
const float c[8]={uintBits(nvofW_),uintBits(nvofH_),uintBits(workW_),uintBits(workH_),0,0,0,0};
fgFlowAdaptPass_.bind(list,c,gpuHandleOf(fgFlowAdaptPass_,0).ptr,gpuHandleOf(fgFlowAdaptPass_,1).ptr);
@@ -2942,10 +2933,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
tracker_.transition(list, videoFrame_[parity].Get(), D3D12_RESOURCE_STATE_COMMON);
}
- if(presentSinkFg()&&fgBypass_){
- // Bypassed: the presenter disables XeSS generation and reads no motion.
- presentMotionValid_[parity]=false;motionPreviousSource_[parity]=previousSource_;
- }else if(presentSinkFg()){
+ if(presentSinkFg()){
// Test-only: fgMotionProbe (never set by the product) also feeds the XeSS
// present path, held in COMMON, same current->previous pixel convention.
auto* input=desc_.fgMotionProbe&&!reset?desc_.fgMotionProbe:desc_.fgUsesFlow()&&haveFlow&&!reset?(flowRefine_?fgBaseFlow_.Get():baseFlow_.Get()):nrZeroMotion_.Get();
@@ -2960,10 +2948,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
motionPreviousSource_[parity]=previousSource_;
}
previousSource_=sourceFrameId;
- // A bypassed FG is not a skipped pair: no candidates, no rejection, but
- // the next generated pair must start from a fresh history.
- if(fgBypass_&&fgEnabled_&&fgCreated())fgHistorySkipped_=true;
- const bool fgBackendAvailable=fgEnabled_&&fgCreated()&&!fgBypass_;
+ const bool fgBackendAvailable=fgEnabled_&&fgCreated();
const unsigned fgMultiplier=previewMultiplier&&fgBackendAvailable?std::clamp(previewMultiplier,2u,desc_.fgMultiplier):desc_.fgMultiplier;
out.fgCandidates=fgBackendAvailable?fgMultiplier-1:0;
bool resetFg=reset||!prevValid_||fgHistorySkipped_;
diff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cpp
index fcb8c57a..cb74898c 100644
--- a/src/ui/QmlPlayerBridge.cpp
+++ b/src/ui/QmlPlayerBridge.cpp
@@ -1,5 +1,6 @@
#include "veyra/ui/QmlPlayerBridge.h"
#include "veyra/gfx/PresentSink.h"
+#include "veyra/gfx/NvidiaVrr.h"
#include <QElapsedTimer>
#include "veyra/ui/EffectAvailability.h"
#include "veyra/engine/FrameGenerationSelection.h"
@@ -390,6 +391,12 @@ struct QmlPlayerBridge::Impl {
QString runStatus, runLevel, runDetail;
QStringList runOptions;
double effectiveOutputFps=-1;
+ // FG output hint for the 倍率 row; 可变刷新 level (gfx::vrrLevel) of the
+ // presenting monitor, or of the main window's monitor while idle.
+ QString fgDisplayHint;
+ int vrrState=0;
+ gfx::VrrState idleVrr{};
+ std::chrono::steady_clock::time_point idleVrrQuery{};
std::atomic<double> gpuUtil{-1.0};
// Hardware adapters in Windows' high-performance order (discrete first). The
// sampler only counts engines of the adapter whose LUID is in gpuMonitorLuid
@@ -1248,6 +1255,7 @@ QmlPlayerBridge::QmlPlayerBridge(engine::EngineController& engine, std::filesyst
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);
+ pr.variableRefresh = saved.value(QStringLiteral("vrr")).toBool();
}
if (pr.valid()) impl_->engine.requestPresentation(pr);
impl_->aspectMode = std::clamp(impl_->prefs.value(QStringLiteral("aspect")).toInt(), 0, 6);
@@ -6471,10 +6479,25 @@ void QmlPlayerBridge::updateRunStatus() {
const auto sync=i.presentation.display==engine::DisplaySync::Vsync?tr("垂直同步"):tr("自动显示同步");
options<<((refresh>0)?tr("%1 · 屏幕 %2 Hz").arg(sync).arg(refresh,0,'f',1):sync);
}
- // Variable refresh (NVIDIA G-SYNC / G-SYNC Compatible), set in the driver.
- if(s.running&&s.displayVrr==4)options<<tr("可变刷新生效中");
- else if(s.running&&s.displayVrr==3)options<<tr("可变刷新已开启");
- else if(s.running&&s.displayVrr==2)options<<tr("屏幕支持可变刷新(未开启)");
+ // Variable refresh (NVIDIA G-SYNC / G-SYNC Compatible): the presenting
+ // monitor while playing, otherwise the main window's monitor (NVAPI,
+ // at most every 2 s). The driver setting is the user's; the 可变刷新
+ // switch decides how Veyra presents when it is possible.
+ int vrrLevel=int(s.displayVrr);
+ if(!s.running){
+ const auto now=std::chrono::steady_clock::now();
+ if(i.idleVrrQuery==std::chrono::steady_clock::time_point{}||now-i.idleVrrQuery>=std::chrono::seconds(2)){
+ HWND host=owner;
+ if(!host)if(auto* window=QGuiApplication::focusWindow())host=reinterpret_cast<HWND>(window->winId());
+ if(host){i.idleVrr=gfx::queryVrr(host);i.idleVrrQuery=now;}
+ }
+ vrrLevel=int(gfx::vrrLevel(i.idleVrr));
+ }
+ if(i.presentation.variableRefresh){
+ if(vrrLevel>=4)options<<tr("可变刷新 · 生效中");
+ else if(vrrLevel==3)options<<tr("可变刷新 · 未生效");
+ else options<<tr("可变刷新 · 当前屏幕不可用");
+ }else if(s.running&&vrrLevel>=4)options<<tr("屏幕可变刷新生效中");
if(i.presentation.outputRate!=engine::OutputRateMode::Off){
if(s.running&&s.presentationEffective.outputRate==engine::OutputRateMode::Off)
options<<tr("输出限帧 · 当前未生效");
@@ -6486,6 +6509,17 @@ void QmlPlayerBridge::updateRunStatus() {
if(!s.capture&&std::abs(s.playbackRate-1.0)>.001)options<<tr("播放速度 %1×").arg(s.playbackRate,0,'f',2);
if(i.compareMode!=0)options<<tr("画面对比 · 补帧暂停");
QStringList detail;
+ // Live output hint: also shown under the 倍率 control (fgDisplayHint).
+ QString fgHint;
+ if (s.running && !s.image && s.applied.multiplier > 1 && i.compareMode == 0 && s.displayFgSuggestion > 0 &&
+ s.displayFgContentFps > 0 && s.displayFgRefreshHz > 0) {
+ const double output = s.displayFgContentFps * s.applied.multiplier;
+ fgHint = s.displayFgSuggestion == 1
+ ? tr("当前帧率 %1 fps 超出屏幕刷新率 %2 Hz,建议关闭补帧来获得更好的延迟体验")
+ .arg(output, 0, 'f', 0).arg(s.displayFgRefreshHz, 0, 'f', 0)
+ : tr("当前帧率 %1 fps 超出屏幕刷新率 %2 Hz,建议降至 %3X 来获得更好的延迟体验")
+ .arg(output, 0, 'f', 0).arg(s.displayFgRefreshHz, 0, 'f', 0).arg(s.displayFgSuggestion);
+ }
if (s.running && !s.image) {
if (s.applied.multiplier > 1) {
QString backend;
@@ -6501,11 +6535,9 @@ void QmlPlayerBridge::updateRunStatus() {
}
else detail << tr("未补帧");
if (s.applied.multiplier > 1 && impl_->compareMode != 0) detail << tr("补帧暂停");
- // Live output budget (DisplayFgBudget.h): what the panel can show.
- else if (s.applied.multiplier > 1 && s.displayFgLimited && s.displayFgMultiplier <= 1)
- detail << tr("屏幕 %1 Hz · 内容 %2 fps:补帧已旁路,真帧直接显示(延迟最低)").arg(s.displayFgRefreshHz, 0, 'f', 0).arg(s.displayFgContentFps, 0, 'f', 0);
- else if (s.applied.multiplier > 1 && s.displayFgLimited)
- detail << tr("屏幕 %1 Hz 只显示得下 %2X:已从 %3X 降到 %2X").arg(s.displayFgRefreshHz, 0, 'f', 0).arg(s.displayFgMultiplier).arg(s.applied.multiplier);
+ // Live output hint (DisplayFgBudget.h): a suggestion only, the
+ // multiplier stays the user's choice.
+ else if (!fgHint.isEmpty()) detail << fgHint;
else if (s.applied.multiplier > 1 && (s.fgBudgetLimited || s.xessGenerationSuppressed) &&
(!rate.policyLimited()||i.history.overloaded)) detail << tr("调度降档");
// Why VFG cannot hold the requested multiplier. One VFG interpolation
@@ -6533,7 +6565,7 @@ void QmlPlayerBridge::updateRunStatus() {
else detail << tr("VFG 每张约 %1 ms,当前负载约可稳定 %2X").arg(*perRun, 0, 'f', 1).arg(fits);
}
}
- if (!s.displayFgLimited && refresh > 1 && source > 1 && source * s.applied.multiplier > refresh * 1.02)
+ if (fgHint.isEmpty() && refresh > 1 && source > 1 && source * s.applied.multiplier > refresh * 1.02)
detail << tr("屏幕 %1 Hz 最多显示约 %2X").arg(refresh, 0, 'f', 0).arg(std::max(1, int(refresh / source)));
}
if (s.nominalSourceFps > 0.01) detail << tr("源 %1 fps").arg(s.nominalSourceFps, 0, 'f', 2);
@@ -6553,9 +6585,10 @@ void QmlPlayerBridge::updateRunStatus() {
const QString text = detail.join(QStringLiteral(" · "));
const double gpu = i.gpuUtil.load();
const double target=active&&f.rateWindowReady&&rate.targetFps>0?rate.targetFps:-1;
- const bool changed = ratioChanged || active || status != i.runStatus || level != i.runLevel || text != i.runDetail || options!=i.runOptions || std::abs(target-i.effectiveOutputFps)>.05 || std::abs(gpu - i.gpuPublished) > 0.05;
+ const bool changed = ratioChanged || active || status != i.runStatus || level != i.runLevel || text != i.runDetail || options!=i.runOptions || std::abs(target-i.effectiveOutputFps)>.05 || std::abs(gpu - i.gpuPublished) > 0.05 ||
+ fgHint != i.fgDisplayHint || vrrLevel != i.vrrState;
i.runStatus = status; i.runLevel = level; i.runDetail = text; i.gpuPublished = gpu;
- i.runOptions=options;i.effectiveOutputFps=target;
+ i.runOptions=options;i.effectiveOutputFps=target;i.fgDisplayHint=fgHint;i.vrrState=vrrLevel;
if (changed) emit perfChanged();
}
@@ -6768,6 +6801,29 @@ void QmlPlayerBridge::setDisplaySync(int value) {
impl_->presentation.display = static_cast<engine::DisplaySync>(value);
applyPresentation();
}
+bool QmlPlayerBridge::variableRefresh() const { return impl_->presentation.variableRefresh; }
+void QmlPlayerBridge::setVariableRefresh(bool value) {
+ if (impl_->presentation.variableRefresh == value) return;
+ impl_->presentation.variableRefresh = value;
+ applyPresentation();
+}
+int QmlPlayerBridge::vrrState() const { return impl_->vrrState; }
+QString QmlPlayerBridge::vrrHint() const {
+ // The 可变刷新 switch is available (not grey) from level 2: the monitor
+ // can do VRR even if the driver setting is still off.
+ const bool on = impl_->presentation.variableRefresh, running = impl_->snapshot.running;
+ switch (impl_->vrrState) {
+ case 0: return tr("无法检测屏幕是否支持(目前只支持 NVIDIA 显卡)");
+ case 1: return tr("当前屏幕不支持可变刷新");
+ case 2: return tr("屏幕支持,但驱动未开启:NVIDIA 控制面板 → 设置 G-SYNC");
+ case 3:
+ if (!on) return tr("屏幕跟着画面刷新:不撕裂,也几乎不用等刷新");
+ return running ? tr("已开启,屏幕还没进入可变刷新:全屏并隐藏控制栏,或在 NVIDIA 控制面板为窗口模式开启 G-SYNC")
+ : tr("已开启,播放时生效");
+ default: return on ? tr("生效中:屏幕跟着画面刷新") : tr("屏幕正处于可变刷新(驱动已开启)");
+ }
+}
+QString QmlPlayerBridge::fgDisplayHint() const { return impl_->fgDisplayHint; }
int QmlPlayerBridge::outputRateMode() const { return int(impl_->presentation.outputRate); }
void QmlPlayerBridge::setOutputRateMode(int value) {
if (value < 0 || value > 2 || int(impl_->presentation.outputRate) == value) return;
@@ -6788,12 +6844,13 @@ 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}};
+ {"lowQueue", p.enabled}, {"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}",
- p.enabled, int(p.display), int(p.outputRate), p.customFps));
+ 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));
emit presentationChanged();
emit settingsChanged();
+ emit perfChanged();
}
// --- design gap B8-B11: compare and aspect ------------------------------------
diff --git a/tests/unit/RealtimePreviewSchedulingTests.cpp b/tests/unit/RealtimePreviewSchedulingTests.cpp
index 2795b517..ae1781fe 100644
--- a/tests/unit/RealtimePreviewSchedulingTests.cpp
+++ b/tests/unit/RealtimePreviewSchedulingTests.cpp
@@ -133,36 +133,39 @@ int main() {
check(!gate.suppressed(), "reset clears suppression state");
}
- // --- Live FG output budget (latency-min B2)
+ // --- Live FG output hint (latency-min; suggestion only, never applied)
{
using B = FrameGenerationBackend;
- check(displayFgMultiplier(B::Dlss, 6, 60, 320) == 4, "DLSS 6X at 60 fps on 320 Hz lowers to 4X (5X is not a DLSS multiplier)");
- check(displayFgMultiplier(B::Dlss, 4, 60, 320) == 4, "DLSS 4X at 60 fps on 320 Hz fits and is unchanged");
- check(displayFgMultiplier(B::Dlss, 2, 60, 320) == 2, "2X below the refresh is unchanged");
- check(displayFgMultiplier(B::Vfg, 8, 60, 320) == 5, "VFG 8X at 60 fps on 320 Hz lowers to 5X");
- check(displayFgMultiplier(B::Dlss, 3, 60, 144) == 2, "3X at 60 fps on 144 Hz lowers to 2X");
- check(displayFgMultiplier(B::Dlss, 4, 60, 240) == 4, "4X at 60 fps on 240 Hz fits exactly");
- check(displayFgMultiplier(B::Dlss, 2, 60, 119.88) == 2, "2X at 60 fps on 119.88 Hz is within the fit tolerance");
- check(displayFgMultiplier(B::Dlss, 2, 60, 60) == 0, "60 fps on 60 Hz bypasses generation");
- check(displayFgMultiplier(B::Dlss, 2, 59.94, 60) == 0, "59.94 fps capture on 60 Hz bypasses generation");
- check(displayFgMultiplier(B::Dlss, 2, 60, 59.94) == 0, "60 fps on 59.94 Hz bypasses generation");
- check(displayFgMultiplier(B::XeSS, 2, 60, 60) == 0, "XeSS bypasses when the source fills the panel");
- check(displayFgMultiplier(B::Fsr, 2, 60, 60) == 0, "FSR bypasses when the source fills the panel");
- check(displayFgMultiplier(B::Dlss, 2, 30, 60) == 2, "a 30 fps game with 2X on 60 Hz keeps generation");
- check(displayFgMultiplier(B::Dlss, 4, 30, 60) == 2, "a 30 fps game with 4X on 60 Hz lowers to 2X");
- check(displayFgMultiplier(B::Dlss, 6, 60, 100) == 2, "60 fps on 100 Hz keeps 2X: it still adds pictures per refresh");
- check(displayFgMultiplier(B::Dlss, 2, 40, 60) == 2, "40 fps on 60 Hz keeps 2X");
- check(displayFgMultiplier(B::XeSS, 4, 60, 144) == 4, "XeSS keeps its multiplier unless bypassed");
- check(displayFgMultiplier(B::Dlss, 6, 0, 60) == 6 && displayFgMultiplier(B::Dlss, 6, 60, 0) == 6, "unknown rates keep the request");
- check(displayFgMultiplier(B::Dlss, 1, 60, 60) == 1, "no generation requested stays unchanged");
- check(displayFgMultiplier(B::Dlss, 6, 60, 100, true) == 0, "under VSync 60 fps on 100 Hz bypasses: the surplus would queue");
- check(displayFgMultiplier(B::Dlss, 6, 60, 320, true) == 4, "under VSync a fitting lower multiplier is still used");
- check(displayFgMultiplier(B::Dlss, 2, 30, 60, true) == 2, "under VSync a fitting request is unchanged");
- check(displayFgMultiplier(B::XeSS, 4, 60, 144, true) == 0, "under VSync XeSS bypasses when its output does not fit");
- check(displayFgMultiplier(B::XeSS, 2, 60, 144, true) == 2, "under VSync a fitting XeSS request is unchanged");
+ check(displayFgSuggestion(B::Dlss, 6, 60, 320) == 4, "DLSS 6X at 60 fps on 320 Hz suggests 4X (5X is not a DLSS multiplier)");
+ check(displayFgSuggestion(B::Dlss, 4, 60, 320) == 0, "DLSS 4X at 60 fps on 320 Hz fits: no hint");
+ check(displayFgSuggestion(B::Dlss, 2, 60, 320) == 0, "2X below the refresh: no hint");
+ check(displayFgSuggestion(B::Vfg, 8, 60, 320) == 5, "VFG 8X at 60 fps on 320 Hz suggests 5X");
+ check(displayFgSuggestion(B::Dlss, 3, 60, 144) == 2, "3X at 60 fps on 144 Hz suggests 2X");
+ check(displayFgSuggestion(B::Dlss, 4, 60, 240) == 0, "4X at 60 fps on 240 Hz fits exactly");
+ check(displayFgSuggestion(B::Dlss, 2, 60, 119.88) == 0, "2X at 60 fps on 119.88 Hz is within the fit tolerance");
+ check(displayFgSuggestion(B::Dlss, 2, 60, 60) == 1, "60 fps on 60 Hz suggests turning generation off");
+ check(displayFgSuggestion(B::Dlss, 2, 59.94, 60) == 1, "59.94 fps capture on 60 Hz suggests off");
+ check(displayFgSuggestion(B::Dlss, 2, 60, 59.94) == 1, "60 fps on 59.94 Hz suggests off");
+ check(displayFgSuggestion(B::XeSS, 2, 60, 60) == 1, "XeSS 2X with the source filling the panel suggests off");
+ check(displayFgSuggestion(B::Fsr, 2, 60, 60) == 1, "FSR 2X with the source filling the panel suggests off");
+ check(displayFgSuggestion(B::Dlss, 2, 30, 60) == 0, "a 30 fps game with 2X on 60 Hz: no hint");
+ check(displayFgSuggestion(B::Dlss, 4, 30, 60) == 2, "a 30 fps game with 4X on 60 Hz suggests 2X");
+ check(displayFgSuggestion(B::Dlss, 6, 60, 100) == 2, "60 fps on 100 Hz with 6X suggests 2X: it still adds pictures per refresh");
+ check(displayFgSuggestion(B::Dlss, 2, 60, 100) == 0, "60 fps on 100 Hz with 2X: no hint (Automatic replaces the surplus)");
+ check(displayFgSuggestion(B::Dlss, 2, 40, 60) == 0, "40 fps on 60 Hz with 2X: no hint");
+ check(displayFgSuggestion(B::XeSS, 4, 60, 144) == 2, "XeSS 4X at 60 fps on 144 Hz suggests 2X");
+ check(displayFgSuggestion(B::XeSS, 4, 60, 200) == 3, "XeSS 4X at 60 fps on 200 Hz suggests 3X");
+ check(displayFgSuggestion(B::Fsr, 2, 60, 100) == 0, "FSR has no lower multiplier than 2X: no hint on 100 Hz");
+ check(displayFgSuggestion(B::Dlss, 6, 0, 60) == 0 && displayFgSuggestion(B::Dlss, 6, 60, 0) == 0, "unknown rates suggest nothing");
+ check(displayFgSuggestion(B::Dlss, 1, 60, 60) == 0, "no generation requested: no hint");
+ check(displayFgSuggestion(B::Dlss, 6, 60, 100, true) == 1, "under VSync 60 fps on 100 Hz suggests off: the surplus would wait");
+ check(displayFgSuggestion(B::Dlss, 2, 60, 100, true) == 1, "under VSync 2X at 60 fps on 100 Hz suggests off");
+ check(displayFgSuggestion(B::Dlss, 6, 60, 320, true) == 4, "under VSync a fitting lower multiplier is suggested");
+ check(displayFgSuggestion(B::Dlss, 2, 30, 60, true) == 0, "under VSync a fitting request: no hint");
+ check(displayFgSuggestion(B::XeSS, 4, 60, 144, true) == 2, "under VSync XeSS 4X on 144 Hz suggests 2X");
DisplayFgBudgetGate gate(15000000);
- check(gate.update(4, 0) && gate.applied() == 4, "first budget decision applies at once");
+ check(gate.update(4, 0) && gate.applied() == 4, "first hint decision applies at once");
check(!gate.update(0, 10000000) && gate.applied() == 4, "a new decision waits for the hold");
check(!gate.update(2, 20000000) && gate.applied() == 4, "a different candidate restarts the hold");
check(!gate.update(0, 30000000) && !gate.update(0, 44000000) && gate.applied() == 4, "1.4 s of a candidate is not enough");