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 B2: live FG output budget (lower multiplier or bypass)

Veyra Goal Agentf9e6dfc1afc9
diff --git a/apps/veyra/ui/LiveStatusHistory.h b/apps/veyra/ui/LiveStatusHistory.h
index d8b85c19..6bf7e7b0 100644
--- a/apps/veyra/ui/LiveStatusHistory.h
+++ b/apps/veyra/ui/LiveStatusHistory.h
@@ -42,6 +42,12 @@ 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 533adde5..c9dc9839 100644
--- a/docs/LATENCY_MIN_PLAN_2026-10-13.md
+++ b/docs/LATENCY_MIN_PLAN_2026-10-13.md
@@ -26,7 +26,7 @@
| **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 周期内完成 睡眠→读输入→提交→送显,修正周期错位 | 去掉 CPU 等 GPU 的约 7ms 和轮询抖动;XeLL 的队列控制按设计生效 | 320Hz/60Hz 下 XeSS 回调→送显、真帧率、XeLL 睡眠时长;画面校验无错帧 |
-| **B2 补帧输出预算** | 内容帧率×倍数 > 0.97×刷新率时:DLSS/FSR/VFG 自动降到能放下的合法倍数;连 2X 都放不下(如 60Hz 屏 + 60fps 源)就旁路补帧,真帧直接显示、不等插帧;XeSS 用 SetEnabled(false) 旁路;带迟滞防抖,状态栏说明原因 | 不浪费 GPU、动作均匀;60Hz+60fps 时延迟等于仅 NR | DLSS 6X@320Hz 自动降到 4X;60Hz 下 2X 旁路;30fps 游戏 + 2X@60Hz 不被误判 |
+| **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 |
| **B3 “垂直同步”也不排队** | 用户显式选垂直同步时,在读采集帧之前等待可等待对象(≤1 个刷新),不在送显前等;XeSS 代理最大延迟设 1;“低延迟队列”改成这个语义 | 垂直同步模式下的排队上限 1 帧 | DLSS 6X@320Hz 垂直同步模式送显→上屏≈1 个刷新;回调→送显不升 |
| **C1 VRR 研究** | 用户在驱动开启 G-SYNC/FreeSync 后,实测“自动”是否触发可变刷新;若不触发,评估“垂直同步 + B2 输出预算(输出始终低于最高刷新)”的 VRR 模式(不会撕裂) | 少等 0–1 个刷新(60Hz 平均约 8ms) | 需用户开启 VRR;对比送显→上屏 |
| **C2 独立翻转确认** | 用 PresentMon(需管理员)确认全屏/窗口的呈现模式;窗口合成会多 1 个刷新 | 明确“全屏更低”的条件或修掉窗口合成 | PresentMon PresentMode 列 |
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index d53815e8..b221042e 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -9357,3 +9357,13 @@ v2.0.7 ID 410800361,published_at 2026-10-12T16:24:59Z,latest/非草稿/非
测试(私有程序副本 tests/claude-latency-min-20261013/app):veyra_repair_contract_tests 259 项 0 失败;veyra_ui_contract_tests 通过;新验收 `scripts/acceptance/latency-min-tests.py` display-sync 12/12(窗口/全屏×低延迟队列×三种模式,实际 Present 参数:自动 sync=0 flags=0,垂直同步 sync=1,允许撕裂 0x200;像素校验通过,D3D12 错误 0),lifecycle 通过。历史 2.0.6 验收脚本仍写死“自动=sync1”,按规则不改旧脚本。
实卡(T911 2K60 NV12 → NR,320Hz,内容不去重):DLSS 6X(360fps 超刷新率)送显→上屏 P50/P95 由垂直同步语义的 11.8/18.3ms 降到 6.2/8.0ms,插帧过期 44→0.6/s,邮箱等待 11.2→0.3ms;同一 EXE 显式垂直同步仍为 12.2/18.4ms(B3 待做);DLSS 4X 5.4/7.0ms 与改前一致;XeSS 2X 自动 sync=0 flags=0,补帧正常 120fps,回调→送显 P95 10.0ms;仅 NR 8.9ms、送显→上屏 4.5ms。60Hz PBP 下 XeSS 超刷新率场景本机无法复现,需用户光学复测。日志 logs/claude-latency-min-20261013/<场景>/。
+
+## 2026-10-13 极限低延迟 B2 补帧输出预算(Claude)
+
+用户“全部做掉!”授权 B1–C3。B2:直播来源(采集/串流/屏幕)按 内容帧率×倍数 与屏幕刷新率决定实际倍数(`include/veyra/engine/DisplayFgBudget.h`):输出放得下不变;放不下降到放得下的最大合法倍数(DLSS 2/3/4/6、VFG 2–8、FSR 2);连 2X 都放不下但源比屏幕慢(60fps@100Hz)保留 2X;源已占满屏幕(≥0.97×刷新,60fps@60Hz)旁路补帧。XeSS 只做旁路(SetNumInterpolatedFrames 按 Intel 文档会换模型/编译着色器,不做运行中降倍数)。新决定须持续 1.5 秒才生效,设置变更立即重算;“允许撕裂”不做预算;文件播放不受影响。旁路时图不跑补帧、不跑只供补帧的光流/XeSS 运动精修与拷贝,恢复时补帧与光流历史重置;真帧不再等插帧间隔(配对延迟 0),读帧门按“未补帧”处理。刷新率改为换屏或每 2 秒重读。状态栏显示“屏幕 X Hz 只显示得下 NX:已从 MX 降到 NX”或“补帧已旁路,真帧直接显示(延迟最低)”,输出评估不再误报“输出未达标”。测试开关:`VEYRA_TEST_NO_DISPLAY_FG_BUDGET=1` 恢复旧行为,`VEYRA_TEST_DISPLAY_HZ=<hz>` 只替换预算使用的刷新率。
+
+计划修正:原方案“连 2X 都放不下就旁路”在 60fps@75–119Hz 会丢掉补帧带来的额外画面,改为“源已占满屏幕才旁路”。
+
+构建:build.py 新增目标 veyra_realtime_preview_tests,并对包含改动头文件的 Qt moc 生成源重编(快照结构变化,不能混用旧布局);回执 logs/claude-latency-min-20261013/build-20261013-213309,check_rebuilt 所有链接对象已重编。测试:veyra_realtime_preview_tests 0 失败(新增预算 19 项、防抖 7 项)、veyra_repair_contract_tests、veyra_ui_contract_tests 通过。
+
+实卡(T911 2K60 NV12 → NR,320Hz,logs/claude-latency-min-20261013/b2-*):DLSS 6X 自动→4X:送显 360→240/s,补帧 GPU P95 7.4→5.7ms,送显→上屏 P50/P95 6.2/8.0→5.0/6.9ms(等于原生 4X);同 EXE 关预算对照 6X 为 5.6/9.5ms、回调→送显 P95 28.6 vs 26.5ms。显式垂直同步 6X:12.2/18.4→5.7/8.5ms,插帧过期 46→0/s,邮箱等待 10.7→0.3ms。模拟 60Hz(测试开关)DLSS 2X 旁路:回调→送显 P95 8.8ms,与仅 NR 8.9ms 相同(补帧时约 26ms);XeSS 2X 旁路:SDK 提交 120→60/s、enabled=0、Present 调用 0.64→0.20ms;60→30(30fps 内容)+2X@60Hz 保持 2X(60/s)。仅 NR 不变(8.9ms)。真实 60Hz 屏幕的光学复测仍需用户。
diff --git a/i18n/catalog.json b/i18n/catalog.json
index 11eaf599..703d70e7 100644
--- a/i18n/catalog.json
+++ b/i18n/catalog.json
@@ -15730,6 +15730,20 @@
"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 に下げました"
}
]
}
diff --git a/include/veyra/engine/DisplayFgBudget.h b/include/veyra/engine/DisplayFgBudget.h
new file mode 100644
index 00000000..18538162
--- /dev/null
+++ b/include/veyra/engine/DisplayFgBudget.h
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-3.0-only
+#pragma once
+#include "veyra/engine/EnhancementSettings.h"
+#include <cmath>
+#include <cstdint>
+
+namespace veyra::engine {
+// Live frame-generation output budget (claude/latency-min-20261013 B2).
+//
+// 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: it still shows more distinct pictures per refresh;
+// 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 rule 4 applies (xefgSwapChainSetEnabled).
+inline constexpr double kDisplayFgFitTolerance=1.02;
+inline constexpr double kDisplayFgFillRatio=0.97;
+
+constexpr bool displayFgMultiplierSupported(FrameGenerationBackend backend,unsigned multiplier){
+ switch(backend){
+ case FrameGenerationBackend::Dlss: return multiplier==2||multiplier==3||multiplier==4||multiplier==6;
+ 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].
+// Unknown rates keep the request.
+inline unsigned displayFgMultiplier(FrameGenerationBackend backend,unsigned requested,double contentFps,double refreshHz){
+ 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||backend==FrameGenerationBackend::XeSS)return requested;
+ for(unsigned m=requested-1;m>=2;--m)
+ if(displayFgMultiplierSupported(backend,m)&&contentFps*m<=refreshHz*kDisplayFgFitTolerance)return m;
+ return 2;
+}
+
+// A changed decision applies 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.
+class DisplayFgBudgetGate {
+public:
+ explicit DisplayFgBudgetGate(int64_t hold100ns=15000000):hold_(hold100ns){}
+ void reset(){valid_=pendingValid_=false;}
+ // Returns true when the applied decision changed.
+ bool update(unsigned decision,int64_t now){
+ if(!valid_){applied_=decision;valid_=true;pendingValid_=false;return true;}
+ if(decision==applied_){pendingValid_=false;return false;}
+ if(!pendingValid_||pending_!=decision){pending_=decision;since_=now;pendingValid_=true;return false;}
+ if(now-since_<hold_)return false;
+ applied_=decision;pendingValid_=false;return true;
+ }
+ bool valid()const{return valid_;}
+ unsigned applied()const{return applied_;}
+private:
+ int64_t hold_,since_=0;
+ unsigned applied_=0,pending_=0;
+ bool valid_=false,pendingValid_=false;
+};
+}
diff --git a/include/veyra/engine/EngineController.h b/include/veyra/engine/EngineController.h
index c8078f84..56e4b33a 100644
--- a/include/veyra/engine/EngineController.h
+++ b/include/veyra/engine/EngineController.h
@@ -118,6 +118,13 @@ 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;
+ double displayFgRefreshHz=0,displayFgContentFps=0;
// 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/VideoPresenter.h b/include/veyra/engine/VideoPresenter.h
index 00c7d836..7fbeaf01 100644
--- a/include/veyra/engine/VideoPresenter.h
+++ b/include/veyra/engine/VideoPresenter.h
@@ -66,6 +66,10 @@ public:
// per-frame history reset, never a per-frame toggle.
void setXessGenerationSuppressed(bool v){xessGenerationSuppressed_=v;}
bool xessGenerationSuppressed() const {return xessGenerationSuppressed_;}
+ // Monitor refresh for the live output budget. The swap chain samples it
+ // only at creation; the window may move to another monitor or the mode
+ // may change, so it is re-read on a monitor change and every 2 s.
+ double displayRefreshHz();
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
@@ -135,6 +139,8 @@ private:
bool xessWasEnabled_=false;
bool xessFailed_=false;
bool xessGenerationSuppressed_=false;
+ HMONITOR refreshMonitor_=nullptr;double refreshHz_=0;
+ std::chrono::steady_clock::time_point refreshQuery_{};
uint32_t xessInputId_=0;
struct XessWork {pipeline::FrameIdentity identity{};uint32_t id=0;};
std::array<XessWork,4> xessWork_{};
diff --git a/include/veyra/gfx/PresentSink.h b/include/veyra/gfx/PresentSink.h
index a48c31f6..6ccded50 100644
--- a/include/veyra/gfx/PresentSink.h
+++ b/include/veyra/gfx/PresentSink.h
@@ -131,6 +131,8 @@ public:
};
DisplayLatencySummary takeDisplayLatency();
double displayRefreshHz()const{return displayRefreshHz_;}
+ // The owner re-reads the monitor after a move or mode change.
+ void setDisplayRefreshHz(double hz){if(hz>=1.0)displayRefreshHz_=hz;}
bool configurePacing(bool enabled,bool vsync,bool tearing);
bool presentationReady();
bool pacingActive()const{return pacing_;}
diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.h
index 8cd0e00f..14e6bc8d 100644
--- a/include/veyra/pipeline/EnhanceGraph.h
+++ b/include/veyra/pipeline/EnhanceGraph.h
@@ -468,6 +468,12 @@ 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;
@@ -866,6 +872,10 @@ 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/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index e87c4444..749ec71d 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -22,6 +22,7 @@
#include "veyra/engine/RealtimePreviewScheduling.h"
#include "veyra/engine/CaptureHalfRate.h"
#include "veyra/engine/ContentDedup.h"
+#include "veyra/engine/DisplayFgBudget.h"
#include "veyra/source/MediaFileSource.h"
#include "veyra/source/CaptureCardSource.h"
#include "veyra/source/DeckLinkCapture.h"
@@ -966,6 +967,13 @@ 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;
+ // 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;
+ 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;
int64_t nextFgAdmissionLog=0,nextFgRejectionLog=0;
@@ -1532,14 +1540,15 @@ 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=[&]{
- if(presentationEffective.enabled&&!options.fg&&(isCapture||!fileAwaitingVideo)&&liveScheduler->occupancy()>=1)return true;
+ const bool fgRunning=options.fg&&!fgBypassed;
+ if(presentationEffective.enabled&&!fgRunning&&(isCapture||!fileAwaitingVideo)&&liveScheduler->occupancy()>=1)return true;
// Live sources: never stack a second frame behind one the GPU
// is still enhancing. When NR/SR cost more than one source
// interval, a second queued frame doubled capture-to-present
// latency (3 NR layers at 1440p60: 49 ms for 20 ms of GPU
// work); waiting and then taking the newest mailbox sample
// keeps it at one GPU pass. No effect while the GPU keeps up.
- return isCapture&&!(options.fg&&presentSinkFrameGeneration(options.settings.frameGenerationBackend))&&!pendingCompletions.empty();
+ return isCapture&&!(fgRunning&&presentSinkFrameGeneration(options.settings.frameGenerationBackend))&&!pendingCompletions.empty();
};
const auto leaseWaitStart=Clock::now();
while((liveScheduler->occupancy()>=2||!graph->nextFrameSlotAvailable()||enhancementPending())&&!stop_&&(!paused_||seekPreviewPending)&&!liveScheduler->failed()){
@@ -1864,7 +1873,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
nextFgAdmissionLog=now+10000000;if(!admitted)nextFgRejectionLog=now+10000000;
veyra::log::info("live-fg-admission",std::format("timeline={} revision={} source={} multiplier={} requestedMultiplier={} admitted={} admittedPairs={} rejectedPairs={} remainingDeadlineMs={:.3f} firstDeadlineMs={:.3f} queuedGpuMs={:.3f} predictedMs={:.3f} elapsedMs={:.3f} blitGpuP95Ms={:.3f} presentCpuP95Ms={:.3f} warmingHistory={} (CPU Present is backpressure, not added GPU cost; firstDeadlineMs=-1 when unused)",timeline,batch.identity.settingsRevision,batch.identity.sourceFrameId,previewFgMultiplier,options.fgMultiplier,admitted,fgAdmittedPairs,fgRejectedPairs,double(deadline-now)/10000,firstDeadline?double(firstDeadline-now)/10000:-1,queuedMs,fgBudget.predicted(now,warmingHistory).value_or(-1),elapsed,blit,livePresent.p95(),warmingHistory));
};
- if(fgBudgetRevision!=options.settings.revision){fgBudget.reset();vfgOverload.reset();pairLatency.reset();fgBudgetRevision=options.settings.revision;}
+ if(fgBudgetRevision!=options.settings.revision){fgBudget.reset();vfgOverload.reset();pairLatency.reset();fgBudgetRevision=options.settings.revision;displayFgGate.reset();}
previewFgMultiplier=options.fgMultiplier;
// An output cap used to only drop candidates at present time, so
// the GPU still generated frames that were thrown away: at 6X on
@@ -1883,6 +1892,39 @@ 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.
+ {
+ const bool budgeted=displayFgBudgetEnabled&&isCapture&&!isImage&&options.fg&&options.fgMultiplier>1&&
+ presentationEffective.display!=DisplaySync::Tearing;
+ double contentFps=0,refreshHz=0;
+ if(budgeted){
+ // Content rate: 60->30 halves the transport; dedup uses its
+ // measured cadence and decides 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),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();}
+ }
+ }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_.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
@@ -1891,16 +1933,17 @@ 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&&options.fg&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)?
+ const auto processingAllowance=isCapture&&fgActive&&!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.
- const auto legacyPairDelay=presentSinkFrameGeneration(options.settings.frameGenerationBackend)?0:liveInterval+processingAllowance;
- const auto pairDelay=adaptiveCapturePhase&&options.fg&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)?
+ // 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)?
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&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)){
+ if(isCapture&&!rereadCached&&fgActive&&!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
@@ -2126,15 +2169,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&&options.fg;
+ const bool pairPacing=pairAnchoredLive&&fgActive;
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=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);
+ 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);
}
if(!isImage&&!isCapture&&frames==0){anchor=Clock::now();anchorMs=lastAudioClockMs=pts;}
double frameWaitMs=0,framePresentMs=0;
@@ -2456,7 +2499,7 @@ 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();
+ snapshot_.xessGenerationSuppressed=graph->xessEnabled()&&presenter.xessGenerationSuppressed()&&!fgBypassed; // budget bypass is not an overload
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 821af503..9ec4f46f 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;
+ viewWidth_=viewHeight_=0;bufferMonitor_=nullptr;monitorWidth_=monitorHeight_=0;refreshMonitor_=nullptr;refreshHz_=0;refreshQuery_={};
++generation_;
Status st=Status::Ok;
// Keep one presentation queue for the native chain's lifetime. A later
@@ -413,6 +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_={};
retainedFrame_.reset();
xessInputId_=0;xessWork_={};xessWorkPosition_=0;
reflex_.close();reflexFrame_=0;
@@ -423,6 +424,17 @@ void VideoPresenter::close(){
if(presentationEvent_){CloseHandle(presentationEvent_);presentationEvent_=nullptr;}
presentationDevice_=nullptr;presentationFormat_=DXGI_FORMAT_UNKNOWN;window_=nullptr;
}
+double VideoPresenter::displayRefreshHz(){
+ if(!window_)return 0;
+ const auto now=std::chrono::steady_clock::now();
+ const auto monitor=MonitorFromWindow(window_,MONITOR_DEFAULTTONEAREST);
+ if(monitor!=refreshMonitor_||now-refreshQuery_>=std::chrono::seconds(2)){
+ const double hz=gfx::PresentSink::displayRefreshFps(window_);
+ 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);
+ }
+ return refreshHz_;
+}
PresentationSettings VideoPresenter::configurePresentation(gfx::D3D12DeviceContext& ctx,PresentationSettings requested,bool fg,std::wstring& status){
bool wanted=requested.hdrFgCompatibility&&copyEligible_;
wchar_t copyOverride[4]{};
diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cpp
index ffbb9040..85f9446a 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;cadence_.reset();scene_.reset();sceneLastSourceId_=0;previousLuma_.clear();
+ desc_ = desc;lastSourceColor_={};tracker_={};prevValid_=false;fgHistorySkipped_=false;flowStale_=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,10 +2359,19 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
};
// Guidance from original source-space color before SR/NR. Queue waits are GPU-side.
bool haveFlow = false;
- const bool runMotion = nvofStandalone_ || (presentSinkFg()&&desc_.fgUsesFlow()) || (fgEnabled_&&desc_.fgUsesFlow()) || (srEnabled_&&desc_.srUsesFlow()&&(desc_.videoSrQuality==0||desc_.videoSrQuality==engine::kVideoSrFsr));
- if (runMotion && (gpuDis_ || amdOf_ || (nvof_ && nvof_->initialized()))) {
+ // 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 float dims[8] = {uintBits(nvofW_),uintBits(nvofH_),uintBits(nvofW_),uintBits(nvofH_),0,0,0,0};
- if (prevValid_) {
+ if (flowPrevValid) {
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);
@@ -2378,11 +2387,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(),!prevValid_))return false;
- ++metrics_.amdOfExecuteCount;haveFlow=prevValid_;
- if(!flowRefine_||!haveFlow)gpuTimer_.mark(list,GpuStage::Flow,true);
+ if(!amdOf_->dispatch(list,nvofInB_.Get(),!flowPrevValid))return false;
+ ++metrics_.amdOfExecuteCount;haveFlow=flowPrevValid;
+ if(!refineFlow||!haveFlow)gpuTimer_.mark(list,GpuStage::Flow,true);
}
- if(gpuDis_ && prevValid_){
+ if(gpuDis_ && flowPrevValid){
gpuTimer_.mark(list,GpuStage::Flow);
tracker_.transition(list,flowTex_.Get(),D3D12_RESOURCE_STATE_COMMON);
tracker_.transition(list,confTex_.Get(),D3D12_RESOURCE_STATE_COMMON);
@@ -2394,7 +2403,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
++metrics_.gpuDisExecuteCount;haveFlow=true;
gpuTimer_.mark(list,GpuStage::Flow,true);
}
- if (prevValid_ && !gpuDis_) {
+ if (flowPrevValid && !gpuDis_) {
if(!amdOf_){
gpuTimer_.mark(list,GpuStage::Flow);
if(!submitGraph(slot))return false;
@@ -2413,7 +2422,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(!flowRefine_||!haveFlow)gpuTimer_.mark(list,GpuStage::Flow,true);
+ if(!refineFlow||!haveFlow)gpuTimer_.mark(list,GpuStage::Flow,true);
}
if(haveFlow) {
if(amdOf_)tracker_.transition(list,amdOf_->sceneChanges(),D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
@@ -2428,7 +2437,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(flowRefine_){
+ if(refineFlow){
// 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);
@@ -2486,7 +2495,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(flowRefine_){
+ if(refineFlow){
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);
@@ -2933,7 +2942,10 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
tracker_.transition(list, videoFrame_[parity].Get(), D3D12_RESOURCE_STATE_COMMON);
}
- if(presentSinkFg()){
+ if(presentSinkFg()&&fgBypass_){
+ // Bypassed: the presenter disables XeSS generation and reads no motion.
+ presentMotionValid_[parity]=false;motionPreviousSource_[parity]=previousSource_;
+ }else 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();
@@ -2948,7 +2960,10 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
motionPreviousSource_[parity]=previousSource_;
}
previousSource_=sourceFrameId;
- const bool fgBackendAvailable=fgEnabled_&&fgCreated();
+ // 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 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 e6bd74a4..770dfefe 100644
--- a/src/ui/QmlPlayerBridge.cpp
+++ b/src/ui/QmlPlayerBridge.cpp
@@ -6497,6 +6497,11 @@ 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);
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
@@ -6524,7 +6529,7 @@ void QmlPlayerBridge::updateRunStatus() {
else detail << tr("VFG 每张约 %1 ms,当前负载约可稳定 %2X").arg(*perRun, 0, 'f', 1).arg(fits);
}
}
- if (refresh > 1 && source > 1 && source * s.applied.multiplier > refresh * 1.02)
+ if (!s.displayFgLimited && 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);
diff --git a/tests/unit/RealtimePreviewSchedulingTests.cpp b/tests/unit/RealtimePreviewSchedulingTests.cpp
index 2b576846..f70ee4e7 100644
--- a/tests/unit/RealtimePreviewSchedulingTests.cpp
+++ b/tests/unit/RealtimePreviewSchedulingTests.cpp
@@ -4,6 +4,7 @@
// relative to enhancement cost; only the enhancement opportunity of an
// expired candidate is dropped.
#include "veyra/engine/RealtimePreviewScheduling.h"
+#include "veyra/engine/DisplayFgBudget.h"
#include <algorithm>
#include <cstdint>
#include <iostream>
@@ -132,6 +133,40 @@ int main() {
check(!gate.suppressed(), "reset clears suppression state");
}
+ // --- Live FG output budget (latency-min B2)
+ {
+ 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");
+
+ DisplayFgBudgetGate gate(15000000);
+ check(gate.update(4, 0) && gate.applied() == 4, "first budget 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");
+ check(gate.update(0, 45000000) && gate.applied() == 0, "a candidate held 1.5 s applies");
+ check(!gate.update(0, 46000000), "an unchanged decision reports no change");
+ gate.reset();
+ check(!gate.valid() && gate.update(6, 47000000) && gate.applied() == 6, "reset applies the next decision at once");
+ }
+
std::cout << "failures=" << failures << '\n';
return failures ? 1 : 0;
}