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 B1: XeSS presents right after submit, one XeLL cycle per loop
Veyra Goal Agent3c2d6caae8ee
diff --git a/docs/LATENCY_MIN_PLAN_2026-10-13.md b/docs/LATENCY_MIN_PLAN_2026-10-13.mdindex d18b62d2..96e5b355 100644--- a/docs/LATENCY_MIN_PLAN_2026-10-13.md+++ b/docs/LATENCY_MIN_PLAN_2026-10-13.md@@ -25,7 +25,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 睡眠时长;画面校验无错帧 |+| **B1 XeSS“提交即送显”**(已实施) | XeSS 时读帧→处理→立即打标签并 Present,不再由调度器等 GPU 完成后才送;一个 XeLL 周期内完成 睡眠→读输入→提交→送显;XeSS 也遵守“GPU 未完成不读下一帧” | 去掉 CPU 等 GPU 的时间和轮询抖动;XeLL 周期对齐 | 屏幕采集 XeSS 2X:周期错位 922/960→0,回调→送显 P95 3.8→3.0ms;采集卡+NR 实测待设备上线 || **B2 补帧输出预算**(已实施) | 内容帧率×倍数 > 1.02×刷新率时:DLSS/FSR/VFG 自动降到能放下的最大合法倍数;放不下但源比屏幕慢(60fps@100Hz)保留 2X(仍多出画面);源已占满屏幕(≥0.97×刷新,如 60Hz 屏 + 60fps 源)旁路补帧,真帧直接显示、不等插帧;XeSS 只做 SetEnabled(false) 旁路;新决定持续 1.5 秒才生效,状态栏说明原因 | 不浪费 GPU、动作均匀;60Hz+60fps 时延迟等于仅 NR | 实测:DLSS 6X@320Hz→4X,送显→上屏 6.2/8.0→5.0/6.9ms,垂直同步 12.2/18.4→5.7/8.5ms;模拟 60Hz 旁路回调→送显 8.8ms=仅 NR;30fps+2X@60Hz 保持 2X || **B3 “垂直同步”也不排队**(已实施) | 只有显式垂直同步节流:启用时清掉可等待对象积累的计数并放行一帧;直播未补帧时在读采集帧之前取得屏幕容量,每次送显前也取得容量(插帧最多等 ≤2ms 否则让给下一帧);自动/撕裂永不等待;“低延迟队列”=只保留一帧在处理 + 未补帧时 Reflex;XeSS 代理不设最大延迟(Intel:XeLL 以外的延迟手段不受支持) | 垂直同步模式下的排队上限 1 帧 | 回放 6X 超刷新:送显→上屏 18.4→5.8ms;探针源快 5%:7.3→2.5 个刷新;常规配置无回退;采集卡实测待设备上线 || **C1 VRR 研究** | 用户在驱动开启 G-SYNC/FreeSync 后,实测“自动”是否触发可变刷新;若不触发,评估“垂直同步 + B2 输出预算(输出始终低于最高刷新)”的 VRR 模式(不会撕裂) | 少等 0–1 个刷新(60Hz 平均约 8ms) | 需用户开启 VRR;对比送显→上屏 |diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex c7650989..254b9359 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -9375,3 +9375,11 @@ v2.0.7 ID 410800361,published_at 2026-10-12T16:24:59Z,latest/非草稿/非改动:只有显式“垂直同步”启用 DXGI 节流(最大延迟 1),启用时先让已排的帧显示完(≤100ms)、清掉积累的计数、再放行一帧(空队列不会卡死);直播且未补帧时在读采集帧之前取得屏幕容量(读帧门,无事可等时直接等这个对象而不是 1ms 轮询);每次送显前都取得容量,插帧最多等半个子帧间隔(≤2ms)否则让给下一帧,真帧继续等。“自动/撕裂”永不等待这个对象;“低延迟队列”改为“只保留一帧在处理 + 未补帧时 Reflex”,提示文字与状态栏改写并追加翻译。B2 在垂直同步下放不下时直接旁路(多出的帧会排队而不是被替换),XeSS 放不下也旁路。XeSS 代理不设最大延迟:Intel 文档写明 XeLL 以外的延迟手段不受支持、可能异常。运行中等待失败只停节流并提示,不再反复重配。测试开关 `VEYRA_TEST_LEGACY_VSYNC_QUEUE=1` 恢复旧的不等待队列。验证:veyra_realtime_preview_tests(新增垂直同步规则 5 项)、repair/ui contract 通过;latency-min-tests display-sync 12/12、lifecycle 通过(日志 staleLatencyCounts=3)。采集卡本时段离线(PnP 状态 Unknown,几小时前可用),改用同一条直播链路的回放与探针:回放垂直同步 DLSS 6X(关预算强制超刷新)送显→上屏 18.4→5.8ms、排队 7→2、Present 阻塞 3.3→0.4ms;开预算的常规配置 B3 与旧行为完全一致(无回退);自动+低延迟队列 6X 不再被卡到刷新率(361 次/s);Reflex 与生命周期场景 13/13 通过。读帧门探针(采集式邮箱,320Hz):源比刷新快 5% 时旧行为显示帧年龄 22.9ms(7.3 个刷新)→ B3 7.7ms(2.5 个刷新),自动模式 4.8ms;源比刷新慢时三者相同。60Hz 下对应约 122→41ms。回放的连续时间线本身让真帧等一个源间隔,故回放的读→送显不代表采集卡延迟;采集卡实测待设备重新上线。++## 2026-10-14 极限低延迟 B1 XeSS 提交即送显(Claude)++问题:XeSS 直播时调度器要等 GPU 做完才送显;这期间主循环已经读入并提交了下一帧,它与上一帧共用同一个 XeLL 周期,于是下一次送显时才开启新周期、在 Present 里执行 XeLL 睡眠,周期整体错位。XeSS 还被排除在“GPU 未完成不读下一帧”的门之外。++改动:XeSS 呈现器与图共用同一个直接队列,真帧提交后立刻打标签并 Present(GPU 顺序保证在增强之后执行),每次循环就是一个完整 XeLL 周期:睡眠→读帧→提交→送显;XeSS 也遵守“GPU 未完成不读下一帧”(等完再从邮箱取最新帧)。GPU 就绪耗时改由完成轮询记录(从任务创建到观察到完成),统计口径不再是“作业等待”。XessPresenter 日志新增 cycleMismatches(送显的源帧不在本周期准备的次数)。测试开关:`VEYRA_TEST_XESS_PRESENT_AFTER_READY=1` 恢复等 GPU 后送显,`VEYRA_TEST_XESS_STACKED_READS=1` 恢复叠读。++验证(采集卡离线,用屏幕采集直播链路 screen-xess,30fps 源,XeSS 2X,320Hz,测量窗口内):cycleMismatches 旧 922/960 → 新 0/960;回调→送显 P95 3.8→3.0ms;SDK 提交 56→58/s,补帧照常;测试断言 10/10 通过。屏幕采集负载很轻(无 NR),带 NR 的采集卡实测收益待设备上线。diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cppindex 9a620f80..f7aa36e7 100644--- a/src/engine/EngineController.cpp+++ b/src/engine/EngineController.cpp@@ -991,6 +991,10 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sint64_t predictedGpuStart100ns=0;std::optional<double> gpuExecutionMs,fgExecutionMs,firstFgExecutionMs;bool real=false;+ // B1: presented before the GPU finished; the completion poll+ // records the GPU-ready time (from jobStart) instead of the job.+ bool presentedBeforeReady=false;+ Clock::time_point jobStart{};std::atomic<bool> ready=false;Clock::time_point readyObserved{};std::array<int64_t,pipeline::FrameBatch::Capacity> frameReadyObserved{};@@ -1123,7 +1127,13 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,spairLatency.observe(observed,requiredDelay);}completeReset(batch.batch.identity);- watch.readyObserved=Clock::now();watch.ready=true;it=pendingCompletions.erase(it);+ watch.readyObserved=Clock::now();+ if(watch.presentedBeforeReady&&watch.flow==frameFlow&&liveScheduler){+ const double readyMs=std::max(0.0,std::chrono::duration<double,std::milli>(watch.readyObserved-watch.jobStart).count());+ watch.flow->cpu(diagnostics::CpuStage::ReadyWait,readyMs,host100ns());+ liveReady.add(readyMs);liveStats.readyMs=readyMs;liveStats.readyP95=liveReady.p95();+ }+ watch.ready=true;it=pendingCompletions.erase(it);}collectTimings();};@@ -1136,6 +1146,17 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s// (no read gate, waits only with the toggle/cap) for A/B runs.bool presentationPaced=false;static const bool legacyVsyncQueue=GetEnvironmentVariableW(L"VEYRA_TEST_LEGACY_VSYNC_QUEUE",nullptr,0)>0;+ // XeSS live presentation (latency-min B1): the presenter records on the+ // graph's own queue, so a real frame can be tagged and presented right+ // after its graph submission; GPU order keeps it after the enhancement.+ // One loop is then one XeLL cycle: sleep -> read -> submit -> present.+ // Waiting for the CPU fence first let the next source enter the same+ // cycle, so the following present opened the next cycle and slept+ // inside Present. VEYRA_TEST_XESS_PRESENT_AFTER_READY=1 restores the+ // fence wait; VEYRA_TEST_XESS_STACKED_READS=1 lets XeSS read the next+ // source while the previous one is still on the GPU, as before.+ static const bool xessPresentAfterReady=GetEnvironmentVariableW(L"VEYRA_TEST_XESS_PRESENT_AFTER_READY",nullptr,0)>0;+ static const bool xessStackedReads=GetEnvironmentVariableW(L"VEYRA_TEST_XESS_STACKED_READS",nullptr,0)>0;uint64_t pacingRevision=0,presenterGeneration=0;auto applyPresentation=[&]{PresentationSettings requested;uint64_t revision;@@ -1558,7 +1579,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s// 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&&!(fgRunning&&presentSinkFrameGeneration(options.settings.frameGenerationBackend))&&!pendingCompletions.empty();+ return isCapture&&!(fgRunning&&presentSinkFrameGeneration(options.settings.frameGenerationBackend)&&(xessStackedReads||xessPresentAfterReady))&&!pendingCompletions.empty();};const auto leaseWaitStart=Clock::now();while((liveScheduler->occupancy()>=2||!graph->nextFrameSlotAvailable()||enhancementPending())&&!stop_&&(!paused_||seekPreviewPending)&&!liveScheduler->failed()){@@ -2216,6 +2237,8 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sdiagnostics::GpuSample blit;};auto step=std::make_shared<LiveStepState>();+ watch->jobStart=step->readyStart;+ const bool submitThenPresent=isCapture&&presenter.xessActive()&&!xessPresentAfterReady;for(unsigned i=0;i<out.batch.count;++i)if(out.batch.frames[i].kind!=pipeline::FrameKind::Generated||out.batch.frames[i].validity==pipeline::GenerationValidity::Valid)++step->remaining;const double sourceIntervalMs=double(isCapture?liveInterval:liveSourceInterval100ns(pkt.duration,activeSource->info().averageFps))/10000;const auto baselineReady=pkt.decodedHost100ns>0?pkt.decodedHost100ns:captureArrival;@@ -2237,7 +2260,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,&playbackRate,&frameFlow,&graph,&host100ns,&isCapture,&isImage,&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,flow=frameFlow](int64_t now)->LiveGpuScheduler::Step{+ &seekDecoded,&seekStarted,&audio,&audioPipe,&audioStarted,&cadence,&ctx,&fileAudioAlignPending,&fileAwaitingVideo,&fileInputEnded,&playbackRate,&frameFlow,&graph,&host100ns,&isCapture,&isImage,&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,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;@@ -2257,7 +2280,10 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sconst 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 graph->resolveFrame(batch,s.next);});+ // B1: an XeSS real frame needs no CPU fence; the queue orders it.+ const bool early=submitThenPresent&&!generated&&!watch->ready;+ const auto readiness=previewFrameReadiness(item,comparisonMode_!=0||!generatedPresentationCurrent(jobGeneration,presentationGeneration.load()),generationExpired,[&]{return early||graph->resolveFrame(batch,s.next);});+ if(early&&readiness==PreviewFrameReadiness::Ready&&!s.readyReported){watch->presentedBeforeReady=true;s.readyReported=true;}if(traceSubframes&&generated&&(readiness==PreviewFrameReadiness::Expired||readiness==PreviewFrameReadiness::Suppressed))traceFrame(diagnostics::TraceKind::Discarded,item.identity,batch.batch.batchId,item.lease->readyFence,item.pts100ns,item.subframe,unsigned(readiness),isCapture?double(decisionTime-timeline.deadline(item.pts100ns))/10000:nowMs()-itemPtsMs);if(readiness==PreviewFrameReadiness::Pending){@@ -2423,8 +2449,10 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sflow->update([&](auto& m){m.counters.cancelledBeforePresent+=batch.batch.count-s.handled;m.gpuReadyWaitMs=s.readyMs;m.deadlineWaitMs=s.waitMs;if(s.count)m.captureArrivalToPresentReturnMs=s.ageMs;m.counters.generatedExpiredAfterEval+=s.dropped;});if(flow!=frameFlow)return;liveStats.submitted+=s.count;liveStats.expired+=s.dropped;- if(s.count){liveStats.waitMs=s.waitMs;liveStats.presentMs=s.presentMs;liveStats.readyMs=s.readyMs;liveStats.ageMs=s.ageMs;liveStats.blit=s.blit;- liveAges.add(s.ageMs);liveWaits.add(s.waitMs);liveReady.add(s.readyMs);liveStats.ageP95=liveAges.p95();liveStats.waitP95=liveWaits.p95();liveStats.presentP95=livePresent.p95();liveStats.readyP95=liveReady.p95();}+ if(s.count){liveStats.waitMs=s.waitMs;liveStats.presentMs=s.presentMs;liveStats.ageMs=s.ageMs;liveStats.blit=s.blit;+ liveAges.add(s.ageMs);liveWaits.add(s.waitMs);liveStats.ageP95=liveAges.p95();liveStats.waitP95=liveWaits.p95();liveStats.presentP95=livePresent.p95();+ // An early (B1) present learns its GPU-ready time in the completion poll.+ if(!watch->presentedBeforeReady){liveStats.readyMs=s.readyMs;liveReady.add(s.readyMs);liveStats.readyP95=liveReady.p95();}}liveStats.fps=liveSubmissions.size()>1?double(liveSubmissions.size()-1)*1e7/(liveSubmissions.back()-liveSubmissions.front()):0;})){status(L"视频呈现队列失败",true);break;}frameFlow->update([&](auto& m){m.pendingOutputFrames+=step->remaining;});diff --git a/src/gfx/XessPresenter.cpp b/src/gfx/XessPresenter.cppindex d995b7fb..864cbbb2 100644--- a/src/gfx/XessPresenter.cpp+++ b/src/gfx/XessPresenter.cpp@@ -31,6 +31,9 @@ struct XessPresenter::Impl {const uint64_t traceInstance=++nextTraceInstance;pipeline::FrameIdentity traceIdentity{};uint32_t preparationCycle=0;+ // Presents whose source was prepared in another XeLL cycle (the next+ // cycle's sleep then ran inside Present). latency-min B1 keeps it 0.+ uint64_t cycleMismatches=0;int64_t presentBegin=0;uint64_t generated=0,presented=0;uint32_t requestedGenerated=0; // generated frames requested by the user (0 = 2X stock)@@ -250,6 +253,7 @@ bool XessPresenter::beginFrame(uint32_t preparedFrameId,pipeline::FrameIdentityauto& p=*p_;p.id=beginInput();p.traceIdentity=identity;p.preparationCycle=preparedFrameId;+ p.cycleMismatches+=preparedFrameId&&preparedFrameId!=p.id;if(p.traceEnabled){const auto now=traceHost();p.record(diagnostics::TraceKind::XessBind,p.id,now,now);}if(log::verboseFrameLogs()&&preparedFrameId!=p.id)log::info("xess-fg",std::format("presentation cycle id={} preparationCycle={}; cycle timing is not source-frame latency",p.id,preparedFrameId));@@ -303,7 +307,7 @@ bool XessPresenter::afterPresent(){if(!p.check(p.xefgSwapChainGetLastPresentStatusFn(p.fg,&status),"PresentStatus"))return false;if(status.isFrameGenEnabled&&status.frameGenResult==XEFG_SWAPCHAIN_RESULT_SUCCESS&&status.framesPresented>1)p.generated+=status.framesPresented-1;if(status.frameGenResult>=0)p.presented+=status.framesPresented;- if(log::verboseFrameLogs()||p.id%60==0||status.frameGenResult<0)log::info("xess-fg",std::format("presentId={} enabled={} result={} framesPresented={} generatedTotal={} (SDK submissions, not measured scanout)",p.id,status.isFrameGenEnabled,int(status.frameGenResult),status.framesPresented,p.generated));+ if(log::verboseFrameLogs()||p.id%60==0||status.frameGenResult<0)log::info("xess-fg",std::format("presentId={} enabled={} result={} framesPresented={} generatedTotal={} cycleMismatches={} (SDK submissions, not measured scanout; cycleMismatches = presents of a source prepared in another XeLL cycle)",p.id,status.isFrameGenEnabled,int(status.frameGenResult),status.framesPresented,p.generated,p.cycleMismatches));return status.frameGenResult>=0;#elsereturn false;