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 NVOF resource registration fences and NR failure readouts
Veyra Goal Agentb0d02e9a539a
diff --git a/AGENTS.md b/AGENTS.mdindex 7403c935..6e8265aa 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -1,5 +1,7 @@# Veyra 项目 Agent 执行规则+> **2026-10-16 RTX2060 光流注册修复授权**:用户在 logs(19).zip 诊断后明确“补一下,补之前存档”。按 docs/NR2060_SYNC_PLAN_2026-10-16.md,从 main b571a44 在 E盘 codex/nr2060-sync-20261016 隔离修复 NVOF 资源注册同步、初始化/部分失败清理及 NR 未执行的界面状态和必要回归/翻译接点;这些范围覆盖旧冻结。先完成 checkpoint/pre-nr2060-sync-20261016、全引用 bundle verify、80旧树/92分支/509脏文件与日志备份。默认算法/模型/逐帧调度、33ms/250ms、GPU优先级/真实配置保持,不派Agent、不造压、不改驱动或专有运行库;产物全E盘,测试≤300秒/构建≤900秒。无新main合并/push/用户包/Release/关机授权,2060现场恢复必须实卡复测,不能用5070替代。+> **2026-10-16 PR44授权**:用户要求研究合并HDR显示页PR44。基于main8d8eb09,在codex/pr44-hdr-display-20261016保留PR44 head3ee17b6并按docs/PR44_HDR_DISPLAY_PLAN_2026-10-16.md适配HDR显示/曲线/记忆/元数据/低频GPU统计及必要shader/构建回归,覆盖这些接点旧冻结。正常播放不回读像素、只读GPU归约统计且面板隐藏无采样;不提高33ms/250ms频率。78旧树/509脏文件和上一轮issues分支保持;产物全E盘,测试≤300秒/构建≤900秒。不派Agent、不改专有运行库/模型/驱动/真实配置。检查通过允许PR44合main及普通GitHub同步;无Release/用户包/评论/代发/关机授权。> **2026-10-15 2.0.8 正式发布授权**:用户实测当前两个2.0.8测试包正常,明确要求仅改外部文件名直接发布2.0.8,不重编译、不重打包。按docs/RELEASE_2.0.8_PLAN_2026-10-15.md,汇总Claude与Codex自2.0.7以来全部最终保留内容,重点为延迟链路、窗口/显示器捕获游戏模式、可变刷新、采集卡画面与手柄转发以及搭配第三方远程软件的电脑游戏使用方式;公开说明不叙述用户要求省略的旧显示同步设定。允许本地main文档合入、普通推送nrvideo/main及v2.0.8/v2.0.8-sources标签、GitHub正式Release,主下载区只放NVIDIA/AMD两包,源材料另放非latest归档并引用已有依赖/FFmpeg源。保留六群/赞助二维码各width220、Discord、Ko-fi、知识库。77旧树/509脏文件及五个原归档保护;所有产物E盘,不改产品/运行库/模型/配置,不派Agent、不代发、不关机。内部2.0.8-test及manifest标签原样保留并明示,实测/模拟/未验证边界如实说明。diff --git a/docs/NR2060_SYNC_PLAN_2026-10-16.md b/docs/NR2060_SYNC_PLAN_2026-10-16.mdnew file mode 100644index 00000000..c9330515--- /dev/null+++ b/docs/NR2060_SYNC_PLAN_2026-10-16.md@@ -0,0 +1,16 @@+# RTX 2060 光流注册同步修复计划++用户明确要求“补一下,补之前存档”。基于 main b571a44,在 codex/nr2060-sync-20261016 / E:/项目/Veyra/worktrees/nr2060-sync-20261016 隔离实施。先完成 checkpoint/pre-nr2060-sync-20261016、archives/nr2060-sync-20261016/source-before.bundle(已 verify)、80 个旧工作树/92 个分支/509 份脏文件快照及逐文件备份、用户 logs(19).zip 与诊断证据备份,再修改产品。main 和其它工作树保持。++现场证据:RTX2060,驱动 610.88 与 617.42;54 次 nvOFInit 成功后均在 inputA 注册返回 NV_OF_ERR_INVALID_PTR(4),随后按 OpticalFlow 故障关闭 NR;2345 条采集统计 nr/nvof 均为 0,尚未进入 SF-v2 初始化。当前注册调用遗漏输入/输出 fence,与官方 SDK 5.0.7 参考实现不同。这是有证据的修复候选,不是已证明的唯一现场根因。++本轮只修改 NvOfSession 资源注册、初始化/失败回收同步与错误详情,NR 未执行时的节点/列表耗时提示,以及对应回归、翻译与文档;必要构建接点随同授权,覆盖这些范围旧冻结。保持现有光流算法/方向/分辨率/NR 模型、逐帧执行和显示调度、UI33ms/250ms、GPU 默认优先级、用户设置和专有运行组件。无需子 Agent、竞争负载、驱动或 NVIDIA App 设置修改,不合并 main、不 push、不 Release、不打新用户包、不关机。++实施步骤:++1. 注册阶段传入真实有效的输入/输出 fence;使用独立、仅初始化期间存在的注册完成 fence 串行衔接四个/六个资源,初始化成功或部分失败回滚前有界确认注册完成。它不占用逐帧光流完成计数,不向正常逐帧路径增加 CPU 等待、像素回读或队列。记录 HRESULT、SDK 错误详情和同步结果。+2. 补一个默认不生效、只用于本轮定向测试的注册失败入口,覆盖部分注册后失败回收;不模拟真实硬件通过。真实 GPU 验证首次执行、双向光流、初始化后立即清理、重复初始化及 D3D12 错误。+3. 当前设置已被引擎失败回退为 NR 关闭时,节点/列表显示“启用失败”及实际原因,不借用旧计时或继续“等待样本”。仅依据当前会话/设置确认状态;正常暖机、暂停、未连接、草稿及用户禁用语义保持,不清空用户保存的 NR 参数。+4. 本机 RTX5070 构建、真实 NVOF/NR/SR/FG 相关回归与界面失败状态验证,单测试≤300秒、单构建≤900秒;有失败保留原证据并修复,不造压。2060 的修改前后验证明确留给现场,不将 5070 通过冒充 20 系验收。++产物统一 E:/项目/Veyra/{build,tests,logs,tmp,reports,archives}/nr2060-sync-20261016。本轮结尾记录实际命令、源码/构建/日志身份、结果和未验项,复核原 80 树/92 分支/509 脏文件保持。当前用户只授权修复与存档,未授权发布或 main 合并。diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 098d6534..7435369b 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -9590,3 +9590,8 @@ PR44最终产品输入26db779;37目标构建通过(命令python -X utf8 -B -实际python .../checks.py --retry、ui-cards.py、ui-hdr.py与scripts/i18n/extract.py --check:HDR/链/预设/事务/颜色/几何/数据迁移通过,Qt Quick 76/76;2401翻译缺译/占位符0。真实HDR10/scRGB曲线/黑帧/统计/resize/metadata/符号RGB/强度0恒等通过,D3D12 ERROR/CORRUPTION0;另--video-hdr真实SDR→已核验TrueHDR→显示曲线sourceHdr0/videoHdrActive1通过。英日繁中五卡窄窗及OBS软件渲染、非法参数不变、A/B影片记忆37恢复、关闭清除后0条、19/60/900重开保持通过。最新完整命令/输入SHA/EXE SHA/截图在E:/项目/Veyra/{logs,reports,tests}/pr44-hdr-display-20261016;build.json/checks.json/ui.json/cards.json为指针。首轮统计描述符/ClearUAV6项GPU错误与黑帧夹具未恢复灰阶2项失败已修后重测,漏传测试目录/未建截图目录的环境失败也已修后重跑,旧失败证据保留。未测实体投影仪/AMD/Intel/跨屏/光学延迟,不宣称无开销或性能百分比。来源及边界详见THIRD_PARTY_NOTICES与PR44_HDR_DISPLAY_REPORT_2026-10-16.md。按用户授权检查后正常推进main/nrvideo并核对PR状态,使用final-audit.py --stage pre/post保护78原树/90原分支/509脏文件(只允许main推进),复核产品输入与验收EXE一致,增量bundle/远端回执写E盘archives/reports/...;最终实际SHA、PR合并状态和保护结果以final.json为准。上一轮issues41–45分支与其它旧树原样保留,本轮无Release/打用户包/代发/子Agent/关机。+## 2026-10-16 RTX2060 光流注册修复开工++用户明确先存档再补同步。已运行 python -X utf8 -B -I E:/项目/Veyra/tmp/nr2060-sync-20261016/archive.py:80旧树/92原分支/509脏文件状态与内容完整保存,dirty-files.zip、logs(19).zip与诊断原件备份,checkpoint/pre-nr2060-sync-20261016 指向 main b571a44,source-before.bundle 74948191字节且 git bundle verify 成功;归档后原状态复核一致。回执 E:/项目/Veyra/archives/nr2060-sync-20261016/archive-receipt.json。其后 git worktree add -b codex/nr2060-sync-20261016 E:/项目/Veyra/worktrees/nr2060-sync-20261016 main;原 main 未推进。++方案 docs/NR2060_SYNC_PLAN_2026-10-16.md。只补 NVOF 初始化注册同步与 NR 失败状态的必要接点;不改模型/默认设置/逐帧调度或 UI 刷新频率,不派Agent,不改驱动/用户配置/专有运行库,不造压,无本轮合并/发布/用户包/关机。54次现场无效指针与 NR 全零是诊断证据,尚不能宣称同步缺口是唯一根因;2060最终效果待用户实卡复测。后续构建/回归与失败另记,产物统一 E:/项目/Veyra/{用途}/nr2060-sync-20261016。diff --git a/i18n/catalog.json b/i18n/catalog.jsonindex c89e96b2..9adf2318 100644--- a/i18n/catalog.json+++ b/i18n/catalog.json@@ -16808,6 +16808,13 @@"zh-TW": ";預設“即時”,同時執行遊戲或其他重負載程式變慢時可改為“高”或“普通”","en": "; Realtime by default. If a game or other heavy program running alongside slows down, choose High or Normal","ja": ";既定は「リアルタイム」。同時に動かすゲームや重い処理が遅くなる場合は「高」か「通常」に変更してください"+ },+ {+ "zh": "启用失败",+ "src": "qml/NodePage.qml; qml/ProPage.qml",+ "zh-TW": "啟用失敗",+ "en": "Failed to enable",+ "ja": "有効化に失敗"}]}diff --git a/include/veyra/ngx/NvOfSession.h b/include/veyra/ngx/NvOfSession.hindex 75f7e88b..d277b8bd 100644--- a/include/veyra/ngx/NvOfSession.h+++ b/include/veyra/ngx/NvOfSession.h@@ -75,6 +75,9 @@ public:// All four resources are validated via GetDesc before registration; any// registration failure unregisters everything already registered in// reverse order and returns false.+ // Registration supplies explicit fence points and completes on a separate+ // initialization-only fence before success or partial-failure rollback.+ // It does not publish a flow result or add waits to execute().bool initialize(ID3D12Device* device,ID3D12Resource* inputA,ID3D12Resource* inputB,diff --git a/qml/Veyra/NodePage.qml b/qml/Veyra/NodePage.qmlindex d5c9c54a..062d38ed 100644--- a/qml/Veyra/NodePage.qml+++ b/qml/Veyra/NodePage.qml@@ -1064,7 +1064,8 @@ VPage {if (!n || !n.enabled) continueconst t = timings[String(id)] || {}out.push({ id: id, label: n.label, color: hues[n.type] || Theme.accent,- measured: t.state === "measured", ms: t.state === "measured" ? t.ms : 0, state: t.state || "" })+ measured: t.state === "measured", ms: t.state === "measured" ? t.ms : 0,+ state: t.state || "", reason: t.reason || "" })}return out}@@ -1102,6 +1103,7 @@ VPage {horizontalAlignment: Text.AlignHCenterelide: Text.ElideRighttext: modelData.label + " " + (modelData.measured ? modelData.ms.toFixed(1) + " ms"+ : modelData.state === "failed" ? qsTr("启用失败"): modelData.state === "sdk" ? qsTr("SDK内部") : modelData.state === "fused" ? qsTr("并入输入") : qsTr("等待样本"))color: modelData.measured ? Qt.rgba(0, 0, 0, 0.8) : Theme.t3font.family: Theme.fontUi@@ -1110,7 +1112,7 @@ VPage {}HoverHandler { id: segHover; cursorShape: Qt.PointingHandCursor }ToolTip.visible: segHover.hovered- ToolTip.text: modelData.label + ":" + (modelData.measured ? modelData.ms.toFixed(2) + qsTr(" ms(GPU 最近一秒平均)") : qsTr("暂无本节点计时"))+ ToolTip.text: modelData.label + ":" + (modelData.measured ? modelData.ms.toFixed(2) + qsTr(" ms(GPU 最近一秒平均)") : modelData.reason || qsTr("暂无本节点计时"))TapHandler {gesturePolicy: TapHandler.WithinBoundsonTapped: root.focusNode(modelData.id)@@ -1399,6 +1401,10 @@ VPage {implicitHeight: 18radius: 5color: Qt.rgba(0, 0, 0, 0.35)+ HoverHandler { id: timingHover }+ ToolTip.visible: timingHover.hovered && !!msText.timing.reason+ ToolTip.text: msText.timing.reason || ""+ ToolTip.delay: 400Text {id: msTextobjectName: "node-ms-" + card.node.id@@ -1413,6 +1419,7 @@ VPage {case "idle": return qsTr("未连接")case "draft": return qsTr("草稿未运行")case "pending": return qsTr("等待样本")+ case "failed": return qsTr("启用失败")case "stopped": return qsTr("未播放")case "hdr-sdr": return qsTr("SDR显示未转换")case "fg-skipped": return qsTr("预算拒绝")diff --git a/qml/Veyra/ProPage.qml b/qml/Veyra/ProPage.qmlindex 6d22a7e0..cd3d53ea 100644--- a/qml/Veyra/ProPage.qml+++ b/qml/Veyra/ProPage.qml@@ -393,7 +393,8 @@ VPage {// This layer's own GPU time (list mode keys a node by its index + 2).readonly property var timing: veyra.nodeTimings[String(layerData.index + 2)] || ({})readonly property string timingText: timing.state === "measured" ? timing.ms.toFixed(2) + " ms"- : timing.state === "pending" ? qsTr("等待样本") : ""+ : timing.state === "pending" ? qsTr("等待样本")+ : timing.state === "failed" ? qsTr("启用失败") : ""summary: nrEditor.sizeLabel + qsTr(" · 强度 ") + layerData.intensity.toFixed(2)+ (layerData.enabled ? (timingText.length > 0 ? " · " + timingText : "") : qsTr(" · 已旁路"))on: layerData.enableddiff --git a/src/ngx/NvOfSession.cpp b/src/ngx/NvOfSession.cppindex 8a41830d..aaf003d7 100644--- a/src/ngx/NvOfSession.cpp+++ b/src/ngx/NvOfSession.cpp@@ -2,12 +2,14 @@#include <windows.h>#include <d3d12.h>+#include <wrl/client.h>// NVOF SDK headers#include <nvOpticalFlowCommon.h>#include <nvOpticalFlowD3D12.h>#include <format>+#include <memory>#include "veyra/Log.h"@@ -268,6 +270,61 @@ bool NvOfSession::initialize(ID3D12Device* device,return false;}+ // Registration has its own GPU work and requires valid fence points too.+ // Do not signal outFence_ here: that fence advertises completed optical+ // flow to the caller, whose first execute must still signal value 1.+ Microsoft::WRL::ComPtr<ID3D12Fence> registrationFence;+ const HRESULT fenceHr = device->CreateFence(0, D3D12_FENCE_FLAG_NONE,+ IID_PPV_ARGS(®istrationFence));+ if (FAILED(fenceHr)) {+ log::error("nvof-session", std::format("registration fence creation hr=0x{:X}", unsigned(fenceHr)));+ status = Status::DeviceFailure;+ return false;+ }+ std::unique_ptr<void, decltype(&CloseHandle)> registrationEvent(+ CreateEventW(nullptr, FALSE, FALSE, nullptr), &CloseHandle);+ if (!registrationEvent) {+ log::error("nvof-session", std::format("registration event creation error={}", GetLastError()));+ status = Status::DeviceFailure;+ return false;+ }+ const uint64_t inputReady = inFence_->GetCompletedValue();+ if (inputReady == UINT64_MAX) {+ log::error("nvof-session", "registration input fence reports device removal");+ status = Status::DeviceFailure;+ return false;+ }+ uint64_t registered = 0;+ auto finishRegistration = [&]() {+ if (!registered) return true;+ uint64_t completed = registrationFence->GetCompletedValue();+ if (completed != UINT64_MAX && completed >= registered) return true;+ if (completed == UINT64_MAX) {+ log::error("nvof-session", "registration completion fence reports device removal");+ return false;+ }+ const HRESULT hr = registrationFence->SetEventOnCompletion(registered, registrationEvent.get());+ if (FAILED(hr)) {+ log::error("nvof-session", std::format("registration completion event hr=0x{:X}", unsigned(hr)));+ return false;+ }+ // One bounded initialization/rollback wait, never a per-frame wait.+ const DWORD waited = WaitForSingleObject(registrationEvent.get(), 5000);+ completed = registrationFence->GetCompletedValue();+ if (waited != WAIT_OBJECT_0 || completed == UINT64_MAX || completed < registered) {+ log::error("nvof-session", std::format(+ "registration completion failed wait={} requested={} completed={} deviceHr=0x{:X}",+ waited, registered, completed, unsigned(device->GetDeviceRemovedReason())));+ return false;+ }+ return true;+ };+ // Default-inert diagnostic: exercise partial registration rollback without+ // changing a driver DLL or creating an artificial GPU load.+ wchar_t rejectText[16]{};+ const DWORD rejectLength = GetEnvironmentVariableW(L"VEYRA_TEST_NVOF_REGISTER_FAILURE", rejectText, 16);+ const unsigned rejectAt = rejectLength > 0 && rejectLength < 16 ? unsigned(_wtoi(rejectText)) : 0;+// Unified registration with rollback: whichever of inputA/inputB/flowOut/// costOut fails, every already-registered resource is unregistered in// REVERSE order (logged) before returning false. No reliance on later@@ -294,14 +351,34 @@ bool NvOfSession::initialize(ID3D12Device* device,NV_OF_REGISTER_RESOURCE_PARAMS_D3D12 reg{};reg.resource = resource;reg.hOFGpuBuffer = &handle;- const NV_OF_STATUS rst = fn_->list.nvOFRegisterResourceD3D12(ofHandle, ®);+ reg.inputFencePoint = registered+ ? NV_OF_FENCE_POINT{registrationFence.Get(), registered}+ : NV_OF_FENCE_POINT{inFence_, inputReady};+ reg.outputFencePoint = {registrationFence.Get(), registered + 1};+ const bool injected = rejectAt == registered + 1;+ if (injected) log::warn("nvof-session", std::format(+ "test-only registration rejection resource={}; not a hardware failure", name));+ const NV_OF_STATUS rst = injected ? NV_OF_ERR_INVALID_PTR+ : fn_->list.nvOFRegisterResourceD3D12(ofHandle, ®);handleOpaque = handle;- log::info("nvof-session", std::format("register {} status={}", name, static_cast<int>(rst)));+ log::info("nvof-session", std::format(+ "register {} status={} inputSync={} outputSync={} completion={}", name, static_cast<int>(rst),+ reg.inputFencePoint.fence != nullptr, reg.outputFencePoint.fence != nullptr, registered + 1));if (rst != NV_OF_SUCCESS) {log::error("nvof-session", std::format("register {} failed st={}; rolling back all registered resources", name, (int)rst));+ if (!injected && fn_->list.nvOFGetLastError) {+ char detail[512]{}; uint32_t size = sizeof(detail);+ const auto errorStatus = fn_->list.nvOFGetLastError(ofHandle, detail, &size);+ detail[sizeof(detail) - 1] = '\0';+ log::error("nvof-session", std::format(+ "register {} SDK detail status={} message={}", name, int(errorStatus), detail));+ }+ // Earlier registrations may still be queued even though this one+ // failed. Observe their completion before unregister/release.+ if (!finishRegistration()) log::error("nvof-session", "partial registration did not complete before rollback");rollbackAll();- }+ } else ++registered;return rst == NV_OF_SUCCESS;};if (!registerResource(inputA, hInputA_, "inputA") ||@@ -313,6 +390,13 @@ bool NvOfSession::initialize(ID3D12Device* device,status = Status::DeviceFailure;return false;}+ if (!finishRegistration()) {+ rollbackAll();+ status = Status::DeviceFailure;+ return false;+ }+ log::info("nvof-session", std::format(+ "registration completed resources={} firstFlowValue={} (initialization only)", registered, nextOutValue_));initialized_ = true;status = Status::Ok;diff --git a/src/ui/QmlPlayerBridge.cpp b/src/ui/QmlPlayerBridge.cppindex 4e8c1d94..c02c3992 100644--- a/src/ui/QmlPlayerBridge.cpp+++ b/src/ui/QmlPlayerBridge.cpp@@ -1815,10 +1815,18 @@ QVariantMap QmlPlayerBridge::nodeTimings() const {if (draft) path.clear();}const bool live = queuedFramesKnown();+ const auto& snapshot = impl_->snapshot;+ // A failed optical-flow/NR backend can leave the requested editor layer+ // enabled while the engine has deliberately resumed playback without NR.+ // Show that confirmed recovery, not an endless timing warmup or stale ms.+ const bool nrRejected = live && !snapshot.applying && snapshot.rejectedRevision != 0 &&+ snapshot.desired.revision == snapshot.applied.revision &&+ !snapshot.desired.nr && !snapshot.applied.nr && !snapshot.backendWarning.empty();const bool xess = fgBackendName() == QLatin1String("xess");QVariantMap out;auto publish = [&](uint32_t i, const QString& state, std::optional<Stage> stage) {QVariantMap item{{"state", state}, {"ms", 0.0}, {"samples", QVariant::fromValue<qulonglong>(0)}};+ if (state == QLatin1String("failed")) item["reason"] = uiText(snapshot.backendWarning);if (stage) {const auto& sample = flow.gpuTiming[size_t(*stage)];if (live && sample.samples > 0 && sample.mean && std::isfinite(*sample.mean) && *sample.mean >= 0.0) {@@ -1842,7 +1850,8 @@ QVariantMap QmlPlayerBridge::nodeTimings() const {QString waiting = live ? QStringLiteral("pending") : QStringLiteral("stopped");switch (n.type) {case engine::EffectType::NrEnhance:- if (n.enabled && enabledNr < diagnostics::kTimedNrLayers) stage = diagnostics::nrLayerStage(enabledNr);+ if (nrRejected) waiting = QStringLiteral("failed");+ else if (n.enabled && enabledNr < diagnostics::kTimedNrLayers) stage = diagnostics::nrLayerStage(enabledNr);if (n.enabled) ++enabledNr;break;case engine::EffectType::Color:diff --git a/tests/integration/BidirectionalFlowTests.cpp b/tests/integration/BidirectionalFlowTests.cppindex 33dff940..2eb13da1 100644--- a/tests/integration/BidirectionalFlowTests.cpp+++ b/tests/integration/BidirectionalFlowTests.cpp@@ -40,6 +40,7 @@ int run(unsigned w,unsigned h,bool both,bool occlusion){session.shutdown();}if(!session.initialize(ctx.device(),tex[0].Get(),tex[1].Get(),tex[2].Get(),tex[3].Get(),desc,st))return 2;+ if(session.nextOutValue()!=1||ready->GetCompletedValue()!=0)return 2;// A malformed paired call must preserve the initialized session.auto malformed=desc;malformed.reverseFlow=tex[4].Get();malformed.reverseCost=nullptr;if(session.initialize(ctx.device(),tex[0].Get(),tex[1].Get(),tex[2].Get(),tex[3].Get(),malformed,st)||!session.initialized())return 2;@@ -101,5 +102,38 @@ int run(unsigned w,unsigned h,bool both,bool occlusion){std::cout<<"BIDIRECTIONAL width="<<w<<" height="<<h<<" both="<<both<<" occlusion="<<occlusion<<" meanBatchMs="<<ms<<" reverseAllocationBytes="<<reverseBytes<<" medianEpe="<<median(errors)<<" reverseMedianEpe="<<(both?median(reverseErrors):-1)<<" novel="<<novelTotal<<" novelBaseAccepted="<<novelBase<<" novelConsistent="<<novelConsistent<<" good="<<goodTotal<<" goodBaseAccepted="<<goodBase<<" goodConsistent="<<goodConsistent<<" debugErrors="<<debugErrors<<" pass="<<(ok&&!debugErrors)<<std::endl;return ok&&!debugErrors?0:1;}+int registrationLifecycle(bool both,unsigned rejectAt){+ gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status st;gfx::DeviceContextDesc dd;dd.enableDebugLayer=true;+ if(!ctx.initialize(dd,st)||!ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),4,st))return 2;+ std::array<ComPtr<ID3D12Resource>,6> tex;+ for(unsigned i=0;i<6;++i)tex[i]=makeTexture(ctx.device(),i<2?640:160,i<2?360:90,+ i<2?DXGI_FORMAT_B8G8R8A8_UNORM:i%2==0?DXGI_FORMAT_R16G16_SINT:DXGI_FORMAT_R8_UINT,false);+ for(auto& t:tex)if(!t)return 2;+ ComPtr<ID3D12Fence> ready;if(FAILED(ctx.device()->CreateFence(0,D3D12_FENCE_FLAG_NONE,IID_PPV_ARGS(&ready))))return 2;+ ngx::NvOfSession session;bool cleaned=false,cleanupOk=true;+ Cleanup cleanup{[&]{if(cleaned)return;cleaned=true;cleanupOk=ring.drainQueue();+ if(session.initialized())cleanupOk=session.unregisterAll(st)&&cleanupOk;+ for(auto& t:tex)t.Reset();session.shutdown();}};+ ngx::NvOfSession::Desc desc;desc.width=640;desc.height=360;desc.inFence=ctx.fence();desc.outFence=ready.Get();+ if(both){desc.reverseFlow=tex[4].Get();desc.reverseCost=tex[5].Get();}+ const auto reject=std::to_wstring(rejectAt);+ SetEnvironmentVariableW(L"VEYRA_TEST_NVOF_REGISTER_FAILURE",rejectAt?reject.c_str():nullptr);+ const bool initialized=session.initialize(ctx.device(),tex[0].Get(),tex[1].Get(),tex[2].Get(),tex[3].Get(),desc,st);+ SetEnvironmentVariableW(L"VEYRA_TEST_NVOF_REGISTER_FAILURE",nullptr);+ // Registration-only setup/rollback must not advertise completed flow.+ bool ok=ready->GetCompletedValue()==0&&session.nextOutValue()==1&&session.executeCount()==0;+ ok=ok&&(rejectAt?(!initialized&&!session.initialized()&&st==Status::DeviceFailure):(initialized&&session.initialized()));+ cleanup.fn();ok=ok&&cleanupOk;+ ComPtr<ID3D12InfoQueue> iq;if(FAILED(ctx.device()->QueryInterface(IID_PPV_ARGS(&iq))))return 2;unsigned errors=0;+ for(UINT64 i=0;i<iq->GetNumStoredMessages();++i){SIZE_T n=0;if(FAILED(iq->GetMessage(i,nullptr,&n)))return 2;+ std::vector<uint8_t>b(n);auto* m=reinterpret_cast<D3D12_MESSAGE*>(b.data());if(FAILED(iq->GetMessage(i,m,&n)))return 2;+ if(m->Severity<=D3D12_MESSAGE_SEVERITY_ERROR){++errors;std::cerr<<m->pDescription<<std::endl;}}+ std::cout<<"REGISTRATION_LIFECYCLE both="<<both<<" rejectAt="<<rejectAt<<" debugErrors="<<errors+ <<" noFlowPublished="<<(ready->GetCompletedValue()==0)<<" pass="<<(ok&&!errors)<<std::endl;+ return ok&&!errors?0:1;+}}-int main(int argc,char** argv){unsigned w=argc>1?unsigned(std::stoi(argv[1])):640,h=argc>2?unsigned(std::stoi(argv[2])):360;if(w<128||h<128||w>3840||h>2160)return 2;for(bool occlusion:{false,true})for(bool both:{false,true}){int r=run(w,h,both,occlusion);if(r)return r;}return 0;}+int main(int argc,char** argv){unsigned w=argc>1?unsigned(std::stoi(argv[1])):640,h=argc>2?unsigned(std::stoi(argv[2])):360;if(w<128||h<128||w>3840||h>2160)return 2;+ for(bool both:{false,true})for(unsigned rejected:{0u,2u,4u}){int r=registrationLifecycle(both,rejected);if(r)return r;}+ if(int r=registrationLifecycle(true,6))return r;+ for(bool occlusion:{false,true})for(bool both:{false,true}){int r=run(w,h,both,occlusion);if(r)return r;}return 0;}