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: account for first DLSS output deadline and queued GPU work
Veyra Goal Agentec0f57df5c04
diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.mdindex 7e98adc1..9635dd19 100644--- a/docs/CURRENT_STATUS.md+++ b/docs/CURRENT_STATUS.md@@ -2,6 +2,8 @@更新:2026-09-20。发布状态与开发状态分别记录,历史计划不代表当前验收。+最新固定 6X 调查:同一 p001.mp4、RTX5070、NR 开启、4K 目标,首帧截止时间与排队成本修正后,固定 6X 末尾留存窗口约 265 提交/s,但仍有 15-17ms 空档,**尚未通过均匀呈现验收**。2X 仍稳定 120;请求 6X 自动回退实际 4X 时稳定 240,此结果不能代替固定 6X 修复。关闭 NR 的诊断对照固定 6X 可达稳定 360,不作为用户解决方案。121 项 CPU 检查及 GPU 恢复/倍率检查通过,详见 [本轮部分验收](FG_CADENCE_REPAIR_ACCEPTANCE_2026-09-20.md)。仅本地构建,未打包或发布。+最新节奏调查:已存档 `b2c3d0e` / `checkpoint/pre-fg-cadence-audit-20260920`,在 `codex/fg-cadence-audit-20260920` 复测相同实卡参数。关闭逐帧文件日志后仍约 194 提交/s,末尾 8.07 秒内 90 次间隔超过 16.667ms,478 批中 233 批只呈现原帧,直接记录到 114 次拒绝后预热。确认提交节奏断续,尚未修复;PresentMon 权限不足,未测物理显示。见 [节奏调查](FG_CADENCE_AUDIT_2026-09-20.md)。最新 DLSS 恢复修复:`codex/dlss-recovery-20260920` 从 `c8a3828` 隔离,将无有效 A/B 历史时的整组 MFG 重置改为单次完整预热,按实际预热成本判定预算,新增未执行重置候选计数。主程序构建、105 项 CPU 调度检查和 RTX5070 的 1080p NR+DLSS 2X/4X/6X 恢复检查通过,D3D12 错误为 0。用户关闭程序后,实卡 1440p60 NV12、NR+DLSS SR 到 4K+6X 各 120 秒对照:提交率 202.57→204.10/s,预热调用减少但主要吞吐限制未解决;关闭测试预算拒绝反而降到 184.76/s,采集丢帧及生成过期增加。未达到稳定 6X,不能宣称已修好。未覆盖用户便携包、未发布。见 [恢复修复记录](DLSS_RECOVERY_REPAIR_2026-09-20.md)。diff --git a/docs/FG_CADENCE_REPAIR_ACCEPTANCE_2026-09-20.md b/docs/FG_CADENCE_REPAIR_ACCEPTANCE_2026-09-20.mdnew file mode 100644index 00000000..8c54f8af--- /dev/null+++ b/docs/FG_CADENCE_REPAIR_ACCEPTANCE_2026-09-20.md@@ -0,0 +1,103 @@+# FG cadence: partial acceptance, fixed 6X still open++## Scope and result++Branch: `codex/fg-cadence-audit-20260920`. RTX5070, user p001.mp4,+3840x2160 60fps, NR realtime 1080, 4K output target, DLSS 6X/2X,+pacing setting off. The source already matches the 4K target, so SR does+not execute. No package, push or release. No physical scanout measurement.++The requested NR-on fixed 6X uniform cadence has **not passed**. Promoted+prefix admission and pacing reduce the original roughly 80 submissions/s+collapse to about 265, but repeated admission rejection and history warmup+still create 15-17ms holes. Automatic 4X fallback is separately successful;+it must not be used as evidence that fixed 6X was solved.++## Changes under test++- File DLSS admission checks first-output cost against its deadline and whole+ group cost against the last deadline. Account for older queued GPU work,+ retaining predicted start when an earlier completion watch retires.+- Normal file DLSS playback enforces the existing 90% minimum output spacing+ after the audio-clock deadline, preventing dense catch-up submissions.+ XeSS/FSR provider pacing and capture admission are not changed by this rule.+- Sixteen command allocators cover two bounded jobs, each with up to three+ enhancement lists and five MFG lists. The two-job scheduler and texture+ history capacities remain unchanged. This is a deliberate expansion from+ the earlier six-slot allocator budget, not a sixteen-frame queue.+- Logs distinguish requested/effective multipliers, first deadline and queued+ GPU cost. Failed admission/spacing experiment switches were removed.+- Earlier checkpoint `1be28a4` preserves valid prior generated leases across+ soft drops, while still resetting processing history and invalidating on+ hard boundaries. Earlier fallback checkpoint: `0050870`.++## Measured results++Each trace is the **final retained window** of a bounded in-memory trace,+not the entire run. FPS below means application submissions, not display.+All GPU runs were sequential; startup, window size and media were matched.++| Run | Duration | Retained seconds | FPS | P95 / max gap ms | Result |+| --- | ---: | ---: | ---: | ---: | --- |+| prefix2, NR on 2X | 30s | 11.367 | 120.001 | 8.751 / 9.061 | throughput assertion >=95% passed |+| prefix6, NR on fixed 6X | 45s | 5.760 | 265.445 | 15.428 / 17.169 | lifecycle only; cadence fails |+| prefix-adaptive6, NR on request 6X, actual 4X | 30s | 6.204 | 240.007 | 4.514 / 5.560 | fallback only |+| prefix-headroom6, effects off fixed 6X | 30s | 4.869 | 360.004 | 3.198 / 3.592 | diagnostic; throughput assertion >=95% passed |++No sub-ms gaps in these retained windows. prefix6 retains 236 complete+six-frame batches, 54 rejected pairs and 54 warmups, with no generated+discards in that window (16 over the whole run). Its 19 gaps over16.667ms+are why the higher average FPS is insufficient for acceptance.++The NR-on serial stage measurements are approximately NR6.8ms, flow1.2ms,+FG9.8-10ms, plus remaining work, against a 16.667ms source interval.+This establishes an over-budget **current serial implementation**; it does+not prove the hardware cannot benefit from a different implementation.+Removing admission entirely previously caused ~59fps and 1620 expired+generated frames in the retained trace. More buffering cannot cure a+sustained service-time deficit without growing latency.++XeSS `prefix-xess4`: 30s, lifecycle passes, app60/s and SDK240/s in the+final reported samples, zero admission skips/expiration. SDK counters do+not establish subframe scanout timing. Earlier XeSS2X evidence remains in+`xess-final2`; no claim of a new 2X run after the allocator change.++CPU policy suite: 121 PASS, exit0, including first/last deadlines, queued+cost, CPU time not erasing future FG work and history warmup. GPU+`prefix-content6`: dynamic2/4/6/default, real PTS, reset/recovery,40 NR+frames,144 FG evaluations,140 valid outputs, debugErrors=0, exit0.++`prefix-lifecycle`: paused seek, resume, live pacing-mode changes, resize,+off-mode playback and clean stop pass, exit0. `prefix-smoke`: main program+`--smoke-empty --smoke-seconds 5`, exit0. These validate lifecycle, not+NR-on fixed6 cadence. The final rebuild only added diagnostic log fields+after prefix2/6/adaptive6/headroom6; scheduling behavior is identical.++## Reproduction and evidence++Outputs: `E:/项目/Veyra/tests/fg-cadence-repair-20260920/<run>` and+`<run>.{stdout,stderr}.log`, JSON from `scripts/acceptance/analyze-fg-cadence.py`.+Build/log root: `E:/项目/Veyra/logs/fg-cadence-repair-20260920`.+Temporary root: `E:/项目/Veyra/tmp/fg-cadence-repair-20260920`.+Current local build: `E:/项目/Veyra/build/slider-reset-20260919/veyra.exe`.++Build via `scripts/build-isolated.ps1`, existing build/cache, display1.4.3,+targets `veyra`, `veyra_fg_sustained_tests`, `veyra_presentation_worker_tests`,+`veyra_fg_admission_tests`, `veyra_presentation_pacing_tests`; logs+`prefix-final-build.log`, `prefix-lifecycle-build.log`, `prefix-final-cpu.log`.+Run via `scripts/run-short-test.ps1`,95s watchdog (admission150s), working+directory `E:/项目/Veyra/tests/dlss-recovery-20260920`, process TEMP/TMP set+to the temporary root. Sustained arguments: media,output,multiplier,on,+seconds,on,minimumRatio,file-4k; headroom uses effects off, XeSS uses+file-xess-4k. Fixed6 diagnostics set `VEYRA_TEST_FIXED_FG_MULTIPLIER=1`;+per-subframe analysis sets `VEYRA_TEST_TRACE_SUBFRAMES=1`.++## Remaining acceptance++NR-on fixed6X smoothness remains open. Investigate serial enhancement/FG+cost and reject/warmup recovery rather than further arbitrary admission+tuning. A second enhancement queue requires per-pair motion/depth and+independent fence ownership; do not share the current monotonically+signaled fence across unordered queues or assume concurrency is faster.+Neither disabling NR, changing the 4K contract nor actual4X is fixed6X+acceptance. The active goal remains open; shutdown is not yet performed.diff --git a/docs/FG_CADENCE_REPAIR_PLAN_2026-09-20.md b/docs/FG_CADENCE_REPAIR_PLAN_2026-09-20.mdindex 9aba1922..717bd056 100644--- a/docs/FG_CADENCE_REPAIR_PLAN_2026-09-20.md+++ b/docs/FG_CADENCE_REPAIR_PLAN_2026-09-20.md@@ -1,5 +1,12 @@# Fixed-media DLSS cadence repair+Latest continuation: prefix admission, carried queue prediction and minimum+file output spacing are now enabled normally; command allocator budget16,+two-job capacity unchanged. Experimental admission/spacing flags removed.+The historical default6/opt-in statements below describe earlier experiments.+See FG_CADENCE_REPAIR_ACCEPTANCE_2026-09-20.md for current measured results+and remaining fixed6X acceptance. No claim of a completed fixed6X 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.diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 34b69f8f..83c1fb73 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -4752,3 +4752,43 @@ remaining16 reached274.567/s in its retained window but kept48 rejected/warmup pXeSS xess-final2 and xess-final4 ran30s each: lifecycle passed, app submissions60/s, SDK-reported output120/240 respectively, no admission skips or post-evaluation expiration in reported samples. These are not per-subframe scanout measurements. content-build.log succeeded, content6 GPU regression exited0 (150s watchdog, actual about5s): dynamic2/4/6/default, reset/recovery and D3D12 validation passed with zero errors. Diagnostic readback on source frames13/21/29 found adjacent generated images different (3.0-6.9 million changed RGB channels; mean absolute byte difference0.218-1.079). This excludes byte-identical repetition in these samples, not incorrect temporal order or interpolation artifacts. Readback is test-only. Artifacts remain under the previously recorded E:/ paths.Fixed6X uniform-cadence acceptance remains open. Experimental queue/profile/spacing controls remain opt-in and must not be described as production-ready. No publication, package or shutdown.++### Prefix admission promotion and partial acceptance++Enabled measured first-output/whole-group file admission with carried GPU+queue debt, minimum file DLSS output spacing and16 command allocators for+the existing two-job bound. Removed rejected experimental admission/spacing+switches; preserved fixed-multiplier and trace diagnostics. Admission logs+now expose first deadline, queue cost and requested/effective multipliers.+Files: FgRecoveryBudget.h, EngineController.cpp, LiveGpuSchedulerTests.cpp;+current status, plan and new FG_CADENCE_REPAIR_ACCEPTANCE_2026-09-20.md.++Build commands: scripts/build-isolated.ps1 with existing slider-reset build+and CMakeCache, explicit E:/ tmp, display1.4.3 and targets sustained, worker,+main, admission, pacing. Logs prefix-final-build.log and+prefix-lifecycle-build.log succeeded. Worker test prefix-final-cpu.log:+121 PASS, exit0. Every GPU run used scripts/run-short-test.ps1, bounded+95s watchdog (admission150s), process-local TEMP/TMP; sequential runs.+prefix2/adaptive6/headroom6/xess4 duration30s, prefix6 duration45s;+analyzed frame-trace.txt with scripts/acceptance/analyze-fg-cadence.py.++Results: NR-on2X120.001/s; NR-on fixed6X265.445/s but P95gap15.428ms,+max17.169ms and19 gaps over16.667ms in retained5.760s, NOT accepted as+uniform6X. Requested6 adaptive actual4X240.007/s, P95gap4.514ms, fallback+only. Effects-off fixed6X360.004/s, P95gap3.198ms, diagnostic only. Both2X+and headroom6 meet>=95% target assertion. Others' exit0 means lifecycle,+not target throughput. No scanout measurement; no physical latency claim.++XeSS prefix-xess4: SDK240/s, app60/s in final samples, no budget rejection+or generated expiration. prefix-content6 validates dynamic2/4/6/default,+PTS, reset and recovery; debugErrors0, exit0. prefix-lifecycle passes+paused seek, resume, mode changes, resize and stop. prefix-smoke passes+main startup/exit5s. Final added log fields do not alter scheduling.++All new outputs remain E:/项目/Veyra/{tests,logs,tmp}/fg-cadence-repair-20260920;+current executable E:/项目/Veyra/build/slider-reset-20260919/veyra.exe.+No intermediate package or extraction created. Retain diagnostic evidence.+Current serial NR+flow+FG exceeds60Hz budget; do not infer architectural+optimization is impossible. Fixed6X cadence remains an active goal; no+shutdown, package, push or publication. This continuation supersedes the+earlier opt-in/default6 descriptions without rewriting historical results.diff --git a/include/veyra/engine/FgRecoveryBudget.h b/include/veyra/engine/FgRecoveryBudget.hindex 5f3774db..5f6ebd07 100644--- a/include/veyra/engine/FgRecoveryBudget.h+++ b/include/veyra/engine/FgRecoveryBudget.h@@ -14,6 +14,11 @@ class FgRecoveryBudget {std::deque<Sample> base_,fg_,warmup_;bool limited_=false;unsigned recoveryPairs_=0;+ bool recordAdmission(bool fits){+ if(!fits){limited_=true;recoveryPairs_=0;return false;}+ if(limited_&&++recoveryPairs_>=2){limited_=false;recoveryPairs_=0;}+ return true;+ }static void add(std::deque<Sample>& values,int64_t now,double ms){if(!std::isfinite(ms)||ms<0)return;while(!values.empty()&&(values.size()>=64||values.front().time<now-10000000))values.pop_front();@@ -63,16 +68,22 @@ public:const double queued=std::isfinite(queuedMs)?std::max(0.0,queuedMs):0.0;const double progress=std::clamp(elapsed,0.0,queued+baseCost(now).value_or(0));const bool fits=double(deadline-now)/10000+10>=std::max(0.0,queued+cost.value_or(0)-progress)+std::max(0.0,present);- if(!fits){- limited_=true;recoveryPairs_=0;return false;- }- if(limited_){- // A probe consists of consecutive admitted pairs, not an isolated- // warmup. A fresh pair that fits can recover immediately; a fixed- // cooldown otherwise discards 15 healthy 60 Hz opportunities.- if(++recoveryPairs_>=2){limited_=false;recoveryPairs_=0;}- }- return true;+ return recordAdmission(fits);+ }+ bool admitFile(int64_t now,int64_t firstDeadline,int64_t lastDeadline,int64_t outputInterval,+ double elapsed,double present,std::optional<double> firstFgMs,bool warmingHistory,double queuedMs){+ const auto whole=predicted(now,warmingHistory),base=baseCost(now);+ if(warmingHistory||!whole||!base||!firstFgMs||!std::isfinite(*firstFgMs)||*firstFgMs<0)+ return admit(now,lastDeadline,elapsed,present,warmingHistory,queuedMs);+ const double queued=std::isfinite(queuedMs)?std::max(0.0,queuedMs):0.0;+ const double progress=std::clamp(elapsed,0.0,queued+*base);+ const double blit=std::max(0.0,present),grace=double(std::max<int64_t>(0,outputInterval))/10000;+ const auto fits=[&](int64_t deadline,double cost){+ return double(deadline-now)/10000+grace>=std::max(0.0,queued+cost-progress)+blit;+ };+ // The first output must be reachable too: the last deadline alone can+ // admit a whole MFG group whose early outputs are already doomed.+ return recordAdmission(fits(firstDeadline,*base+*firstFgMs)&&fits(lastDeadline,*whole));}bool recovering()const{return limited_&&recoveryPairs_>0;}};diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cppindex 6529aaa8..2df1df04 100644--- a/src/engine/EngineController.cpp+++ b/src/engine/EngineController.cpp@@ -194,7 +194,9 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,stry {do {Status st=Status::Ok;gfx::DeviceContextDesc dd;dd.commandSlotCount=6;- wchar_t testSlots[16]{};unsigned commandSlots=6;+ // Two bounded jobs, each up to three enhancement lists plus five+ // MFG lists. Allocators must not stall the presentation owner.+ wchar_t testSlots[16]{};unsigned commandSlots=16;if(GetEnvironmentVariableW(L"VEYRA_TEST_COMMAND_SLOTS",testSlots,16))commandSlots=std::clamp(unsigned(_wtoi(testSlots)),6u,24u);if(!ctx.initialize(dd,st)||!ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),commandSlots,st)){status(L"D3D12初始化失败,请查看诊断",true);break;}auto ext=std::filesystem::path(path).extension().wstring();for(auto& c:ext)c=towlower(c);@@ -1057,13 +1059,13 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sconst bool injectedReject=transaction&&!options.nr&&GetEnvironmentVariableW(L"VEYRA_TEST_REJECT_NR_DISABLE",nullptr,0)>0;if(injectedReject)veyra::log::error("settings-test","test-only reject NR-disable transaction before graph process; no driver failure");pipeline::EnhanceGraph::FgAdmission admitFg;- const auto logAdmission=[&](const pipeline::FrameBatch& batch,int64_t now,int64_t deadline,double elapsed,double blit,bool admitted,bool warmingHistory,const char* timeline){+ const auto logAdmission=[&](const pipeline::FrameBatch& batch,int64_t now,int64_t deadline,double elapsed,double blit,bool admitted,bool warmingHistory,const char* timeline,int64_t firstDeadline=0,double queuedMs=0){if(admitted)++fgAdmittedPairs;else ++fgRejectedPairs;// Keep the first rejection even if the periodic sample just// logged a success. Both channels remain rate bounded.if(now<nextFgAdmissionLog&&(admitted||now<nextFgRejectionLog))return;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));+ veyra::log::info("live-fg-admission",std::format("timeline={} revision={} source={} multiplier={} requestedMultiplier={} admitted={} admittedPairs={} rejectedPairs={} remainingDeadlineMs={:.3f} firstDeadlineMs={:.3f} queuedGpuMs={:.3f} predictedMs={:.3f} elapsedMs={:.3f} blitGpuP95Ms={:.3f} presentCpuP95Ms={:.3f} warmingHistory={} (CPU Present is backpressure, not added GPU cost; firstDeadlineMs=-1 when unused)",timeline,batch.identity.settingsRevision,batch.identity.sourceFrameId,previewFgMultiplier,options.fgMultiplier,admitted,fgAdmittedPairs,fgRejectedPairs,double(deadline-now)/10000,firstDeadline?double(firstDeadline-now)/10000:-1,queuedMs,fgBudget.predicted(now,warmingHistory).value_or(-1),elapsed,blit,livePresent.p95(),warmingHistory));};if(fgBudgetRevision!=options.settings.revision){fgBudget.reset();fgCapacity.reset();pairLatency.reset();fgBudgetRevision=options.settings.revision;}previewFgMultiplier=options.fgMultiplier;@@ -1100,13 +1102,12 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sreturn admitted;};}- // File playback: same pair admission, but deadlines are PTS- // deadlines on the audio master clock. A pair whose last- // generated timestamp can no longer be reached spends no FG- // Evaluate; the real frame keeps its normal cadence (plan §4.1).+ // File playback checks both the first output and whole-group+ // deadlines against the audio clock, including older queued+ // GPU work. The real frame retains its original media PTS.double queuedGpuMs=0;if(!isCapture&&!isImage&&!rereadCached&&!transaction&&options.fg&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)){- if(GetEnvironmentVariableW(L"VEYRA_TEST_ADMISSION_QUEUE",nullptr,0)){+ {const auto start=std::chrono::duration_cast<std::chrono::nanoseconds>(processStart.time_since_epoch()).count()/100;int64_t finish=0;for(const auto& previous:pendingCompletions){@@ -1114,42 +1115,22 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sconst auto began=std::chrono::duration_cast<std::chrono::nanoseconds>(previous->processStart.time_since_epoch()).count()/100;const auto cost=previous->output.fgEvaluated?fgBudget.predicted(start,previous->output.historyReset||previous->output.fgRecovery):fgBudget.baseCost(start);finish=std::max({finish,began,previous->predictedGpuStart100ns})+int64_t(cost.value_or(0)*10000);- if(GetEnvironmentVariableW(L"VEYRA_TEST_ADMISSION_REMAINING",nullptr,0)&&ctx.fence()->GetCompletedValue()>=previous->output.videoFenceValue){- const auto timing=frameFlow->snapshot(start).gpuTiming;- double remaining=0;bool known=true;- for(const auto& item:previous->output.batch.frames){- if(item.kind!=pipeline::FrameKind::Generated||!item.lease||ctx.fence()->GetCompletedValue()>=item.lease->readyFence)continue;- const auto stage=size_t(diagnostics::GpuStage::Fg1)+item.subframe-1;- if(stage>=timing.size()||!timing[stage].p95){known=false;break;}- remaining+=*timing[stage].p95;- }- if(known&&!previous->output.historyReset&&!previous->output.fgRecovery)- finish=std::min(finish,start+int64_t(remaining*10000));- }}queuedGpuMs=double(std::max<int64_t>(0,finish-start))/10000;}admitFg=[&,historyReset,queuedGpuMs](const pipeline::FrameBatch& batch,bool warmingHistory){if(fileAwaitingVideo)return true; // Bounded startup lookahead; audio has not started.- if(GetEnvironmentVariableW(L"VEYRA_TEST_ADMISSION_ALWAYS",nullptr,0))return true;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,previewFgMultiplier-1,previewFgMultiplier);const auto now=host100ns();- const auto admissionPts=GetEnvironmentVariableW(L"VEYRA_TEST_ADMISSION_FIRST",nullptr,0)?pipeline::FrameBatch::interpolate(a,batch.b100ns,1,previewFgMultiplier):lastGenerated;- const auto reserve=GetEnvironmentVariableW(L"VEYRA_TEST_ADMISSION_RESERVE",nullptr,0)?100000:0;- auto deadline=now+admissionPts-int64_t(nowMs()*10000.0)-reserve;- if(GetEnvironmentVariableW(L"VEYRA_TEST_ADMISSION_PROFILE",nullptr,0)&&!warmingHistory){- const auto first=frameFlow->snapshot(now).gpuTiming[size_t(diagnostics::GpuStage::Fg1)].p95;- const auto whole=fgBudget.predicted(now),base=fgBudget.baseCost(now);- if(first&&whole&&base){- const auto firstPts=pipeline::FrameBatch::interpolate(a,batch.b100ns,1,previewFgMultiplier);- deadline=now+firstPts-int64_t(nowMs()*10000.0)-100000+interval/previewFgMultiplier+int64_t(std::max(0.0,*whole-*base-*first)*10000);- }- }+ const auto media=int64_t(nowMs()*10000.0);+ const auto firstPts=pipeline::FrameBatch::interpolate(a,batch.b100ns,1,previewFgMultiplier);+ const auto firstDeadline=now+firstPts-media,deadline=now+lastGenerated-media;+ const auto first=frameFlow->snapshot(now).gpuTiming[size_t(diagnostics::GpuStage::Fg1)].p95;const auto elapsed=elapsedMs(processStart),blit=livePresentGpu.p95();- const auto admitted=fgBudget.admit(now,deadline,elapsed,blit,warmingHistory,queuedGpuMs);- logAdmission(batch,now,deadline,elapsed,blit,admitted,warmingHistory,"file-audio");+ const auto admitted=fgBudget.admitFile(now,firstDeadline,deadline,interval/previewFgMultiplier,elapsed,blit,first,warmingHistory,queuedGpuMs);+ logAdmission(batch,now,deadline,elapsed,blit,admitted,warmingHistory,"file-audio",firstDeadline,queuedGpuMs);return admitted;};}@@ -1337,7 +1318,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sif(nowMs()+.25<itemPtsMs)return {State::Pending,now+std::min<int64_t>(10000,int64_t((itemPtsMs-nowMs())*10000))};}const auto optionalNow=host100ns();- if(!isCapture&&!fileAwaitingVideo&&options.fg&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)&&GetEnvironmentVariableW(L"VEYRA_TEST_SUBFRAME_SPACING",nullptr,0)){+ if(!isCapture&&!fileAwaitingVideo&&options.fg&&!presentSinkFrameGeneration(options.settings.frameGenerationBackend)){const auto interval=std::max<int64_t>(1,int64_t(sourceIntervalMs*10000)/std::max(1u,batch.batch.count));const auto due=cadence.due(optionalNow+int64_t((itemPtsMs-nowMs())*10000),interval);if(optionalNow<due)return {State::Pending,due};diff --git a/tests/unit/LiveGpuSchedulerTests.cpp b/tests/unit/LiveGpuSchedulerTests.cppindex 3a77cf2c..43e18e05 100644--- a/tests/unit/LiveGpuSchedulerTests.cpp+++ b/tests/unit/LiveGpuSchedulerTests.cpp@@ -72,6 +72,17 @@ int main(){check(!scheduler.push([](int64_t){return Scheduler::Step{State::Complete};},[]{}),"failed scheduler rejects new work");veyra::engine::TimingWindow timing;for(unsigned i=0;i<100;++i)timing.add(i);check(timing.p95()==94,"percentile order statistic");timing.clear();timing.add(6);check(timing.p95()==6,"reset removes old timing window");veyra::engine::FgRecoveryBudget budget;+ {+ veyra::engine::FgRecoveryBudget prefix;+ prefix.complete(18,true,false,10000000,10);+ check(!prefix.admitFile(10000000,10070000,10250000,27778,0,0,3,false,0),"late first subframe rejects even when the last output fits");+ check(prefix.admitFile(10000000,10100000,10250000,27778,0,0,3,false,0),"first deadline uses prefix cost rather than full MFG group");+ check(!prefix.admitFile(10000000,10100000,10140000,27778,0,0,3,false,0),"last subframe also has to fit when later FG work is slower");+ check(!prefix.admitFile(10000000,10100000,10250000,27778,0,0,3,false,5),"pending previous batch cannot be mistaken for free first-frame headroom");+ check(!prefix.admitFile(10000000,10000000,10250000,27778,100,0,3,false,0),"CPU delay cannot erase future first interpolation work");+ prefix.complete(4,true,true,10000000);+ check(prefix.admitFile(10000000,9900000,10010000,27778,0,0,3,true,0),"history seed has no generated prefix to present");+ }{veyra::engine::FgRecoveryBudget queued;queued.complete(10,true,false,10000000,4);