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++
Pace deduplicated capture frame generation on the content clock
Veyra Goal Agentb10ec2b95552
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 4396c40b..21130a7a 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -954,3 +954,14 @@ VB-Audio 许可允许在符合捐赠软件条款时附带原安装包,未找## 2026-11-09 2.1.4 NR 推理复用致谢按用户要求,在 GitHub Release 和版本说明中补充 Magpie Experimental v0.6.12 的 DLSSNR「隔帧」模式、SAOG0721 与 yejincheng420 的贡献,并标明 Veyra 的独立实现。用 gh release edit 更新正文,复查公开正文、资产 ID/大小/SHA-256 和 Latest。群公告同步更新。+++## 2026-11-10 采集去重后的 40 帧补帧送帧修复++独立分支 `codex/capture-dedup-pacing-20261110`,起点 `c5782a5`。40 帧在 60 Hz 采样后的有效回调间隔交替约 17/33 ms。原先组内按校正 PTS 插值,组间仍按回调重新锚定。现在物理采集卡的图内补帧把去重内容 PTS 映射到平滑采集时钟,自适应相位按同一个锚点统计 GPU 就绪时间。保留两批队列、原始采集时间、原判重和倍率。去重以外的 VFG 模型快档及垂直同步等待逻辑保持原合同。++运行 `scripts/acceptance/build-recording-handoff.py --task codex-capture-dedup-pacing-20261110 --label 2.1.4-dedup-pacing-test --jobs 2 veyra_qml_ui veyra_live_timing_tests`,首次 278.0 秒,最终增量 11.9 秒。时序测试 166 项通过,含 40-in-60/30-in-60 3X 的实际时序组件模拟。先只启用去重时间戳平滑的首轮实卡 P99 14.16 ms,仍有首张生成帧晚于期限。最终版改用采集时钟映射并给自适应相位保留有界采样余量。++用户退出正式版后,用隔离 NVIDIA 包对 MCS 4K-T911 的 4K60 NV12、约 40 FPS 内容、VFG 中档 3X 做 20 秒 A/B。使用同一程序的 `VEYRA_TEST_LEGACY_LIVE_PACING=1` 对照原去重路径。提交 119.95→119.93 FPS,界面 1% low 中位 57.66→110.03,逐帧提交间隔 P99 17.33→9.04 ms。真实帧回调到提交返回的中位 24.12→31.54 ms,P95 24.81→37.69 ms。稳定采样窗内两轮均无邮箱覆盖、降档、生成过期或容量丢弃增量。固定 60→30 复测 90.00 FPS,P99 11.87 ms,未走新去重锚点。未测物理屏幕扫描或手柄到屏幕延迟。++回执 `E:/项目/Veyra/reports/codex-capture-dedup-pacing-20261110/FINAL.json`,逐帧日志在同任务 `logs` 目录。独立启动入口 `E:/项目/Veyra/tests/codex-capture-dedup-pacing-20261110/启动去重补帧测试.cmd`。验收后核对 QML 探针已恢复,E:/App 的正式 EXE 哈希保持发布值。diff --git a/include/veyra/engine/LivePairLatency.h b/include/veyra/engine/LivePairLatency.hindex 538d9423..2f9ef74e 100644--- a/include/veyra/engine/LivePairLatency.h+++ b/include/veyra/engine/LivePairLatency.h@@ -18,19 +18,19 @@ public:while(!samples_.empty()&&(samples_.size()>=64||samples_.front().time<now-10000000))samples_.pop_front();samples_.push_back({now,requiredDelay});}- int64_t select(int64_t now,int64_t legacyDelay,int64_t interval,unsigned multiplier){+ int64_t select(int64_t now,int64_t legacyDelay,int64_t interval,unsigned multiplier,int64_t samplingAllowance=0){std::vector<int64_t> current;for(const auto& sample:samples_)if(sample.time>=now-10000000)current.push_back(sample.delay);if(current.size()<8||interval<=0||multiplier<2){selected_=legacyDelay;return selected_;}const auto index=(current.size()*95+99)/100-1;std::nth_element(current.begin(),current.begin()+index,current.end());- // One millisecond covers polling/wakeup jitter. Never add latency above- // the existing policy, or compress phase by more than 0.25 ms per pair.- // 0.5 ms covers wake-up jitter with MMCSS on the owner thread; the- // per-pair step may close a subframe interval over eight pairs.- const auto target=std::min(legacyDelay,current[index]+5000);+ // 0.5 ms covers wake-up jitter with MMCSS. The allowance is only used+ // by deduplicated capture, where a later sample can move readiness+ // past a deadline on the continuous content clock.+ const auto limit=legacyDelay+samplingAllowance;+ const auto target=std::min(limit,current[index]+5000);const auto step=std::min<int64_t>(5000,interval/multiplier/8);- selected_=std::clamp(selected_?selected_-step:legacyDelay,target,legacyDelay);+ selected_=std::clamp(selected_?selected_-step:legacyDelay,target,limit);return selected_;}};diff --git a/include/veyra/engine/LivePresentationTiming.h b/include/veyra/engine/LivePresentationTiming.hindex 7782439e..f97d4ecb 100644--- a/include/veyra/engine/LivePresentationTiming.h+++ b/include/veyra/engine/LivePresentationTiming.h@@ -51,7 +51,7 @@ inline double livePairHoldMs(bool hasGenerated,double realPtsMs,double generated// 0.5% more late generated frames (reports/claude-fg-sidefx-20261101/sim_final).// One callback beyond min(interval/3, 8 ms) does not move the line; a second on// the same side moves it there at once. The FG budget, generated-frame expiry-// and LivePairLatency stay on the callback itself.+// stays tied to the callback. Deduplicated capture also learns GPU readiness on the content clock.class LiveArrivalSmoother {double offset_=0,drift_=0,jitter_=0,outside_=0;unsigned samples_=0;@@ -76,6 +76,11 @@ public:}return source+std::llround(offset_)-kLead100ns;}+ // Reuse the capture clock offset for content timestamps. Center the+ // one-slot sampling uncertainty so a late sample can still reach its first deadline.+ int64_t contentAnchor(int64_t contentPts,int64_t samplePts,int64_t callback,int64_t transportInterval){+ return anchor(samplePts,callback,transportInterval)+(contentPts-samplePts)+transportInterval/2;+ }// Diagnostics: mean distance of a callback from the line, the clock difference, jumps.double jitterMs()const{return jitter_/10000;}double driftPpm(int64_t interval)const{return interval>0?drift_/double(interval)*1e6:0;}diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cppindex 8f3c3202..7985e09f 100644--- a/src/engine/EngineController.cpp+++ b/src/engine/EngineController.cpp@@ -1172,6 +1172,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sstruct CompletionWatch {uint64_t reflexFrame=0;int64_t captureArrival=0;+ int64_t phaseAnchor=0;uint64_t presentationGeneration=0;pipeline::EnhanceGraph::FrameOutputs output;std::shared_ptr<FrameFlowWindow> flow;@@ -1315,7 +1316,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s// so the evaluated group is recognised by its generated frames.const bool phaseSample=phaseValidOnly?valid==batch.fgCandidates&&batch.hasGenerated:batch.fgCandidates>0&&valid+invalid==batch.fgCandidates&&!failed;- if(adaptiveCapturePhase&&watch.captureArrival>0&&phaseSample&&+ if(adaptiveCapturePhase&&watch.phaseAnchor>0&&phaseSample&&!batch.historyReset&&!batch.fgRecovery&&!costSettling&&!batch.fgFast&&batch.batch.identity.settingsRevision==fgBudgetRevision&&watch.presentationGeneration==presentationGeneration.load()){int64_t requiredDelay=0;@@ -1324,7 +1325,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s// resolveGeneration can observe a fence after the// first poll. Its current host time is a safe upper bound.const auto ready=watch.frameReadyObserved[i]?watch.frameReadyObserved[i]:observed;- requiredDelay=std::max(requiredDelay,ready-watch.captureArrival+batch.batch.b100ns-item.pts100ns);+ requiredDelay=std::max(requiredDelay,ready-watch.phaseAnchor+batch.batch.b100ns-item.pts100ns);}pairLatency.observe(observed,requiredDelay);}@@ -2314,12 +2315,24 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s// 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;+ // Dedup corrects the content PTS, but the kept callbacks can still arrive+ // 17/33 ms apart for a 40 fps game. Map both times through the capture clock.+ const bool smoothAnchor=pairAnchoredLive&&options.fg&&!isStream&&!legacyLivePacing&&+ !presentSinkFrameGeneration(options.settings.frameGenerationBackend);+ const bool smoothTransportAnchor=smoothAnchor&&!dedupActive;+ const bool smoothContentAnchor=smoothAnchor&&dedupActive&&physicalCapture&&!pkt.pts.isUnknown();+ const auto transportInterval=smoothContentAnchor?+ liveSourceInterval100ns(pipeline::Rational::unknown(),activeSource->info().averageFps):0;const auto pairDelay=adaptiveCapturePhase&&options.fg&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)?- pairLatency.select(host100ns(),legacyPairDelay,liveInterval,previewFgMultiplier):legacyPairDelay;- const bool smoothAnchor=pairAnchoredLive&&options.fg&&!isStream&&!dedupActive&&!legacyLivePacing&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend);+ pairLatency.select(host100ns(),legacyPairDelay,liveInterval,previewFgMultiplier,transportInterval/2):legacyPairDelay;std::optional<int64_t> pairPresentAnchor;const auto presentAnchorFor=[&](int64_t source){- if(!pairPresentAnchor)pairPresentAnchor=smoothAnchor?liveArrival.anchor(source,liveInputReady,liveInterval):liveInputReady;+ if(!pairPresentAnchor){+ if(smoothContentAnchor)+ pairPresentAnchor=liveArrival.contentAnchor(source,samplePts100ns,liveInputReady,transportInterval);+ else+ pairPresentAnchor=smoothTransportAnchor?liveArrival.anchor(source,liveInputReady,liveInterval):liveInputReady;+ }return *pairPresentAnchor;};// DLSS can reseed after a skipped pair. XeSS@@ -2345,7 +2358,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sconst bool admitted=!vfgCostSettling.holding(now)&&fgBudget.admit(now,deadline,elapsed,presentP95,warmingHistory);logAdmission(batch,now,deadline,elapsed,presentP95,admitted,warmingHistory,pairAnchoredLive?(isStream?"decoded-pair":"capture-pair"):"continuous");auto decision=admitted?pipeline::EnhanceGraph::FgDecision::Evaluate:pipeline::EnhanceGraph::FgDecision::Skip;- if(smoothAnchor&&options.settings.vfgAutoRegulate&&previewFgMultiplier==2&&!warmingHistory&&graph->vfgFastReady()){+ if(smoothTransportAnchor&&options.settings.vfgAutoRegulate&&previewFgMultiplier==2&&!warmingHistory&&graph->vfgFastReady()){const double base=fgBudget.baseCost(now).value_or(0),progress=std::clamp(elapsed,0.0,base),blit=std::max(0.0,presentP95);if(!admitted){if(double(deadline-now)/10000+10>=std::max(0.0,base+vfgFastFgMs-progress)+blit)decision=pipeline::EnhanceGraph::FgDecision::FastForBudget;@@ -2592,9 +2605,9 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sconst auto presentAnchor=presentAnchorFor(out.batch.b100ns);liveGeneratedGrace=liveGeneratedGrace100ns(liveInputReady,presentAnchor);liveTimeline.resetPair(out.batch.identity.epoch,out.batch.b100ns,presentAnchor,options.fg?pairDelay:0,paceSourcePts);- if(smoothAnchor&&host100ns()>=nextLiveAnchorLog){+ if((smoothTransportAnchor||smoothContentAnchor)&&host100ns()>=nextLiveAnchorLog){nextLiveAnchorLog=host100ns()+10000000;- veyra::log::info("live-anchor",std::format("revision={} callbackJitterMs={:.3f} clockDriftPpm={:.0f} snaps={} callbackMinusAnchorMs={:.3f} capacityWaitMs={:.2f} (presentation anchor: source PTS plus a tracked offset to the capture callback, less a 0.5 ms lead; capacity wait applies under explicit VSync)",options.settings.revision,liveArrival.jitterMs(),liveArrival.driftPpm(liveInterval),liveArrival.snaps(),double(liveInputReady-presentAnchor)/10000,liveSmoothedCapacityWaitMs(double(liveInterval)/10000/std::max(1u,previewFgMultiplier),fixedCapacityWait?0:liveArrival.jitterMs())));+ veyra::log::info("live-anchor",std::format("revision={} contentClock={} callbackJitterMs={:.3f} clockDriftPpm={:.0f} snaps={} callbackMinusAnchorMs={:.3f} phaseMs={:.3f} capacityWaitMs={:.2f} (presentation anchor: source or deduplicated content PTS on the tracked capture clock; capacity wait applies under explicit VSync)",options.settings.revision,smoothContentAnchor,liveArrival.jitterMs(),liveArrival.driftPpm(smoothContentAnchor?transportInterval:liveInterval),liveArrival.snaps(),double(liveInputReady-presentAnchor)/10000,double(pairDelay)/10000,smoothTransportAnchor?liveSmoothedCapacityWaitMs(double(liveInterval)/10000/std::max(1u,previewFgMultiplier),fixedCapacityWait?0:liveArrival.jitterMs()):2.0));}}else if(!liveTimeline.anchored(out.batch.identity.epoch,paceSourcePts))liveTimeline.reset(out.batch.identity.epoch,out.batch.b100ns,liveInputReady,options.fg?duration100ns:0,paceSourcePts);@@ -2608,6 +2621,8 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sauto watch=std::make_shared<CompletionWatch>();watch->output=out;watch->flow=frameFlow;watch->processStart=processStart;watch->real=!rereadCached;watch->predictedGpuStart100ns=std::chrono::duration_cast<std::chrono::nanoseconds>(processStart.time_since_epoch()).count()/100+int64_t(queuedGpuMs*10000);watch->captureArrival=captureArrival;watch->presentationGeneration=jobGeneration;+ // Learn enough phase for early content-clock deadlines on late capture slots.+ watch->phaseAnchor=smoothContentAnchor?presentAnchorFor(out.batch.b100ns):captureArrival;watch->reflexFrame=currentReflexFrame;pendingCompletions.push_back(watch);if(physicalCapture&&gpuReadyEvent.handle)for(unsigned i=0;i<out.batch.count;++i){@@ -2644,7 +2659,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s#ifdef VEYRA_ENABLE_XBOX&xb,#endif- &seekDecoded,&seekStarted,&audio,&audioPipe,&audioStarted,&cadence,&ctx,&fileAudioAlignPending,&fileAwaitingVideo,&fileInputEnded,&generatedDropCap,&generatedDropCapacity,&generatedDropDeadline,&playbackRate,&frameFlow,&graph,&host100ns,&isCapture,&isImage,&liveArrival,&livePresent,&liveScheduler,&nextFgDeadlineLog,&nowMs,&options,&pendingCompletions,&physicalCapture,&presentEntryDeviation,&presentReturnDeviation,&presentationEffective,&presentationGeneration,&presentationSkippedGenerated,&presenter,&ring,&runSessionId,&seekPreviewPending,&traceFrame,&traceSubframes,watch,step,timeline,captureArrival,baselineReady,delayEnhanced,activeSeekId,lineage,jobGeneration,rereadCached,sourceIntervalMs,submitThenPresent,generatedGrace=liveGeneratedGrace,smoothAnchor,flow=frameFlow](int64_t now)->LiveGpuScheduler::Step{+ &seekDecoded,&seekStarted,&audio,&audioPipe,&audioStarted,&cadence,&ctx,&fileAudioAlignPending,&fileAwaitingVideo,&fileInputEnded,&generatedDropCap,&generatedDropCapacity,&generatedDropDeadline,&playbackRate,&frameFlow,&graph,&host100ns,&isCapture,&isImage,&liveArrival,&livePresent,&liveScheduler,&nextFgDeadlineLog,&nowMs,&options,&pendingCompletions,&physicalCapture,&presentEntryDeviation,&presentReturnDeviation,&presentationEffective,&presentationGeneration,&presentationSkippedGenerated,&presenter,&ring,&runSessionId,&seekPreviewPending,&traceFrame,&traceSubframes,watch,step,timeline,captureArrival,baselineReady,delayEnhanced,activeSeekId,lineage,jobGeneration,rereadCached,sourceIntervalMs,submitThenPresent,generatedGrace=liveGeneratedGrace,smoothTransportAnchor,flow=frameFlow](int64_t now)->LiveGpuScheduler::Step{using State=LiveGpuScheduler::State;auto& batch=watch->output;auto& s=*step;auto updatePending=[&](LiveStepState*){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;@@ -2732,7 +2747,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sif(generated&&!legacyVsyncQueue){if(!s.capacityStart)s.capacityStart=Clock::now();const double outputIntervalMs=sourceIntervalMs/std::max(1u,batch.batch.count);- if(elapsedMs(*s.capacityStart)>std::min(smoothAnchor?liveSmoothedCapacityWaitMs(outputIntervalMs,fixedCapacityWait?0:liveArrival.jitterMs()):2.0,outputIntervalMs/2)){++generatedDropCapacity;++s.dropped;++s.handled;++s.next;s.deadlineStart.reset();s.capacityStart.reset();continue;}+ if(elapsedMs(*s.capacityStart)>std::min(smoothTransportAnchor?liveSmoothedCapacityWaitMs(outputIntervalMs,fixedCapacityWait?0:liveArrival.jitterMs()):2.0,outputIntervalMs/2)){++generatedDropCapacity;++s.dropped;++s.handled;++s.next;s.deadlineStart.reset();s.capacityStart.reset();continue;}}return {State::Pending,optionalNow+2000};}diff --git a/tests/unit/LivePresentationTimingTests.cpp b/tests/unit/LivePresentationTimingTests.cppindex 8d2f63b7..4dccbe38 100644--- a/tests/unit/LivePresentationTimingTests.cpp+++ b/tests/unit/LivePresentationTimingTests.cpp@@ -1,10 +1,12 @@#define NOMINMAX#include "veyra/engine/LivePresentationTiming.h"+#include "veyra/engine/LivePairLatency.h"#include "veyra/engine/LivePresentationResetPolicy.h"#include "veyra/source/CaptureTiming.h"#include "veyra/engine/CaptureHalfRate.h"#include "veyra/engine/ContentDedup.h"#include "veyra/pipeline/PictureCompare.h"+#include "veyra/pipeline/FrameBatch.h"#include <algorithm>#include <array>#include <vector>@@ -417,6 +419,56 @@ int main(){{const auto r=run(60.0,[](int i){return int64_t(std::floor(i*40.0/60.0+1e-9));},n,0,0,250000);check(r.keptRepeats==0&&r.droppedReal==0&&std::abs(r.kept-n*2/3)<=1,"dedup 40-in-60: all real pictures kept, no repeats");check(r.monotonic&&r.neverLate&&r.regularSpans*100>=r.spans*95,"dedup 40-in-60: alternating 33/17 ms samples become even 25 ms content spans");}+ {+ // 40 unique pictures sampled at 60 Hz, with a two-step 3X GPU batch.+ // The presentation deadline of each batch must follow content PTS,+ // while readiness still depends on when the sampled picture arrives.+ struct TimingRun { double lowFps; int missed; };+ const auto present=[&](bool smooth, int contentRate){+ using namespace veyra::engine;+ ContentDedup cadence;+ LiveArrivalSmoother arrival;+ LivePairLatency phase;+ PresentationScheduler scheduler;+ FramePaceWindow window;+ constexpr int64_t transport=166667, hostStart=1000000;+ constexpr std::array<int64_t,3> gpuReady{60000,100000,25000};+ int64_t prevPts=0, prevPresent=0;+ int missed=0;+ for(int i=0;i<n;++i){+ const int64_t sample=i*transport;+ const uint64_t id=uint64_t(i*contentRate/60);+ const auto frame=cadence.observe(&id,sample,transport,i==0);+ if(!frame.keep)continue;+ const auto callback=hostStart+sample;+ const auto anchor=smooth?arrival.contentAnchor(frame.contentPts,sample,callback,transport):callback;+ if(!frame.interval){prevPts=frame.contentPts;continue;}+ const auto delay=phase.select(callback,frame.interval,frame.interval,3,smooth?transport/2:0);+ scheduler.resetPair(1,frame.contentPts,anchor,delay);+ int64_t requiredDelay=0;+ for(unsigned j=0;j<gpuReady.size();++j){+ const auto pts=j==2?frame.contentPts:+ veyra::pipeline::FrameBatch::interpolate(prevPts,frame.contentPts,j+1,3);+ const auto deadline=scheduler.deadline(pts);+ const auto ready=callback+gpuReady[j];+ requiredDelay=std::max(requiredDelay,ready-anchor+frame.contentPts-pts);+ if(i>120){+ missed+=ready>deadline;+ prevPresent=std::max({prevPresent+1,deadline,ready});+ window.complete(prevPresent);+ }+ }+ phase.observe(callback,requiredDelay);+ prevPts=frame.contentPts;+ }+ return TimingRun{window.lowFps(prevPresent).value_or(0),missed};+ };+ const auto legacy=present(false,40), fixed=present(true,40);+ check(legacy.lowFps<70&&fixed.lowFps>105&&fixed.missed==0,+ "dedup 40-in-60 3X: content anchor removes cross-batch stutter and retains readiness");+ const auto steady=present(true,30);+ check(steady.lowFps>88&&steady.missed==0,"dedup 30-in-60 3X: steady cadence stays smooth");+ }{const auto r=run(60.0,[](int i){return int64_t(i);},n,0,0,166667);check(r.kept==n&&r.regularSpans==r.spans,"dedup true 60: nothing dropped, timing unchanged");}{// +-1 per sample: two samples of one picture differ by up to 2, like the T911 (card_diff.py).