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++
Capture RX7000 worker startup stderr, exception phase and crash events
Veyra Goal Agent77fcd8998711
diff --git a/AGENTS.md b/AGENTS.mdindex 98f7cfe0..477814a8 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -1,5 +1,7 @@# Veyra Agent 工作规则+> **2026-11-03 RX7000后续崩溃(诊断进行中)**:用户veyra-qml(4).log和cache(1).zip确认上次NVAPI修复已生效:m_gpuArch=0x1b0,NR进入Small网络创建,最后记录108.6MiB权重heap请求后worker管道断开。不能称为已查明OOM或再次修好。当前同分支新增worker diagnostics=2:阶段、CRT/原生stderr、未处理SEH记录;不改变算法/参数/fence/主EXE,提供只读Windows崩溃事件收集工具。CPU诊断14、GPU协议54通过,收集脚本5.1夹具通过;本机无RX7000推理。记录docs/RDNA3_WORKER_CRASH_2026-11-03.md,回执reports/rdna3-crash-diagnostics-20261103/FINAL.json,诊断包test-packages/codex-rdna3-crash-diagnostics-20261103。优先让用户收集已有三次崩溃事件,证据不足再试新worker一次。原组件/配置/发布包不动,不合main、不push/发布。+> **2026-11-03 RX7000多GPU身份映射修复(本地待实卡)**:用户cache.zip显示7900XTX有gfx1036核显/gfx1100独显,NGX因GPU身份匹配失败报Unsupported GPU architecture 0x0。codex/rdna3-nvapi-luid-20261103基线ecfbb0f,修固定ZLUDA b135e233的nvapi/src/lib.rs:当前CUDA上下文设备LUID代替写死ordinal0,歧义/失败明确报错。只重新编译开源zluda_nvapi.dll,不改NVIDIA模型/驱动/原翻译器或缓存。原正式组件13组8失败,新组件13组全通过(含双线程64次),不等于RX7000推理已验。源码patch、MIT/Apache许可证、构建和夹具测试已记录;更新包test-packages/codex-rdna3-nvapi-luid-20261103,FINAL位于reports/rdna3-nvapi-luid-20261103。未来组RX7000包必须带此更新后的NVAPI并重做manifest,勿从旧供体回退b86425dd…;新DLL身份a7adb043…/215040字节。原app/依赖/正式包保留,不合main、不push/Release。详见docs/RDNA3_NVAPI_LUID_2026-11-03.md。测试用nvcuda.dll绝不能进入产品包。> **2026-11-03 NVENC导出关键帧修复(本地)**:按用户要求先审第三方诊断,在codex/nvenc-export-keyframes-20261103(基线edad6e9)复现H.264/HEVC MP4仅首帧索引,确认低延迟preset继承无限IDR。显式同步当前codec idrPeriod到原GOP120并记录参数,不采纳I帧一律标KEY。14组生产导出/码流/原始索引及28次像素一致跳转通过;首次HDR合成素材漏PQ元数据已修正测试,保留失败。记录docs/NVENC_EXPORT_KEYFRAMES_2026-11-03.md,回执reports/nvenc-export-keyframes-20261103/FINAL.json,覆盖补丁test-packages/codex-nvenc-export-keyframes-20261103。继承全屏/VFG实验变更,不合main、不push/发布,不改真实配置、驱动或运行组件。diff --git a/CMakeLists.txt b/CMakeLists.txtindex 49b6ef7f..2d69e7dc 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -414,6 +414,10 @@ if(EXISTS "${VEYRA_RDNA3_NETWORK_SOURCE_DIR}/runtime/core/network.cpp")target_link_libraries(veyra_amd_nr_worker PRIVATE d3d12 dxgi dxguid version)endif()add_executable(veyra_amd_nr_test_worker src/pipeline/Rdna3NrWorker.cpp)+add_executable(veyra_rdna3_worker_diagnostics_tests tests/integration/Rdna3WorkerDiagnosticsTests.cpp)+target_include_directories(veyra_rdna3_worker_diagnostics_tests PRIVATE include)+target_compile_features(veyra_rdna3_worker_diagnostics_tests PRIVATE cxx_std_20)+target_compile_definitions(veyra_rdna3_worker_diagnostics_tests PRIVATE NOMINMAX UNICODE _UNICODE WIN32_LEAN_AND_MEAN)target_include_directories(veyra_amd_nr_test_worker PRIVATE include)target_compile_features(veyra_amd_nr_test_worker PRIVATE cxx_std_20)target_compile_definitions(veyra_amd_nr_test_worker PRIVATE NOMINMAX UNICODE _UNICODE WIN32_LEAN_AND_MEAN VEYRA_RDNA3_CONTRACT_WORKER=1)diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.mdindex e291aafe..69b2b2ba 100644--- a/docs/CURRENT_STATUS.md+++ b/docs/CURRENT_STATUS.md@@ -1,5 +1,7 @@# 当前项目状态+**2026-11-03 RX7000后续诊断**:用户新缓存确认架构识别已经通过;Small网络建立到权重heap请求时worker退出,尚无异常码。当前只补worker阶段/stderr/异常记录与崩溃事件收集,不把诊断更新冒充新的崩溃已修好。[新证据与诊断交付](RDNA3_WORKER_CRASH_2026-11-03.md)。+**2026-11-03 RX7000本地兼容补丁**:发现核显+独显设备的NVAPI LUID误报,当前分支codex/rdna3-nvapi-luid-20261103修开源zluda_nvapi.dll并提供独立小更新。原正式组件实测合同失败、新组件13组通过;没有RX7000实卡推理结论,不改模型/缓存/驱动。尚未合main、未发布。[证据及未来打包要求](RDNA3_NVAPI_LUID_2026-11-03.md)。**2026-11-03 本地导出修复**:codex/nvenc-export-keyframes-20261103显式覆盖NVENC低延迟preset的无限IDR,恢复每120帧真正IDR与封装索引,不把普通I标KEY。14组生产导出、28次跳转通过,继承全屏修复与RTX30 VFG实验兼容;未合main、未push/发布。[审查与证据](NVENC_EXPORT_KEYFRAMES_2026-11-03.md)。diff --git a/docs/RDNA3_WORKER_CRASH_2026-11-03.md b/docs/RDNA3_WORKER_CRASH_2026-11-03.mdnew file mode 100644index 00000000..91f2082b--- /dev/null+++ b/docs/RDNA3_WORKER_CRASH_2026-11-03.md@@ -0,0 +1,31 @@+# RX7900 XTX NR:架构通过后的worker退出++用户确认首个NVAPI更新后仍不可用,并提供veyra-qml(4).log与cache(1).zip。继续在codex/rdna3-nvapi-luid-20261103(已提交基线b27c0df)排查,不合main、不push/Release。此次先补足崩溃证据,不能把诊断更新说成第二处崩溃已修复。++## 新证据++- 新主日志UTC12:35:36.490、12:35:51.074、12:36:33.615均为`RDNA3 worker status pipe failed`,不再是之前的CreateFeature明确返回0xBAD00001。管道断开只说明子进程通信中止,不给出异常码或退出点。+- 新NGX日志本地时间20:36:30明确`m_gpuArch=0x1b0`,目标LUID0x100e2;NR进入CreateFeature、列出两种模型,选中Small:`hnet-crazy-cuckoo-small-fp8`,1920×1080。最后记录权重heap请求113907200字节(108.6MiB)。架构识别补丁确实生效。+- 对应worker-14168/13764/13260只记录三行基础信息,最后仍有24351MiB显存空闲。日志没有证明是哪次分配、CUDA调用或翻译失败;不能仅凭最后heap日志认定OOM。gate日志只见原生内核登记,也没有异常码。++当前结论:初始设备身份缺口已解决,新的阻塞发生在Small网络创建阶段、权重heap请求附近。仅凭这两份新日志,尚不能确定具体崩溃指令或原因。++## 有限诊断改动++只更新独立worker:记录初始化阶段及请求模型/设备参数;把CRT和Windows标准错误/输出句柄都重定向到独立stderr日志(原CREATE_NO_WINDOW进程会丢失Rust/CUDA异常输出);未处理SEH异常记录异常码、地址、访问地址和最后阶段,仍交原Windows异常机制处理,不假装从损坏上下文恢复。某些fail-fast会绕过普通异常过滤器,因此同时提供只读收集Windows Application 1000/1001中匹配worker的事件。++不改变模型选择、CUDA参数、共享纹理/fence、调度、颜色或原失败回退。主EXE不改,保留已验证身份映射DLL;只在worker初始化打印阶段,不加逐帧日志。无自动上传、无注册表/驱动修改,不下载模型,不尝试以切换模型/分辨率掩盖未知崩溃。++新增scripts/diagnostics/collect-rdna3-nr.ps1:只复制app日志/worker日志与组件身份清单,读取近3小时、最多20条匹配worker的崩溃事件;不复制ComputeCache数据库、模型或配置。默认输出软件logs下ZIP。-AppRoot/-OutputRoot允许在E盘夹具中验证,-SkipWindowsEvents用于明确的离线夹具,不把跳过说成真实事件已验。++## 实际验证与本地交付++构建入口build-recording-handoff.py,task codex-rdna3-crash-diagnostics-20261103,既有build-dir,reconfigure、label2.1.2-test、jobs2,目标worker/test-worker/diagnostics-tests/rdna3-contract-tests;23.1秒退出0,回执logs/codex-rdna3-crash-diagnostics-20261103/build-20261103-044618。++CPU诊断夹具14项通过:无控制台子进程正常退出和故意SEH退出的阶段、CRT/原生stderr、异常记录与原退出码保持;不吞掉异常。既有跨进程D3D12合同54项通过,包含颜色、双层并存和死worker自有等待解除;是协议夹具,不是AMD NR推理。回执reports/rdna3-crash-diagnostics-20261103/tests.json。++最终增量构建4.2秒通过(build-20261103-045220),加Rust panic backtrace默认值和更细的共享fence/预热阶段。最终CPU14项与跨进程GPU54项再次通过,见reports/rdna3-crash-diagnostics-20261103/final/tests.json。中间重复跑GPU合同因复用已有证据目录被程序以exit2拒绝,不是产品崩溃;改每轮独立目录后通过,tests-repeat-refused.json保留。++收集脚本在PowerShell5.1私有夹具验证:CRT/原生stderr都进入ZIP,真实新worker哈希与Python独立SHA256一致,包中不含数据库/可执行组件,Windows事件查询实际执行(不是Skip分支)。起初Get-FileHash在子进程脚本环境不可解析,改为.NET流式SHA256以消除该命令依赖后通过;保留失败日志collector-final.log和成功collector-test.json。输出里没有匹配worker事件只代表本机这次未找到该事件,不冒充用户那台机器的崩溃已定位。++最终ZIP、文件身份与源码证据写FINAL.json。本地诊断更新只带新worker、保留的身份修复DLL、收集工具和对应源码/许可,放test-packages/codex-rdna3-crash-diagnostics-20261103;不是NR已跑通的交付。先收集用户刚才三次失败留下的Windows事件即可;证据若仍不足再用新worker开启一次NR,不反复变更设置。原正式包、工作app及运行组件原件不覆盖。diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 219b0626..cf66b2ad 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -1,5 +1,11 @@# 当前工作日志+## 2026-11-03 RX7000补丁后worker退出:新日志与诊断更新++用户veyra-qml(4).log与cache(1).zip表明NVAPI身份修复确实生效(m_gpuArch0x1b0),新失败是12:35之后三次worker管道中断。NGX已进入Small1920×1080网络建立,最后权重heap请求108.6MiB;不能凭末行认定显存不足或具体CUDA错误。当前只更新worker诊断:阶段/请求参数、CRT与Win32 stderr、Rust backtrace、普通未处理SEH独立记录;保持原Windows异常处理、不吞异常。算法/模型/共享GPU同步/主EXE/设置不改,附只读Windows1000/1001事件收集,不包数据库或模型。++构建23.1秒、最终增量4.2秒通过,task codex-rdna3-crash-diagnostics-20261103;最终CPU诊断14项、GPU协议54项通过(不是AMD推理),收集脚本5.1实际查询事件及输出内容/哈希验证通过。重跑旧证据目录一次被合同拒绝exit2,改独立目录;收集脚本Get-FileHash解析失败后改.NET SHA256,失败日志保留。命令/详细结果见docs/RDNA3_WORKER_CRASH_2026-11-03.md,reports/rdna3-crash-diagnostics-20261103/FINAL.json。本地诊断包test-packages/codex-rdna3-crash-diagnostics-20261103,优先收集既有崩溃事件,不让用户反复变更参数。源码/依赖/正式包原件和用户配置保持,未合main/push/Release。尚未修复新的网络创建崩溃。+## 2026-11-03 RX7000 cache.zip续查与多GPU映射修复用户补充cache.zip,52份worker日志相同,NR创建前24GB显存可用、缓存覆盖gfx1100,NGX明确Unsupported GPU architecture 0x0/min0x1b0且m_gpuArch=0xe0。固定ZLUDA NVAPI源码硬编码CUDA设备0,而Veyra按独显上下文运行。使用正式包同SHA转发层及NVAPI实际复现“核显0/独显1”误报核显LUID。分支codex/rdna3-nvapi-luid-20261103基线ecfbb0f,重编译同源开源NVAPI,改用当前上下文设备并显式拒绝歧义/查询失败;不改模型/驱动/原件,未使用二进制补丁。diff --git a/include/veyra/pipeline/Rdna3WorkerDiagnostics.h b/include/veyra/pipeline/Rdna3WorkerDiagnostics.hnew file mode 100644index 00000000..d95df91a--- /dev/null+++ b/include/veyra/pipeline/Rdna3WorkerDiagnostics.h@@ -0,0 +1,70 @@+// SPDX-License-Identifier: GPL-3.0-only+#pragma once+#include <windows.h>+#include <atomic>+#include <cstdio>+#include <cstdint>+#include <io.h>+#include <string>++namespace veyra::pipeline::rdna3::diagnostics {+inline std::atomic<const char*> currentPhase{"before-init"};+inline FILE* mainLog=nullptr;+inline wchar_t exceptionPath[2048]{};+inline LPTOP_LEVEL_EXCEPTION_FILTER previousFilter=nullptr;++// Do not recover from a corrupt third-party stack or GPU context. Write a small+// independent exception record, then leave normal Windows crash handling intact.+inline LONG WINAPI exceptionRecord(EXCEPTION_POINTERS* exception) {+ const auto* record=exception?exception->ExceptionRecord:nullptr;+ if(record&&exceptionPath[0]){+ HANDLE file=CreateFileW(exceptionPath,GENERIC_WRITE,FILE_SHARE_READ,nullptr,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,nullptr);+ if(file!=INVALID_HANDLE_VALUE){+ char line[768]{};+ const int size=_snprintf_s(line,sizeof(line),_TRUNCATE,+ "worker pid=%lu tid=%lu phase=%s exception=0x%08lX address=%p parameters=%lu\r\n",+ GetCurrentProcessId(),GetCurrentThreadId(),currentPhase.load(std::memory_order_relaxed),+ record->ExceptionCode,record->ExceptionAddress,record->NumberParameters);+ DWORD written=0;+ if(size>0)WriteFile(file,line,DWORD(size),&written,nullptr);+ if(record->ExceptionCode==EXCEPTION_ACCESS_VIOLATION&&record->NumberParameters>=2){+ const int count=_snprintf_s(line,sizeof(line),_TRUNCATE,"access=%llu target=0x%llX\r\n",+ static_cast<unsigned long long>(record->ExceptionInformation[0]),+ static_cast<unsigned long long>(record->ExceptionInformation[1]));+ if(count>0)WriteFile(file,line,DWORD(count),&written,nullptr);+ }+ FlushFileBuffers(file);CloseHandle(file);+ }+ }+ return previousFilter?previousFilter(exception):EXCEPTION_CONTINUE_SEARCH;+}++inline bool begin(FILE* log,const wchar_t* path) {+ if(!log||!path)return false;+ const std::wstring stderrPath=std::wstring(path)+L".stderr.log";+ if(wcsncpy_s(exceptionPath,std::wstring(path).append(L".exception.log").c_str(),_TRUNCATE))return false;+ FILE* redirected=nullptr;+ if(_wfreopen_s(&redirected,stderrPath.c_str(),L"ab",stderr)||!redirected)return false;+ setvbuf(redirected,nullptr,_IONBF,0);+ const auto handle=reinterpret_cast<HANDLE>(_get_osfhandle(_fileno(redirected)));+ if(handle==INVALID_HANDLE_VALUE||!SetStdHandle(STD_ERROR_HANDLE,handle)||!SetStdHandle(STD_OUTPUT_HANDLE,handle))return false;+ mainLog=log;+ wchar_t backtrace[8]{};+ if(!GetEnvironmentVariableW(L"RUST_BACKTRACE",backtrace,DWORD(std::size(backtrace))))SetEnvironmentVariableW(L"RUST_BACKTRACE",L"1");+ // This is an owned background process. Suppress a Windows crash dialog;+ // the error code, stderr and Windows Application events remain available.+ SetErrorMode(GetErrorMode()|SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX);+ previousFilter=SetUnhandledExceptionFilter(exceptionRecord);+ fprintf(log,"worker diagnostics=2 pid=%lu stderr=%ls\n",GetCurrentProcessId(),stderrPath.c_str());fflush(log);+ return true;+}++inline void phase(const char* value) {+ currentPhase.store(value,std::memory_order_relaxed);+ if(mainLog){fprintf(mainLog,"phase=%s\n",value);fflush(mainLog);}+}++inline void finish() {+ SetUnhandledExceptionFilter(previousFilter);mainLog=nullptr;+}+} // namespace veyra::pipeline::rdna3::diagnosticsdiff --git a/scripts/diagnostics/collect-rdna3-nr.ps1 b/scripts/diagnostics/collect-rdna3-nr.ps1new file mode 100644index 00000000..816ebbff--- /dev/null+++ b/scripts/diagnostics/collect-rdna3-nr.ps1@@ -0,0 +1,72 @@+param(+ [string]$AppRoot = $PSScriptRoot,+ [string]$OutputRoot = '',+ [switch]$SkipWindowsEvents+)+$ErrorActionPreference = 'Stop'+# A PowerShell 7 parent can pass its own module search path to Windows+# PowerShell. Prefer this process's built-in modules without changing the+# user/system environment or requiring an installed third-party module.+$nativeModules = Join-Path $PSHOME 'Modules'+if (-not (($env:PSModulePath -split ';') -contains $nativeModules)) { $env:PSModulePath = $nativeModules + ';' + $env:PSModulePath }+$AppRoot = (Get-Item -LiteralPath $AppRoot).FullName+if ([string]::IsNullOrWhiteSpace($OutputRoot)) { $OutputRoot = Join-Path $AppRoot 'logs' }+New-Item -ItemType Directory -Force -Path $OutputRoot | Out-Null+$stamp = (Get-Date -Format 'yyyyMMdd-HHmmss') + '-' + ([guid]::NewGuid().ToString('N').Substring(0,8))+$stage = Join-Path $OutputRoot ('Veyra-NR-Diagnostics-' + $stamp)+New-Item -ItemType Directory -Path $stage | Out-Null+$notes = [Collections.Generic.List[string]]::new()+function Get-ComponentSHA256([string]$Path) {+ $stream = $null; $digest = $null+ try {+ $stream = [IO.File]::OpenRead($Path)+ $digest = [Security.Cryptography.SHA256]::Create()+ return [BitConverter]::ToString($digest.ComputeHash($stream)).Replace('-', '')+ } finally { if ($digest) { $digest.Dispose() }; if ($stream) { $stream.Dispose() } }+}+foreach ($spec in @(@('runtime/amd-nr-rdna3/cache','worker-logs'), @('logs','app-logs'))) {+ $from = Join-Path $AppRoot $spec[0]+ $to = Join-Path $stage $spec[1]+ if (-not (Test-Path -LiteralPath $from -PathType Container)) { $notes.Add('Missing log directory: ' + $from); continue }+ New-Item -ItemType Directory -Path $to | Out-Null+ foreach ($file in (Get-ChildItem -LiteralPath $from -File -Filter '*.log')) {+ # Read shared logs without requiring the user to stop/restart again.+ $inputStream = $null; $outputStream = $null+ try {+ $inputStream = [IO.File]::Open($file.FullName, [IO.FileMode]::Open, [IO.FileAccess]::Read, [IO.FileShare]::ReadWrite -bor [IO.FileShare]::Delete)+ $outputStream = [IO.File]::Create((Join-Path $to $file.Name))+ $inputStream.CopyTo($outputStream)+ } catch { $notes.Add('Could not copy ' + $file.Name + ': ' + $_.Exception.Message) }+ finally { if ($outputStream) { $outputStream.Dispose() }; if ($inputStream) { $inputStream.Dispose() } }+ }+}+$components = foreach ($relative in @(+ 'runtime/amd-nr-rdna3/veyra_amd_nr_worker.exe',+ 'runtime/amd-nr-rdna3/zluda/zluda_nvapi.dll',+ 'runtime/amd-nr-rdna3/zluda/nvapi64.dll',+ 'runtime/amd-nr-rdna3/zluda/nvcuda.dll',+ 'runtime/amd-nr-rdna3/zluda/zluda_real.dll',+ 'runtime/amd-nr-rdna3/zluda/nvngx.dll',+ 'runtime/amd-nr-rdna3/nvngx_dlssnr.dll'+)) {+ $path = Join-Path $AppRoot $relative+ if (Test-Path -LiteralPath $path -PathType Leaf) {+ $file = Get-Item -LiteralPath $path+ [pscustomobject]@{ Path=$relative; Bytes=$file.Length; SHA256=(Get-ComponentSHA256 $path); Version=$file.VersionInfo.FileVersion }+ } else { [pscustomobject]@{ Path=$relative; Missing=$true } }+}+ConvertTo-Json -InputObject @($components) -Depth 5 | Set-Content -LiteralPath (Join-Path $stage 'components.json') -Encoding UTF8+$eventResult = @{ Skipped=[bool]$SkipWindowsEvents; Events=@(); Error=$null; ErrorId=$null }+if (-not $SkipWindowsEvents) {+ try {+ $eventResult.Events = @(Get-WinEvent -FilterHashtable @{LogName='Application';Id=1000,1001;StartTime=(Get-Date).AddHours(-3)} -ErrorAction Stop |+ Where-Object { $_.ToXml().IndexOf('veyra_amd_nr_worker.exe', [StringComparison]::OrdinalIgnoreCase) -ge 0 } |+ Select-Object -First 20 TimeCreated,Id,ProviderName,Message,@{Name='Xml';Expression={$_.ToXml()}})+ } catch { $eventResult.Error=$_.Exception.Message; $eventResult.ErrorId=$_.FullyQualifiedErrorId }+}+ConvertTo-Json -InputObject $eventResult -Depth 8 | Set-Content -LiteralPath (Join-Path $stage 'worker-windows-events.json') -Encoding UTF8+ConvertTo-Json -InputObject @{CollectedUtc=[DateTime]::UtcNow.ToString('o');AppRoot=$AppRoot;Notes=@($notes);DatabaseIncluded=$false} -Depth 5 |+ Set-Content -LiteralPath (Join-Path $stage 'collection.json') -Encoding UTF8+$archive = $stage + '.zip'+Compress-Archive -LiteralPath $stage -DestinationPath $archive -CompressionLevel Optimal+Write-Host ('Diagnostics saved: ' + $archive)diff --git a/src/pipeline/Rdna3NrWorker.cpp b/src/pipeline/Rdna3NrWorker.cppindex dea7f707..6b8eaa53 100644--- a/src/pipeline/Rdna3NrWorker.cpp+++ b/src/pipeline/Rdna3NrWorker.cpp@@ -7,6 +7,7 @@#include <wrl/client.h>#include "veyra/pipeline/Rdna3NrProtocol.h"#include "veyra/pipeline/AmdNrProvider.h"+#include "veyra/pipeline/Rdna3WorkerDiagnostics.h"#ifndef VEYRA_RDNA3_CONTRACT_WORKER#include "runtime/core/network.h"#endif@@ -56,6 +57,8 @@ struct Worker {if(!validHeader(init.h,Op::Init,sizeof(init))||!validExtent(init.width,init.height)||init.reserved||init.h.sequence||(init.preset!=1&&init.preset!=2)||!safePath(init.runtime)||!safePath(init.data)||!safePath(init.log)){error="invalid initialization/protocol/model/extent";return false;}if(_wfopen_s(&logfile,init.log.data(),L"wb")||!logfile){error="worker diagnostic log could not be created";return false;}+ if(!diagnostics::begin(logfile,init.log.data())){error="worker stderr/exception diagnostics could not be initialized";return false;}+ diagnostics::phase("device-and-shared-resource-setup");std::error_code ec;std::filesystem::create_directories(std::filesystem::path(init.data.data())/L"tmp",ec);const auto tmp=std::filesystem::path(init.data.data())/L"tmp";SetEnvironmentVariableW(L"TEMP",tmp.c_str());SetEnvironmentVariableW(L"TMP",tmp.c_str());SetEnvironmentVariableW(L"DLSS5NR_ALLOW_TRANSLATION",nullptr); // packaged cache only, no surprise 30-minute build@@ -117,19 +120,28 @@ struct Worker {#ifndef VEYRA_RDNA3_CONTRACT_WORKERdlss5nr::set_network_log(logLine);dlss5nr::NetworkPaths paths;paths.runtime_dir=init.runtime.data();paths.snippet=snippet;paths.data_dir=init.data.data();paths.adapter_luid=init.adapterLuid;- if(!network.load(paths,error)||!network.can_share(device.Get())){if(error.empty())error="native D3D12/HIP shared images are unavailable; CPU pixel-copy fallback is forbidden";return false;}+ diagnostics::phase("network-load");+ if(!network.load(paths,error))return false;+ diagnostics::phase("shared-memory-preflight");+ if(!network.can_share(device.Get())){error="native D3D12/HIP shared images are unavailable; CPU pixel-copy fallback is forbidden";return false;}network.set_copy_mode(false);controls.preset=int(init.preset);+ fprintf(logfile,"network create width=%u height=%u preset=%u adapterLuid=0x%llX\n",init.width,init.height,init.preset,static_cast<unsigned long long>(init.adapterLuid));fflush(logfile);+ diagnostics::phase("create-feature");if(!network.create_feature(init.width,init.height,controls,error))return false;+ diagnostics::phase("import-shared-images");for(unsigned i=0;i<4;++i){auto& t=shared[i];t.resource=image[i].Get();t.nt_handle=reinterpret_cast<void*>(uintptr_t(init.handles[i]));t.width=init.width;t.height=init.height;t.dxgi_format=image[i]->GetDesc().Format;t.writable=i==1;if(!network.import(t,error))return false;}if(hrFailed(__LINE__,device->CreateFence(0,D3D12_FENCE_FLAG_SHARED,IID_PPV_ARGS(&cudaDone)))||hrFailed(__LINE__,device->CreateSharedHandle(cudaDone.Get(),nullptr,GENERIC_ALL,nullptr,&cudaDoneHandle))){error="private CUDA completion fence creation failed";return false;}+ diagnostics::phase("import-shared-fences");if(!network.import_fence(reinterpret_cast<void*>(uintptr_t(init.handles[4])),&producerSem,error)||!network.import_fence(cudaDoneHandle,&doneSem,error))return false;dlss5nr::EvaluateDesc warm;warm.color=&shared[0];warm.output=&shared[1];warm.depth=&shared[2];warm.motion=&shared[3];warm.controls=controls;warm.reset=true;+ diagnostics::phase("warmup-evaluate");if(!network.evaluate(warm,error))return false;logLine(2,"native Small/Original warm-up complete; shared GPU semaphores required, no async old-frame residual");#elselogLine(2,"CONTRACT TEST WORKER: copies proxy; does not execute NR or validate Radeon inference");#endif+ diagnostics::phase("ready");started=true;return true;}bool publish(uint64_t sequence,bool copy){@@ -184,7 +196,7 @@ struct Worker {if(cudaDoneHandle)CloseHandle(cudaDoneHandle);#endiffor(auto h:init.handles)if(h)CloseHandle(reinterpret_cast<HANDLE>(uintptr_t(h)));- if(logfile){fclose(logfile);logfile=nullptr;}+ if(logfile){diagnostics::finish();fclose(logfile);logfile=nullptr;}}};}@@ -193,7 +205,7 @@ int wmain(int argc,wchar_t** argv){HANDLE input=reinterpret_cast<HANDLE>(uintptr_t(_wcstoui64(argv[1],nullptr,10)));HANDLE output=reinterpret_cast<HANDLE>(uintptr_t(_wcstoui64(argv[2],nullptr,10)));Worker w;if(!readAll(input,&w.init,sizeof(w.init)))return 3;- const bool opened=w.open();if(!answer(output,0,opened?0:1,w.error)||!opened)return 4;+ const bool opened=w.open();if(!opened)logLine(0,w.error.c_str());if(!answer(output,0,opened?0:1,w.error)||!opened)return 4;for(;;){Header h;if(!readAll(input,&h,sizeof(h)))return 5;if(validHeader(h,Op::Stop,sizeof(h))&&h.sequence==w.last+1){w.close(h.sequence);return 0;}diff --git a/tests/integration/Rdna3WorkerDiagnosticsTests.cpp b/tests/integration/Rdna3WorkerDiagnosticsTests.cppnew file mode 100644index 00000000..dca49c92--- /dev/null+++ b/tests/integration/Rdna3WorkerDiagnosticsTests.cpp@@ -0,0 +1,46 @@+// SPDX-License-Identifier: GPL-3.0-only+#define WIN32_LEAN_AND_MEAN+#include "veyra/pipeline/Rdna3WorkerDiagnostics.h"+#include <filesystem>+#include <fstream>+#include <sstream>+#include <iostream>++namespace d=veyra::pipeline::rdna3::diagnostics;+std::string read(const std::filesystem::path& p){std::ifstream f(p,std::ios::binary);std::ostringstream s;s<<f.rdbuf();return s.str();}+int wmain(int argc,wchar_t** argv){+ if(argc==4&&std::wstring(argv[1])==L"--child"){+ const std::filesystem::path root=argv[2];FILE* log=nullptr;+ if(_wfopen_s(&log,(root/L"worker.log").c_str(),L"wb")||!log||!d::begin(log,(root/L"worker.log").c_str()))return 7;+ d::phase("network-load");d::phase("create-feature");+ fprintf(stderr,"simulated runtime stderr\n");+ DWORD n=0;const char rustStyle[]="simulated native stderr handle\n";+ WriteFile(GetStdHandle(STD_ERROR_HANDLE),rustStyle,DWORD(sizeof(rustStyle)-1),&n,nullptr);+ if(std::wstring(argv[3])==L"crash")RaiseException(0xE0007001,EXCEPTION_NONCONTINUABLE,0,nullptr);+ d::phase("ready");d::finish();fclose(log);return 0;+ }+ if(argc!=2)return 2;+ const auto base=std::filesystem::absolute(argv[1]);std::filesystem::create_directories(base);+ wchar_t executable[32768]{};GetModuleFileNameW(nullptr,executable,DWORD(std::size(executable)));+ unsigned checks=0,failures=0;+ auto check=[&](bool ok,const char* name){++checks;if(!ok)++failures;std::cout<<(ok?"PASS ":"FAIL ")<<name<<"\n";};+ for(const auto* mode:{L"normal",L"crash"}){+ const auto root=base/mode;std::filesystem::create_directories(root);+ auto command=std::wstring(L"\"")+executable+L"\" --child \""+root.wstring()+L"\" "+mode;+ STARTUPINFOW startup{};startup.cb=sizeof(startup);PROCESS_INFORMATION process{};+ const bool created=CreateProcessW(executable,command.data(),nullptr,nullptr,FALSE,CREATE_NO_WINDOW,nullptr,root.c_str(),&startup,&process)!=FALSE;+ check(created,"owned no-console fixture starts");if(!created)continue;+ const auto wait=WaitForSingleObject(process.hProcess,10000);check(wait==WAIT_OBJECT_0,"fixture exits within 10 seconds");+ if(wait!=WAIT_OBJECT_0)TerminateProcess(process.hProcess,99);+ DWORD code=0;GetExitCodeProcess(process.hProcess,&code);CloseHandle(process.hThread);CloseHandle(process.hProcess);+ const bool crash=std::wstring(mode)==L"crash";+ check(code==(crash?0xE0007001u:0u),"original process exception/normal exit status preserved");+ const auto log=read(root/L"worker.log"),stderrLog=read(root/L"worker.log.stderr.log");+ check(log.find("diagnostics=2")!=std::string::npos&&log.find("phase=create-feature")!=std::string::npos,"version and initialization phase flushed");+ check(stderrLog.find("simulated runtime stderr")!=std::string::npos,"CRT stderr captured");+ check(stderrLog.find("simulated native stderr handle")!=std::string::npos,"native stderr handle captured without a console");+ const auto exceptionLog=read(root/L"worker.log.exception.log");+ check(crash?(exceptionLog.find("exception=0xE0007001")!=std::string::npos&&exceptionLog.find("phase=create-feature")!=std::string::npos):exceptionLog.empty(),"exception recorded only for crash and not swallowed");+ }+ std::cout<<"checks="<<checks<<" failures="<<failures<<" (CPU diagnostic fixture, not Radeon inference)\n";return failures?1:0;+}