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(capture): present screen capture when ready without frame generation
Veyra Goal Agentb81989133db8
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 48a91214..4b90dc77 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -121,3 +121,31 @@ A/B(GTA VI原生4K两帧,全部质量4,完整表见DUAL_SR_PLAN“复查用户明确要求“直接合并到Main即可”,覆盖此前各段“不合并main”。在`codex/dual-sr-20261028`把复查修正与超采样选项提交为一个提交,再以合并提交并入本地`main`(原`7b0b64b`,是该分支祖先,无分叉),沿用以往“Merge … for local integration”的做法;仓库没有启用的git钩子。活动树随后切回`main`,内容与已测试的工作区一致,无需重编。并入内容:claude/sr-stage-20261028(cf84762)、codex/sr-stage-freeze-20261028(67d0294)、codex/dual-sr-20261028(e61e497)及本次提交。独立`claude/capture-fps-audio-20261027`未并入;施工分支保留未删。未push、未Release,正式版仍2.1.1,运行目录与真实配置不变。提交与合并哈希、合并后检查见reports/claude-sr-supersample-20261028/FINAL.json。++## 2026-10-29 屏幕采集无补帧时的首帧锚定扣留(Claude)++上级会话复查英伟达低延迟时测到:60fps窗口采集、关闭补帧时,读取→GPU就绪每帧<1ms,但每帧在Present前被固定扣留,每轮p50 3.1–52ms,等于该轮首帧的合成→读取延迟;低队列下扣留超过一个源间隔还使下一次读取晚约15ms。此问题main已有,与Reflex无关。按要求从本地main `4351bbd`新建工作树`worktrees/screen-capture-hold-20261029`(分支`claude/screen-capture-hold-20261029`),不碰共享树中未提交的低延迟改动;未提交、未合并、未push/Release,未改真实配置/驱动/运行组件。++原因:`EngineController.cpp`无补帧分支用`paceSourcePts=options.fg||!physicalCapture`。2026-09-11(history/reports/CAPTURE_LATENCY_AUDIT_2026-09-11.md)只把物理采集改为GPU就绪即呈现;1.4.2加入屏幕采集时只接入了FG成对重锚,无FG仍走文件回放的源PTS时钟——每epoch只锚一次,`deadline=host_+(pts-source_)`把首帧晚读的偏移带到整段会话。同类第二条路径:开/关补帧会重建图,新图epoch从1重新计数,最后一个FG成对锚(按PTS)可能以相同epoch号留到关闭补帧之后继续扣留,物理采集同样受影响。++修改:+- `LivePresentationTiming.h`新增`livePacesSourcePts(fg,physicalCapture,screenCapture)`:物理与屏幕采集无FG按就绪呈现;文件回放、串流(每帧重锚)和FG成对相位保持源PTS。+- `PresentationScheduler::anchored(epoch,paceSourcePts=true)`同时比较锚定模式,另一模式的锚视为未锚定;默认参数让其他调用行为不变。+- `EngineController.cpp`该段改用以上两者;屏幕无FG的`capture-timeline pacing=`由`source-pts`变为`capture-ready`。文件回放、串流与FG路径的参数与原来一致。+- 测试:`LivePresentationTimingTests`新增6项(各来源策略、首帧晚读52ms后600帧的扣留、文件回放保留PTS钟、FG锚在重复epoch中不再扣留、锚记录模式);`PresentationPacingTests`新增`latency-screen`(60fps窗口采集、开详细帧日志;与低延迟分支同名同义,但无英伟达模式映射),1X时断言`schedulingWaitP95Ms`不超过一个显示刷新+2ms。++构建:`py -3.11 -X utf8 -B -I scripts/acceptance/build-recording-handoff.py --task claude-screen-capture-hold-20261029 --root E:/项目/Veyra/worktrees/screen-capture-hold-20261029 --label 2.1.1-hold --jobs 2 veyra_live_timing_tests veyra_repair_contract_tests veyra_presentation_pacing_tests veyra_live_presentation_tests`,新建`build/claude-screen-capture-hold-20261029`,配置+编译218.6秒退出0,改动文件无警告。A/B基线:detached工作树`worktrees/screen-capture-hold-main-20261029`(main加本次测试文件,引擎未修复),同脚本加`--build-dir E:/项目/Veyra/build/claude-screen-capture-hold-20261029-main --label 2.1.1-main`构建两个集成目标210.7秒退出0。++运行:`py -3.11 -X utf8 -B -I E:/项目/Veyra/tmp/claude-screen-capture-hold-20261029/run.py stage|stage-main|unit|latency 3 10|pacing …|live …`(`--main`跑基线EXE,`--warm`共用CUDA缓存)。私有运行目录`tests/claude-screen-capture-hold-20261029/app`由2.1.1 NVIDIA供体硬链接,EXE/着色器以新文件替换,97个运行组件与manifest逐一一致;基线EXE以`*_main.exe`并存,两侧着色器字节相同。每进程≤290秒,TEMP/TMP/CUDA缓存私有。++结果:+- unit:live timing 106/0(含新6项),RepairContract 272/0。RepairContract首次以0xC0000135退出,是runner没给Qt/FFmpeg DLL路径,补PATH后重跑通过。反向检查`tmp/claude-screen-capture-hold-20261029/negative/negative.py`:恢复main的策略时新检查4项失败、其余102项通过;只恢复不比较模式的`anchored`时2项FG关闭检查失败、其余104项通过。+- latency-screen A/B(RTX 5070,2560×1440@320Hz,60fps窗口,无FG,每轮10秒,关/低队列/Reflex各3轮,hold=GPU就绪→Present开始):修复后9轮hold p50均0.002ms、p95≤0.016ms、max≤0.087ms,`pacing=capture-ready`,9/9通过,读取max≤−0.05ms,未见延后。同一工具的main基线hold p50:关4.08/32.33/27.41、低队列36.74/33.38/32.01、Reflex 36.44/29.61/36.27ms(p95最高55.4ms),低队列/Reflex 6轮读取p95延后13.9–39.1ms(其中3轮p50也延后10.5–20.2ms),`pacing=source-pts`;9轮中8轮新断言失败(关第1轮4.1ms低于320Hz阈值5.1ms,所以确定性回归以单元检查为准)。两侧read(process−pts)约−1.4ms:WGC时间戳早于读取时刻,不能当作合成→读取年龄(上级会话数据同样如此)。+- 原有节奏测试(修复版):lifecycle 13项、回放6X垂直同步4项、screen-dlss 4X 10项(capture-pair)、screen-xess 2X 10项、回放无FG 3项(仍`source-pts`)、文件2X低队列5项、overload 9项全部通过。effects在冷CUDA缓存时“first frames”(15秒内>10帧)失败、其余5项通过:NGX初始化约7.9秒;main基线同样失败;共享缓存后修复版2/2通过。+- live presentation(修复版):默认回放28/0、--overload 3/0、--settings-rebuild 21/0、--reset-rollback 33/0、--inactive-effects 69/0。--source-gap用120秒片源时2过4失败(EOF须90秒内到达而片源太长,首项8秒内12帧赶不上冷启动),main基线完全一致(EOS 2726/2726/2723)。改用40秒切片(`tests/claude-screen-capture-hold-20261029/media/nr-1080p30-40s.mp4`,1200帧,ffmpeg流复制):冷缓存修复版与main都4过2失败(启动项及EOF快照1199/1198;跨epoch日志“每帧恰好呈现一次”通过),预热后修复版6/0(1200/1200/1200)。++合并提示:引擎、两个头文件与单元测试补丁可直接应用到低延迟分支提交`4edcb49`(临时索引`git apply --cached --check`);`PresentationPacingTests.cpp`第31行冲突,该分支未提交工作区已有同义`latency-screen`,合并时保留其版本、补上本次1X扣留断言即可。++空间:新增构建411,825,958字节、工作树88,250,651字节、运行目录新文件(4个EXE+着色器)56,796,288字节、40秒切片77,515,754字节、40个证据目录66,153,977字节、日志/回执约0.33MB;基线工作树已恢复为干净后正常移除,基线构建405,895,676字节确认无reparse/进程后删除,每次运行的临时CUDA缓存84,422,224字节已回收。++未做/边界:未用采集卡(物理采集无FG本已就绪呈现,只新增FG关闭后重复epoch的处理,由单元覆盖);未测串流;运行中切换FG的屏幕采集只做了单元检查;未重编产品`veyra_qml_ui`(同一引擎库已编译通过)及独立probe工程的`veyra_remoteplay_core_tests`(未调用`anchored`);Present开始是CPU侧观测,不是屏幕端到端延迟;仅本机RTX 5070/320Hz。回执`reports/claude-screen-capture-hold-20261029/`(FINAL.json及各阶段JSON),日志`logs/claude-screen-capture-hold-20261029/`,证据`tests/claude-screen-capture-hold-20261029/`。diff --git a/include/veyra/engine/LivePresentationTiming.h b/include/veyra/engine/LivePresentationTiming.hindex 0783bbb6..49e74d34 100644--- a/include/veyra/engine/LivePresentationTiming.h+++ b/include/veyra/engine/LivePresentationTiming.h@@ -24,6 +24,11 @@ inline int64_t capturePairInterval100ns(pipeline::Rational duration,double nominif(!reset&&std::isfinite(span)&&span>=1&&span<=100)return int64_t(std::llround(span*10000));return liveSourceInterval100ns(duration,nominalFps);}+// File replay has no arrival clock and keeps its PTS anchor; FG keeps the A/B+// pair phase; streams re-anchor every frame. Physical and screen capture without+// FG present when ready: one PTS anchor per epoch turned the first sample's late+// read into a hold on every later frame (60 fps window capture: 3-52 ms per run).+inline bool livePacesSourcePts(bool fg,bool physicalCapture,bool screenCapture){return fg||!(physicalCapture||screenCapture);}// Live capture never waits on an absolute source PTS. Once B is available,// display generated(A,B), then B up to half an input interval later. Anchor// each pair to current host time, not to the first (possibly stale) sample.diff --git a/include/veyra/engine/PresentationScheduler.h b/include/veyra/engine/PresentationScheduler.hindex 30458a15..a3202ee4 100644--- a/include/veyra/engine/PresentationScheduler.h+++ b/include/veyra/engine/PresentationScheduler.h@@ -14,7 +14,9 @@ public:void resetPair(uint64_t epoch,int64_t source,int64_t host,int64_t lookahead,bool paceSourcePts=true) {reset(epoch,source,host,lookahead,paceSourcePts);}- bool anchored(uint64_t epoch)const{return anchored_&&epoch==epoch_;}+ // An anchor of the other pacing mode is stale: FG on/off rebuilds the graph,+ // whose epochs restart, so a paced FG pair anchor could outlive FG.+ bool anchored(uint64_t epoch,bool paceSourcePts=true)const{return anchored_&&epoch==epoch_&&paced_==paceSourcePts;}// Unbuffered capture is ready-driven. A late first callback or clock drift// must not turn its source timestamps into a persistent presentation hold.int64_t deadline(int64_t pts)const{return paced_?host_+(pts-source_)+delay_:host_;}diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cppindex ab664cb0..49766eb0 100644--- a/src/engine/EngineController.cpp+++ b/src/engine/EngineController.cpp@@ -2456,14 +2456,14 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sveyra::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;- if(isCapture&&!rereadCached&&(isStream||pairPacing||!liveTimeline.anchored(out.batch.identity.epoch))){+ // File replay has no device pacing and still needs its PTS clock.+ // Physical and screen capture without FG present as soon as ready.+ const bool paceSourcePts=livePacesSourcePts(options.fg,physicalCapture,isScreen);+ if(isCapture&&!rereadCached&&(isStream||pairPacing||!liveTimeline.anchored(out.batch.identity.epoch,paceSourcePts))){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(!liveTimeline.anchored(out.batch.identity.epoch,paceSourcePts)||(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);+ else if(!liveTimeline.anchored(out.batch.identity.epoch,paceSourcePts))liveTimeline.reset(out.batch.identity.epoch,out.batch.b100ns,liveInputReady,options.fg?duration100ns:0,paceSourcePts);}if(!isImage&&!isCapture&&frames==0){anchor=Clock::now();anchorMs=lastAudioClockMs=pts;}double frameWaitMs=0,framePresentMs=0;diff --git a/tests/integration/PresentationPacingTests.cpp b/tests/integration/PresentationPacingTests.cppindex dde510be..8d1e597e 100644--- a/tests/integration/PresentationPacingTests.cpp+++ b/tests/integration/PresentationPacingTests.cpp@@ -31,11 +31,13 @@ int wmain(int argc,wchar_t** argv){const int mode=_wtoi(argv[3]),display=_wtoi(argv[4]),multiplier=_wtoi(argv[5]),seconds=std::clamp(_wtoi(argv[6]),3,120);if(mode< -1||mode>2||display<0||display>2)return 2;const std::wstring scenario=argc>7?argv[7]:L"";- const bool screen=scenario==L"screen-xess"||scenario==L"screen-dlss";+ // latency-screen: a live 60 fps window capture for capture-to-present runs.+ const bool latency=scenario.starts_with(L"latency-");+ const bool screen=scenario==L"screen-xess"||scenario==L"screen-dlss"||latency;const bool xess=scenario==L"xess"||scenario==L"screen-xess";if(scenario==L"legacy"){if(mode!=-1)return 2;SetEnvironmentVariableW(L"VEYRA_TEST_LEGACY_SWAPCHAIN",L"1");}std::filesystem::path dir=argv[2];std::filesystem::create_directories(dir);- SetEnvironmentVariableW(L"VEYRA_VERBOSE_FRAME_LOGS",screen?L"0":L"1");+ SetEnvironmentVariableW(L"VEYRA_VERBOSE_FRAME_LOGS",screen&&!latency?L"0":L"1");veyra::Logger::instance().openFile((dir/L"engine.log").wstring());veyra::Logger::instance().setConsoleEnabled(false);if(FAILED(CoInitializeEx(nullptr,COINIT_MULTITHREADED)))return 2;const bool physical=scenario==L"capture-nr"||scenario==L"capture-nr-recovery";@@ -69,7 +71,7 @@ int wmain(int argc,wchar_t** argv){if(!inputWindow)std::this_thread::sleep_for(std::chrono::milliseconds(10));}if(!inputWindow){TerminateProcess(inputProcess.hProcess,2);WaitForSingleObject(inputProcess.hProcess,1000);CloseHandle(inputProcess.hProcess);return 2;}- veyra::source::ScreenCaptureOptions input;input.target=reinterpret_cast<uint64_t>(inputWindow);input.fps=30;input.cursor=false;+ veyra::source::ScreenCaptureOptions input;input.target=reinterpret_cast<uint64_t>(inputWindow);input.fps=latency?60:30;input.cursor=false;sourcePath=input.uri();}MONITORINFOEXW monitor{};monitor.cbSize=sizeof(monitor);GetMonitorInfoW(MonitorFromWindow(window,MONITOR_DEFAULTTONEAREST),&monitor);@@ -104,13 +106,15 @@ int wmain(int argc,wchar_t** argv){if(physical){check(last.nrActive&&last.fgActive&&last.nrEvaluated>first.nrEvaluated,"real capture NR and DLSS remain active");std::cout<<"captureReceivedDelta="<<last.captureReceived-first.captureReceived<<" captureDroppedDelta="<<last.captureDropped-first.captureDropped<<" generatedDelta="<<last.generated-first.generated<<" requested="<<mode<<" effective="<<(last.presentationEffective.enabled?int(last.presentationEffective.mode):-1)<<std::endl;}std::cout<<"mediaSpeed="<<speed<<" processedDelta="<<last.frames-first.frames<<std::endl;check(!last.failed&&last.frames>first.frames+10&&speed>.8&&speed<1.2,"sustained playback at media speed");+ // Without FG the ready->Present wait is display capacity only, never a first-frame PTS anchor.+ if(latency&&multiplier==1){std::cout<<"schedulingWaitP95Ms="<<last.schedulingWaitP95Ms<<std::endl;check(last.schedulingWaitP95Ms<1000.0/std::max<DWORD>(dm.dmDisplayFrequency,30)+2,"screen capture without FG is held at most one display refresh");}if(multiplier>1)check(last.fgActive&&last.generated>first.generated,"real provider generated frames during measurement");if(scenario==L"effects")check(last.nrActive&&last.srActive&&last.nrEvaluated>first.nrEvaluated,"NR and SR remain active with pacing");if(mode>=0&&!xess)check(last.presentationEffective.enabled,"optional pacing active");if(mode==2&&multiplier==1)check(last.presentationEffective.mode==PacingMode::Reflex,"native Reflex active");if(mode==2&&multiplier>1&&!xess)check(last.presentationEffective.mode==PacingMode::LowQueue,"Reflex with FG explicitly falls back to low queue");if(mode>=0&&xess)check(!last.presentationEffective.enabled&&last.fgActive,"provider remains pacing owner");- if(screen){+ if(screen&&!latency){for(unsigned cycle=0;cycle<3;++cycle){SetEnvironmentVariableW(L"VEYRA_TEST_VIDEO_WORK_MS",L"80");auto before=engine.snapshot();diff --git a/tests/unit/LivePresentationTimingTests.cpp b/tests/unit/LivePresentationTimingTests.cppindex a0775f4e..442373c3 100644--- a/tests/unit/LivePresentationTimingTests.cpp+++ b/tests/unit/LivePresentationTimingTests.cpp@@ -149,6 +149,34 @@ int main(){check(livePairHoldMs(true,1e12,0)<=1000./30,"timestamp jump has bounded hold");check(livePairHoldMs(true,10,20)==0,"backwards PTS cannot sleep negatively");check(livePairHoldMs(true,std::numeric_limits<double>::infinity(),0)==0,"nonfinite PTS rejected");+ {+ // 60 fps window capture without FG (2026-10-29): the first frame was read+ // 52 ms after its compositor time, later frames 1 ms after theirs. Same+ // sequence as the engine: anchor only when this epoch and mode have none.+ using veyra::engine::livePacesSourcePts;+ check(!livePacesSourcePts(false,false,true)&&!livePacesSourcePts(false,true,false),"screen and physical capture without FG are ready-driven");+ check(livePacesSourcePts(false,false,false)&&livePacesSourcePts(true,false,true)&&livePacesSourcePts(true,true,false),"file replay, streams and FG pairs keep their PTS clock");+ auto worstHold=[](bool screen){+ veyra::engine::PresentationScheduler timeline;const bool paced=livePacesSourcePts(false,false,screen);+ int64_t read=0,worst=std::numeric_limits<int64_t>::min();+ for(int i=0;i<600;++i){+ const int64_t pts=i*166667;read=std::max(read,pts)+(i?10000:520000);const int64_t ready=read+5000;+ if(!timeline.anchored(1,paced))timeline.reset(1,pts,read,0,paced);+ if(i>=60)worst=std::max(worst,std::max(timeline.deadline(pts),timeline.cadenceDeadline(pts,ready))-ready);+ }+ return worst;+ };+ check(worstHold(true)<=0,"late first screen read is not held on every later frame");+ check(worstHold(false)>=500000,"file replay keeps the PTS clock of its first anchor");+ // FG on/off rebuilds the graph and its epochs restart at 1: the last FG pair+ // anchor (B read 52 ms late, one interval of phase) must not pace capture+ // after FG. The next frame is read 1 ms after its compositor time.+ veyra::engine::PresentationScheduler timeline;timeline.resetPair(1,1000000,1520000,166667);+ const bool paced=livePacesSourcePts(false,false,true);+ if(!timeline.anchored(1,paced))timeline.reset(1,5000000,5010000,0,paced);+ check(timeline.deadline(5000000)<=5015000&&timeline.cadenceDeadline(5000000,5015000)<=5015000,"FG pair anchor in a repeated epoch does not hold capture after FG is off");+ check(timeline.anchored(1,false)&&!timeline.anchored(1),"anchor records its pacing mode");+ }{// PictureCompare.h: a sample repeats the last new picture only when every// component of the whole picture is within the capture-noise band.