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

fix: preserve steady preview cadence under measured FG overload

Veyra Goal Agent00508702bdca
diff --git a/apps/veyra/SettingsWindow.cpp b/apps/veyra/SettingsWindow.cpp
index d131a999..7c3dd1b4 100644
--- a/apps/veyra/SettingsWindow.cpp
+++ b/apps/veyra/SettingsWindow.cpp
@@ -1682,6 +1682,8 @@ case WM_TIMER:{auto s=controller->snapshot();putText(1150,s.presentationStatus.c
o<<L"期望版本 "<<s.desired.revision<<L" / 已应用 "<<s.applied.revision<<(s.applying?L" · 应用中":L"");
const wchar_t* backend=s.applied.frameGenerationBackend==engine::FrameGenerationBackend::XeSS?L"XeSS":s.applied.frameGenerationBackend==engine::FrameGenerationBackend::Fsr?L"AMD FSR":L"DLSS";
o<<L"\n"<<backend<<L" · "<<(s.applied.multiplier<=1?L"补帧关闭":s.fgActive?L"补帧运行":L"等待有效补帧");
+ if(s.applied.multiplier>1&&s.previewFgMultiplier>1&&s.previewFgMultiplier<s.applied.multiplier)
+ o<<L" · 目标 "<<s.applied.multiplier<<L"X / 当前 "<<s.previewFgMultiplier<<L"X";
if(!s.backendWarning.empty())message(s.backendWarning);
else if(!displayedBackendWarning.empty())message(L"设置已应用");
displayedBackendWarning=s.backendWarning;
diff --git a/apps/veyra/ui/LiveStatusPanel.h b/apps/veyra/ui/LiveStatusPanel.h
index 1b83ad89..12e2d53e 100644
--- a/apps/veyra/ui/LiveStatusPanel.h
+++ b/apps/veyra/ui/LiveStatusPanel.h
@@ -55,6 +55,8 @@ inline LRESULT CALLBACK proc(HWND h,UINT message,WPARAM wp,LPARAM lp){
else if(old(f.lastPresent100ns))progress=L"GPU已就绪,等待呈现";
}
rows.emplace_back(L"状态",progress);
+ if(playing&&s.applied.frameGenerationBackend==engine::FrameGenerationBackend::Dlss&&s.applied.multiplier>1&&s.previewFgMultiplier>1)
+ rows.emplace_back(L"补帧倍率 · 目标 / 调度",std::format(L"{}X / {}X",s.applied.multiplier,s.previewFgMultiplier));
if(!s.capture)rows.emplace_back(L"媒体播放速度",playing?std::format(L"{:.2f} x",s.playbackSpeed):L"未测");
if(!s.capture&&!s.image){
rows.emplace_back(L"预览状态",!playing?L"未运行":s.previewSkipped?std::format(L"已跳帧 {}",s.previewSkipped):s.fgBudgetLimited?L"补帧预算不足":L"正常");
diff --git a/docs/FG_CADENCE_REPAIR_PLAN_2026-09-20.md b/docs/FG_CADENCE_REPAIR_PLAN_2026-09-20.md
new file mode 100644
index 00000000..90cb98e2
--- /dev/null
+++ b/docs/FG_CADENCE_REPAIR_PLAN_2026-09-20.md
@@ -0,0 +1,22 @@
+# Fixed-media DLSS cadence repair
+
+User authorized repair, checkpointing validated improvements, testing p001.mp4 with NR / 4K target / DLSS 6X and comparison to 2X, then shutdown after reporting. Starting checkpoint: dad189a, tag checkpoint/pre-fg-cadence-repair-20260920. Work remains on codex/fg-cadence-audit-20260920; no publish authorization.
+
+Media: E:/项目/Likely7 个人账号/Deepseek Grok/p001.mp4. ffprobe reports H.264 yuv420p 3840x2160 60/1, AAC, 333.764 seconds. A 4K target does not upscale an already 4K source; report actual graph sizes and enabled stages rather than claim SR execution from its UI flag.
+
+1. Baseline matched file playback 2X/6X and bounded live replay as needed. Use original NR realtime policy and fixed 4K target, same display size, pacing disabled. Never interpret software FPS as scanout.
+2. Inspect submission, temporal recovery and deadline models; fix evidenced scheduling defects. Preserve real resets, bounded queues, audio speed and export behavior. Investigate increasing command slots or scheduling changes only with measured evidence and resource lifetime checks.
+3. Compare stable cadence, source continuity, valid generated frames, PTS, latency and CPU/GPU timing, not only average FPS. If 6X exceeds compute capacity, prioritize sustainable even output and retain requested quality/multiplier semantics honestly.
+4. Build main program and affected tests; run CPU policy tests, GPU reset/admission regression and fixed-media playback. Each run <=300 seconds. Commit verified improvements individually. Record failures and reverted experiments.
+5. Write final report with rollback points, available build path and unmeasured display/hardware boundaries, then request Windows shutdown as authorized.
+
+New outputs: E:/项目/Veyra/tests/fg-cadence-repair-20260920, logs/fg-cadence-repair-20260920, tmp/fg-cadence-repair-20260920. Reuse build/slider-reset-20260919; no source-tree artifacts.
+
+## Implementation and rejected experiments
+
+- File presentation now resolves each frame's own fence and interpolation status, as capture already does, instead of waiting for the entire generated batch.
+- Moving DLSS preview measures base GPU work and cost per generated frame over 60 samples. After 30 samples, persistent overload lowers the effective multiplier (15 confirmations); sustained headroom restores it (120 confirmations). Down/up headroom thresholds are 90%/82% of the source interval. The saved request remains unchanged and UI reports the scheduled multiplier separately. Unknown cost preserves the request. This is a measured-cost heuristic, not a guarantee of scanout cadence.
+- The graph uses the effective number for NGX evaluations and interpolation PTS. Queued batches keep their own size for pacing. Export/default graph calls retain the configured full multiplier. Provider-owned XeSS/FSR pacing is excluded from this DLSS controller.
+- Combining all MFG evaluations into a single command list reduced measured output to about 72 FPS; reverted. Servicing older presentations during producer slot waits reached only about 89 FPS; reverted. No CommandSlotRing changes retained.
+- XeSS is included in the active goal. Test the same media/effects at 2X and 4X, checking SDK generation counters separately from application Present calls; provider-owned subframe timing needs separate evidence.
+- Final acceptance: sustained matched DLSS 6X/2X; XeSS 2X/4X; dynamic multiplier GPU validity/PTS and recovery tests; CPU policy and application lifecycle/startup. Results belong in FG_CADENCE_REPAIR_ACCEPTANCE_2026-09-20.md.
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 387e2472..68b56d2e 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -4724,3 +4724,13 @@ Blackwell 上会改变一条已经正常工作的路径,无法区分"补丁生
- PowerShell `Select-String`、正则字段摘取核对5080日志:87条admission采样均true,11:35:30至34累计拒绝固定9,但暖机/过期增长且中间有120fps提交。避免将累计拒绝误算为每秒新增,也避免把XeSS套用DLSS门禁。
- 方案新增2.5节:分离计算成本与显示反压、逐子帧期限、连续恢复、供给阻塞及对应测试矩阵。预算数值例子仅为算式推演,没有冒充实机结果。
- 本轮仅修改方案与WORKLOG,未改产品代码、未构建、未运行新单测或实卡测试、未生成包或发布;没有新增仓库外产物。
+## 2026-09-20 Fixed-media cadence fallback checkpoint (not final 6X repair)
+
+Branch: codex/fg-cadence-audit-20260920; starting checkpoint dad189a.
+User media p001.mp4 is 3840x2160/60 H.264. NR realtime1080 and 4K output; SR does not run when input already matches target. Baseline target6X: 81.61 average software submissions/s, retained trace 79.37/s with 182 gaps below 1ms and 499 above 16.667ms. Baseline2X: 120/s.
+
+Implemented per-frame file readiness and measured preview capacity fallback. Requested settings remain saved; actual scheduling multiplier and PTS agree. Export uses default full multiplier. Final build via scripts/build-isolated.ps1 succeeded; veyra_presentation_worker_tests passed 110 checks. Final6 ran 120s: steady 240/s at actual4X, retained 7.579s P95 4.5733ms / max5.0918ms, no sub-ms or >16.667ms gaps. Final2 ran45s: mean119.913/s, retained P95 8.8444ms / max9.1539ms. GPU admission6 on actual4K media passed dynamic2/4/6/default, reset/recovery, generated texture nonblack and PTS checks, D3D12 errors0. These do not prove full6X or physical display quality.
+
+Outputs: E:/项目/Veyra/tests/fg-cadence-repair-20260920 (baseline2/6, final2/6, admission6, JSON traces), logs/fg-cadence-repair-20260920 (final-build.log, cpu-final.log), tmp/fg-cadence-repair-20260920; build reused build/slider-reset-20260919. All tests run using scripts/run-short-test.ps1, limits <=185s. Combining FG command lists and servicing presentation during slot waits did not sufficiently improve throughput and were reverted.
+
+User explicitly clarified automatic downshift is only a fallback; full6X uneven presentation still must be investigated. Saving this verified improvement before further fixed6X experiments. XeSS and final lifecycle verification remain pending. No package, push, release or shutdown yet.
diff --git a/include/veyra/engine/EngineController.h b/include/veyra/engine/EngineController.h
index 28f8fc01..66507979 100644
--- a/include/veyra/engine/EngineController.h
+++ b/include/veyra/engine/EngineController.h
@@ -72,6 +72,7 @@ struct PlayerSnapshot {
uint64_t pausedFrameRefreshes=0;
double playbackSpeed=0;
bool fgBudgetLimited=false,xessGenerationSuppressed=false;
+ unsigned previewFgMultiplier=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/PreviewFgCapacity.h b/include/veyra/engine/PreviewFgCapacity.h
new file mode 100644
index 00000000..103c7efd
--- /dev/null
+++ b/include/veyra/engine/PreviewFgCapacity.h
@@ -0,0 +1,40 @@
+#pragma once
+#include <algorithm>
+#include <cmath>
+#include <cstdint>
+#include <deque>
+
+namespace veyra::engine {
+// Real-time preview only. Keep headroom for presentation and scheduling;
+// use sustained measured work, never a single late CPU observation.
+class PreviewFgCapacity {
+ struct Cost { double base, perGenerated; };
+ std::deque<Cost> costs_;
+ unsigned effective_=0, candidate_=0, confirmations_=0;
+public:
+ void reset(){costs_.clear();effective_=candidate_=confirmations_=0;}
+ void observe(double whole,double fg,unsigned calls){
+ if(!calls||!std::isfinite(whole)||!std::isfinite(fg)||fg<=0||whole<fg)return;
+ costs_.push_back({whole-fg,fg/calls});
+ if(costs_.size()>60)costs_.pop_front();
+ }
+ unsigned select(unsigned requested,double intervalMs){
+ requested=std::clamp(requested,2u,6u);
+ if(!effective_)effective_=requested;
+ effective_=std::min(effective_,requested);
+ if(costs_.size()<30||!std::isfinite(intervalMs)||intervalMs<=0)return effective_;
+ double base=0,per=0;
+ for(auto c:costs_){base+=c.base;per+=c.perGenerated;}
+ base/=costs_.size();per/=costs_.size();
+ unsigned target=2;
+ for(unsigned n=2;n<=requested;++n)
+ if(base+per*(n-1)<=intervalMs*(n>effective_?.82:.90))target=n;
+ if(target==effective_){candidate_=target;confirmations_=0;return effective_;}
+ if(candidate_!=target){candidate_=target;confirmations_=0;}
+ if(++confirmations_>=(target<effective_?15u:120u)){
+ effective_=target;confirmations_=0;
+ }
+ return effective_;
+ }
+};
+}
diff --git a/include/veyra/pipeline/EnhanceGraph.h b/include/veyra/pipeline/EnhanceGraph.h
index 803ecdf0..fde54150 100644
--- a/include/veyra/pipeline/EnhanceGraph.h
+++ b/include/veyra/pipeline/EnhanceGraph.h
@@ -174,7 +174,7 @@ public:
// `hardwareSurface` carries the decoded texture for paths whose surface
// 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 = {});
+ 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 nextFrameSlotAvailable()const {
const unsigned slot=unsigned(realFrameIndex_%2);
if(presentationFences_[slot]&&presentationFences_[slot]->GetCompletedValue()<presentationValues_[slot])return false;
diff --git a/scripts/acceptance/analyze-fg-cadence.py b/scripts/acceptance/analyze-fg-cadence.py
index 0c46e175..912bc66d 100644
--- a/scripts/acceptance/analyze-fg-cadence.py
+++ b/scripts/acceptance/analyze-fg-cadence.py
@@ -94,7 +94,7 @@ def analyze_trace(path):
return "unknown"
if int(submit["detail"]) > 0:
return "rejected"
- return "warmup" if submit["count"] == "1" else "steady"
+ return "warmup" if batch in only_real and submit["count"] == "1" else "steady"
transitions = {}
for a, b in zip(complete, complete[1:]):
key = state(a) + "->" + state(b)
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index 3b4d8b92..744cb13b 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -13,6 +13,7 @@
#include "veyra/engine/FrameFlowWindow.h"
#include "veyra/engine/LiveFgAdmission.h"
#include "veyra/engine/FgRecoveryBudget.h"
+#include "veyra/engine/PreviewFgCapacity.h"
#include "veyra/engine/LivePairLatency.h"
#include "veyra/engine/RealtimePreviewScheduling.h"
#include "veyra/engine/CaptureHalfRate.h"
@@ -478,6 +479,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
TimingWindow livePresent{std::chrono::seconds(1)};
TimingWindow livePresentGpu{std::chrono::seconds(1)};
FgRecoveryBudget fgBudget;uint64_t fgBudgetRevision=options.settings.revision;
+ PreviewFgCapacity fgCapacity;unsigned previewFgMultiplier=options.fgMultiplier;
LivePairLatency pairLatency;
const bool adaptiveCapturePhase=physicalCapture&&GetEnvironmentVariableW(L"VEYRA_TEST_LEGACY_CAPTURE_PHASE",nullptr,0)==0;
int64_t nextFgAdmissionLog=0,nextFgRejectionLog=0;
@@ -579,7 +581,9 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
traceFrame(diagnostics::TraceKind::Ready,batch.batch.identity,batch.batch.batchId,std::max(batch.videoFenceValue,batch.genFenceValue),batch.batch.b100ns,invalid,valid,elapsedMs(watch.processStart));
if(watch.real)completedProcessing(batch.batch.identity);
if(batch.batch.identity.settingsRevision==fgBudgetRevision)fgBudget.complete(watch.gpuExecutionMs,batch.fgEvaluated>0,batch.historyReset||batch.fgRecovery,host100ns(),watch.fgExecutionMs);
- if(adaptiveCapturePhase&&watch.captureArrival>0&&valid==options.fgMultiplier-1&&
+ if(batch.batch.identity.settingsRevision==fgBudgetRevision&&!batch.historyReset&&!batch.fgRecovery&&watch.gpuExecutionMs&&watch.fgExecutionMs)
+ fgCapacity.observe(*watch.gpuExecutionMs,*watch.fgExecutionMs,batch.fgEvaluated);
+ if(adaptiveCapturePhase&&watch.captureArrival>0&&valid==batch.fgCandidates&&
batch.hasGenerated&&!batch.historyReset&&!batch.fgRecovery&&
batch.batch.identity.settingsRevision==fgBudgetRevision&&watch.presentationGeneration==presentationGeneration.load()){
int64_t requiredDelay=0;
@@ -1053,7 +1057,11 @@ 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={} admitted={} admittedPairs={} rejectedPairs={} remainingDeadlineMs={:.3f} predictedMs={:.3f} elapsedMs={:.3f} blitGpuP95Ms={:.3f} presentCpuP95Ms={:.3f} warmingHistory={} (CPU Present is backpressure, not added GPU cost)",timeline,batch.identity.settingsRevision,batch.identity.sourceFrameId,options.fgMultiplier,admitted,fgAdmittedPairs,fgRejectedPairs,double(deadline-now)/10000,fgBudget.predicted(now,warmingHistory).value_or(-1),elapsed,blit,livePresent.p95(),warmingHistory));
};
- if(fgBudgetRevision!=options.settings.revision){fgBudget.reset();pairLatency.reset();fgBudgetRevision=options.settings.revision;}
+ if(fgBudgetRevision!=options.settings.revision){fgBudget.reset();fgCapacity.reset();pairLatency.reset();fgBudgetRevision=options.settings.revision;}
+ previewFgMultiplier=options.fgMultiplier;
+ if(!isImage&&!rereadCached&&options.fg&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend))
+ previewFgMultiplier=fgCapacity.select(options.fgMultiplier,double(liveSourceInterval100ns(pkt.duration,activeSource->info().averageFps))/10000);
+ {std::lock_guard lock(mutex_);snapshot_.previewFgMultiplier=previewFgMultiplier;}
const auto liveInterval=livePhaseInterval100ns(pkt.duration,activeSource->info().averageFps/(isScreen&&halfRate?2:1),isScreen);
const auto processingAllowance=isCapture&&options.fg&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)?
fgBudget.processingAllowance(host100ns(),liveInterval):0;
@@ -1061,7 +1069,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
// 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)?
- pairLatency.select(host100ns(),legacyPairDelay,liveInterval,options.fgMultiplier):legacyPairDelay;
+ 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&&useLiveFgAdmission&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)){
@@ -1076,7 +1084,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
else if(!liveTimeline.anchored(batch.identity.epoch))liveTimeline.reset(batch.identity.epoch,batch.b100ns,liveInputReady,liveSourceInterval100ns(pkt.duration,activeSource->info().averageFps));
const auto interval=liveSourceInterval100ns(pkt.duration,activeSource->info().averageFps);
const auto a=(historyReset||batch.b100ns<=batch.a100ns||batch.b100ns-batch.a100ns>10000000)?batch.b100ns-interval:batch.a100ns;
- const auto lastGenerated=pipeline::FrameBatch::interpolate(a,batch.b100ns,options.fgMultiplier-1,options.fgMultiplier);
+ const auto lastGenerated=pipeline::FrameBatch::interpolate(a,batch.b100ns,previewFgMultiplier-1,previewFgMultiplier);
const auto now=host100ns(),deadline=liveTimeline.deadline(lastGenerated);
const double elapsed=elapsedMs(processStart);
const bool admitted=fgBudget.admit(now,deadline,elapsed,presentP95,warmingHistory);
@@ -1093,7 +1101,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
if(fileAwaitingVideo)return true; // Bounded startup lookahead; audio has not started.
const auto interval=liveSourceInterval100ns(pkt.duration,activeSource->info().averageFps);
const auto a=(historyReset||batch.b100ns<=batch.a100ns||batch.b100ns-batch.a100ns>10000000)?batch.b100ns-interval:batch.a100ns;
- const auto lastGenerated=pipeline::FrameBatch::interpolate(a,batch.b100ns,options.fgMultiplier-1,options.fgMultiplier);
+ const auto lastGenerated=pipeline::FrameBatch::interpolate(a,batch.b100ns,previewFgMultiplier-1,previewFgMultiplier);
const auto now=host100ns();
const auto deadline=now+lastGenerated-int64_t(nowMs()*10000.0);
const auto elapsed=elapsedMs(processStart),blit=livePresentGpu.p95();
@@ -1112,7 +1120,11 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
if(!isImage&&GetEnvironmentVariableW(L"VEYRA_TEST_VIDEO_WORK_MS",testWork,16))std::this_thread::sleep_for(std::chrono::milliseconds(std::clamp(_wtoi(testWork),0,150)));
loopTrace.mark("prepare");
if(!presenter.beginSourceProcessing()){status(L"XeSS processing timing failed",true);break;}
- bool processed=false;{processWaitBase=ring.cpuWaitCount();processWaitMsBase=ring.cpuWaitMilliseconds();processSubmitBase=ring.submitCount();processed=!injectedReject&&graph.process(frame,pts,historyReset,out,pkt.sequence,&pkt.colorInfo,&pkt.hardwareSurface,comparisonMode_!=0,admitFg);processSlotWaitMs=ring.cpuWaitMilliseconds()-processWaitMsBase;}
+ bool processed=false;{
+ processWaitBase=ring.cpuWaitCount();processWaitMsBase=ring.cpuWaitMilliseconds();processSubmitBase=ring.submitCount();
+ processed=!injectedReject&&graph.process(frame,pts,historyReset,out,pkt.sequence,&pkt.colorInfo,&pkt.hardwareSurface,comparisonMode_!=0,admitFg,previewFgMultiplier);
+ processSlotWaitMs=ring.cpuWaitMilliseconds()-processWaitMsBase;
+ }
loopTrace.mark("graphSubmit");
previewSkipSinceProcess=false;
if(!processed){
@@ -1244,10 +1256,6 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
unsigned left=0;for(unsigned i=s.next;i<batch.batch.count;++i)if(batch.batch.frames[i].kind!=pipeline::FrameKind::Generated||batch.batch.frames[i].validity==pipeline::GenerationValidity::Valid)++left;
flow->update([&](auto& m){if(left>s.remaining)m.pendingOutputFrames+=left-s.remaining;else m.pendingOutputFrames-=std::min(m.pendingOutputFrames,s.remaining-left);});s.remaining=left;
};std::unique_ptr<LiveStepState,decltype(updatePending)> pendingUpdate(&s,updatePending);
- if(!isCapture&&!watch->ready){
- if(elapsedMs(s.readyStart)>2000){veyra::log::error("capture-present","GPU ready timeout");return {State::Failed};}
- return {State::Pending,now+2000};
- }
if(watch->ready&&!s.readyReported){s.readyMs=std::max(0.0,std::chrono::duration<double,std::milli>(watch->readyObserved-s.readyStart).count());s.readyReported=true;flow->cpu(diagnostics::CpuStage::ReadyWait,s.readyMs,host100ns());}
if(!isCapture&&fileAwaitingVideo&&!seekPreviewPending&&!fileInputEnded&&
(liveScheduler->occupancy()<2||!pendingCompletions.empty()))return {State::Pending,now+2000};
@@ -1262,7 +1270,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
const double itemPtsMs=double(item.pts100ns)/10000;
const auto decisionTime=host100ns();
const bool generationExpired=generated&&(isCapture?timeline.expired(item.pts100ns,decisionTime,100000):!fileAwaitingVideo&&previewGeneratedExpired(nowMs(),itemPtsMs));
- const auto readiness=previewFrameReadiness(item,comparisonMode_!=0||!generatedPresentationCurrent(jobGeneration,presentationGeneration.load()),generationExpired,[&]{return !isCapture||graph.resolveFrame(batch,s.next);});
+ const auto readiness=previewFrameReadiness(item,comparisonMode_!=0||!generatedPresentationCurrent(jobGeneration,presentationGeneration.load()),generationExpired,[&]{return graph.resolveFrame(batch,s.next);});
if(readiness==PreviewFrameReadiness::Pending){
if(elapsedMs(s.readyStart)>2000){veyra::log::error("capture-present","GPU frame ready timeout");return {State::Failed};}
return {State::Pending,host100ns()+2000};
@@ -1284,7 +1292,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
}
const auto optionalNow=host100ns();
if(presentationEffective.enabled){
- const auto interval=std::max<int64_t>(1,int64_t(sourceIntervalMs*10000)/std::max(1u,options.fg?options.fgMultiplier:1u));
+ const auto interval=std::max<int64_t>(1,int64_t(sourceIntervalMs*10000)/std::max(1u,batch.batch.count));
const auto mediaDeadline=isCapture?timeline.deadline(item.pts100ns):fileAwaitingVideo?optionalNow:optionalNow+int64_t((itemPtsMs-nowMs())*10000);
const auto due=presentationEffective.mode==PacingMode::Even?cadence.due(mediaDeadline,interval):mediaDeadline;
if(generated&&presentationEffective.mode==PacingMode::Even&&due>mediaDeadline+interval){++s.dropped;++s.handled;++s.next;s.deadlineStart.reset();continue;}
diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cpp
index 162afcf9..b47b3dab 100644
--- a/src/pipeline/EnhanceGraph.cpp
+++ b/src/pipeline/EnhanceGraph.cpp
@@ -1255,7 +1255,7 @@ bool EnhanceGraph::createViews()
// ---------------------------------------------------------------------------
// process: the per-frame chain (verbatim from the probe lambda).
// ---------------------------------------------------------------------------
-bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, FrameOutputs& out, uint64_t sourceFrameId, const ColorDescription* color, const HardwareSurfaceInput* hardwareSurface, bool retainReferences, const FgAdmission& admitFg)
+bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, FrameOutputs& out, uint64_t sourceFrameId, const ColorDescription* color, const HardwareSurfaceInput* hardwareSurface, bool retainReferences, const FgAdmission& admitFg, unsigned previewMultiplier)
{
diagnostics::CpuStallTrace cpuTrace("graph-cpu-stall",sourceFrameId,30.0);
failedBackend_=engine::FailedBackend::Infrastructure;
@@ -1888,12 +1888,13 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
}
previousSource_=sourceFrameId;
const bool fgBackendAvailable=fgEnabled_&&(fgBackend_&&fgBackend_->created());
- out.fgCandidates=fgBackendAvailable?desc_.fgMultiplier-1:0;
+ const unsigned fgMultiplier=previewMultiplier&&fgBackendAvailable?std::clamp(previewMultiplier,2u,desc_.fgMultiplier):desc_.fgMultiplier;
+ out.fgCandidates=fgBackendAvailable?fgMultiplier-1:0;
const bool resetFg=reset||!prevValid_||fgHistorySkipped_;
const bool runFg=fgBackendAvailable&&(!admitFg||admitFg(out.batch,resetFg));
// A reset has no usable A/B pair. Seed one complete 2X evaluation group;
// all later subframes would repeat reset work and cannot be presented.
- const uint32_t fgCalls=resetFg?1:desc_.fgMultiplier-1;
+ const uint32_t fgCalls=resetFg?1:fgMultiplier-1;
if(runFg&&resetFg)out.fgSkippedForReset=out.fgCandidates-fgCalls;
out.fgRecovery=runFg&&fgHistorySkipped_;
if(fgBackendAvailable&&!runFg){out.fgSkippedBeforeEval=out.fgCandidates;fgHistorySkipped_=true;}
@@ -1951,7 +1952,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame
if(out.hasGenerated){
++metrics_.fgSubmittedCandidates;
BatchFrame f;f.identity=out.batch.identity;f.kind=FrameKind::Generated;f.validity=GenerationValidity::Pending;f.subframe=sub;
- f.pts100ns=FrameBatch::interpolate(out.batch.a100ns,out.batch.b100ns,sub,desc_.fgMultiplier);
+ f.pts100ns=FrameBatch::interpolate(out.batch.a100ns,out.batch.b100ns,sub,fgMultiplier);
f.lease=std::make_shared<FrameLease>();f.lease->texture=genFrame_[generatedSlot];f.lease->slot=generatedSlot;f.lease->readyFence=out.genFenceValue;generatedLeases_[generatedSlot]=f.lease;out.batch.append(std::move(f));
}
}
diff --git a/tests/integration/FgAdmissionTests.cpp b/tests/integration/FgAdmissionTests.cpp
index 9aaae0ae..e549d4da 100644
--- a/tests/integration/FgAdmissionTests.cpp
+++ b/tests/integration/FgAdmissionTests.cpp
@@ -76,6 +76,29 @@ int wmain(int argc,wchar_t** argv){
}
const auto nr=graph.metrics().nrEvaluateCount;
ok=ok&&real==40&&nr==40&&skipped==8*(multiplier-1)&&resetSkipped==4*(multiplier-2)&&evaluated==28*(multiplier-1)+4&&recoveries==2&&generated>0;
+ // Change preview group size without recreating NGX, then return to the
+ // default requested size used by export. Check actual GPU output and PTS.
+ for(unsigned requested:{2u,4u,6u,0u}){
+ if(!ok)break;
+ const auto effective=requested?std::min(requested,multiplier):multiplier;
+ pipeline::FramePacket packet;const AVFrame* frame=nullptr;
+ ok=source.read(packet,&frame)==source::SourceReadStatus::Frame;
+ pipeline::EnhanceGraph::FrameOutputs output;
+ ok=ok&&graph.process(frame,packet.pts.toDouble()*1000,false,output,packet.sequence,&packet.colorInfo,nullptr,false,{},requested);
+ const auto start=std::chrono::steady_clock::now();
+ while(ok&&!graph.resolveGeneration(output)){
+ if(std::chrono::steady_clock::now()-start>std::chrono::seconds(2)){ok=false;break;}wait.slice(.2);
+ }
+ ok=ok&&output.batch.count==effective&&output.fgEvaluated==effective-1;
+ for(unsigned j=0;ok&&j+1<output.batch.count;++j){
+ const auto& f=output.batch.frames[j];
+ ok=f.validity==pipeline::GenerationValidity::Valid&&f.pts100ns==pipeline::FrameBatch::interpolate(output.batch.a100ns,output.batch.b100ns,j+1,effective);
+ sink::RgbaImage image;ok=ok&&sink::readRgba8(ctx,ring,f.lease->texture.Get(),image);
+ unsigned nonblack=0;for(size_t p=0;p+3<image.pixels.size();p+=4)nonblack+=image.pixels[p]>8||image.pixels[p+1]>8||image.pixels[p+2]>8;
+ ok=ok&&nonblack>image.width*image.height/20;
+ }
+ std::cout<<"ADAPT requested="<<requested<<" effective="<<effective<<" pass="<<ok<<std::endl;
+ }
ring.drainQueue();graph.shutdown();source.close();
unsigned errors=0;if(info)for(UINT64 i=0;i<info->GetNumStoredMessagesAllowedByRetrievalFilter();++i){SIZE_T size=0;info->GetMessage(i,nullptr,&size);std::vector<uint8_t> data(size);auto* m=reinterpret_cast<D3D12_MESSAGE*>(data.data());if(SUCCEEDED(info->GetMessage(i,m,&size))&&m->Severity<=D3D12_MESSAGE_SEVERITY_ERROR){++errors;log::error("debug",m->pDescription);}}
ok=ok&&errors==0;
diff --git a/tests/integration/FgSustainedTests.cpp b/tests/integration/FgSustainedTests.cpp
index cd64a344..a460562e 100644
--- a/tests/integration/FgSustainedTests.cpp
+++ b/tests/integration/FgSustainedTests.cpp
@@ -16,12 +16,14 @@ int wmain(int argc,wchar_t** argv){
if(argc==3&&std::wstring_view(argv[1])==L"--fg-compat-probe")
return runFgCompatibilityProbe(reinterpret_cast<HANDLE>(_wcstoui64(argv[2],nullptr,10)));
if(argc!=7&&argc!=8&&argc!=9)return 2; // optional target ratio, then live-1440p profile
- const bool liveProfile=argc==9&&std::wstring_view(argv[8])==L"live-1440p";
+ const bool xessProfile=argc==9&&std::wstring_view(argv[8])==L"file-xess-4k";
+ const bool fileProfile=argc==9&&(std::wstring_view(argv[8])==L"file-4k"||xessProfile);
+ const bool liveProfile=argc==9&&(std::wstring_view(argv[8])==L"live-1440p"||fileProfile);
if(argc==9&&!liveProfile)return 2;
const unsigned multiplier=_wtoi(argv[3]);
const int seconds=_wtoi(argv[5]);
const double minimumRatio=argc>=8?_wtof(argv[7]):0;
- if((multiplier!=4&&multiplier!=6)||seconds<30||seconds>240)return 2;
+ if((multiplier!=2&&multiplier!=4&&multiplier!=6)||seconds<30||seconds>240)return 2;
if(FAILED(CoInitializeEx(nullptr,COINIT_MULTITHREADED)))return 2;
std::filesystem::create_directories(argv[2]);
veyra::Logger::instance().openFile((std::filesystem::path(argv[2])/L"engine.log").wstring());
@@ -35,13 +37,14 @@ int wmain(int argc,wchar_t** argv){
{
EngineController engine;engine.setVolume(0,true);
EnhancementSettings settings;settings.multiplier=multiplier;
+ if(xessProfile)settings.frameGenerationBackend=FrameGenerationBackend::XeSS;
const std::wstring_view effects=argv[6];
settings.nr=effects==L"on"||effects==L"nr";
settings.sr=effects==L"on"||effects==L"sr";
if(liveProfile){settings.flow=FlowQuality::Performance;settings.videoSrQuality=0;settings.srTarget=veyra::pipeline::SrTarget::Uhd4K;}
auto options=PlayerOptions::from(settings);
const std::wstring source=argv[1];
- options.captureReplayForTest=!source.starts_with(L"capture:")&&!source.starts_with(L"capture2:");
+ options.captureReplayForTest=!fileProfile&&!source.starts_with(L"capture:")&&!source.starts_with(L"capture2:");
options.captureReplayDisableFgAdmissionForTest=std::wstring_view(argv[4])==L"off";
engine.open(window,source,options);
const auto opened=Clock::now();auto started=Clock::time_point{};
@@ -59,8 +62,9 @@ int wmain(int argc,wchar_t** argv){
if(elapsed>=17&&!cleared){SetEnvironmentVariableW(L"VEYRA_TEST_VIDEO_WORK_MS",nullptr);cleared=true;beforeRecovery=s.generated;}
if(elapsed!=reported){
reported=elapsed;const auto& f=s.metrics.flow;const auto& c=f.counters;
- std::cout<<"t="<<elapsed<<" multiplier="<<s.applied.multiplier<<" frames="<<s.frames<<" generated="<<s.generated
+ std::cout<<"t="<<elapsed<<" multiplier="<<s.applied.multiplier<<" effective="<<s.previewFgMultiplier<<" frames="<<s.frames<<" generated="<<s.generated
<<" sourceFps="<<f.sourceCompletedFps<<" submitFps="<<f.presentSubmitFps<<" validFps="<<f.validGeneratedFps
+ <<" providerFps="<<f.xessSdkSubmitFps<<" providerGenerated="<<c.xessSdkGenerated
<<" limited="<<s.fgBudgetLimited<<" skipped="<<c.fgSkippedBeforeEval<<" expired="<<c.generatedExpiredAfterEval
<<" received="<<c.captureReceived<<" accepted="<<c.sourceAccepted<<" overwritten="<<c.mailboxOverwritten
<<" evaluated="<<c.fgEvaluated<<" warmup="<<c.fgWarmup<<" realPresented="<<c.realPresented<<" generatedPresented="<<c.generatedPresented
diff --git a/tests/unit/LiveGpuSchedulerTests.cpp b/tests/unit/LiveGpuSchedulerTests.cpp
index 6eada2fa..d78da642 100644
--- a/tests/unit/LiveGpuSchedulerTests.cpp
+++ b/tests/unit/LiveGpuSchedulerTests.cpp
@@ -1,6 +1,7 @@
#include "veyra/engine/LiveGpuScheduler.h"
#include "veyra/engine/TimingWindow.h"
#include "veyra/engine/FgRecoveryBudget.h"
+#include "veyra/engine/PreviewFgCapacity.h"
#include "veyra/engine/LivePairLatency.h"
#include "veyra/engine/PreviewFrameReadiness.h"
#include "veyra/engine/PresentationGeometry.h"
@@ -10,6 +11,17 @@
int main(){
using Scheduler=veyra::engine::LiveGpuScheduler;using State=Scheduler::State;
int failures=0;auto check=[&](bool pass,const char* text){std::cout<<(pass?"PASS ":"FAIL ")<<text<<'\n';failures+=!pass;};
+ {
+ veyra::engine::PreviewFgCapacity capacity;
+ check(capacity.select(6,16.667)==6,"unknown work preserves requested multiplier");
+ for(int i=0;i<60;++i){capacity.observe(18,10,5);capacity.select(6,16.667);}
+ check(capacity.select(6,16.667)==4,"sustained overload retains an evenly spaced sustainable group");
+ for(int i=0;i<30;++i){capacity.observe(8,4,3);capacity.select(6,16.667);}
+ check(capacity.select(6,16.667)==4,"brief headroom does not oscillate multiplier");
+ for(int i=0;i<200;++i){capacity.observe(8,4,3);capacity.select(6,16.667);}
+ check(capacity.select(6,16.667)==6,"sustained headroom restores requested multiplier");
+ capacity.reset();check(capacity.select(2,16.667)==2,"reset and 2X request cannot inherit a larger multiplier");
+ }
{
using namespace veyra;
using R=engine::PreviewFrameReadiness;