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++

feat: add scoped experimental RTX30 NR and disable fresh-install effects

Veyra Goal Agent831432fa9e18
diff --git a/AGENTS.md b/AGENTS.md
index e98e9164..844bac2e 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,5 +1,8 @@
# Veyra 项目 Agent 执行规则
+> 2026-09-14 用户授权实施 RTX30 NR 兼容选项与首次启动全部效果关闭。允许将用户提供的 NeuralScreen 1.8.2 包内 native/nvngx_dlssnr.dll 原样用于隔离本地接入测试:SHA256 DCC0DC2414AEDEC4A8E084647070383BE068554042587180C20C784D4772D36F,165840496 bytes,310.8.0.0,HashMismatch。独立 runtime_local/nvidia/nr-ampere/,不覆盖原版/RTX40社区版;调用方兼容限定所选NR模块,不修改磁盘驱动或运行库。不授予新Release或将此文件入源码权限。初始NR/SR/FG全部关闭,已有明确保存的设置保留;RTX30实际性能需持卡验收,不能用本机RTX50通过代替。
+
+
> 2026-09-14 用户授权发布1.1.0至Likely7/Veyra-NRVideo:包含普通版Smooth Motion开启说明、允许自主叠加的策略及此前采集格式扩展;更新双语README与教程、完整便携包及对应源码。沿用已批准七个增强运行文件与patched FFmpeg,不新增驱动文件或SDK入Git。Smooth Motion由NVIDIA App管理,用户已反馈本机有效稳定,不宣称驱动算法内置、所有设备验收或叠加必然更好。发布完成并核实资产后按用户要求关机。
> 2026-09-14 用户确认 Smooth Motion 在本机实验版有效且稳定,决定普通版仅提供 NVIDIA App 开启方法与注意事项:只用驱动补帧时选择软件“关闭补帧”;换回内部 DLSS/XeSS 时由用户在 NVIDIA App 关闭 AI 插帧。允许用户自行叠加驱动与内部补帧,不检测、不拦截、不强制互斥,也不自动修改驱动配置。叠加效果未验证,不宣称更好;软件统计/截图/导出不冒充含驱动生成帧。本条取代此前 Smooth Motion 实验方案的强制互斥与软件内驱动配置管理要求;保留原实验分支作历史存档。本轮未授权新发布。
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 78d27416..9c9ee21a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -141,6 +141,10 @@ veyra_add_compute_shader(veyra_shader_parity_encode ParityEncode)
veyra_add_compute_shader(veyra_shader_parity_decode ParityDecode)
if(VEYRA_ENABLE_EXPERIMENTAL_DLSSNR)
veyra_add_compute_shader(veyra_shader_test_pattern GenerateTestPattern)
+ add_executable(veyra_nr_ampere_tests tests/integration/NrAmpereTests.cpp)
+ target_compile_features(veyra_nr_ampere_tests PRIVATE cxx_std_20)
+ target_compile_definitions(veyra_nr_ampere_tests PRIVATE UNICODE _UNICODE WIN32_LEAN_AND_MEAN NOMINMAX)
+ target_link_libraries(veyra_nr_ampere_tests PRIVATE veyra_gfx veyra_ngx)
add_executable(veyra_nr_harness
tools/nr_harness/main.cpp
tools/nr_harness/frame_loop.cpp
@@ -472,6 +476,9 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avform
target_compile_definitions(veyra_realtime_preview_tests PRIVATE UNICODE _UNICODE WIN32_LEAN_AND_MEAN NOMINMAX)
target_include_directories(veyra_realtime_preview_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
add_executable(veyra_live_presentation_tests tests/integration/LivePresentationTests.cpp)
+ add_executable(veyra_nr_runtime_switch_tests tests/integration/NrRuntimeSwitchTests.cpp)
+ target_compile_features(veyra_nr_runtime_switch_tests PRIVATE cxx_std_20)
+ target_link_libraries(veyra_nr_runtime_switch_tests PRIVATE veyra_engine)
add_executable(veyra_audio_timeline_tests tests/integration/AudioTimelineTests.cpp)
target_compile_features(veyra_audio_timeline_tests PRIVATE cxx_std_20)
target_link_libraries(veyra_audio_timeline_tests PRIVATE veyra_sinks)
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md
index 6d9ee265..b63cc312 100644
--- a/THIRD_PARTY_NOTICES.md
+++ b/THIRD_PARTY_NOTICES.md
@@ -104,6 +104,7 @@ Remote Play also depends on **OpenSSL, Opus, json-c, libevent, miniupnpc, curl,
| --- | --- |
| [Magpie Experimental](https://github.com/SAOG0721/Magpie/tree/experimental) | NR / SR / FG combinations, configurable processing order, motion guidance, residual composition, resource synchronization and presentation pacing; an important practical comparison during development. |
| [OBS Studio](https://github.com/obsproject/obs-studio) | DirectShow capture, pixel formats, color metadata, buffering and window-capture behavior. |
+| [DLSS5-NeuralScreen](https://github.com/perseval-BLR/DLSS5-NeuralScreen/tree/8098ccf261bedc16e4b5fe7887c51a07eb41720e) | RTX30 NR compatibility research and architecture-query behavior reference. Veyra's scoped adapter is independently implemented; the user-provided modified runtime has a separate identity and is not covered by the application's MIT license. See [local integration record](docs/RTX30_NR_AND_SAFE_DEFAULTS_2026-09-14.md). |
| [NVEnc](https://github.com/rigaya/NVEnc) / [RTXVideoProcessor](https://github.com/DrC0ns0le/RTXVideoProcessor) | Video upscaling, GPU frame resources, codecs and scheduling. FRUC was also researched; it has since been removed from Veyra. |
| [mpv](https://github.com/mpv-player/mpv) | RTX upscaling integration and video-processing approaches in a media player. |
| [video2dlssnr](https://github.com/DaniilSokolyuk/video2dlssnr) / [dlss5-nr-player](https://github.com/Zonnery/dlss5-nr-player) | Research comparisons for NR pipelines, stage order and data transfers; their code was not copied. |
diff --git a/apps/veyra/SettingsWindow.cpp b/apps/veyra/SettingsWindow.cpp
index f0795082..fa9244bd 100644
--- a/apps/veyra/SettingsWindow.cpp
+++ b/apps/veyra/SettingsWindow.cpp
@@ -217,8 +217,8 @@ case WM_CREATE:{window=h;font=makeFont(h);items.clear();displayedBackendWarning.
button(L"2K",730,0,12,100,80);button(L"4K",731,0,100,100,80);button(L"8K",732,0,188,100,80);
for(auto& entry:items)if(entry.page==0&&entry.y>=56)entry.y+=80;
add(L"STATIC",L"NR 运行版本",1117,0,0,12,56,-1,24);
- combo(218,0,84,{L"NVIDIA 原版 · RTX 50",L"社区兼容 · RTX 40/50 实验"});
- SetPropW(item(218),L"veyra.tip",HANDLE(L"社区版为用户提供的修改版;RTX 40 兼容性需实机验证。切换会重建增强管线。"));
+ combo(218,0,84,{L"NVIDIA 原版 · RTX 50",L"社区兼容 · RTX 40/50 实验",L"RTX 30 兼容 · 实验"});
+ SetPropW(item(218),L"veyra.tip",HANDLE(L"社区版为修改运行时。RTX 30 档需单独组件,性能与兼容性待持卡验证;不解锁 DLSS 补帧。切换会重建管线,失败恢复原设置。"));
// Final layout in reading order; existing control IDs and bindings stay intact.
for(auto& entry:items){
const int id=GetDlgCtrlID(entry.h);
diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cpp
index 382501f0..71575953 100644
--- a/apps/veyra/ui/AppShell.cpp
+++ b/apps/veyra/ui/AppShell.cpp
@@ -245,12 +245,12 @@ void startVideoExport(bool hevc){auto s=engine.snapshot();if(currentFile.empty()
#include "UiRepairChecks.h"
LRESULT CALLBACK proc(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp){switch(msg){
-case WM_CREATE:{mainWindow=hwnd;backdrop.attach(hwnd);font=veyra::ui::makeFont(hwnd);veyra::ui::titleTheme(hwnd);uiState.configured=initialOptions.snapshot();
+case WM_CREATE:{mainWindow=hwnd;backdrop.attach(hwnd);font=veyra::ui::makeFont(hwnd);veyra::ui::titleTheme(hwnd);uiState.configured=initialOptions.snapshot();uiState.enhanced=initialOptions.nr||initialOptions.sr||initialOptions.fg;
#ifdef VEYRA_ENABLE_REMOTEPLAY
control(L"BUTTON",L"PS5",RemotePlay,BS_PUSHBUTTON,0,0,56,28);veyra::ui::ghost(GetDlgItem(hwnd,RemotePlay));SetPropW(GetDlgItem(hwnd,RemotePlay),L"veyra.tip",HANDLE(L"PS5 串流 · 配对与连接"));
#endif
control(L"BUTTON",L"打开",Open,BS_PUSHBUTTON,10,10,150,30);control(L"BUTTON",L"播放",Play,BS_PUSHBUTTON,168,10,68,30);control(L"BUTTON",L"停止",Stop,BS_PUSHBUTTON,244,10,62,30);control(L"BUTTON",L"截图",Save,BS_PUSHBUTTON,314,10,95,30);
-control(L"BUTTON",L"DLSS5 NR",Nr,BS_AUTOCHECKBOX,425,10,110,30);control(L"BUTTON",L"SR",Sr,BS_AUTOCHECKBOX,518,10,78,30);control(L"BUTTON",L"补帧",Fg,BS_AUTOCHECKBOX,600,10,78,30);CheckDlgButton(hwnd,Nr,BST_CHECKED);
+control(L"BUTTON",L"DLSS5 NR",Nr,BS_AUTOCHECKBOX,425,10,110,30);control(L"BUTTON",L"SR",Sr,BS_AUTOCHECKBOX,518,10,78,30);control(L"BUTTON",L"补帧",Fg,BS_AUTOCHECKBOX,600,10,78,30);CheckDlgButton(hwnd,Nr,initialOptions.nr?BST_CHECKED:BST_UNCHECKED);
control(L"BUTTON",L"采集",Capture,BS_PUSHBUTTON,690,10,75,30);control(L"BUTTON",L"导出视频",Export,BS_PUSHBUTTON,773,10,103,30);control(L"BUTTON",L"性能/诊断",Info,BS_PUSHBUTTON,884,10,100,30);
control(L"BUTTON",L"实时NR档",Realtime,BS_AUTOCHECKBOX,952,10,100,30);
control(L"BUTTON",L"最近打开",Recent,BS_PUSHBUTTON,1072,10,75,30);
@@ -514,7 +514,7 @@ SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);INITCO
CoInitializeEx(nullptr,COINIT_APARTMENTTHREADED);
initialOptions=veyra::engine::PlayerOptions::from(veyra::ui::defaultSettings());
-int argc=0;auto argv=CommandLineToArgvW(GetCommandLineW(),&argc);for(int i=1;i<argc;++i){const std::wstring arg=argv[i];if(arg==L"--export-worker"&&i+1<argc)workerMapping=reinterpret_cast<HANDLE>(_wcstoui64(argv[++i],nullptr,10));else if(arg==L"--smoke-view"&&i+1<argc)smokeView=argv[++i];else if(arg==L"--smoke-repair-ui")smokeRepair=true;else if(arg==L"--smoke-repair-ui-reject")smokeRepair=smokeRepairReject=true;else if(arg==L"--smoke-hover")smokeZoom=smokeHover=true;else if(arg==L"--smoke-protection")smokeProtection=true;else if(arg==L"--smoke-zoom")smokeZoom=true;else if(arg==L"--smoke-empty")smokeEmpty=true;else if(arg==L"--smoke-dual")smokeDual=true;else if(arg==L"--smoke-dual-pause"){smokeDual=smokeDualPause=true;}else if(arg==L"--smoke-master-reject")smokeMaster=smokeMasterReject=true;else if(arg==L"--smoke-master")smokeMaster=true;else if(arg==L"--smoke-audio")smokeAudio=true;else if(arg==L"--smoke-job-cancel")smokeJobCancel=true;else if(arg==L"--smoke-job-exit")smokeJobExit=true;else if(arg==L"--smoke-job")smokeJob=true;else if(arg==L"--smoke-dual-export"&&i+1<argc)smokeDualOutput=argv[++i];else if(arg==L"--smoke-seconds"&&i+1<argc)smokeSeconds=std::clamp(_wtoi(argv[++i]),1,240);else if(arg==L"--export-out"&&i+1<argc)exportOutput=argv[++i];else if(arg==L"--max-frames"&&i+1<argc)exportFrames=std::max(1,_wtoi(argv[++i]));else if(arg==L"--cancel-after-ms"&&i+1<argc)cancelAfterMs=std::clamp(_wtoi(argv[++i]),1,240000);else if(arg==L"--hevc")exportHevc=true;else if(arg==L"--smoke-rollback-flow"){smokeRollback=true;smokeRollbackFlow=true;}else if(arg==L"--smoke-rollback")smokeRollback=true;else if(arg==L"--smoke-ui")smokeUi=true;else if(arg==L"--no-fg")initialOptions.fg=false;else if(arg==L"--smoke-settings")smokeSettings=true;else if(arg==L"--smoke-screenshot")smokeScreenshot=true;else if(arg==L"--smoke-controls")smokeControls=true;else if(arg==L"--smoke-save"&&i+1<argc)smokeSave=argv[++i];else if(arg==L"--native")initialOptions.realtime=false;else if(arg==L"--realtime")initialOptions.realtime=true;else if(arg==L"--fg")initialOptions.fg=true;else if(arg==L"--fg-multiplier"&&i+1<argc){initialOptions.fgMultiplier=std::clamp(_wtoi(argv[++i]),2,4);initialOptions.fg=true;}else if(arg==L"--video-sr"&&i+1<argc){initialOptions.settings.videoSrQuality=std::clamp(_wtoi(argv[++i]),1,4);initialOptions.sr=true;}else if(arg==L"--nr-community")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Community;else if(arg==L"--nr-original")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Original;else if(arg==L"--sr")initialOptions.sr=true;else if(arg==L"--no-nr")initialOptions.nr=false;else if(arg==L"--nr")initialOptions.nr=true;else if(arg==L"--no-sr")initialOptions.sr=false;else autoInput=arg;}LocalFree(argv);
+int argc=0;auto argv=CommandLineToArgvW(GetCommandLineW(),&argc);for(int i=1;i<argc;++i){const std::wstring arg=argv[i];if(arg==L"--export-worker"&&i+1<argc)workerMapping=reinterpret_cast<HANDLE>(_wcstoui64(argv[++i],nullptr,10));else if(arg==L"--smoke-view"&&i+1<argc)smokeView=argv[++i];else if(arg==L"--smoke-repair-ui")smokeRepair=true;else if(arg==L"--smoke-repair-ui-reject")smokeRepair=smokeRepairReject=true;else if(arg==L"--smoke-hover")smokeZoom=smokeHover=true;else if(arg==L"--smoke-protection")smokeProtection=true;else if(arg==L"--smoke-zoom")smokeZoom=true;else if(arg==L"--smoke-empty")smokeEmpty=true;else if(arg==L"--smoke-dual")smokeDual=true;else if(arg==L"--smoke-dual-pause"){smokeDual=smokeDualPause=true;}else if(arg==L"--smoke-master-reject")smokeMaster=smokeMasterReject=true;else if(arg==L"--smoke-master")smokeMaster=true;else if(arg==L"--smoke-audio")smokeAudio=true;else if(arg==L"--smoke-job-cancel")smokeJobCancel=true;else if(arg==L"--smoke-job-exit")smokeJobExit=true;else if(arg==L"--smoke-job")smokeJob=true;else if(arg==L"--smoke-dual-export"&&i+1<argc)smokeDualOutput=argv[++i];else if(arg==L"--smoke-seconds"&&i+1<argc)smokeSeconds=std::clamp(_wtoi(argv[++i]),1,240);else if(arg==L"--export-out"&&i+1<argc)exportOutput=argv[++i];else if(arg==L"--max-frames"&&i+1<argc)exportFrames=std::max(1,_wtoi(argv[++i]));else if(arg==L"--cancel-after-ms"&&i+1<argc)cancelAfterMs=std::clamp(_wtoi(argv[++i]),1,240000);else if(arg==L"--hevc")exportHevc=true;else if(arg==L"--smoke-rollback-flow"){smokeRollback=true;smokeRollbackFlow=true;}else if(arg==L"--smoke-rollback")smokeRollback=true;else if(arg==L"--smoke-ui")smokeUi=true;else if(arg==L"--no-fg")initialOptions.fg=false;else if(arg==L"--smoke-settings")smokeSettings=true;else if(arg==L"--smoke-screenshot")smokeScreenshot=true;else if(arg==L"--smoke-controls")smokeControls=true;else if(arg==L"--smoke-save"&&i+1<argc)smokeSave=argv[++i];else if(arg==L"--native")initialOptions.realtime=false;else if(arg==L"--realtime")initialOptions.realtime=true;else if(arg==L"--fg")initialOptions.fg=true;else if(arg==L"--fg-multiplier"&&i+1<argc){initialOptions.fgMultiplier=std::clamp(_wtoi(argv[++i]),2,4);initialOptions.fg=true;}else if(arg==L"--video-sr"&&i+1<argc){initialOptions.settings.videoSrQuality=std::clamp(_wtoi(argv[++i]),1,4);initialOptions.sr=true;}else if(arg==L"--nr-ampere")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Ampere;else if(arg==L"--nr-community")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Community;else if(arg==L"--nr-original")initialOptions.settings.nrRuntime=veyra::engine::NrRuntime::Original;else if(arg==L"--sr")initialOptions.sr=true;else if(arg==L"--no-nr")initialOptions.nr=false;else if(arg==L"--nr")initialOptions.nr=true;else if(arg==L"--no-sr")initialOptions.sr=false;else autoInput=arg;}LocalFree(argv);
if(workerMapping){const int code=veyra::engine::runExportWorker(workerMapping);CoUninitialize();return code;}
if(smokeSeconds<=0&&exportOutput.empty()){uiPreferences=preferences.load();initialOptions=veyra::engine::PlayerOptions::from(preferences.startup(initialOptions.snapshot()));engine.setVolume(uiPreferences.volume,uiPreferences.muted);uiState.subtitles=uiPreferences.subtitles;subtitlePixels=uiPreferences.subtitleSize;}
engine.requestSettings(initialOptions.snapshot());
diff --git a/apps/veyra/ui/LiveStatusPanel.h b/apps/veyra/ui/LiveStatusPanel.h
index 7295e990..25eadb21 100644
--- a/apps/veyra/ui/LiveStatusPanel.h
+++ b/apps/veyra/ui/LiveStatusPanel.h
@@ -124,7 +124,7 @@ inline LRESULT CALLBACK proc(HWND h,UINT message,WPARAM wp,LPARAM lp){
}
rows.emplace_back(L"补帧方式",s.applied.multiplier<=1?L"关闭":std::format(L"{} {}X",xess?L"XeSS":L"DLSS",s.applied.multiplier));
rows.emplace_back(L"NR内部尺寸",s.applied.nr?std::format(L"{} x {}",s.metrics.resolution.nr.width,s.metrics.resolution.nr.height):L"关闭");
- rows.emplace_back(L"NR运行版本",s.nrActive?(s.applied.nrRuntime==engine::NrRuntime::Community?L"社区兼容 · 实验":L"NVIDIA原版"):L"未运行");
+ rows.emplace_back(L"NR运行版本",s.nrActive?(s.applied.nrRuntime==engine::NrRuntime::Ampere?L"RTX 30兼容 · 实验":s.applied.nrRuntime==engine::NrRuntime::Community?L"社区兼容 · 实验":L"NVIDIA原版"):L"未运行");
rows.emplace_back(L"显示模式",s.running?(s.applied.captureCompatible?L"直播兼容 · 实验":L"标准显示"):L"未运行");
rows.emplace_back(L"音频同步",s.audioAvailable?(s.capture?(s.captureAudio.running?L"软件估算同步":L"等待视频锚点"):(s.audioEndpointRecovering?L"音频设备恢复中 · 时间线保持":s.audioRebuffering?L"重新同步 · 等待视频锚点":L"音频主时钟")):L"无音频");
if(!s.capture&&s.audioAvailable){
diff --git a/apps/veyra/ui/UiSessionState.h b/apps/veyra/ui/UiSessionState.h
index 70ba56c2..83e13434 100644
--- a/apps/veyra/ui/UiSessionState.h
+++ b/apps/veyra/ui/UiSessionState.h
@@ -4,7 +4,7 @@ namespace veyra::ui {
enum class Mode { Daily, Professional };
struct UiSessionState {
Mode mode=Mode::Daily;
- bool enhanced=true,subtitles=true,diagnostics=false,drawer=false;
+ bool enhanced=false,subtitles=true,diagnostics=false,drawer=false;
int inspector=0,preferredComparison=0;
engine::EnhancementSettings configured;
// An explicit user toggle creates a settings transaction. Mode changes do
diff --git a/docs/RTX30_NR_AND_SAFE_DEFAULTS_2026-09-14.md b/docs/RTX30_NR_AND_SAFE_DEFAULTS_2026-09-14.md
new file mode 100644
index 00000000..e44d9174
--- /dev/null
+++ b/docs/RTX30_NR_AND_SAFE_DEFAULTS_2026-09-14.md
@@ -0,0 +1,39 @@
+# RTX 30 实验 NR 与首次启动全关
+
+用户于 2026-09-14 授权实施。分支 `codex/rtx30-nr-safe-defaults`,开工前审计存档 `11977ab`。本轮仅本地实现与验证,不发布新版本。此前调研见 [运行组件审计](RTX30_NEURALSCREEN_AUDIT_2026-09-14.md)。
+
+## 实现与边界
+
+- NR 运行版本新增「RTX 30 兼容 · 实验」。原版和 RTX 40/50 社区版保留,设置枚举追加为 2,不改变已有预设含义。
+- 用户提供的 `neuralscreen-v1.8.2-full/native/nvngx_dlssnr.dll` 原样复制至忽略的 `runtime_local/nvidia/nr-ampere/`。SHA256 `DCC0DC2414AEDEC4A8E084647070383BE068554042587180C20C784D4772D36F`,165840496 bytes,310.8.0.0,签名 `HashMismatch`。未修改、重签或提交 DLL,未扩大 Release 默认运行文件白名单。
+- 兼容适配独立实现,只更换所选 NR 模块自身的 GetProcAddress 导入指针,使其架构查询进入专用包装。仅当查询成功、物理 GPU 属于实际 D3D12 adapter LUID、且为 Ampere 架构时返回兼容架构值。未知句柄、其他查询、其他 GPU 均保留原结果;系统 NVAPI 函数入口不修改。RTX20 不在支持尝试范围。
+- 与上游行为参考的区别:不使用全进程 NVAPI 函数指令补丁,不把未知句柄默认为显卡索引 0;使用原有图重建与 GPU drain 顺序,卸载时恢复导入指针。未复制上游 worker 实现。
+- 开启该选项不会解锁 DLSS FG。NR 是否成功、性能和画质需 RTX30 用户实际测试;本机只有 RTX5070。
+- 首次启动默认 NR=false、SR=false、内部 FG 倍率=1,总增强=false;底层 PlayerOptions 同步关闭。光流等参数保留默认选择,但全关状态不因这些选择自动执行增强。
+- 已保存的预设、上次确认设置继续恢复,不清除个人配置。效果全关指干净首次安装;已有配置若开启 NR,升级后不会自动替用户关闭。软件也不会修改 NVIDIA App 中的 Smooth Motion。
+- 便携包扫描新增禁止个人设置文件检查。后续发布仍需沿用脚本白名单、重新制作干净包;GitHub 现有 1.1.0 资产没有被替换。
+
+## 操作方法
+
+启动本地 `out/remoteplay/product-repair/veyra.exe`(桌面「Veyra PS5 测试版」快捷方式也指向它)。专业模式选择 NR 运行版本「RTX 30 兼容 · 实验」,再开启 NR。只选择运行版本不会自动开启效果。首次在 RTX30 上先保留实时档、关闭 SR/FG,确认 NR 单项有效后再逐项开启。
+
+本机组件已经放好。单独拷贝 EXE 到其他电脑不会附带运行组件;未来发布需独立处理新组件的来源、manifest 与分发范围。缺少该组件时应报告加载失败并恢复原管线,不能偷偷改用其他版本。
+
+## 验证记录
+
+证据目录:`logs/rtx30-defaults/`,不提交本地日志或测试图。
+
+1. `out/release-1.1.0-build.cmd`:完整增量编译通过;之后新增同进程切换测试重新构建通过。日志 `build.log`、`build-final.log`、`build-switch.log`。
+2. `veyra_repair_preset_tests.exe out/rtx30-preset-test.v1`:预设与 42 组旧后端迁移通过;新增 Ampere 预设往返、48 组架构/选中句柄/查询结果策略检查通过。
+3. `veyra_ui_contract_tests.exe out/rtx30-ui-clean-test`:通过,含首次全关、已保存参数恢复和损坏配置保护、四种 DPI 的布局测试。该测试参数应是独立新目录。
+4. `veyra_nr_ampere_tests.exe runtime_local/nvidia/nr-ampere`:真实 NVAPI 路由/选中 GPU 查询/未修改系统入口、三次安装与卸载通过。RTX5070 架构 0x1B0,因此 rewrite=false;这不是 Ampere 真机通过证据。
+5. `veyra.exe <用户4K视频> --smoke-seconds 12 --nr --nr-ampere --realtime`:本机 RTX5070 创建 NR Feature 18 成功(0x1、SEH=0),输出 162 帧,failed=false。`ampere-play.log` 包含历史追加日志,只以 2026-09-14T06:48:23Z 开始的当前会话为此次证据。最初 `--smoke-save` 未与对应截图测试开关联用,因此该次未生成截图;下项补充实际输出验证。
+6. `veyra_nr_runtime_switch_tests.exe <用户4K视频> logs/rtx30-defaults/switch`:同进程先全关播放,再 Ampere → Original → Community → Ampere → 全关,16 项断言通过。四次真实 Feature 18 Create 均 0x1/SEH0,各次确认当前 revision 已生效且有实际 NR Evaluate;保存四张 3840×2160 PNG(文件有效、RGB 标准差非零)。该检查证明输出和切换,不是画质优劣评判。两次 Ampere 卸载均 restore=true,系统架构未伪装。
+
+7. `powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/gates/delivery.ps1 -Root <项目根> -BuildDirectory <项目根>/out/remoteplay/product-repair`:23/23 通过,47.26 秒。证据 `logs/delivery/e4d638da6ada4df58e208c1545a35171/result.json`。覆盖真实 NR/NVOF、原生4K、播放/暂停seek、JPEG、H.264/HEVC NVENC带音轨导出与取消。统一门禁显式增加 `--nr`,防止首次默认全关后把原 NR 回归变成旁路测试。
+
+已构建本地 EXE SHA256:`7E3A86371544D27173195E9D6E9071B467CB6261F2E1370D2FF3AC1E69F785B5`。原有桌面 PS5 测试快捷方式直接指向此文件,不需要再次替换。旧 `Veyra.cmd` 引用的 `out/build/x64-release` 已不存在,本轮不将旧启动脚本冒充有效入口。源码扫描没有受版本控制的 DLL/LIB/PDB/EXE/ONNX;复制前后新 NR 文件哈希一致,仍为 HashMismatch。
+
+## 待验证
+
+唯一下一步是 RTX30 实卡验收:确认 NR Create/Evaluate、输入输出画面、耗时与显存、持续播放以及切回其他运行版本。未执行 RTX30/RTX40 真机、新版本 PS5/采集实卡、长时间压力或驱动补帧叠加测试。不宣称 30 系全型号可用、性能充足或画质与官方 DLSS 等价。
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 92a0091c..540d09b1 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -1935,4 +1935,14 @@ GitHub Release https://github.com/Likely7/Veyra-NRVideo/releases/tag/v1.0.0 于
## 2026-09-14 — 用户提供 NeuralScreen 1.8.2 的 RTX30 调研
-仅静态读取用户包、Get-FileHash/Authenticode/VersionInfo、dumpbin exports 和包内固定提交的 worker 源码。确认 DLL 为 DCC0DC24…/165840496 bytes/310.8.0.0/HashMismatch,与包清单一致但不同于已批准两版;五项 NGX 入口存在。架构查询进程 hook 是额外兼容条件,发现索引0/未知句柄回退、无恢复生命周期等不适合直接照搬的边界。详见 docs/RTX30_NEURALSCREEN_AUDIT_2026-09-14.md。未启动第三方程序、未加载/复制/修改 DLL、未执行 Create/Evaluate、未构建;没有 RTX30 实机验收。git diff --check 通过。未提交、未推送、未发布。下一步如授权实施,先隔离验证 NR 适配器与可恢复的老架构兼容。
+仅静态读取用户包、Get-FileHash/Authenticode/VersionInfo、dumpbin exports 和包内固定提交的 worker 源码。确认 DLL 为 DCC0DC24…/165840496 bytes/310.8.0.0/HashMismatch,与包清单一致但不同于已批准两版;五项 NGX 入口存在。架构查询进程 hook 是额外兼容条件,发现索引0/未知句柄回退、无恢复生命周期等不适合直接照搬的边界。详见 docs/RTX30_NEURALSCREEN_AUDIT_2026-09-14.md。未启动第三方程序、未加载/复制/修改 DLL、未执行 Create/Evaluate、未构建;没有 RTX30 实机验收。git diff --check 通过。当时未提交、未推送、未发布;后续开工前提交为11977ab。
+
+## 2026-09-14 — RTX30 NR 实验选项与首次默认全关
+
+- 用户授权后在 codex/rtx30-nr-safe-defaults 施工。NR选择器追加RTX30独立档,复用现有处理图和重建事务。独立编写仅NR模块作用域的架构查询适配,按D3D12 LUID匹配显卡;只兼容成功查询的选中Ampere,未知句柄不猜索引0;恢复IAT再卸载,不改系统驱动入口或磁盘DLL。
+- 用户指定DCC0DC24…组件原样置于忽略目录 runtime_local/nvidia/nr-ampere/,哈希与原件一致、HashMismatch不伪装为原版。未扩大Release资产白名单,未把组件/SDK/配置加入Git。THIRD_PARTY_NOTICES追加一行NeuralScreen行为参考归因。
+- EnhancementSettings/PlayerOptions/UiSessionState及启动UI统一首次NR/SR/FG全关;保留已有预设/上次确认设置。便携扫描禁止个人配置,统一delivery显式传--nr,避免默认改变后漏测NR。
+- 实际执行out/release-1.1.0-build.cmd构建通过;预设回归(含42迁移及48架构策略组合)、UI合同(首次全关/已有参数恢复/布局)、真实NVAPI三次装卸通过。命令与日志见docs/RTX30_NR_AND_SAFE_DEFAULTS_2026-09-14.md。
+- 本机RTX5070加载实验组件:Feature18 Create=0x1、SEH=0;12秒软件smoke输出162帧且NR Evaluate162次、NVOF161次、failed=false。新增共享Engine同进程切换测试16项通过:全关→Ampere→Original→Community→Ampere→全关,四张实际3840×2160 PNG有效;两次兼容卸载restore=true。未执行RTX30真机,5070查询无需架构改写,不能据此声称30系成功。
+- delivery23/23,47.26秒,logs/delivery/e4d638da6ada4df58e208c1545a35171/result.json。播放、暂停seek、截图、原生4K、带音轨NVENC H264/HEVC及取消通过。最初单独--smoke-save未生成截图,之后同进程测试保存实际PNG补齐输出验证;历史追加日志已按本次时间划界。
+- 本地out/remoteplay/product-repair/veyra.exe(现有桌面PS5测试快捷方式目标)SHA256 7E3A86371544D27173195E9D6E9071B467CB6261F2E1370D2FF3AC1E69F785B5。未改GitHub下载包、未push/发布;下一步RTX30持卡用户验收NR单项、耗时、显存与切换。没有PS5/采集实卡、长时或Smooth Motion叠加的新验收。
diff --git a/include/veyra/engine/EngineController.h b/include/veyra/engine/EngineController.h
index d986aa99..2514df62 100644
--- a/include/veyra/engine/EngineController.h
+++ b/include/veyra/engine/EngineController.h
@@ -17,7 +17,7 @@ namespace veyra::sink { struct RgbaImage; }
namespace veyra::gfx { class D3D12DeviceContext; class CommandSlotRing; }
namespace veyra::engine {
class FrameFlowWindow;
-struct PlayerOptions { bool nr=true,sr=false,fg=false,realtime=true; uint32_t fgMultiplier=2; EnhancementSettings settings;
+struct PlayerOptions { bool nr=false,sr=false,fg=false,realtime=true; uint32_t fgMultiplier=2; EnhancementSettings settings;
bool captureReplayForTest=false; // file-backed live scheduler test; never enabled by UI
bool captureReplayDisableFgAdmissionForTest=false; // controlled scheduler A/B only
EnhancementSettings snapshot()const{auto s=settings;s.nr=nr;s.sr=sr;s.multiplier=fg?fgMultiplier:1;s.nrPolicy=realtime?pipeline::NrSizePolicy::Realtime:pipeline::NrSizePolicy::Native;return s;}
diff --git a/include/veyra/engine/EnhancementSettings.h b/include/veyra/engine/EnhancementSettings.h
index 91801d2a..938ed62f 100644
--- a/include/veyra/engine/EnhancementSettings.h
+++ b/include/veyra/engine/EnhancementSettings.h
@@ -7,11 +7,12 @@
#include "veyra/pipeline/ResolutionPlan.h"
namespace veyra::engine {
enum class FrameGenerationBackend { Dlss, XeSS };
-enum class NrRuntime { Original, Community };
+enum class NrRuntime { Original, Community, Ampere };
constexpr std::string_view nrRuntimeName(NrRuntime runtime) {
switch(runtime) {
case NrRuntime::Original:return "NVIDIA-original";
case NrRuntime::Community:return "community-RTX40-RTX50";
+ case NrRuntime::Ampere:return "community-RTX30-experimental";
}
return "unknown";
}
@@ -65,7 +66,7 @@ struct EnhancementSettings {
NrSettings model;
ResidualSettings residual;
ProtectionSettings protection;
- bool nr=true,sr=false;
+ bool nr=false,sr=false;
bool lowLatency=false; // preview only: NR before SR, opt-in
NrRuntime nrRuntime=NrRuntime::Original;
bool captureCompatible=false;
@@ -100,7 +101,7 @@ struct EnhancementSettings {
auto range=[](float v,float hi){return std::isfinite(v)&&v>=0&&v<=hi;};
if(auto error=protection.validate();!error.empty())return error;
if(!revision)return "settingsRevision must be nonzero";
- if(nrRuntime!=NrRuntime::Original&&nrRuntime!=NrRuntime::Community)return "invalid NR runtime";
+ if(nrRuntime!=NrRuntime::Original&&nrRuntime!=NrRuntime::Community&&nrRuntime!=NrRuntime::Ampere)return "invalid NR runtime";
if(audioSync<AudioSyncMode::Automatic||audioSync>AudioSyncMode::Off||audioOffsetMs<-250||audioOffsetMs>250)return "invalid audio sync setting";
if(!range(model.intensity,1)||!range(model.tone,1)||!range(model.structure,1))return "model parameter out of range";
if(model.skin!=-1&&!range(model.skin,2))return "skin parameter out of range";
diff --git a/include/veyra/ngx/DlssNrRuntimeAdapter.h b/include/veyra/ngx/DlssNrRuntimeAdapter.h
index 17dd4c7c..49d29f7d 100644
--- a/include/veyra/ngx/DlssNrRuntimeAdapter.h
+++ b/include/veyra/ngx/DlssNrRuntimeAdapter.h
@@ -66,6 +66,10 @@ public:
// slot (Playbook 8.3). Exactly one adapter session may own the slot.
// P1.3 implements install/restore; load() alone never touches the IAT.
bool installCallerCompatibility(Status& status);
+ // Opt-in RTX30 route. Intercepts only this NR module's NVAPI lookup;
+ // the driver entry point and other NGX consumers remain untouched.
+ bool installAmpereCompatibility(ID3D12Device* device, Status& status);
+ bool verifyAmpereCompatibilityForTest();
void restoreCallerCompatibility();
bool callerCompatibilityInstalled() const { return shimInstalled_; }
@@ -106,6 +110,8 @@ private:
bool shimInstalled_ = false;
void** iatSlot_ = nullptr;
void* originalGetModuleFileNameW_ = nullptr;
+ void** archLookupSlot_ = nullptr;
+ void* originalGetProcAddress_ = nullptr;
};
} // namespace veyra::ngx
diff --git a/include/veyra/ngx/NrArchitecturePolicy.h b/include/veyra/ngx/NrArchitecturePolicy.h
new file mode 100644
index 00000000..b3951500
--- /dev/null
+++ b/include/veyra/ngx/NrArchitecturePolicy.h
@@ -0,0 +1,11 @@
+#pragma once
+#include <cstdint>
+namespace veyra::ngx {
+// The experimental profile only changes a successful query for the exact
+// selected Ampere adapter. Other GPUs and driver failures retain their result.
+constexpr bool rewriteNrAmpereArchitecture(uint32_t& architecture, bool selected, int result) {
+ if(result!=0||!selected||(architecture&0xFFFFFFF0u)!=0x170u)return false;
+ architecture=0x1B0u;
+ return true;
+}
+}
diff --git a/scripts/gates/delivery.ps1 b/scripts/gates/delivery.ps1
index ecfc51c3..1ef0b754 100644
--- a/scripts/gates/delivery.ps1
+++ b/scripts/gates/delivery.ps1
@@ -46,20 +46,20 @@ try{
Run quality4k "$bin/veyra_quality_probe.exe" @('--input',$clip4k,'--native','--guidance','motion','--frames','12','--json-file',"$dir/quality4k.json",'--dump',"$dir/enhanced4k.png")
$q4=Get-Content "$dir/quality4k.json" -Raw|ConvertFrom-Json
Check native4k ($q4.failures -eq 0 -and $q4.sourceExtent.width -eq 3840 -and $q4.workingExtent.width -eq 3840 -and $q4.nrEvaluateCount -eq 12) 'native4K correctness only; not a realtime60 claim'
- Run player $PlayerExe @($clip4k,'--realtime','--fg','--smoke-seconds','6') 20
+ Run player $PlayerExe @($clip4k,'--nr','--realtime','--fg','--smoke-seconds','6') 20
$log=Get-Content "$dir/player.stdout.log" -Raw
Check player-sync ($log -match 'smoke frames=(\d+).*generated=(\d+).*failed=false.*absLatenessP95Ms=([\d.]+)' -and [int]$Matches[1] -gt 60 -and [int]$Matches[2] -gt 0 -and [double]$Matches[3] -le 50) 'real-time profile 4K ingress, generated frames, observed abs lateness P95 <=50ms'
- Run controls $PlayerExe @($clip1080,'--realtime','--smoke-seconds','6','--smoke-controls','--smoke-save',"$dir/snapshot.jpg") 20
+ Run controls $PlayerExe @($clip1080,'--nr','--realtime','--smoke-seconds','6','--smoke-controls','--smoke-save',"$dir/snapshot.jpg") 20
$controlLog=Get-Content "$dir/controls.stdout.log" -Raw
Check paused-seek ($controlLog -match 'seek done' -and $controlLog -match 'controlsStep=4' -and (Test-Path "$dir/snapshot.jpg")) 'pause / seek while paused / resume / real WIC JPEG'
- Run image $PlayerExe @("$dir/enhanced.png",'--smoke-seconds','3') 15
- Run image4k $PlayerExe @("$dir/enhanced4k.png",'--realtime','--smoke-seconds','6','--smoke-controls','--smoke-save',"$dir/image4k.jpg") 15
+ Run image $PlayerExe @("$dir/enhanced.png",'--nr','--smoke-seconds','3') 15
+ Run image4k $PlayerExe @("$dir/enhanced4k.png",'--nr','--realtime','--smoke-seconds','6','--smoke-controls','--smoke-save',"$dir/image4k.jpg") 15
Run inspect-image4k $ffprobe @('-v','error','-show_streams','-of','json',"$dir/image4k.jpg") 10
$img=(Get-Content "$dir/inspect-image4k.stdout.log" -Raw|ConvertFrom-Json).streams[0]
Check native4k-image ($img.width -eq 3840 -and $img.height -eq 2160) 'realtime default must not shrink image export'
foreach($codec in @('h264','hevc')){
$file="$dir/$codec.mp4"
- $a=@($clip4k,'--export-out',$file,'--max-frames','12','--fg');if($codec -eq 'hevc'){$a+='--hevc'}
+ $a=@($clip4k,'--nr','--export-out',$file,'--max-frames','12','--fg');if($codec -eq 'hevc'){$a+='--hevc'}
Run "export-$codec" $PlayerExe $a 30
Run "inspect-$codec" $ffprobe @('-v','error','-count_frames','-show_streams','-of','json',$file) 10
$streams=(Get-Content "$dir/inspect-$codec.stdout.log" -Raw|ConvertFrom-Json).streams
@@ -71,7 +71,7 @@ try{
Check "frame-kinds-$codec" ($exportLog -match 'export-counts\] source=12 generated=11 hold=1 output=24 multiplier=2') '12 real + 11 generated + 1 declared CFR tail hold; never count hold as DLSSG'
Check "decode-$codec" ($v.width -eq 3840 -and $v.height -eq 2160 -and $v.codec_name -eq $codec -and [int]$v.nb_read_frames -eq 24 -and $v.avg_frame_rate -eq '120/1' -and [math]::Abs([double]$v.duration-0.2) -lt 0.00001 -and $a.Count -ge 1) 'all short frames decoded; native4K 2X CFR frame count, duration, rate and audio'
}
- Run cancel $PlayerExe @($clip4k,'--export-out',"$dir/cancel.mp4",'--cancel-after-ms','3000') 15 3
+ Run cancel $PlayerExe @($clip4k,'--nr','--export-out',"$dir/cancel.mp4",'--cancel-after-ms','3000') 15 3
Check cancel-not-success ((-not (Test-Path "$dir/cancel.mp4")) -and (Test-Path "$dir/cancel.mp4.partial")) 'cancel drains with live callback; never promotes incomplete output'
Check test-budget ($timer.Elapsed.TotalSeconds -lt 300) "$($timer.Elapsed.TotalSeconds)s; short validation is not endurance proof"
$result=[ordered]@{runId=$run;status='software_short_gate_passed';capture='awaiting_user_capture_test';distribution='not_assessed_by_software_gate';seconds=$timer.Elapsed.TotalSeconds;exeHash=(Get-FileHash $PlayerExe -Algorithm SHA256).Hash;checks=$checks}
diff --git a/scripts/package-portable.ps1 b/scripts/package-portable.ps1
index f39033f5..63a89101 100644
--- a/scripts/package-portable.ps1
+++ b/scripts/package-portable.ps1
@@ -108,7 +108,7 @@ $payload = @(Get-ChildItem -LiteralPath $stage -Recurse -File)
$forbidden = '\.(pdb|lib|obj|h|hpp|cpp|c|zip|pth|onnx|log|mp4|partial|addon64)$'
foreach ($file in $payload) {
$relative = $file.FullName.Substring($stage.Length+1).Replace('\','/')
- if ($relative -notin $allowed -or $relative -match $forbidden -or $relative -match '(^|/)(third_party_local|logs|captures|\.git)/') { throw "Unexpected payload: $relative" }
+ if ($relative -notin $allowed -or $relative -match $forbidden -or $relative -match '(^|/)(third_party_local|logs|captures|\.git)/' -or $relative -match '(^|/)(last-applied\.v1|ui-preferences\.v1|presets\.v1|veyra\.ini)$') { throw "Unexpected payload: $relative" }
}
$fileManifest = @($payload | ForEach-Object {[ordered]@{path=$_.FullName.Substring($stage.Length+1).Replace('\','/');size=$_.Length;sha256=(Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash}})
[ordered]@{schema=1;version=$Version;files=$fileManifest} | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath (Join-Path $stage 'package-manifest.json') -Encoding UTF8
diff --git a/src/ngx/DlssNrRuntimeAdapter.cpp b/src/ngx/DlssNrRuntimeAdapter.cpp
index de25eceb..13a04fec 100644
--- a/src/ngx/DlssNrRuntimeAdapter.cpp
+++ b/src/ngx/DlssNrRuntimeAdapter.cpp
@@ -3,9 +3,12 @@
#include <windows.h>
#include <format>
+#include <atomic>
+#include <cstring>
#include "veyra/Log.h"
#include "veyra/NgxResult.h"
+#include "veyra/ngx/NrArchitecturePolicy.h"
namespace veyra::ngx {
@@ -125,6 +128,80 @@ void** FindImportedFunctionSlot(HMODULE module, const char* functionName)
return nullptr;
}
+// Independently implemented against the NVAPI public query ABI. This is scoped
+// to the selected NR DLL's import table, not a patch to the process-wide driver.
+// All state is immutable between installation and the drained NR teardown.
+using QueryNvApi = void* (__cdecl*)(unsigned);
+struct NvArchInfo { unsigned version, architecture, implementation, revision; };
+using GetNvArch = int (__cdecl*)(void*, NvArchInfo*);
+struct LogicalGpuData {
+ unsigned version;
+ void* osAdapterId;
+ unsigned physicalGpuCount;
+ void* physicalGpuHandles[64];
+ unsigned reserved[8];
+};
+struct AmpereContext {
+ HMODULE nvapi = nullptr;
+ QueryNvApi query = nullptr;
+ GetNvArch getArch = nullptr;
+ decltype(&GetProcAddress) getProc = nullptr;
+ void* selected[64]{};
+ unsigned count = 0;
+ std::atomic_uint64_t lookups{0}, queries{0}, rewrites{0};
+};
+AmpereContext g_ampere;
+constexpr unsigned kArchQuery = 0xD8265D24u;
+
+int __cdecl AmpereGetArch(void* gpu, NvArchInfo* info)
+{
+ g_ampere.queries.fetch_add(1, std::memory_order_relaxed);
+ const int result = g_ampere.getArch(gpu, info);
+ if(result != 0 || !info) return result;
+ // Unknown handles are never treated as the selected adapter.
+ bool selected=false;
+ for(unsigned i=0;i<g_ampere.count;++i)selected|=gpu==g_ampere.selected[i];
+ if(rewriteNrAmpereArchitecture(info->architecture,selected,result)) {
+ g_ampere.rewrites.fetch_add(1, std::memory_order_relaxed);
+ }
+ return result;
+}
+void* __cdecl AmpereQuery(unsigned id)
+{
+ if(id==kArchQuery)return reinterpret_cast<void*>(&AmpereGetArch);
+ return g_ampere.query(id);
+}
+FARPROC WINAPI AmpereGetProc(HMODULE module, LPCSTR name)
+{
+ // GetProcAddress also accepts integer ordinals.
+ if(module==g_ampere.nvapi && reinterpret_cast<uintptr_t>(name)>0xFFFF &&
+ std::strcmp(name,"nvapi_QueryInterface")==0) {
+ g_ampere.lookups.fetch_add(1, std::memory_order_relaxed);
+ return reinterpret_cast<FARPROC>(&AmpereQuery);
+ }
+ return g_ampere.getProc(module,name);
+}
+
+bool ExchangeImport(void** slot, void* replacement, void*& previous)
+{
+ DWORD old=0;
+ if(!VirtualProtect(slot,sizeof(void*),PAGE_READWRITE,&old))return false;
+ previous=InterlockedExchangePointer(slot,replacement);
+ DWORD ignored=0;
+ if(VirtualProtect(slot,sizeof(void*),old,&ignored))return true;
+ // The page is still writable. Roll back before reporting failure.
+ InterlockedExchangePointer(slot,previous);
+ VirtualProtect(slot,sizeof(void*),old,&ignored);
+ return false;
+}
+
+void ClearAmpereContext()
+{
+ if(g_ampere.nvapi)FreeLibrary(g_ampere.nvapi);
+ g_ampere.nvapi=nullptr;g_ampere.query=nullptr;g_ampere.getArch=nullptr;
+ g_ampere.getProc=nullptr;g_ampere.count=0;
+}
+
} // namespace
DWORD WINAPI DlssNrRuntimeAdapter::testShimGetModuleFileNameW(HMODULE module, LPWSTR filename, DWORD size)
@@ -332,7 +409,7 @@ bool DlssNrRuntimeAdapter::load(const std::wstring& runtimeDir, Status& status)
// Development staging and the explicitly named experimental Release pack.
const auto allowed=[&](const wchar_t* suffix){const size_t n=wcslen(suffix);return dllPath_.size()>n&&_wcsicmp(dllPath_.c_str()+dllPath_.size()-n,suffix)==0;};
- if (!allowed(L"\\runtime_local\\nvidia\\nvngx_dlssnr.dll")&&!allowed(L"\\runtime\\experimental\\nvngx_dlssnr.dll")&&!allowed(L"\\runtime_local\\nvidia\\nr-community\\nvngx_dlssnr.dll")&&!allowed(L"\\runtime\\experimental\\nr-community\\nvngx_dlssnr.dll")) {
+ if (!allowed(L"\\runtime_local\\nvidia\\nvngx_dlssnr.dll")&&!allowed(L"\\runtime\\experimental\\nvngx_dlssnr.dll")&&!allowed(L"\\runtime_local\\nvidia\\nr-community\\nvngx_dlssnr.dll")&&!allowed(L"\\runtime\\experimental\\nr-community\\nvngx_dlssnr.dll")&&!allowed(L"\\runtime_local\\nvidia\\nr-ampere\\nvngx_dlssnr.dll")&&!allowed(L"\\runtime\\experimental\\nr-ampere\\nvngx_dlssnr.dll")) {
status = Status::InvalidArgument;
veyra::log::error("ngx", "nr-adapter: resolved runtime path is outside approved staging/experimental directory; refusing to load");
return false;
@@ -470,8 +547,82 @@ void DlssNrRuntimeAdapter::restoreCallerCompatibility()
shimInstalled_ = false;
}
+bool DlssNrRuntimeAdapter::installAmpereCompatibility(ID3D12Device* device, Status& status)
+{
+ if(!module_||!shimInstalled_||!device||archLookupSlot_||g_ampere.nvapi){status=Status::InvalidArgument;return false;}
+ auto fail=[&](const char* reason){veyra::log::error("nr-ampere",reason);ClearAmpereContext();status=Status::DeviceFailure;return false;};
+ wchar_t system[MAX_PATH]{};
+ if(!GetSystemDirectoryW(system,MAX_PATH))return fail("system directory lookup failed");
+ const std::wstring path=std::wstring(system)+L"\\nvapi64.dll";
+ g_ampere.nvapi=LoadLibraryExW(path.c_str(),nullptr,LOAD_LIBRARY_SEARCH_SYSTEM32);
+ if(!g_ampere.nvapi)return fail("system NVAPI unavailable");
+ g_ampere.query=reinterpret_cast<QueryNvApi>(GetProcAddress(g_ampere.nvapi,"nvapi_QueryInterface"));
+ if(!g_ampere.query)return fail("NVAPI query entry missing");
+ const auto init=reinterpret_cast<int(__cdecl*)()>(g_ampere.query(0x0150E828u));
+ const auto enumerate=reinterpret_cast<int(__cdecl*)(void**,unsigned*)>(g_ampere.query(0x48B3EA59u));
+ const auto getLogical=reinterpret_cast<int(__cdecl*)(void*,LogicalGpuData*)>(g_ampere.query(0x842B066Eu));
+ g_ampere.getArch=reinterpret_cast<GetNvArch>(g_ampere.query(kArchQuery));
+ if(!init||!enumerate||!getLogical||!g_ampere.getArch)return fail("required NVAPI adapter/architecture query missing");
+ const int initResult=init();
+ if(initResult!=0){veyra::log::error("nr-ampere",std::format("NvAPI_Initialize={}",initResult));return fail("NVAPI initialization failed");}
+ void* logical[64]{};unsigned count=0;
+ const int enumResult=enumerate(logical,&count);
+ if(enumResult!=0||count>64){veyra::log::error("nr-ampere",std::format("EnumLogicalGPUs={} count={}",enumResult,count));return fail("GPU enumeration failed");}
+ const LUID target=device->GetAdapterLuid();
+ for(unsigned i=0;i<count;++i){
+ LUID luid{};LogicalGpuData data{};data.version=sizeof(data)|(1u<<16);data.osAdapterId=&luid;
+ const int result=getLogical(logical[i],&data);
+ if(result!=0){veyra::log::warn("nr-ampere",std::format("GetLogicalGpuInfo={}",result));continue;}
+ if(luid.LowPart!=target.LowPart||luid.HighPart!=target.HighPart)continue;
+ if(data.physicalGpuCount==0||data.physicalGpuCount>64)return fail("invalid selected physical GPU count");
+ g_ampere.count=data.physicalGpuCount;
+ for(unsigned j=0;j<data.physicalGpuCount;++j){
+ g_ampere.selected[j]=data.physicalGpuHandles[j];
+ NvArchInfo arch{sizeof(NvArchInfo)|(1u<<16),0,0,0};
+ const int resultArch=g_ampere.getArch(g_ampere.selected[j],&arch);
+ veyra::log::info("nr-ampere",std::format("selected LUID={:X}:{:X} archResult={} architecture=0x{:X} rewrite={}",target.HighPart,target.LowPart,resultArch,arch.architecture,(arch.architecture&0xFFFFFFF0u)==0x170u));
+ if(resultArch!=0)return fail("selected adapter architecture unavailable");
+ const unsigned family=arch.architecture&0xFFFFFFF0u;
+ if(family!=0x170u&&family!=0x190u&&family<0x1A0u)return fail("this experimental route requires RTX30 or newer; RTX20 is unverified");
+ }
+ break;
+ }
+ if(!g_ampere.count)return fail("cannot match NVAPI adapter to selected D3D12 LUID");
+ auto slot=FindImportedFunctionSlot(module_,"GetProcAddress");
+ if(!slot)return fail("NR GetProcAddress import missing; refusing wider driver hooks");
+ g_ampere.getProc=reinterpret_cast<decltype(&GetProcAddress)>(*slot);
+ g_ampere.lookups=0;g_ampere.queries=0;g_ampere.rewrites=0;
+ if(!ExchangeImport(slot,reinterpret_cast<void*>(&AmpereGetProc),originalGetProcAddress_))return fail("NR import install failed and rolled back");
+ archLookupSlot_=slot;
+ veyra::log::info("nr-ampere","scoped NR NVAPI lookup installed; system entry point unchanged");
+ return true;
+}
+
+bool DlssNrRuntimeAdapter::verifyAmpereCompatibilityForTest()
+{
+ if(!archLookupSlot_)return false;
+ auto lookup=reinterpret_cast<decltype(&GetProcAddress)>(*archLookupSlot_);
+ auto query=reinterpret_cast<QueryNvApi>(lookup(g_ampere.nvapi,"nvapi_QueryInterface"));
+ auto arch=reinterpret_cast<GetNvArch>(query(kArchQuery));
+ if(arch==g_ampere.getArch||query(0x0150E828u)!=g_ampere.query(0x0150E828u))return false;
+ for(unsigned i=0;i<g_ampere.count;++i){
+ NvArchInfo original{sizeof(NvArchInfo)|(1u<<16),0,0,0},scoped=original;
+ if(g_ampere.getArch(g_ampere.selected[i],&original)!=0||arch(g_ampere.selected[i],&scoped)!=0)return false;
+ auto expected=original;if((expected.architecture&0xFFFFFFF0u)==0x170u)expected.architecture=0x1B0u;
+ if(std::memcmp(&expected,&scoped,sizeof(expected))!=0)return false;
+ }
+ return reinterpret_cast<GetNvArch>(g_ampere.query(kArchQuery))==g_ampere.getArch;
+}
+
void DlssNrRuntimeAdapter::unload()
{
+ const bool hadAmpere=archLookupSlot_!=nullptr;
+ if(hadAmpere){
+ void* previous=nullptr;
+ const bool restored=ExchangeImport(archLookupSlot_,originalGetProcAddress_,previous);
+ veyra::log::info("nr-ampere",std::format("restore={} lookups={} queries={} rewrites={}",restored,g_ampere.lookups.load(),g_ampere.queries.load(),g_ampere.rewrites.load()));
+ archLookupSlot_=nullptr;originalGetProcAddress_=nullptr;
+ }
if (shimInstalled_) {
restoreCallerCompatibility();
}
@@ -481,6 +632,7 @@ void DlssNrRuntimeAdapter::unload()
module_ = nullptr;
veyra::log::info("ngx", "nr-adapter: snippet module freed");
}
+ if(hadAmpere)ClearAmpereContext();
exports_ = Exports{};
}
diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cpp
index 8552a791..b82a59bc 100644
--- a/src/pipeline/EnhanceGraph.cpp
+++ b/src/pipeline/EnhanceGraph.cpp
@@ -390,12 +390,14 @@ bool EnhanceGraph::initNgxFeatures()
}
if(nrEnabled_){
- if(desc_.nrRuntime!=engine::NrRuntime::Original&&desc_.nrRuntime!=engine::NrRuntime::Community)return false;
+ if(desc_.nrRuntime!=engine::NrRuntime::Original&&desc_.nrRuntime!=engine::NrRuntime::Community&&desc_.nrRuntime!=engine::NrRuntime::Ampere)return false;
auto nrDirectory=std::filesystem::path(desc_.runtimeAbsPath);if(desc_.nrRuntime==engine::NrRuntime::Community)nrDirectory/=L"nr-community";
+ if(desc_.nrRuntime==engine::NrRuntime::Ampere)nrDirectory/=L"nr-ampere";
veyra::log::info("nr-runtime",std::format("selected={} path={}",engine::nrRuntimeName(desc_.nrRuntime),nrDirectory.string()));
nrAdapter_ = std::make_unique<ngx::DlssNrRuntimeAdapter>();
if (!nrAdapter_->load(nrDirectory.wstring(), st) ||
!nrAdapter_->installCallerCompatibility(st) ||
+ (desc_.nrRuntime==engine::NrRuntime::Ampere && !nrAdapter_->installAmpereCompatibility(context_.device(), st)) ||
!nrAdapter_->snippetInitExt(context_.device(), nrDirectory.c_str(), nrResult_, nrSeh_) ||
nrResult_ != static_cast<uint64_t>(NVSDK_NGX_Result_Success)) {
veyra::log::error("graph", std::format("NR snippet init failed 0x{:X}", nrResult_));
diff --git a/tests/integration/NrAmpereTests.cpp b/tests/integration/NrAmpereTests.cpp
new file mode 100644
index 00000000..5a2cd520
--- /dev/null
+++ b/tests/integration/NrAmpereTests.cpp
@@ -0,0 +1,22 @@
+#include "veyra/ngx/DlssNrRuntimeAdapter.h"
+#include "veyra/gfx/D3D12DeviceContext.h"
+#include <iostream>
+
+// Exercise the actual scoped IAT installation and teardown on the local GPU.
+// Passing on Blackwell proves routing/lifetime, not execution on Ampere.
+int wmain(int argc,wchar_t** argv) {
+ if(argc!=2)return 2;
+ veyra::Status status{};
+ veyra::gfx::D3D12DeviceContext device;
+ veyra::gfx::DeviceContextDesc desc;desc.requiredVendorId=0x10DE;
+ if(!device.initialize(desc,status))return 1;
+ for(int cycle=0;cycle<3;++cycle){
+ veyra::ngx::DlssNrRuntimeAdapter nr;
+ if(!nr.load(argv[1],status)||!nr.installCallerCompatibility(status)||
+ !nr.installAmpereCompatibility(device.device(),status)||!nr.verifyAmpereCompatibilityForTest())return 1;
+ if(nr.installAmpereCompatibility(device.device(),status))return 1;
+ nr.unload();nr.unload();
+ }
+ std::cout<<"PASS scoped NVAPI routing, real selected adapter query, unchanged system entry and three reinstall cycles; RTX30 Evaluate NOT TESTED\n";
+ return 0;
+}
diff --git a/tests/integration/NrRuntimeSwitchTests.cpp b/tests/integration/NrRuntimeSwitchTests.cpp
new file mode 100644
index 00000000..d510a33a
--- /dev/null
+++ b/tests/integration/NrRuntimeSwitchTests.cpp
@@ -0,0 +1,56 @@
+#include "veyra/engine/EngineController.h"
+#include "veyra/Log.h"
+#include <chrono>
+#include <filesystem>
+#include <iostream>
+using namespace std::chrono_literals;
+int wmain(int argc,wchar_t** argv) {
+ if(argc!=3)return 2;
+ CoInitializeEx(nullptr,COINIT_MULTITHREADED);
+ const std::filesystem::path output=argv[2];
+ std::filesystem::create_directories(output);
+ veyra::Logger::instance().openFile((output/L"engine.log").wstring());
+ veyra::Logger::instance().setConsoleEnabled(false);
+ HWND window=CreateWindowExW(0,L"STATIC",L"NR runtime switching test",WS_POPUP,0,0,960,540,nullptr,nullptr,GetModuleHandleW(nullptr),nullptr);
+ if(!window)return 3;
+ int failures=0;
+ {
+ veyra::engine::EngineController engine;
+ engine.setVolume(0,true);
+ auto wait=[&](auto predicate,int seconds=15) {
+ const auto end=std::chrono::steady_clock::now()+std::chrono::seconds(seconds);
+ while(std::chrono::steady_clock::now()<end) {
+ MSG msg;while(PeekMessageW(&msg,nullptr,0,0,PM_REMOVE)){TranslateMessage(&msg);DispatchMessageW(&msg);}
+ auto s=engine.snapshot();if(s.failed)return false;
+ if(predicate(s))return true;
+ std::this_thread::sleep_for(10ms);
+ }
+ return false;
+ };
+ auto check=[&](bool ok,const char* text){std::cout<<(ok?"PASS ":"FAIL ")<<text<<std::endl;failures+=!ok;return ok;};
+ engine.open(window,argv[1],{});
+ check(wait([](const auto& s){return s.frames>30&&!s.nrActive&&!s.srActive&&!s.fgActive&&s.nrEvaluated==0&&s.generated==0;}),"fresh defaults play without enhancement");
+ int cycle=0;
+ for(const auto runtime:{veyra::engine::NrRuntime::Ampere,veyra::engine::NrRuntime::Original,veyra::engine::NrRuntime::Community,veyra::engine::NrRuntime::Ampere}) {
+ if(failures)break;
+ auto settings=engine.snapshot().desired;settings.nr=true;settings.nrRuntime=runtime;
+ if(!check(engine.requestSettings(settings),"request runtime switch"))break;
+ const auto revision=engine.snapshot().desired.revision;
+ if(!check(wait([&](const auto& s){return !s.applying&&s.applied.revision==revision&&s.applied.nrRuntime==runtime&&s.nrActive&&s.nrEvaluated>10;},25),"selected runtime produces NR output"))break;
+ const auto path=output/(L"runtime-"+std::to_wstring(cycle++)+L".png");
+ engine.saveFrame(path.wstring());
+ check(wait([&](const auto&){return std::filesystem::exists(path)&&std::filesystem::file_size(path)>1024;}),"actual processed output saved");
+ }
+ if(!failures) {
+ auto settings=engine.snapshot().desired;settings.nr=false;settings.sr=false;settings.multiplier=1;
+ check(engine.requestSettings(settings),"disable all enhancements after switching");
+ const auto revision=engine.snapshot().desired.revision;
+ check(wait([&](const auto& s){return !s.applying&&s.applied.revision==revision&&!s.nrActive&&!s.srActive&&!s.fgActive;}),"plain playback restored in same process");
+ }
+ engine.stop();
+ check(wait([&](const auto&){return engine.idle();}),"GPU drained and engine stopped");
+ }
+ DestroyWindow(window);CoUninitialize();
+ std::cout<<"RTX30 hardware performance and visual quality NOT TESTED\n";
+ return failures?1:0;
+}
diff --git a/tests/unit/RepairPresetTests.cpp b/tests/unit/RepairPresetTests.cpp
index d4dd4ec6..26f29b32 100644
--- a/tests/unit/RepairPresetTests.cpp
+++ b/tests/unit/RepairPresetTests.cpp
@@ -1,4 +1,5 @@
#include "veyra/engine/PresetStore.h"
+#include "veyra/ngx/NrArchitecturePolicy.h"
#include <iostream>
#include <fstream>
#include <sstream>
@@ -48,6 +49,10 @@ bool legacyBackends(const std::filesystem::path& path) {
}
}
int main(int argc,char** argv){if(argc!=2)return 2;using namespace veyra::engine;const std::filesystem::path p=argv[1];PresetStore a(p);bool ok=a.load();EnhancementSettings s;s.videoSrQuality=2;s.frameGenerationBackend=FrameGenerationBackend::Dlss;s.opticalFlowBackend=OpticalFlowBackend::AmdFidelityFx;s.amdFlowHalfResolution=true;s.protection.enabled=true;s.protection.featherPixels=3.5f;s.protection.regions[0]={.1f,.2f,.7f,.8f};s.protection.regions[3]={0,0,1,1};s.model.intensity=.375f;s.model.skin=1.5f;s.residual.darken=1.2f;s.multiplier=4;s.flow=FlowQuality::Quality;s.content=ContentRate::Fps50;s.nrPolicy=veyra::pipeline::NrSizePolicy::Native;
+ for(uint32_t family:{0x160u,0x170u,0x171u,0x190u,0x1A0u,0x1B0u})for(bool selected:{false,true})for(int result:{0,-1}){
+ auto value=family;const bool expected=selected&&result==0&&(family==0x170u||family==0x171u);
+ ok=ok&&(veyra::ngx::rewriteNrAmpereArchitecture(value,selected,result)==expected)&&value==(expected?0x1B0u:family);
+ }
s.srTarget=veyra::pipeline::SrTarget::Uhd8K;
s.audioSync=AudioSyncMode::Manual;s.audioOffsetMs=137;
s.nrRuntime=NrRuntime::Community;s.captureCompatible=true;s.lowLatency=true;
@@ -58,7 +63,8 @@ int main(int argc,char** argv){if(argc!=2)return 2;using namespace veyra::engine
auto badBackend=s;badBackend.frameGenerationBackend=static_cast<FrameGenerationBackend>(3);ok=ok&&!b.put(L"invalid backend",badBackend);
auto dis=s;dis.opticalFlowBackend=OpticalFlowBackend::GpuDis;ok=ok&&b.put(L"GPU DIS",dis)&&b.save();PresetStore disReload(p);ok=ok&&disReload.load()&&disReload.entries().back().settings==dis&&b.erase(1);
auto badFlow=s;badFlow.opticalFlowBackend=static_cast<OpticalFlowBackend>(3);ok=ok&&!b.put(L"invalid flow backend",badFlow);
- auto badNr=s;badNr.nrRuntime=static_cast<NrRuntime>(2);ok=ok&&!b.put(L"invalid NR runtime",badNr);
+ auto ampere=s;ampere.nr=true;ampere.nrRuntime=NrRuntime::Ampere;ok=ok&&b.put(L"RTX30",ampere);PresetStore ampereReload(p);ok=ok&&ampereReload.load()&&ampereReload.entries().back().settings==ampere&&b.erase(1);
+ auto badNr=s;badNr.nrRuntime=static_cast<NrRuntime>(3);ok=ok&&!b.put(L"invalid NR runtime",badNr);
auto half=s;half.content=ContentRate::Capture60To30;ok=ok&&b.put(L"capture half rate",half);PresetStore halfReload(p);ok=ok&&halfReload.load()&&halfReload.entries().back().settings.content==ContentRate::Capture60To30&&b.erase(1);
auto badSr=s;badSr.videoSrQuality=5;ok=ok&&!b.put(L"invalid video SR",badSr);
auto invalid=s;invalid.model.tone=9;ok=ok&&!b.put(L"bad",invalid)&&b.entries().size()==1&&b.erase(0)&&b.entries().empty();
diff --git a/tests/unit/UiContractTests.cpp b/tests/unit/UiContractTests.cpp
index 54dc8af4..f52b876d 100644
--- a/tests/unit/UiContractTests.cpp
+++ b/tests/unit/UiContractTests.cpp
@@ -15,7 +15,7 @@ int wmain(int argc,wchar_t** argv){try{
const float anchored=(800-500)/(1920.0f*(1000.0f/1920)*v.zoom)+v.centerX;require(std::abs(anchored-.8f)<.0001f,"pointer anchor fixed");
v.wheel(-3,800,300,1000,600,1920,1080);require(std::abs(v.zoom-1)<.0001f&&std::abs(v.centerX-.5f)<.0001f,"inverse wheel returns same view");
v.pan(100,0,1000,600,1920,1080);require(std::abs(v.centerX-.4f)<.0001f,"pan measured in displayed pixels");}
- ui::UiSessionState state;state.configured.multiplier=4;state.configured.sr=true;state.configured.model.intensity=.37f;state.configured.residual.color=1.4f;
+ ui::UiSessionState state;require(!state.enhanced&&!state.configured.nr&&!state.configured.sr&&state.configured.multiplier==1,"fresh startup effects disabled");state.enhanced=true;state.configured.nr=true;state.configured.multiplier=4;state.configured.sr=true;state.configured.model.intensity=.37f;state.configured.residual.color=1.4f;
auto before=state.effective();require(state.mode==ui::Mode::Daily,"startup Daily");state.mode=ui::Mode::Professional;require(state.effective()==before,"mode cannot alter settings");state.enhanced=false;auto bypass=state.effective();require(!bypass.nr&&!bypass.sr&&bypass.multiplier==1,"true full bypass");state.enhanced=true;require(state.effective()==before,"restore all settings");
ui::ChromeLayout daily(1440,900,false,false);require(daily.left==0&&daily.top==0&&daily.viewWidth==1440&&daily.viewHeight==812&&daily.bottom==812,"daily video owns all space above transport");
for(int width:{688,768,868,928,1008,1040,1148,1248,1888,2528}){
@@ -36,6 +36,6 @@ int wmain(int argc,wchar_t** argv){try{
require(MulDiv(l.viewWidth,dpi,96)>0,"DPI physical extent");
}
std::vector<float> tone(4800*2,1);float gain=1;sink::applyStereoGain(tone.data(),4800,.5f,gain);require(std::abs(gain-.5f)<1e-6,"gain ramp reaches half");for(size_t i=480;i<tone.size();++i)require(std::abs(tone[i]-.5f)<1e-6,"actual PCM scaled");tone.assign(tone.size(),1);sink::applyStereoGain(tone.data(),4800,0,gain);require(gain==0,"mute reaches zero");for(size_t i=480;i<tone.size();++i)require(tone[i]==0,"muted PCM exactly zero");
- if(argc>1){auto dir=std::filesystem::path(argv[1]);ui::UiPreferenceStore prefs(dir);ui::UiPreferences p;p.volume=.45f;p.muted=true;p.inspector=3;p.width=1180;require(prefs.save(p,&before),"atomic preferences save");ui::UiPreferenceStore loaded(dir);auto restored=loaded.load();require(restored.volume==p.volume&&restored.muted&&restored.inspector==3,"preferences round trip");auto setting=loaded.startup({});before.revision=setting.revision;require(setting==before,"all confirmed parameters round trip");auto path=dir/"ui-preferences.v1";{std::ofstream bad(path);bad<<"UNKNOWN 9 invalid";}ui::UiPreferenceStore damaged(dir);damaged.load();require(!damaged.save(p,nullptr),"corrupt preference cannot be overwritten");std::ifstream f(path);std::string data((std::istreambuf_iterator<char>(f)),{});require(data=="UNKNOWN 9 invalid","corrupt original preserved");}
+ if(argc>1){auto dir=std::filesystem::path(argv[1]);ui::UiPreferenceStore prefs(dir);const auto fresh=prefs.startup({});require(!fresh.nr&&!fresh.sr&&fresh.multiplier==1,"missing preferences do not enable effects");ui::UiPreferences p;p.volume=.45f;p.muted=true;p.inspector=3;p.width=1180;require(prefs.save(p,&before),"atomic preferences save");ui::UiPreferenceStore loaded(dir);auto restored=loaded.load();require(restored.volume==p.volume&&restored.muted&&restored.inspector==3,"preferences round trip");auto setting=loaded.startup({});before.revision=setting.revision;require(setting==before,"all confirmed parameters round trip");auto path=dir/"ui-preferences.v1";{std::ofstream bad(path);bad<<"UNKNOWN 9 invalid";}ui::UiPreferenceStore damaged(dir);damaged.load();require(!damaged.save(p,nullptr),"corrupt preference cannot be overwritten");std::ifstream f(path);std::string data((std::istreambuf_iterator<char>(f)),{});require(data=="UNKNOWN 9 invalid","corrupt original preserved");}
std::cout<<"PASS: mode/bypass, 384 layout cases at four DPI scales, actual PCM gain/mute, confirmed settings persistence/corruption\n";return 0;
}catch(const std::exception& e){std::cerr<<"FAIL: "<<e.what()<<'\n';return 1;}}