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 file cadence after late generated frames

Veyra Goal Agentbb9139957ea8
diff --git a/docs/FG_CADENCE_DEEP_INVESTIGATION_PLAN_2026-09-20.md b/docs/FG_CADENCE_DEEP_INVESTIGATION_PLAN_2026-09-20.md
index 389c8dee..70b62bdf 100644
--- a/docs/FG_CADENCE_DEEP_INVESTIGATION_PLAN_2026-09-20.md
+++ b/docs/FG_CADENCE_DEEP_INVESTIGATION_PLAN_2026-09-20.md
@@ -182,3 +182,26 @@ GPU 抖动。该方案只缓冲短时抖动,不能解决持续服务时间大
实际修改文件、测试命令和日志路径,以及未测量的显示器物理延迟边界。若所有合法优化后仍
无法在该硬件和原画质下达到 6X,必须把“当前服务时间超过预算”的证据和最稳定的 fallback
单独写清楚,不能把它包装成 6X 已解决。
+## 11. 2026-09-20 findings from the first repair pass
+
+The first production-safe change retains the last same-timeline texture for a
+file-preview hold when a generated candidate is already valid but misses its
+deadline. It is explicitly logged as `fg-hold` / Present detail 2 and is never
+counted as interpolation. This prevents a late candidate from creating an empty
+display slot, but it cannot help pairs rejected before MFG evaluation.
+
+The decisive diagnostic was a test-only file lookahead (35 ms and 50 ms). With
+the original A/B PTS, NR1080 4K fixed6X rejected most pairs because the first
+interpolation PTS precedes the arrival of B; the normal run was about72 software
+submissions/s. At35 ms lookahead, 4,473 generated frames were counted in the
+short run and no generated candidates were discarded, but the retained cadence
+was about203 submissions/s with16 long gaps. At50 ms, about3,010 generated frames
+were counted and cadence fell to about140/s with33 ms media jumps. Therefore a
+blind fixed lookahead is not an acceptable fix: it proves the temporal admission
+error, but adds latency and still cannot hide the serial NR+Flow+MFG service time.
+The test switches were removed; only the bounded hold remains in production.
+
+Next implementation target is an adaptive, bounded file lookahead tied to measured
+service time, followed by a real overlap/resource-ownership experiment. It must
+preserve original PTS, audio continuity, and report added preview latency. No
+downshift or hold-only result will be called fixed6X acceptance.
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 0f11aff4..6f2b82bd 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -5009,3 +5009,26 @@ GPU full-group 观测约 NR 6.715ms、Flow 1.056ms、FG batch 10.042ms,slot CP
4.519/16.692/17.102ms,18 个间隔超过 16.667ms,36 次 rejected→warmup;GPU
P95 约 NR5.664ms、Flow1.265ms、FG10.659ms,slot CPU wait 仍为 0。降低 NR 分辨率
接近但没有达到均匀固定 6X,因此仍只作为性能对照,不改变原画质验收目标。
+### 2026-09-20 late-frame hold experiment
+
+Added a bounded file-preview hold in `src/engine/EngineController.cpp`. When a
+generated candidate is already valid but misses its media deadline, the scheduler
+may submit the last texture from the same epoch/settings revision at that PTS.
+The event is recorded as `Present detail=2` and `fg-hold`; it is not counted as a
+generated/interpolated frame. Reset/seek/settings drains clear the retained lease.
+Capture, export and provider-owned pacing do not use this path.
+
+The clean build `hold-fallback-build.log` succeeded and UI contract tests passed.
+On `p001.mp4`, NR1080, 4K, fixed6X with the normal admission gate, the run still
+submitted about 72 software frames/s because most pairs were rejected before any
+MFG evaluation; this confirms the hold path cannot repair a gate that never creates
+a candidate. A test-only force-admission run reached about349 submissions/s with
+zero gaps over16.667ms, but only2 provider-generated frames were actually counted
+and most submissions were holds/late candidates. That switch was removed; it is
+not a production solution. A second test-only last-deadline admission variant
+remained about74/s and was also removed. The results prove that the dominant
+remaining issue is admission plus serial service time, not a missing display wait.
+
+Artifacts: `E:/项目/Veyra/tests/fg-cadence-repair-20260920/hold-fixed6`,
+`force-admit-fixed6`, `last-only-fixed6`; build logs are under
+`E:/项目/Veyra/logs/fg-cadence-repair-20260920/`. No package, release or shutdown.
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index 5ecc15b6..31d7bcaa 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -613,6 +613,12 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
PresentationCadence cadence;
PresentationSettings presentationEffective;
uint64_t pacingRevision=0,presenterGeneration=0;
+ // Keep the last submitted texture for a bounded file-preview hold
+ // when a generated candidate misses its media deadline. A hold is
+ // explicitly tracked and never reported as an interpolated frame.
+ std::shared_ptr<pipeline::FrameLease> lastPresentedLease;
+ bool lastPresentedGenerated=false,lastPresentedReferences=false;
+ pipeline::FrameIdentity lastPresentedIdentity{};
auto applyPresentation=[&]{
PresentationSettings requested;uint64_t revision;
{std::lock_guard lock(mutex_);requested=presentation_;revision=presentationRevision_;}
@@ -637,7 +643,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
{std::lock_guard lock(mutex_);snapshot_.presentationEffective=presentationEffective;snapshot_.presentationRevision=revision;snapshot_.presentationStatus=message;}
veyra::log::info("pacing",std::format("revision={} requested={}/{}/{} effective={}/{}/{}",revision,requested.enabled,unsigned(requested.mode),unsigned(requested.display),presentationEffective.enabled,unsigned(presentationEffective.mode),unsigned(presentationEffective.display)));
};
- auto drainLivePresentation=[&]{cadence.reset();if(liveScheduler){++presentationDrains;liveScheduler->cancel();pollCompletions();pendingCompletions.clear();}pairLatency.reset();};
+ auto drainLivePresentation=[&]{cadence.reset();lastPresentedLease.reset();lastPresentedIdentity={};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());}};
auto waitLive=[&]{const auto due=liveScheduler?liveScheduler->wakeAt():0;deadlineWait.slice(due>host100ns()?std::min(1.0,double(due-host100ns())/10000):1.0);};
uint64_t metricsRevision=options.settings.revision,metricsEpoch=0,metricsWindowEpoch=0,statsSourceBase=0;
@@ -1267,7 +1273,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
watch->reflexFrame=currentReflexFrame;
pendingCompletions.push_back(watch);
struct LiveStepState {
- unsigned next=0,handled=0,remaining=0;bool readyReported=false;
+ unsigned next=0,handled=0,remaining=0;uint64_t held=0;bool readyReported=false;
Clock::time_point readyStart=Clock::now();std::optional<Clock::time_point> deadlineStart;
double readyMs=0,waitMs=0,presentMs=0,ageMs=0;uint64_t count=0,dropped=0;
diagnostics::GpuSample blit;
@@ -1312,7 +1318,27 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
const auto ready=watch->frameReadyObserved[s.next];
veyra::log::info("fg-deadline",std::format("revision={} batch={} subframe={} expired={} readyObservedLateMs={:.3f} decisionLateMs={:.3f} observedReadyToDecisionMs={:.3f} batchReady={} (CPU fence observations, not scanout; -1 means readiness unknown)",item.identity.settingsRevision,batch.batch.batchId,item.subframe,generationExpired,ready?double(ready-timeline.deadline(item.pts100ns))/10000:-1,double(decisionTime-timeline.deadline(item.pts100ns))/10000,ready?double(decisionTime-ready)/10000:-1,watch->ready.load()));
}
- if(readiness==PreviewFrameReadiness::Expired){++s.dropped;++s.handled;++s.next;s.deadlineStart.reset();continue;}
+ if(readiness==PreviewFrameReadiness::Expired){
+ // Preserve the media cadence when a valid MFG
+ // result arrived late. Repeating the last
+ // submitted texture is a display hold, not an
+ // interpolated frame, and is file-preview only.
+ const bool sameTimeline=lastPresentedLease&&lastPresentedIdentity.epoch==item.identity.epoch&&lastPresentedIdentity.settingsRevision==item.identity.settingsRevision;
+ if(!isCapture&&generated&&sameTimeline&&lastPresentedLease->ready()){
+ const auto begin=Clock::now();const auto before=presenter.submittedCount();
+ if(!presenter.present(ctx,ring,graph,lastPresentedLease->slot,lastPresentedGenerated,lastPresentedReferences,comparisonMode_,comparisonBase_,comparisonSplit_,lastPresentedIdentity,previewView()))return {State::Failed};
+ lastPresentedLease->consumerFence=presenter.consumerFenceValue(ring.lastSignaledValue());
+ const bool didPresent=presenter.submittedCount()>before;
+ if(didPresent){
+ const auto elapsed=elapsedMs(begin);
+ ++s.held;++s.handled;++s.next;s.deadlineStart.reset();cadence.submitted(decisionTime);
+ traceFrame(diagnostics::TraceKind::Present,lastPresentedIdentity,batch.batch.batchId,lastPresentedLease->consumerFence,item.pts100ns,item.subframe,2,elapsed);
+ if(veyra::log::verboseFrameLogs())veyra::log::info("fg-hold",std::format("batch={} source={} subframe={} pts100ns={} reusedSource={} reusedGenerated={} elapsedMs={:.3f} (display hold; not interpolated)",batch.batch.batchId,item.identity.sourceFrameId,item.subframe,item.pts100ns,lastPresentedIdentity.sourceFrameId,lastPresentedGenerated,elapsed));
+ continue;
+ }
+ }
+ ++s.dropped;++s.handled;++s.next;s.deadlineStart.reset();continue;
+ }
if(!s.deadlineStart)s.deadlineStart=Clock::now();
if(isCapture){if(host100ns()<timeline.deadline(item.pts100ns))return {State::Pending,timeline.deadline(item.pts100ns)};}
else if(!fileAwaitingVideo){
@@ -1349,6 +1375,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
}
if(didPresent){
cadence.submitted(optionalNow);
+ lastPresentedLease=item.lease;lastPresentedGenerated=generated;lastPresentedReferences=item.lease->referencesValid;lastPresentedIdentity=item.identity;
if(physicalCapture&&veyra::log::verboseFrameLogs())veyra::log::info("capture-present-sample",std::format("source={} epoch={} revision={} batch={} subframe={} generated={} arrival={} arrivalA={} ready={} begin={} end={}",item.identity.sourceFrameId,item.identity.epoch,item.identity.settingsRevision,batch.batch.batchId,item.subframe,generated,captureArrival,lineage?lineage->a.host100ns:0,watch->frameReadyObserved[s.next],optionalNow,host100ns()));
if(veyra::log::verboseFrameLogs())veyra::log::info("pacing-sample",std::format("mode={} enabled={} sync={} pts={} begin={} end={} ready={} process={} generated={} queue={} lateMs={:.3f}",unsigned(presentationEffective.mode),presentationEffective.enabled,unsigned(presentationEffective.display),item.pts100ns,optionalNow,host100ns(),watch->frameReadyObserved[s.next],std::chrono::duration_cast<std::chrono::nanoseconds>(watch->processStart.time_since_epoch()).count()/100,generated,liveScheduler->occupancy(),isCapture?double(optionalNow-timeline.deadline(item.pts100ns))/10000:fileAwaitingVideo?0:nowMs()-itemPtsMs));
traceFrame(diagnostics::TraceKind::Present,item.identity,batch.batch.batchId,item.lease->consumerFence,item.pts100ns,item.subframe,1,elapsed);