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 frame generation backend switching and XeLL presentation cycles

Veyra Goal Agent8c9957b5344d
diff --git a/apps/veyra/SettingsWindow.cpp b/apps/veyra/SettingsWindow.cpp
index 1312059d..d131a999 100644
--- a/apps/veyra/SettingsWindow.cpp
+++ b/apps/veyra/SettingsWindow.cpp
@@ -856,7 +856,7 @@ bool colourFieldEdited(int index,float value){
return true;
}
void message(const std::wstring& text){if(statusSink)statusSink(text);else putText(401,text.c_str());}
-bool submit(engine::EnhancementSettings s){if(!apply(s)){dirty=true;message(L"总增强正在切换;本次修改未接受,请稍后重试。");return false;}dirty=false;return true;}
+bool submit(engine::EnhancementSettings s){if(!apply(s)){dirty=true;message(L"修改未接受,请查看状态栏或日志;若总增强正在切换,请稍后重试。");return false;}dirty=false;return true;}
void syncProtection(const engine::ProtectionSettings& protection){
check(206,protection.enabled?BST_CHECKED:BST_UNCHECKED);unsigned count=0;for(auto q:protection.regions)count+=!q.empty();
putText(206,(L"NR剔除区 · "+std::to_wstring(count)+L"/4").c_str());
@@ -875,7 +875,8 @@ void selectDiscrete(int group,int value){for(int j=0;j<(group==0?3:2);++j){auto
// Multiplier list is capability-driven: the DLSS runtime reports how many
// generated frames it supports (1 = 2X only on Ada, 5 = 6X on Blackwell), and
// the XeSS unlock path raises its own ceiling. Unknown capability offers the
-// full list; the engine gate rejects an unsupported request with a message.
+// full list; initialization validates a newly requested XeSS context after
+// applying its unlock, rather than treating the current 2X mode as a limit.
int multiplierChoiceCount(engine::FrameGenerationBackend backend){
int cap=6;
if(backend==engine::FrameGenerationBackend::XeSS){
diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cpp
index 9ab6d10e..664588b3 100644
--- a/apps/veyra/ui/AppShell.cpp
+++ b/apps/veyra/ui/AppShell.cpp
@@ -78,7 +78,21 @@ bool openColourPageOnStart=false;
uint64_t colourLiveRevision=0;
uint64_t colourPausedBase=0;
void switchMode();void selectInspector(int);
-bool applySettings(veyra::engine::EnhancementSettings s){if(masterPendingRevision)return false;uiState.configured=s;if(uiState.enhanced)engine.requestSettings(s);else {auto effective=engine.snapshot().desired;if(effective.captureCompatible!=s.captureCompatible||effective.forceSdrPreview!=s.forceSdrPreview||effective.captureFlipVertical!=s.captureFlipVertical||effective.captureBuffer!=s.captureBuffer||!(effective.color==s.color)){effective.captureCompatible=s.captureCompatible;effective.forceSdrPreview=s.forceSdrPreview;effective.captureFlipVertical=s.captureFlipVertical;effective.captureBuffer=s.captureBuffer;effective.color=s.color;engine.requestSettings(effective);}veyra::log::info("ui-settings","enhancement off: draft saved; presentation setting applied independently");}veyra::ui::settingsEnabled(uiState.enhanced,uiState.configured);return true;}
+bool applySettings(veyra::engine::EnhancementSettings s){
+ if(masterPendingRevision)return false;
+ if(uiState.enhanced){if(!engine.requestSettings(s))return false;}
+ else {
+ auto effective=engine.snapshot().desired;
+ if(effective.captureCompatible!=s.captureCompatible||effective.forceSdrPreview!=s.forceSdrPreview||effective.captureFlipVertical!=s.captureFlipVertical||effective.captureBuffer!=s.captureBuffer||!(effective.color==s.color)){
+ effective.captureCompatible=s.captureCompatible;effective.forceSdrPreview=s.forceSdrPreview;
+ effective.captureFlipVertical=s.captureFlipVertical;effective.captureBuffer=s.captureBuffer;effective.color=s.color;
+ if(!engine.requestSettings(effective))return false;
+ }
+ veyra::log::info("ui-settings","enhancement off: draft saved; presentation setting applied independently");
+ }
+ uiState.configured=s;
+ veyra::ui::settingsEnabled(uiState.enhanced,uiState.configured);return true;
+}
struct ToolbarItem{HWND hwnd;int width;};std::vector<ToolbarItem> toolbar;
bool full=false,holdOriginal=false,referenceBase=false;int compareMode=0;float compareSplit=.5f;WINDOWPLACEMENT windowPlacement{sizeof(windowPlacement)};
@@ -598,7 +612,9 @@ case WM_APP+45:{if(masterPendingRevision)return 0;auto settings=uiState.enhanced
if(wp==214){cancelProtection();settings.protection={};}else if(wp==206)settings.protection.enabled=lp==BST_CHECKED;else if(wp==222)settings.protection.featherPixels=float(std::clamp(int(lp),0,64));else return 0;
return applySettings(settings)?1:0;}
case WM_APP+44:{if(masterPendingRevision)return 0;auto setting=uiState.enhanced?engine.snapshot().desired:uiState.configured;const bool enabled=wp==202?lp>1:lp==BST_CHECKED;if(wp==200)setting.nr=enabled;else if(wp==201)setting.sr=enabled;else if(wp==230)setting.videoHdr.enabled=enabled;else if(wp==202){bool allowed=false;for(auto m:veyra::engine::kFgMultiplierChoices)if(uint32_t(lp)==m)allowed=true;if(!allowed)return 0;setting.multiplier=uint32_t(lp);if(!setting.validate().empty())return 0;}else return 0;
- const bool enablesMaster=enabled&&!uiState.enhanced;if(enablesMaster){masterPreviousEnabled=false;uiState.enhanced=true;}applySettings(setting);if(auto pending=engine.snapshot();enablesMaster&&pending.running){masterPendingRevision=pending.desired.revision;masterPendingSession=pending.sessionId;}veyra::log::info("ui-feature",std::format("click={} enabled={} requestedRevision={} draft-independent=true",wp==200?"NR":wp==201?"SR":wp==230?"VideoHDR":"FG",enabled,engine.snapshot().desired.revision));return 1;}
+ const bool enablesMaster=enabled&&!uiState.enhanced;if(enablesMaster){masterPreviousEnabled=false;uiState.enhanced=true;}
+ if(!applySettings(setting)){if(enablesMaster)uiState.enhanced=false;veyra::ui::settingsEnabled(uiState.enhanced,uiState.configured);return 0;}
+ if(auto pending=engine.snapshot();enablesMaster&&pending.running){masterPendingRevision=pending.desired.revision;masterPendingSession=pending.sessionId;}veyra::log::info("ui-feature",std::format("click={} enabled={} requestedRevision={} draft-independent=true",wp==200?"NR":wp==201?"SR":wp==230?"VideoHDR":"FG",enabled,engine.snapshot().desired.revision));return 1;}
case WM_APP+43:showDiagnostics=false;layout();return 0;
case WM_APP+41:switch(wp){case 501:startVideoExport(lp!=0);break;case 502:{auto path=fileDialog(true);if(!path.empty())engine.saveFrame(path);break;}case 503:jobPaused=!jobPaused;exportJob.pause(jobPaused);break;case 504:exportJob.cancel();break;case 505:preferWatching=lp==BST_CHECKED;break;}return 0;
case WM_ENTERSIZEMOVE:
diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.md
index 5d3c1663..4a736c41 100644
--- a/docs/CURRENT_STATUS.md
+++ b/docs/CURRENT_STATUS.md
@@ -2,6 +2,8 @@
更新:2026-09-19。发布状态与开发状态分别记录,历史计划不代表当前验收。
+最新切换修复(09-20 最终回归):`codex/fg-backend-switch-20260919` 修正 XeSS 旧倍率缓存、UI 请求拒绝、失败回退及异步准备帧的 XeLL 标记周期。RTX5070 引擎/真实下拉切换、失败注入、拖动/重置/缩放回归通过。YUY2 50fps 合成输入 2X/4X 有生成输出,1:1 单像素测试未发现额外模糊;用户所述观感及与 PotPlayer 的差异仍缺同条件对照,不能宣称解决。详见 [切换修复记录](FG_BACKEND_SWITCH_REPAIR_2026-09-19.md)。仅本地编译,未更新用户便携包或发布。
+
最新补充修复:`codex/seven-audit-20260919` 基于 `80f7dc4` 完成七项独立审查修复,涵盖压缩采集参考链/帧身份/PTS、FFmpeg EAGAIN 重送、D3D11 引用释放及字幕布局/缓存;同时修正构建依赖编码和字幕设置编译类型问题。干净构建、H.264/HEVC 软件及硬解、4K 文件、字幕像素、时序回归和主程序启动检查通过。实际采集卡队列与 GC573/GC551 未验收,详见 [七项修复报告](SEVEN_AUDIT_REPAIR_2026-09-19.md)。此前 DLSS/XeSS 调度修复保留;本轮仅本地,未打包或发布。
最新本地修复:`codex/fg-scheduling-repair-20260919` 从存档 `5a1931b` 修复 DLSS 暖机预算污染、CPU Present 重复计费、窗口采集期限抖动,以及 XeSS 实时呈现前的额外相位等待。构建和本机持续生成/拥堵恢复测试结果见 [补帧调度验收](FG_SCHEDULING_ACCEPTANCE_2026-09-19.md)。GC573 53fps 只新增定位诊断,尚无实卡根因与修复证明;5080 功耗、30/40 系和物理显示验收未覆盖。本轮未打包、合并 main、推送或发布。
diff --git a/docs/FG_BACKEND_SWITCH_REPAIR_2026-09-19.md b/docs/FG_BACKEND_SWITCH_REPAIR_2026-09-19.md
new file mode 100644
index 00000000..1c66034b
--- /dev/null
+++ b/docs/FG_BACKEND_SWITCH_REPAIR_2026-09-19.md
@@ -0,0 +1,67 @@
+# XeSS / DLSS selector rollback repair
+
+## Evidence and scope
+
+User log: `E:/App/Veyra-1.4.2-test-win64-portable/logs/veyra-app.log`.
+At 2026-09-19T14:20:21.900Z and repeatedly through 14:28:06.169Z, the selector accepts the choice but EngineController logs `xess multiplier gate: requested=4 maxInterpolatedFrames=1 applied=unchanged` (other attempts request 3X). The request never reaches provider initialization.
+
+Baseline `43b8a4a`, checkpoint `checkpoint/pre-fg-backend-switch-20260919`, branch `codex/fg-backend-switch-20260919`. Includes preceding scheduling and seven-audit repairs. Local build only; no package, main merge, push or release.
+
+## Root cause and changes
+
+- EngineController treated the current XeSS context's ceiling as a permanent capability. Stock 2X intentionally does not apply MFG patches; leaving unlocked XeSS restores those patches and retains diagnostic state. Publishing that state as a 2X ceiling then blocked future 3X/4X requests before initialization. Removed this pre-initialization XeSS rejection. XessPresenter still verifies the unlock and queries the actual runtime ceiling before accepting the requested count. No unsupported multiplier is reported as active.
+- Capability publication now reports only the active XeSS context; inactive means unknown (0). The UI's audited-provider choices remain distinct from the current context's count. DLSS retains its runtime capability checks and 6X option.
+- AppShell now propagates requestSettings rejection, changes the saved draft only after acceptance, and restores the master toggle if enabling a feature was rejected. SettingsWindow no longer attributes every rejection to a pending master toggle.
+- Failure injection exposed another behavior: a failed live switch silently disabled FG through startup degradation logic. A live backend/multiplier change from existing FG now uses the existing transaction rollback on FG initialization failure. Startup degradation and first-time enabling remain unchanged.
+
+Further regression exposed `XeLL marker result=-4` when two source preparations advanced marker IDs ahead of the first presentation. A later attempted presentation-ID rebase also failed at sleep ID 33 because it left incomplete cycles. Final implementation in `src/gfx/XessPresenter.cpp` allocates one complete XeLL cycle per presentation: one sleep, simulation start/end, render start/end, present start/end. Queued source preparations share the open cycle; render-submit end stays immediately before presentation, covering all submissions in that cycle. A repaint or previously prepared source starts a fresh complete cycle when necessary. These timings are presentation-cycle instrumentation, not individual source-to-screen latency. Source queueing and frame generation remain asynchronous; no dragging suppression or duplicate output was added.
+
+Product files: `src/engine/EngineController.cpp`, `apps/veyra/ui/AppShell.cpp`, `apps/veyra/SettingsWindow.cpp`, `src/gfx/XessPresenter.cpp`, `include/veyra/gfx/XessPresenter.h`.
+Regression files: `tests/integration/FgSettingsTests.cpp`, `tests/integration/ExperimentalBackendTests.cpp`, `tests/integration/Yuy2ColorTests.cpp`, `scripts/acceptance/ui-fg-backends.py`.
+
+## Verification
+
+Build directory: `E:/项目/Veyra/build/slider-reset-20260919`.
+Dependency cache: `E:/项目/Veyra/build/frame-pacing-20260918/CMakeCache.txt`.
+Process TEMP/TMP: `E:/项目/Veyra/tmp/fg-backend-switch-20260919`.
+Evidence: `E:/项目/Veyra/tests/fg-backend-switch-20260919` and `E:/项目/Veyra/logs/fg-backend-switch-20260919`.
+
+Commands (PowerShell array syntax for Targets/Arguments):
+
+```powershell
+scripts/build-isolated.ps1 -Root . -BuildDirectory 'E:/项目/Veyra/build/slider-reset-20260919' -DependencyCache 'E:/项目/Veyra/build/frame-pacing-20260918/CMakeCache.txt' -TempDirectory 'E:/项目/Veyra/tmp/fg-backend-switch-20260919' -Targets @('veyra','veyra_fg_settings_tests')
+scripts/run-short-test.ps1 -Exe 'E:/项目/Veyra/build/slider-reset-20260919/veyra_fg_settings_tests.exe' -Arguments @('E:/项目/Veyra/tests/1.4.2beta/visible-scene.mp4','E:/项目/Veyra/tests/fg-backend-switch-20260919/engine-final','backend-switch') -TimeoutSeconds 220 -LogPrefix 'E:/项目/Veyra/logs/fg-backend-switch-20260919/engine-final'
+python scripts/acceptance/ui-fg-backends.py 'E:/项目/Veyra/build/slider-reset-20260919/veyra.exe' 'E:/项目/Veyra/tests/1.4.2beta/visible-scene.mp4' 'E:/项目/Veyra/tests/fg-backend-switch-20260919/ui-final'
+python scripts/acceptance/ui-fg-backends.py 'E:/项目/Veyra/build/slider-reset-20260919/veyra.exe' 'E:/项目/Veyra/tests/1.4.2beta/visible-scene.mp4' 'E:/项目/Veyra/tests/fg-backend-switch-20260919/ui-reject-verified' --reject-xess
+```
+
+Test PATH includes the existing 1.4.2 portable root and `C:/veyra-deps/ffmpeg-ps5-dav1d-installed/bin`. GPU tests run sequentially. UI harness bounds each run to 90 seconds and now requires explicit media/output paths.
+
+- Final 2026-09-20 build succeeded: `E:/项目/Veyra/logs/fg-backend-switch-build-verified.log`. Targets: veyra, veyra_fg_settings_tests, veyra_experimental_backend_tests, veyra_yuy2_color_tests, veyra_repair_contract_tests.
+- Engine regression checks seven successive requests: XeSS4 -> DLSS4 -> XeSS4 -> XeSS2 -> XeSS4 -> DLSS6 -> XeSS4. Each must apply its revision/backend/count and increase real and generated frame counters; stop must drain cleanly.
+- Final engine regression: `engine-verified`, exit 0, seven switches and clean stop.
+- Final actual popup test passed: `ui-verified/result.json`, exit 0. Includes repeated backend changes, stock 2X to unlocked 4X, DLSS6 to XeSS4 clamp, FG off, and selector layout at three window sizes.
+- Injected XeSS initialization failure passed: `ui-reject-cycle/result.json`, exit 0. Returns to DLSS and can subsequently disable FG.
+- Final provider regressions: xess-recovery2/4, xess-pan2/4, xess-resize4, xess-yuy50-2/4; all `*-verified` runs exit 0, debugErrors=0. Each uses the experimental backend exe with mode and explicit output directory, through run-short-test.ps1 with TimeoutSeconds=60.
+- `yuy-pixels-verified`: all four range/matrix combinations pass, source error <=1/255 and display error 0. Includes alternating single-pixel luma in the upper half and chroma/matrix patterns in the lower half; NR off, 1:1 presentation, synthetic 256x64 input.
+- `contracts-verified`: repair contract tests exit 0. Both pixel/contract runs use run-short-test.ps1 with TimeoutSeconds=60 and the matching executable.
+- Final application SHA256: `9E7FA94E527BE52FEE8CC875AE249CCA05645A8D7B97B1FC850B21422CE994FC`.
+
+The command examples above describe earlier runs. For the final reruns substitute engine-verified, ui-verified and ui-reject-cycle respectively. Earlier engine-monotonic failed and is retained; engine-cycle and recovery4-cycle passed an intermediate version. Final verified runs supersede intermediate evidence.
+
+Failures retained as evidence: first injected-failure run (`ui-reject`) exposed disabled FG instead of rollback. After repair, the old harness still timed out looking for warnings in hidden inspector label 401, although the engine and selector restored DLSS; professional mode routes warnings through its status sink. Corrected the assertion to check selector, applied-backend label and rollback diagnostics, then reran successfully. An attempted ffprobe command referenced an absent executable; it was not used as validation evidence.
+
+Local GPU: RTX 5070. This verifies settings transactions, generated output and GUI state, not physical scanout, interpolation quality or all RTX 30/40/50 drivers. No new SDK/runtime binaries, no runtime files modified, no export/NR/color algorithm changes. Source diff review checks request rejection, asynchronous rollback and startup recovery separately.
+
+## YUY2 50fps and capture clarity investigation
+
+User clarified the sharpness comparison is against PotPlayer. Its input format, filter settings and display size remain unknown; no matched PotPlayer capture was supplied or measured. User capture stays running and was not interrupted for tests.
+
+- GUID subtype `0x32595559` is YUY2. At 14:19:47.963Z, session 5 revision 15 reports capture 50fps, DLSS generated 150fps and total submission 200fps, no skipped evaluations or expired generated frames. At 14:22:45.964Z DLSS2 reports 50 generated and 100 total fps.
+- At 14:22:49.442Z XeSS2 reports enabled=1, framesPresented=2 and generatedTotal=58. Common frame-flow GPU counters intentionally exclude provider-internal frames, while capture-timing and the UI already use separate provider counters. Added a separate provider-flow log with SDK count/rate and explicit not-scanout label; did not mix these into GPU completion metrics.
+- Synthetic 640x360 YUY2 input with 50fps timestamps and paced arrival, 100 frames: XeSS2 generated 96 frames, XeSS4 generated 288, after test resets/resize. Both pass the generation threshold and D3D12 debug checks. This covers unpack -> graph -> provider, not the real capture driver or visible interpolation quality.
+- Native YUY2 uses direct connection, no intermediate 4:2:0 converter. Shader loads each luma independently; chroma is shared between two pixels as required by 4:2:2. Pixel regression found no extra luma blur at 1:1 presentation.
+- Relevant user intervals preserve 2560x1440 base/output while NR/flow operate at 1920x1080. NrResidualComposite retains the high-resolution base and upsamples the NR residual, so claiming the whole image is reduced to 1080p would be wrong. NR can still alter texture detail.
+- Presentation uses bilinear sampling by default, optional bounded cubic magnification; this can differ from another renderer when scaled. Range/matrix fallback and YUY2 chroma subsampling can affect apparent contrast/colored text, but neither is proven as this user's cause.
+
+Unresolved: perceived lack of smoothing and PotPlayer sharpness difference. Need matched input format/resolution, same frame at 1:1 with all effects off, then effects-on comparison; verify actual unique source cadence and display refresh/pacing separately. Existing logs cannot establish repeated pixel content or physical scanout. No speculative sharpening or input-format downgrade was introduced.
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index bbc1e2b9..59493edb 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -1,5 +1,21 @@
# Veyra 工作记录
+## 2026-09-20 切换最终回归、YUY2 50fps 与清晰度排查
+
+本条更新下方 09-19 的中间验收。进一步发现异步准备两帧导致 XeLL 标记失败;改为每次呈现完整周期、每周期仅一次 sleep,提交结束标记覆盖到呈现之前,未暂停拖动补帧。错误 ID 重映射试验失败记录保留,最终实现已重测。
+
+最终构建 `E:/项目/Veyra/logs/fg-backend-switch-build-verified.log`;验收 `E:/项目/Veyra/tests/fg-backend-switch-20260919`、`E:/项目/Veyra/logs/fg-backend-switch-20260919`。engine-verified 七轮切换、ui-verified 下拉操作、ui-reject-cycle 失败回退、XeSS recovery2/4、pan2/4、resize4、YUY2 50fps 2X/4X、YUY2 像素与 repair contracts 全部退出 0。合成 100 源帧生成 96/288 帧,debugErrors=0;单像素条纹转换误差 <=1/255,呈现误差 0。进程 TEMP/TMP 沿用 E 盘专用目录,未占用用户采集卡。
+
+增加独立 provider-flow 日志,避免通用 GPU 计数为 0 被误读成 XeSS 不生成。用户日志 DLSS50->200fps 与 XeSS2 有生成输出,但不能证明物理显示流畅。用户补充清晰度对比 PotPlayer;尚无相同格式、尺寸、效果的图像对照,未定因,未改画质算法。完整证据、命令及最终哈希见 `docs/FG_BACKEND_SWITCH_REPAIR_2026-09-19.md`。未覆盖 E:/App 下便携包、未打包或发布。
+
+## 2026-09-19 XeSS / DLSS 切换弹回修复
+
+用户日志确认 `xess multiplier gate: requested=4 maxInterpolatedFrames=1 applied=unchanged`。从 `43b8a4a` 存档 `checkpoint/pre-fg-backend-switch-20260919`,隔离分支 `codex/fg-backend-switch-20260919`,保留七项审查和此前调度修复。修正当前 XeSS 上限误用为永久限制、UI 忽略提交失败,以及已运行补帧换后端失败时被直接关闭的问题。
+
+修改 EngineController、AppShell、SettingsWindow、FgSettingsTests 与 ui-fg-backends.py。构建复用 `E:/项目/Veyra/build/slider-reset-20260919`,临时文件 `E:/项目/Veyra/tmp/fg-backend-switch-20260919`,测试/日志分别在同名 tests/logs 子目录;构建日志在 `E:/项目/Veyra/logs/fg-backend-switch-build-final.log`。具体命令、结果、失败过程及最终 exe 哈希见 `docs/FG_BACKEND_SWITCH_REPAIR_2026-09-19.md`。
+
+最终构建、真实 UI 反复切换和初始化失败回退通过;引擎测试检查七组后端/倍率切换后的真实生成计数。初次失败注入发现关闭补帧行为并修复;第二次因旧脚本检查隐藏状态标签超时,核对引擎已回退后修正脚本并重测通过。未打包、覆盖用户测试包、推送或发布;RTX30/40及用户机器未实测,运行库未修改。
+
## 2026-09-19 七项独立审查修复
用户要求将文档中七项一起修复。存档 `checkpoint/pre-seven-audit-20260919`,基线 `80f7dc4`,隔离分支 `codex/seven-audit-20260919`,保留此前 DLSS/XeSS 调度修复。完成压缩队列参考链恢复、解码输出帧身份、EAGAIN 真正接收重送、重排时间戳、D3D11 Context4 释放、字幕顶部/中部布局和全样式缓存键。
diff --git a/include/veyra/gfx/XessPresenter.h b/include/veyra/gfx/XessPresenter.h
index 64ba01b6..c20ebe55 100644
--- a/include/veyra/gfx/XessPresenter.h
+++ b/include/veyra/gfx/XessPresenter.h
@@ -14,6 +14,7 @@ public:
bool initialize(ID3D12Device*,ID3D12CommandQueue*,IDXGIFactory2*,HWND,const DXGI_SWAP_CHAIN_DESC1&,IDXGISwapChain3**,uint32_t fgMultiplier=1);
uint32_t beginInput();
bool beginProcessing(uint32_t frameId);
+ bool endProcessing(uint32_t frameId);
bool beginFrame(uint32_t preparedFrameId=0);
bool tag(ID3D12GraphicsCommandList*,ID3D12Resource* color,ID3D12Resource* motion,ID3D12Resource* depth,
RECT region,bool enabled,bool reset,float elapsedMs);
diff --git a/scripts/acceptance/ui-fg-backends.py b/scripts/acceptance/ui-fg-backends.py
index b6b3a1c7..874a4074 100644
--- a/scripts/acceptance/ui-fg-backends.py
+++ b/scripts/acceptance/ui-fg-backends.py
@@ -96,10 +96,12 @@ def text(hwnd):
return value.value
-exe = pathlib.Path(sys.argv[1] if len(sys.argv) > 1 else 'out/build/x64-release/veyra.exe').resolve()
-media = pathlib.Path('logs/video-sdk-trial-20260909/known-pan15.mp4').resolve()
-out = pathlib.Path('logs/continuation-repair-20260910') / ('ui-fg-' + str(time.time_ns()))
-out.mkdir(parents=True)
+if len(sys.argv) != 4:
+ sys.exit('Usage: ui-fg-backends.py EXE MEDIA OUTPUT_DIRECTORY [--reject-xess] [--portable]')
+exe = pathlib.Path(sys.argv[1]).resolve()
+media = pathlib.Path(sys.argv[2]).resolve()
+out = pathlib.Path(sys.argv[3]).resolve()
+out.mkdir(parents=True, exist_ok=True)
env = os.environ.copy()
env['PATH'] = (os.path.join(os.environ['SYSTEMROOT'], 'System32') + ';' + os.environ['SYSTEMROOT']
if portable else r'C:\veyra-deps\installed\x64-windows\bin;' + env['PATH'])
@@ -173,12 +175,28 @@ with (out / 'stdout.log').open('w') as stdout, (out / 'stderr.log').open('w') as
previous = text(revision_label)
choose(backend, index)
if reject_xess and name == 'XeSS':
- wait_for(lambda: send(backend, 0x147) == 0 and 'XeSS' in text(u.GetDlgItem(panel, 401)), 18)
+ # Professional mode routes warnings to its status sink, not
+ # the inspector's legacy hidden status label (401).
+ wait_for(lambda: send(backend, 0x147) == 0 and 'DLSS' in text(revision_label)
+ and re.search(r'\[reset-lifecycle\].*outcome=3', log()), 18)
result['switches'].append('XeSS rejected, DLSS retained')
continue
wait_for(applied, 18)
result['switches'].append(name)
- assert send(multiplier, 0x146) == (2 if name == 'XeSS' else 4), 'incorrect multiplier choices'
+ assert send(multiplier, 0x146) == (4 if name == 'XeSS' else 5), 'incorrect multiplier choices'
+ if not reject_xess:
+ # Prime the unlocked provider, leave it, then return at 4X. Also
+ # exercise a stock 2X context before requesting unlocked 4X again.
+ for control, index, label in [
+ (multiplier, 3, 'DLSS 4X'), (backend, 1, 'XeSS 4X'),
+ (backend, 0, 'DLSS 4X again'), (backend, 1, 'XeSS 4X again'),
+ (multiplier, 1, 'XeSS 2X'), (multiplier, 3, 'XeSS 4X after 2X'),
+ (backend, 0, 'DLSS return'), (multiplier, 4, 'DLSS 6X'),
+ (backend, 1, 'XeSS clamps 6X to supported 4X')]:
+ previous = text(revision_label)
+ choose(control, index)
+ wait_for(applied, 18)
+ result['switches'].append(label)
previous = text(revision_label)
choose(multiplier, 0)
wait_for(applied, 12)
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index 1b242d42..6a050053 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -51,6 +51,7 @@ int64_t monotonic100ns(){return std::chrono::duration_cast<std::chrono::nanoseco
struct OnExit {std::function<void()> action;~OnExit(){action();}};
void logFrameFlow(const diagnostics::FrameFlowMetrics& m,const char* state){
const auto& c=m.counters;const auto& id=m.latest;
+ if(c.xessSdkPresented)veyra::log::info("provider-flow",std::format("state={} session={} revision={} sdkPresented={} sdkGenerated={} sdkSubmitFps={:.2f} measurement=provider-report-not-scanout",state,id.sessionId,id.frame.settingsRevision,c.xessSdkPresented,c.xessSdkGenerated,m.xessSdkSubmitFps));
const auto& r=m.reset; const auto ms=[&](diagnostics::ResetStage s){return r.stageMs[size_t(s)].value_or(-1.0);};
veyra::log::info("frame-flow",std::format("state={} session={} revision={} epoch={} source={} batch={} readyFence={} consumerFence={} captureReceived={} mailboxOverwritten={} sourceAccepted={} sourceSkippedBeforeGraph={} realSubmitted={} fgCandidate={} fgSkippedBeforeEval={} fgEvaluated={} fgWarmup={} fgReadyValid={} fgInvalid={} realPresented={} generatedPresented={} generatedExpiredAfterEval={} cancelledBeforePresent={} commandSlots={} commandHighWater={} presentationHighWater={} slotWaitCount={} slotWaitMs={:.3f} generatedFps={:.2f} presentSubmitFps={:.2f} resetRevision={} resetEpoch={} resetReason={} resetOutcome={} resetDrainMs={:.3f} resetDestroyMs={:.3f} resetCreateMs={:.3f} resetWarmupMs={:.3f} resetFirstValidMs={:.3f} resetTotalMs={:.3f}",state,id.sessionId,id.frame.settingsRevision,id.frame.epoch,id.frame.sourceFrameId,id.batchId,id.readyFence,id.consumerFence,c.captureReceived,c.mailboxOverwritten,c.sourceAccepted,c.sourceSkippedBeforeGraph,c.realSubmitted,c.fgCandidate,c.fgSkippedBeforeEval,c.fgEvaluated,c.fgWarmup,c.fgReadyValid,c.fgInvalid,c.realPresented,c.generatedPresented,c.generatedExpiredAfterEval,c.cancelledBeforePresent,c.commandSlotsInFlight,c.commandSlotHighWater,c.presentationBatchHighWater,m.slotReuseWaitCount,m.slotReuseWaitMs.value_or(0),m.validGeneratedFps,m.presentSubmitFps,r.settingsRevision,r.epoch,unsigned(r.reason),unsigned(r.outcome),ms(diagnostics::ResetStage::Drain),ms(diagnostics::ResetStage::Destroy),ms(diagnostics::ResetStage::Create),ms(diagnostics::ResetStage::Warmup),ms(diagnostics::ResetStage::FirstValid),r.totalMs.value_or(-1.0)));
}
@@ -109,13 +110,9 @@ bool EngineController::requestSettings(EnhancementSettings s){
veyra::log::info("settings",std::format("multiplier gate: requested={} maxGeneratedFrames={} applied=unchanged",s.multiplier,fgMultiFrameMaxCap_));
return false;
}
- if(s.multiplier>1&&s.frameGenerationBackend==FrameGenerationBackend::XeSS&&xessMaxInterpolatedFramesCap_>0&&
- int(s.multiplier)-1>xessMaxInterpolatedFramesCap_){
- snapshot_.status=std::format(L"XeSS 帧生成上限为 {}X;请求未应用",xessMaxInterpolatedFramesCap_+1);
- snapshot_.failed=false;
- veyra::log::info("settings",std::format("xess multiplier gate: requested={} maxInterpolatedFrames={} applied=unchanged",s.multiplier,xessMaxInterpolatedFramesCap_));
- return false;
- }
+ // XeSS's current ceiling describes this context, not the next one: 2X
+ // intentionally runs without the MFG unlock. Validate a higher request in
+ // XessPresenter after applying the unlock; rebuild failure rolls it back.
// The AMD 3.1.x frame-generation provider delivers exactly one generated
// frame per presented frame; the probe (tools/fsr_probe) measured this on
// every requested count, so anything above 2X is refused instead of
@@ -298,7 +295,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
gd.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();
gd.compatibilityPreflight=[this](const auto& desc,const auto& device){return checkFgCompatibility(desc,device,stop_);};
std::wstring backendRecoveryWarning;
- auto initializePreview=[&](pipeline::EnhanceGraphDesc& desc,PlayerOptions& selected){
+ auto initializePreview=[&](pipeline::EnhanceGraphDesc& desc,PlayerOptions& selected,bool preserveWorkingFg=false){
backendRecoveryWarning.clear();
auto supported=selected.snapshot();
if(disableUnsupportedNvidiaEffects(supported,nvidiaAdapter)){
@@ -325,6 +322,9 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
if(opened&&graph.fsrSrRequested()&&!graph.fsrSrEnabled()){opened=false;failure=FailedBackend::Sr;}
}
if(opened)return true;
+ // A live backend/multiplier switch must not turn a working FG
+ // session into effects-off playback when the new provider fails.
+ if(preserveWorkingFg&&failure==FailedBackend::Fg)return false;
auto reduced=selected.snapshot();
// Requested multiplier above this GPU's capability: clamp to what
// the runtime supports and say so, instead of dropping frame
@@ -382,14 +382,14 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
const auto xessState=gfx::XessMfgUnlock::snapshot();
// Unknown until the XeSS provider actually ran: a DLSS-only
// session must not restrict the XeSS choices in the UI.
- xessMaxInterpolatedFramesCap_=xessState.providerLoaded?(xessState.applied&&xessState.maxInterpolations>0?int(xessState.maxInterpolations):1):0;
+ xessMaxInterpolatedFramesCap_=presenter.xessActive()?int(std::max(1u,xessState.maxInterpolations)):0;
snapshot_.xessMaxInterpolatedFrames=xessMaxInterpolatedFramesCap_;
// AMD FSR ceiling comes from the running presenter; 0 keeps the
// settings UI on its static 2X fallback until a session ran.
fsrMaxGeneratedFramesCap_=graph.fsrEnabled()&&presenter.fsrActive()?int(presenter.fsrMaxGeneratedFrames()):0;
snapshot_.fsrMaxGeneratedFrames=fsrMaxGeneratedFramesCap_;
if(fgMultiFrameMaxCap_>0)veyra::log::info("settings",std::format("frame-generation capability: maxGeneratedFrames={} maxMultiplier={}",fgMultiFrameMaxCap_,fgMultiFrameMaxCap_+1));
- veyra::log::info("settings",std::format("xess capability: maxInterpolatedFrames={} unlockApplied={} => maxMultiplier={}",xessState.maxInterpolations,xessState.applied,xessMaxInterpolatedFramesCap_+1));
+ veyra::log::info("settings",std::format("xess capability: active={} maxInterpolatedFrames={} unlockApplied={} (active context only)",presenter.xessActive(),xessMaxInterpolatedFramesCap_,xessState.applied));
if(fsrMaxGeneratedFramesCap_>0)veyra::log::info("settings",std::format("fsr capability: generatedPerPresent={} => maxMultiplier={}",fsrMaxGeneratedFramesCap_,fsrMaxGeneratedFramesCap_+1));
};
const auto initialRequested=options.snapshot();
@@ -801,7 +801,9 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
markResetStage(diagnostics::ResetStage::Drain);
if(!accepted){finishReset(diagnostics::ResetOutcome::Failed);status(L"设置切换排空失败,已停止",true);break;}
backendRecoveryWarning.clear();
- if(accepted&&rebuild){presenter.close();graph.shutdown();markResetStage(diagnostics::ResetStage::Destroy);accepted=initializePreview(nextDesc,next);
+ const bool preserveWorkingFg=previous.multiplier>1&&requested.multiplier>1&&
+ (previous.frameGenerationBackend!=requested.frameGenerationBackend||previous.multiplier!=requested.multiplier);
+ if(accepted&&rebuild){presenter.close();graph.shutdown();markResetStage(diagnostics::ResetStage::Destroy);accepted=initializePreview(nextDesc,next,preserveWorkingFg);
markResetStage(diagnostics::ResetStage::Create);
if(!accepted){presenter.close();graph.shutdown();if(!graph.initialize(gd)||!presenter.open(ctx,window,graph,options.settings.captureCompatible)||!graph.createViews()){status(L"设置失败且旧资源恢复失败,已停止",true);break;}}
}else if(accepted)accepted=graph.applySettings(requested);
diff --git a/src/gfx/XessPresenter.cpp b/src/gfx/XessPresenter.cpp
index 7c5978f5..ebcb57ab 100644
--- a/src/gfx/XessPresenter.cpp
+++ b/src/gfx/XessPresenter.cpp
@@ -31,6 +31,7 @@ struct XessPresenter::Impl {
xefg_swapchain_handle_t fg=nullptr;
xell_context_handle_t ll=nullptr;
uint32_t id=0,nextId=0;
+ bool cycleOpen=false,renderSubmitStarted=false,renderSubmitEnded=false;
#define XESS_PROC(name) decltype(&name) name##Fn=nullptr
XESS_PROC(xefgSwapChainD3D12CreateContext);
XESS_PROC(xefgSwapChainD3D12GetProperties);
@@ -56,7 +57,11 @@ struct XessPresenter::Impl {
if(result!=0||always||log::verboseFrameLogs())log::info("xess-fg",std::format("{} result={} presentId={}",operation,result,id));
return result>=0;
}
- bool marker(xell_latency_marker_type_t m,uint32_t frameId){return check(xellAddMarkerDataFn(ll,frameId,m),"XeLL marker");}
+ bool marker(xell_latency_marker_type_t m,uint32_t frameId){
+ const auto result=xellAddMarkerDataFn(ll,frameId,m);
+ if(result!=0||log::verboseFrameLogs())log::info("xess-fg",std::format("XeLL marker type={} frameId={} result={} presentId={}",int(m),frameId,int(result),id));
+ return result>=0;
+ }
bool marker(xell_latency_marker_type_t m){return marker(m,id);}
~Impl(){
if(fg&&xefgSwapChainDestroyFn)check(xefgSwapChainDestroyFn(fg),"Destroy",true);
@@ -176,17 +181,38 @@ bool XessPresenter::initialize(ID3D12Device* device,ID3D12CommandQueue* queue,ID
}
uint32_t XessPresenter::beginInput(){
#ifdef VEYRA_HAS_XESS
- auto& p=*p_;const auto frameId=++p.nextId;
+ auto& p=*p_;
+ // XeLL tracks presentation cycles, not every queued source. Complete each
+ // cycle before allocating another ID; the source queue stays asynchronous.
+ if(p.cycleOpen)return p.nextId;
+ const auto frameId=++p.nextId;
diagnostics::CpuStallTrace trace("xess-begin-stall",frameId);
const bool slept=p.check(p.xellSleepFn(p.ll,frameId),"XeLL sleep");trace.mark("sleep");
- return slept&&p.marker(XELL_SIMULATION_START,frameId)?frameId:0;
+ p.cycleOpen=slept&&p.marker(XELL_SIMULATION_START,frameId);
+ p.renderSubmitStarted=p.renderSubmitEnded=false;
+ return p.cycleOpen?frameId:0;
#else
return 0;
#endif
}
bool XessPresenter::beginProcessing(uint32_t frameId){
#ifdef VEYRA_HAS_XESS
- auto& p=*p_;return frameId&&p.marker(XELL_SIMULATION_END,frameId)&&p.marker(XELL_RENDERSUBMIT_START,frameId);
+ auto& p=*p_;
+ if(!frameId)return false;
+ if(!p.cycleOpen||frameId!=p.nextId||p.renderSubmitStarted)return true;
+ p.renderSubmitStarted=p.marker(XELL_SIMULATION_END,frameId)&&p.marker(XELL_RENDERSUBMIT_START,frameId);
+ return p.renderSubmitStarted;
+#else
+ (void)frameId;return false;
+#endif
+}
+bool XessPresenter::endProcessing(uint32_t frameId){
+#ifdef VEYRA_HAS_XESS
+ auto& p=*p_;
+ if(!frameId)return false;
+ if(!p.cycleOpen||frameId!=p.nextId||p.renderSubmitEnded)return true;
+ p.renderSubmitEnded=beginProcessing(frameId)&&p.marker(XELL_RENDERSUBMIT_END,frameId);
+ return p.renderSubmitEnded;
#else
(void)frameId;return false;
#endif
@@ -194,13 +220,10 @@ bool XessPresenter::beginProcessing(uint32_t frameId){
bool XessPresenter::beginFrame(uint32_t preparedFrameId){
#ifdef VEYRA_HAS_XESS
auto& p=*p_;
- // Prepared frames keep the ID assigned before source sampling, even while
- // another source frame is in flight. Repaints have no enhancement phase.
- if(preparedFrameId>p.id){p.id=preparedFrameId;return true;}
- // A repaint can overtake queued work. Never submit an older present ID;
- // the fallback measures this presentation only, not the earlier graph work.
- if(preparedFrameId)log::info("xess-fg",std::format("retire overtaken preparation id={} lastPresentId={}; new presentation markers",preparedFrameId,p.id));
- p.id=beginInput();return p.id&&beginProcessing(p.id);
+ p.id=beginInput();
+ 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));
+ return p.id&&beginProcessing(p.id);
#else
(void)preparedFrameId;
return false;
@@ -234,7 +257,7 @@ bool XessPresenter::tag(ID3D12GraphicsCommandList* list,ID3D12Resource* color,ID
}
bool XessPresenter::beforePresent(){
#ifdef VEYRA_HAS_XESS
- auto& p=*p_;return p.marker(XELL_RENDERSUBMIT_END)&&p.check(p.xefgSwapChainSetPresentIdFn(p.fg,p.id),"SetPresentId")&&p.marker(XELL_PRESENT_START);
+ auto& p=*p_;return endProcessing(p.id)&&p.check(p.xefgSwapChainSetPresentIdFn(p.fg,p.id),"SetPresentId")&&p.marker(XELL_PRESENT_START);
#else
return false;
#endif
@@ -242,6 +265,7 @@ bool XessPresenter::beforePresent(){
bool XessPresenter::afterPresent(){
#ifdef VEYRA_HAS_XESS
auto& p=*p_;if(!p.marker(XELL_PRESENT_END))return false;
+ p.cycleOpen=false;
xefg_swapchain_present_status_t status{};
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;
diff --git a/tests/integration/ExperimentalBackendTests.cpp b/tests/integration/ExperimentalBackendTests.cpp
index dfa05f49..d5c8cd16 100644
--- a/tests/integration/ExperimentalBackendTests.cpp
+++ b/tests/integration/ExperimentalBackendTests.cpp
@@ -182,12 +182,13 @@ int wmain(int argc,wchar_t** argv){
const bool recovery=wcscmp(argv[1],L"xess-recovery2")==0||wcscmp(argv[1],L"xess-recovery3")==0||wcscmp(argv[1],L"xess-recovery4")==0||wcscmp(argv[1],L"xess-resize4")==0;
const bool resizeRecovery=wcscmp(argv[1],L"xess-resize4")==0;
const bool soak=wcscmp(argv[1],L"xess-soak4")==0;
- const bool xess=soak||recovery||pan||wcscmp(argv[1],L"xess")==0||wcscmp(argv[1],L"dis-xess")==0;
+ const bool yuy50=wcscmp(argv[1],L"xess-yuy50-2")==0||wcscmp(argv[1],L"xess-yuy50-4")==0;
+ const bool xess=yuy50||soak||recovery||pan||wcscmp(argv[1],L"xess")==0||wcscmp(argv[1],L"dis-xess")==0;
const bool amd=wcscmp(argv[1],L"amd")==0;
const bool sr=std::wstring(argv[1]).find(L"sr")==0;
if(!xess&&!amd&&!sr&&!dis&&wcscmp(argv[1],L"nvof1080")!=0)return 2;
const bool full=std::wstring(argv[1]).find(L"1080")!=std::wstring::npos;
- const unsigned width=(sr||full)?1920:640,height=(sr||full)?1080:360,frames=soak?3600:sr?3:48;
+ const unsigned width=(sr||full)?1920:640,height=(sr||full)?1080:360,frames=soak?3600:yuy50?100:sr?3:48;
CoInitializeEx(nullptr,COINIT_MULTITHREADED);
std::filesystem::create_directories(argv[2]);
Logger::instance().openFile((std::filesystem::path(argv[2])/"engine.log").wstring());
@@ -202,10 +203,10 @@ int wmain(int argc,wchar_t** argv){
pipeline::EnhanceGraph graph(ctx,ring);engine::VideoPresenter presenter;
pipeline::EnhanceGraphDesc desc;
desc.sourceWidth=desc.workWidth=width;desc.sourceHeight=desc.workHeight=height;
- desc.rgbInput=true;desc.enableNr=false;desc.enableFg=xess;desc.noNgx=true;
+ desc.rgbInput=!yuy50;desc.yuy2Input=yuy50;desc.enableNr=false;desc.enableFg=xess;desc.noNgx=true;
desc.enableNvofStandalone=true;
desc.frameGenerationBackend=engine::FrameGenerationBackend::XeSS;
- if(soak||wcscmp(argv[1],L"xess-pan4")==0)desc.fgMultiplier=4;
+ if(soak||wcscmp(argv[1],L"xess-pan4")==0||wcscmp(argv[1],L"xess-yuy50-4")==0)desc.fgMultiplier=4;
if(recovery)desc.fgMultiplier=(resizeRecovery||wcscmp(argv[1],L"xess-recovery4")==0)?4:wcscmp(argv[1],L"xess-recovery3")==0?3:2;
desc.opticalFlowBackend=dis?engine::OpticalFlowBackend::GpuDis:amd?engine::OpticalFlowBackend::AmdFidelityFx:engine::OpticalFlowBackend::Nvidia;
if(sr){
@@ -224,7 +225,7 @@ int wmain(int argc,wchar_t** argv){
const auto again=gfx::XessPacing::install(GetModuleHandleW(L"libxess_fg.dll"),desc.fgMultiplier-1);
ok=again.installed;
}
- AVFrame* frame=av_frame_alloc();frame->format=AV_PIX_FMT_RGBA;frame->width=int(width);frame->height=int(height);frame->color_trc=AVCOL_TRC_IEC61966_2_1;
+ AVFrame* frame=av_frame_alloc();frame->format=yuy50?AV_PIX_FMT_YUYV422:AV_PIX_FMT_RGBA;frame->width=int(width);frame->height=int(height);frame->color_trc=AVCOL_TRC_IEC61966_2_1;
ok=ok&&av_frame_get_buffer(frame,32)>=0;
pipeline::EnhanceGraph::FrameOutputs out;
FlowSample rightward{}, leftward{};
@@ -235,21 +236,22 @@ int wmain(int argc,wchar_t** argv){
if(pan)view.zoom=1.5f;
const auto cadenceStart=std::chrono::steady_clock::now();
for(unsigned i=0;ok&&i<frames;++i){
- if(soak)std::this_thread::sleep_until(cadenceStart+std::chrono::microseconds(uint64_t(i)*1000000/30));
+ if(soak||yuy50)std::this_thread::sleep_until(cadenceStart+std::chrono::microseconds(uint64_t(i)*1000000/(yuy50?50:30)));
ok=presenter.beginSourceInput()&&ok;
MSG msg;while(PeekMessageW(&msg,nullptr,0,0,PM_REMOVE)){TranslateMessage(&msg);DispatchMessageW(&msg);}
const int phase = i < 24 ? int(i) : int(i - 24);
const int velocity = i < 24 ? 2 : -2;
for(int y=0;y<int(height);++y)for(int x=0;x<int(width);++x){
- const int px=(x-phase*velocity+int(width))%int(width);auto* p=frame->data[0]+y*frame->linesize[0]+x*4;
+ const int px=(x-phase*velocity+int(width))%int(width);auto* p=frame->data[0]+y*frame->linesize[0]+x*(yuy50?2:4);
// A spatially non-periodic pattern makes a two-pixel translation
// identifiable. The previous striped pattern had repeating aliases.
uint32_t hash=uint32_t(px)*0x9E3779B9u^uint32_t(y)*0x85EBCA6Bu;
hash^=hash>>16;hash*=0x7FEB352Du;hash^=hash>>15;hash*=0x846CA68Bu;hash^=hash>>16;
- p[0]=uint8_t(hash);p[1]=uint8_t(hash>>8);p[2]=uint8_t(hash>>16);p[3]=255;
+ if(yuy50){p[0]=uint8_t(16+hash%220);p[1]=128;}
+ else{p[0]=uint8_t(hash);p[1]=uint8_t(hash>>8);p[2]=uint8_t(hash>>16);p[3]=255;}
}
const bool forcedReset=i==0||i==24||(recovery&&(i==8||i==32||i==40));
- out={};ok=ok&&presenter.beginSourceProcessing()&&graph.process(frame,i*1000.0/30,forcedReset,out,i+1);
+ out={};ok=ok&&presenter.beginSourceProcessing()&&graph.process(frame,i*1000.0/(yuy50?50:30),forcedReset,out,i+1);
if(ok)presenter.sourceProcessed(out.batch.identity);
if(ok&&recovery&&i==18){
// Repaint an older identity while the next source is prepared.
@@ -281,7 +283,7 @@ int wmain(int argc,wchar_t** argv){
FlowSample& sample=i==23?rightward:leftward;
ok=ok&&readCanonicalFlow(ctx,ring,graph.flowResource(),sample);
}
- if(!soak)Sleep(34);
+ if(!soak&&!yuy50)Sleep(34);
if(recovery&&info){
const auto messages=info->GetNumStoredMessagesAllowedByRetrievalFilter();
if(messages!=previousMessages)std::cout<<"DEBUG frame="<<i<<" messages="<<messages<<std::endl;
@@ -299,6 +301,11 @@ int wmain(int argc,wchar_t** argv){
std::cout<<"SR extent="<<image.width<<"x"<<image.height<<" evaluate="<<graph.metrics().srEvaluateCount<<" nonblack="<<nonblack<<" pass="<<ok<<std::endl;
}
if(xess)ok=ok&&generated>10;
+ if(yuy50){
+ const auto expectedMinimum=(frames-8)*(desc.fgMultiplier-1);
+ ok=ok&&generated>=expectedMinimum;
+ std::cout<<"YUY50 multiplier="<<desc.fgMultiplier<<" generated="<<generated<<" minimum="<<expectedMinimum<<" pass="<<ok<<std::endl;
+ }
if(recovery)ok=ok&&recovered==3;
if(pan){
ok=ok&&panGenerated>10;
diff --git a/tests/integration/FgSettingsTests.cpp b/tests/integration/FgSettingsTests.cpp
index 6cac402e..f17d93d2 100644
--- a/tests/integration/FgSettingsTests.cpp
+++ b/tests/integration/FgSettingsTests.cpp
@@ -16,7 +16,8 @@ int wmain(int argc,wchar_t** argv) {
return runFgCompatibilityProbe(reinterpret_cast<HANDLE>(_wcstoui64(argv[2],nullptr,10)));
if(argc!=3&&argc!=4)return 2;
const bool probeFailure=argc==4&&std::wstring_view(argv[3])==L"probe-failure";
- if(argc==4&&!probeFailure)return 2;
+ const bool backendSwitch=argc==4&&std::wstring_view(argv[3])==L"backend-switch";
+ if(argc==4&&!probeFailure&&!backendSwitch)return 2;
const HRESULT com=CoInitializeEx(nullptr,COINIT_MULTITHREADED);
if(FAILED(com))return 2;
std::filesystem::create_directories(argv[2]);
@@ -63,8 +64,29 @@ int wmain(int argc,wchar_t** argv) {
std::cout<<"Probe recovery elapsedMs="<<std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now()-started).count()<<std::endl;
}
+ if(backendSwitch){
+ struct Request{FrameGenerationBackend backend;unsigned multiplier;};
+ // Leaving unlocked XeSS used to cache a false 2X hardware limit;
+ // native 2X must also allow a later unlocked 4X context.
+ for(const auto request:{Request{FrameGenerationBackend::XeSS,4},
+ Request{FrameGenerationBackend::Dlss,4},Request{FrameGenerationBackend::XeSS,4},
+ Request{FrameGenerationBackend::XeSS,2},Request{FrameGenerationBackend::XeSS,4},
+ Request{FrameGenerationBackend::Dlss,6},Request{FrameGenerationBackend::XeSS,4}}){
+ if(failures)break;
+ const auto before=engine.snapshot();
+ auto settings=before.desired;
+ settings.nr=settings.sr=false;
+ settings.frameGenerationBackend=request.backend;settings.multiplier=request.multiplier;
+ if(!check(engine.requestSettings(settings),"accept backend switch"))break;
+ const auto revision=engine.snapshot().desired.revision;
+ check(wait([&](const auto& s){return !s.applying&&s.applied.revision==revision&&
+ s.applied.frameGenerationBackend==request.backend&&s.applied.multiplier==request.multiplier&&
+ s.fgActive&&s.frames>=before.frames+12&&s.generated>=before.generated+10;},20),
+ "backend switch applies and generates frames");
+ }
+ }
for(const unsigned multiplier:{2u,6u,1u,6u}){
- if(probeFailure)break;
+ if(probeFailure||backendSwitch)break;
if(failures)break;
const auto beforeSwitch=engine.snapshot();
auto settings=beforeSwitch.desired;
diff --git a/tests/integration/Yuy2ColorTests.cpp b/tests/integration/Yuy2ColorTests.cpp
index 59e745e4..80ec2961 100644
--- a/tests/integration/Yuy2ColorTests.cpp
+++ b/tests/integration/Yuy2ColorTests.cpp
@@ -38,6 +38,12 @@ int wmain(int argc,wchar_t**argv){
for(unsigned y=0;y<h;++y)for(unsigned x=0;x<w;++x)f->data[0][ptrdiff_t(y)*f->linesize[0]+x]=uint8_t(x%256);
for(unsigned y=0;y<h/2;++y)for(unsigned x=0;x<w/2;++x){f->data[1][ptrdiff_t(y)*f->linesize[1]+x]=y%4==0?128:y%4==1?16:y%4==2?240:90;f->data[2][ptrdiff_t(y)*f->linesize[2]+x]=y%4==0?128:y%4==1?240:y%4==2?16:180;}
}
+ // Alternating luma must survive 4:2:2 unpack and 1:1 presentation.
+ // The lower half retains the matrix/range color coverage above.
+ if(!remoteYuv&&!rgb&&!nr)for(unsigned y=0;y<h/2;++y)for(unsigned x=0;x<w;x+=2){
+ auto* p=f->data[0]+ptrdiff_t(y)*f->linesize[0]+x*2;
+ p[0]=(y&1)?235:16;p[2]=(y&1)?16:235;p[1]=p[3]=128;
+ }
if(rgb)for(unsigned y=0;y<h;++y)for(unsigned x=0;x<w;++x){auto* p=f->data[0]+ptrdiff_t(y)*f->linesize[0]+x*4;p[0]=uint8_t(x%256);p[1]=uint8_t((x+37)%256);p[2]=uint8_t((x+129)%256);p[3]=255;}
pipeline::ColorDescription color;color.pixelFormat=pipeline::SourcePixelFormat::Yuy2;color.range=full?pipeline::ColorRange::Full:pipeline::ColorRange::Limited;color.matrix=hd?pipeline::YuvMatrix::BT709:pipeline::YuvMatrix::BT601;color.transfer=pipeline::TransferFunction::SRGB;
if(remoteYuv){color.pixelFormat=pipeline::SourcePixelFormat::Yuv420P;color.transfer=pipeline::TransferFunction::BT709;color.displayReferred709=true;}