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++
Add isolated experimental RX 7000 NR provider and model controls
Veyra Goal Agent31722626cf39
diff --git a/AGENTS.md b/AGENTS.mdindex 9d8b8088..c69164c3 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -1,5 +1,7 @@# Veyra Agent 工作规则+> **2026-10-29 RX7000 NR接入**:用户授权在codex/amd-rdna3-nr-20261029(基线e7a9ae1)加入7000系NR与Small性能模型。按docs/AMD_RDNA3_NR_PLAN_2026-10-29.md隔离RedDuke网络worker,保留9000 lmxxf及现有NVIDIA路径;不接旧帧异步残差,不回读GPU图像,不改真实配置/驱动/现有SDK与运行组件。不合并main、不push/Release。本机无RX7000,合同测试不冒充实卡通过。+> **2026-10-28/29英伟达低延迟任务**:当前隔离分支`codex/nvidia-low-latency-20261028`,基线main4351bbd;用户授权完善Reflex并改为“英伟达低延迟:关/开/开+增强”。直接NVAPI,源帧Sleep与生成帧带外队列标记分开;当前本机DLSS/VFG/FSR原生路径验证,XeSS保持提供方调度并显示不生效。真实证据、失败修正和硬件边界见`docs/NVIDIA_LOW_LATENCY_2026-10-28.md`与`reports/nvidia-low-latency-20261028/FINAL.json`。2026-10-29 Claude复查修正(非英伟达显卡低排队归属、状态逐段翻译、摘要、未补帧通知降级)与屏幕采集延迟对比已提交到本分支(未合并main),见执行记录末节及`reports/claude-nvidia-ll-review-20261029/FINAL.json`。不合并main、不push/Release,不改真实配置、驱动、SDK/模型/DLL;使用私有测试配置。> **2026-10-28后续(用户选择)**:同分支新增“超分后缩回到”超采样选项:单次RTX视频超分到目标尺寸,再线性光精确缩回`srOutput`,NR/补帧/显示按缩回尺寸运行;双重开启时不用、保留选择。复用`srOutput`字段与`SrResolve`,导出协议14,超采样图同双重图走WDDM预算准入。读`docs/SR_SUPERSAMPLE_2026-10-28.md`及`reports/claude-sr-supersample-20261028/FINAL.json`。用户随后要求直接合并:双重超分、复查修正与超采样已合入本地main(未push/Release),活动树切回main,其余限制同下条。diff --git a/CMakeLists.txt b/CMakeLists.txtindex f258ece6..9907a629 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -224,6 +224,7 @@ target_link_libraries(veyra_runtime_probe PRIVATE veyra_gfx)veyra_add_compute_shader(veyra_shader_parity_encode ParityEncode)veyra_add_compute_shader(veyra_shader_parity_decode ParityDecode)+veyra_add_compute_shader(veyra_shader_rdna3_nr_decode Rdna3NrDecode)veyra_add_compute_shader(veyra_shader_hdr_video_sr HdrVideoSrRestore)veyra_add_compute_shader(veyra_shader_sr_resolve SrResolve)veyra_add_compute_shader(veyra_shader_hdr_amd_nr_encode HdrAmdNrEncode)@@ -381,6 +382,7 @@ add_library(veyra_pipeline STATICsrc/pipeline/SmaaLookupTables.cppsrc/pipeline/NrInstance.cppsrc/pipeline/LmxxfNrBackend.cpp+ src/pipeline/Rdna3NrBackend.cppsrc/pipeline/VfgBackend.cpp)veyra_apply_warnings(veyra_pipeline)@@ -397,6 +399,31 @@ if(EXISTS "${VEYRA_CUDA_DRIVER_INCLUDE_DIR}/cuda.h")target_compile_definitions(veyra_pipeline PRIVATE VEYRA_HAVE_CUDA_DRIVER_HEADERS=1)endif()target_link_libraries(veyra_pipeline PUBLIC veyra_base veyra_gfx d3d12 dxgi dxguid d3dcompiler)+add_dependencies(veyra_pipeline veyra_shader_rdna3_nr_decode)++# Optional independent RX7000 network worker. All third-party source and runtime+# assets remain external; only our host and reproducible preparation script live here.+set(VEYRA_RDNA3_NETWORK_SOURCE_DIR "" CACHE PATH "Prepared external RedDuke network source (MIT)")+if(EXISTS "${VEYRA_RDNA3_NETWORK_SOURCE_DIR}/runtime/core/network.cpp")+ add_executable(veyra_amd_nr_worker src/pipeline/Rdna3NrWorker.cpp "${VEYRA_RDNA3_NETWORK_SOURCE_DIR}/runtime/core/network.cpp")+ target_include_directories(veyra_amd_nr_worker PRIVATE include "${VEYRA_RDNA3_NETWORK_SOURCE_DIR}")+ target_compile_features(veyra_amd_nr_worker PRIVATE cxx_std_20)+ target_compile_definitions(veyra_amd_nr_worker PRIVATE NOMINMAX UNICODE _UNICODE WIN32_LEAN_AND_MEAN)+ target_compile_options(veyra_amd_nr_worker PRIVATE /utf-8 /WX-)+ target_link_libraries(veyra_amd_nr_worker PRIVATE d3d12 dxgi dxguid version)+endif()+add_executable(veyra_amd_nr_test_worker src/pipeline/Rdna3NrWorker.cpp)+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)+target_compile_options(veyra_amd_nr_test_worker PRIVATE /utf-8 /WX-)+target_link_libraries(veyra_amd_nr_test_worker PRIVATE d3d12 dxgi dxguid)+add_executable(veyra_rdna3_nr_contract_tests tests/integration/Rdna3NrContractTests.cpp)+target_include_directories(veyra_rdna3_nr_contract_tests PRIVATE include)+target_compile_features(veyra_rdna3_nr_contract_tests PRIVATE cxx_std_20)+target_compile_definitions(veyra_rdna3_nr_contract_tests PRIVATE NOMINMAX UNICODE _UNICODE WIN32_LEAN_AND_MEAN)+target_link_libraries(veyra_rdna3_nr_contract_tests PRIVATE veyra_pipeline veyra_parity)+add_dependencies(veyra_rdna3_nr_contract_tests veyra_shader_rdna3_nr_decode)add_library(veyra_lmxxf_fake_runtime SHARED tests/unit/LmxxfNrFakeRuntime.cpp)target_compile_features(veyra_lmxxf_fake_runtime PRIVATE cxx_std_20)target_compile_definitions(veyra_lmxxf_fake_runtime PRIVATE LMXXF_NR_RUNTIME_EXPORTS NOMINMAX WIN32_LEAN_AND_MEAN)diff --git a/README_CN.md b/README_CN.mdindex 4d02e303..d21679f6 100644--- a/README_CN.md+++ b/README_CN.md@@ -160,6 +160,8 @@ QML 管界面,视频由原生 D3D12 呈现。列表/节点共用引擎,未开发从[当前文档入口](docs/README.md)开始:[构建与验证](docs/DEVELOPMENT.md)、[界面代码职责](docs/ARCHITECTURE.md)。历史任务记录已单独归档。+开发分支新增 [RX 7000 实验 NR 接入](docs/AMD_RDNA3_NR_PLAN_2026-10-29.md):支持 Small / Original 与内部百分比,保留 RX 9000 和 NVIDIA 路径。本地协议/UI回归完成,RX 7000 实卡推理尚待验收;当前正式2.1.1不包含此分支功能。+Veyra 原有代码 GPL-3.0;含 Chiaki 串流的组合程序同时适用 AGPL-3.0 与上游 OpenSSL 例外(见 licenses/remoteplay)。[第三方来源与许可](THIRD_PARTY_NOTICES.md)、[2.1.0 构建与对应源码](docs/history/releases/BUILD_2.1.0.md)。源码与运行库/模型分离;Release manifest 用于发行审计,不用哈希锁阻止用户替换 DLL。## 支持与反馈diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.mdindex 5f04692a..e0ff6251 100644--- a/THIRD_PARTY_NOTICES.md+++ b/THIRD_PARTY_NOTICES.md@@ -1,5 +1,11 @@# Third-party dependencies+## RX 7000 experimental NR provider (2026-10-30, development branch)++RedDukeDev/dlss5-nr-amd-custom, fixed commit `ab455d179922adc11f65675d399e1d553bf423f0`: MIT network layer and NR kernels; ZLUDA at `b135e233bb7a6ff7f8690e49701f87f4944adcee`, MIT OR Apache-2.0. Original notices, exact file selection, modifications and proprietary component boundaries are in [third_party/redduke/VEYRA_ORIGIN.md](third_party/redduke/VEYRA_ORIGIN.md) and its LICENSE. The five external source files are fetched and Git-blob verified by `scripts/amd-nr/prepare-rdna3-source.py`; no SDK, runtime DLL, model or translation cache enters source Git.++Veyra adds a per-layer isolated network host with D3D12 shared textures/fences, adapter-LUID selection, bounded queues, same-frame GPU validity markers and failure teardown. Small/Original model selection uses the existing AMD runtime ID and settings. No OptiScaler/ReShade/game wrapper or SR/RR/FG kernels are used. Private ZLUDA compatibility DLLs are not system driver replacements and never load in the player process. NVIDIA's original 310.9.16.0 DLL and translation cache retain their separate rights; local staging and manifest audit do not confer redistribution rights or change the formal Release whitelist. Existing RX 9000 lmxxf integration retains its own notices and ABI.+## Beauty node: face restore and skin smoothing (2026-10-18)| Source | License | Veyra use |diff --git a/docs/AMD_RDNA3_NR_PLAN_2026-10-29.md b/docs/AMD_RDNA3_NR_PLAN_2026-10-29.mdnew file mode 100644index 00000000..d30b0460--- /dev/null+++ b/docs/AMD_RDNA3_NR_PLAN_2026-10-29.md@@ -0,0 +1,61 @@+# RX7000 NR接入执行记录++用户2026-10-29授权加入RX7000支持,包含Small性能模型。基线e7a9ae1,分支codex/amd-rdna3-nr-20261029,checkpoint/pre-amd-rdna3-nr-20261029;不合并main、不push/Release。保留RX9000 lmxxf路径,不改真实配置/驱动/已有SDK与运行组件。++采用RedDukeDev/dlss5-nr-amd-custom MIT网络层(固定ab455d179922adc11f65675d399e1d553bf423f0),不直接接游戏代理、不引入ReShade/OptiScaler。网络运行在独立的Veyra worker进程,隔离ZLUDA/NGX/NVAPI替身与NVIDIA链路;D3D12共享纹理/fence,不回读图像,不使用上游异步旧残差重投影。每次推理对应当前源帧;主图继续使用既有NR尺寸、HDR代理、残差、保护和历史合成。++步骤:核验依赖与网络层合同;实现有界共享GPU协议及Small/Original选择;接入现有AMD NR接口与硬件能力/组件错误;构建和CPU/D3D12/设置/QML回归;制作私有配置测试入口、保留源代码与许可/manifest/必要证据。每测试≤300秒、构建并发2/≤900秒。++所有产物统一E:/项目/Veyra下amd-rdna3-nr-20261029任务目录,复用构建与测试运行目录,不复制完整工程。外部固定开源源码与运行组件在deps/amd-rdna3-nr-20261029;专有DLL/模型/编译缓存不入源码Git。最终按实际验证记录;本机无RX7000,模拟合同/本机D3D12测试不冒充实卡推理、画质或性能验收。++## 实现结果(2026-10-30)++AMD runtime 数字 ID 4 不变,根据实际适配器将 RX 7000 路由至 RedDuke worker、RX 9000 保持 lmxxf 0.44。没有把文件存在当成显卡支持,也没有顺手向7000开放FSR4。性能模式对应 Small(preset 2),关闭对应 Original(preset 1);每层模型与百分比独立保存,列表和节点共用现有编辑器。内部尺寸仍遵守现有AMD上限:像素≤1920×1080,宽≤2560,高≤1080;支持手动25–100%,超出预算按既有尺寸策略处理。输入可以高于1080p,内部预算不等于最终显示尺寸。++每层独立子进程,主程序不加载ZLUDA替身。linear RGBA16F经Veyra既有parity编码进入上游要求的RGBA16F显示代理;零depth/motion、每帧reset,既有HDR基底还原及残差/保护/历史由Veyra处理。强度在解码中混合,不随滑条反复重建网络。一个原版310.9.16.0 DLL承载两种模型,切模型时重建worker。++GPU顺序:源队列signal → CUDA外部semaphore wait → network enqueue → CUDA私有完成fence → worker D3D12 queue wait → GPU有效标记 → 公共done fence → 源队列wait并解码。默认流完成顺序沿用上游gate事件同步所用顺序;本机无法验证ZLUDA与RX7000实际驱动互操作,初始化明确要求原生共享纹理和GPU semaphore,不允许CPU像素回读兜底。稳态不加CPU GPU-completion等待,控制消息只确认提交。有界8槽结果队列;初始化最多180秒,预热完成才ready。稳态5秒worker看门狗只终止本层子进程,解除自有等待;无有效GPU标记时输出精确保留当前源图,不能用旧结果冒充成功。++## 来源、组件与构建++开源来源和修改详见 `third_party/redduke/VEYRA_ORIGIN.md`。源码准备:++```+python -X utf8 -B scripts/amd-nr/prepare-rdna3-source.py --out E:/项目/Veyra/deps/amd-rdna3-nr-20261029+python -X utf8 -B scripts/acceptance/build-recording-handoff.py --task codex-amd-rdna3-nr-20261029 --root E:/项目/Veyra/worktrees/screen-recording-fix-20261022 --build-dir E:/项目/Veyra/build/claude-screen-recording-20261022 --reconfigure --label 2.1.1-test --jobs 2 --option VEYRA_RDNA3_NETWORK_SOURCE_DIR=E:/项目/Veyra/deps/amd-rdna3-nr-20261029/prepared veyra_qml_ui veyra_amd_nr_worker veyra_amd_nr_test_worker veyra_rdna3_nr_contract_tests veyra_lmxxf_nr_tests veyra_repair_contract_tests veyra_effect_availability_tests veyra_nr_model_settings_tests veyra_ui_i18n_tests+```++后续仅重建受影响目标,最终产品/worker/GPU测试批次6.1秒退出0,日志 `logs/codex-amd-rdna3-nr-20261029/build-20261030-005622/compile.log`。QtQuick另目标 `veyra_qml_quick_tests`。没有声称既有编译警告消失。++上游1.3.0下载包502830084字节,SHA256 `779b7d375bbe6d2419bcbd68e3d229c84acf09c74206837cfb0e12a253da1b00`。筛选24个组件470120771字节,追加两份ZLUDA许可证及本地native worker;stager审核原始网络Valid NVIDIA签名、版本和SHA后形成27项manifest。原始模型、11个NR内核、缓存及开源兼容层均留E盘任务deps,GPU解码shader单列SHA;驱动/HIP SDK不随包复制。既有运行组件保持原样,正式发行白名单不扩展。本地app中的cache为独立可写副本,其余只读组件可硬链接到本任务deps。++```+python -X utf8 -B E:/项目/Veyra/tmp/claude-sr-stage-20261028/stage_app.py+python -X utf8 -B scripts/amd-nr/stage-rdna3-runtime.py --dependency-root E:/项目/Veyra/deps/amd-rdna3-nr-20261029 --components E:/项目/Veyra/reports/amd-rdna3-nr-20261029/runtime-components.json --build-dir E:/项目/Veyra/build/claude-screen-recording-20261022 --app E:/项目/Veyra/tests/claude-sr-stage-20261028/app --report E:/项目/Veyra/reports/amd-rdna3-nr-20261029/staged-runtime.json+```++## 验证与失败记录++执行脚本 `reports/amd-rdna3-nr-20261029/run.py`,GPU/CPU/lmxxf分别以 `gpu final`、`cpu final`、`lmxxf final` 运行;QML以 `qml rdna3-ui-fixed` 运行。实际应用夹具 `scripts/acceptance/amd-rdna3-ui.qml` 由本轮 `ui.py` 以独立data-dir装载,随后 `--verify` 重启复验。++| 检查 | 实际结果及边界 |+|---|---|+| D3D12跨进程协议、颜色、模型并存、错误顺序/崩溃/无结果保护 | 54项0失败;明确copy测试worker,不是NR推理 |+| GPU能力/路由/协议 | 72项0失败 |+| 既有repair合同 | 300项0失败 |+| RX9000 lmxxf原有ABI与GPU合同 | 66项0失败;fake provider,不是RX9000推理 |+| NR设置、旧配置、每层Small/Original、全部76个百分比及导出冻结 | 0失败;不是AMD导出实卡验收 |+| QtQuick | 123通过,0失败,1项既有跳过 |+| 实际应用列表/节点保存和重启 | 通过,无QML错误;原用户配置SHA未变;NVIDIA不会因新增组件被误判为AMD可用 |+| 翻译 | 2712条,缺失0,占位符问题0 |+| RTX5070原生NR+SR+DLSS 2X+Boost回归 | 22.47秒,通过;149处理帧,源时间速率0.987573,干净停止 |++NVIDIA实测复用旧runner,真实回执位于 `reports/nvidia-low-latency-20261028/gpu-native-effects-2-2-rdna3-regression.json`;没有把日志伪装成新目录。其余回执位于 `reports/amd-rdna3-nr-20261029`,原始日志 `logs/amd-rdna3-nr-20261029`,失败也保留。++初始编译遇到WinRPC small宏和共享句柄接口类型错误,修正后构建通过。初始颜色夹具误把既有8bit parity当成恒等映射;改独立CPU golden,并采用上游要求的RGBA16F代理。FP16转换舍入差异使一轮过严的夹具失败;最终分别用CPU双精度转移检查编码在1 FP16 ULP内,再用实际量化代理检查解码,未放宽无标记回退(误差严格0)。QML mock初次重复声明自动生成信号导致测试程序退出,修正夹具后通过。实际UI夹具又遇到Item自带layer属性遮蔽函数、空节点图未添加NR,两次失败独立保留;改夹具后列表/节点及重启通过。CPU runner最初漏传设置输出目录,补参数后通过。以上没有修改历史失败日志或产品预期来伪造通过。++## 本地交付和验收边界++入口:`E:/项目/Veyra/tests/amd-rdna3-nr-20261029/启动RX7000-NR测试.cmd`;复用app:`E:/项目/Veyra/tests/claude-sr-stage-20261028/app`。入口使用专用interactive-profile,不自动打开媒体,首次效果关闭,不碰真实用户配置。选择实际RX7000适配器和AMD NR;先用1080p内部Small测试。目标机需要可用HIP7驱动组件(System32或绝对HIP_PATH),缺少时会给出原因;初始化必须实际导入共享资源成功。++当前机器是RTX5070,没有RX7000实卡,因此不能声称7000全系已跑通。RX7000的实际推理、Small/Original画质和性能、原生HDR代理还原、真实导出、采集、VRR及长时间稳定性未验收;不把GPU合同或上游数据代替现场验证。原8K最终输出+NR+VFG危险组合没有重跑。没有合并main、push或Release;正式2.1.1包不包含本分支新增功能。收尾文件身份、保护、清理及提交信息见 `reports/amd-rdna3-nr-20261029/FINAL.json`。diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.mdindex 1c1facd3..70ba9bbe 100644--- a/docs/CURRENT_STATUS.md+++ b/docs/CURRENT_STATUS.md@@ -1,6 +1,8 @@# 当前项目状态-更新:2026-10-28。这里只描述现在;历史过程见[历史索引](history/INDEX.md)。+更新:2026-10-30。这里只描述现在;历史过程见[历史索引](history/INDEX.md)。++当前施工分支 `codex/amd-rdna3-nr-20261029`,从下述英伟达低延迟及Claude复查后的 `e7a9ae1` 接入 RX 7000 NR(RedDuke 独立网络 worker,Small / Original,兼容手动百分比)。保留 RX 9000 lmxxf 与 NVIDIA;本地构建、GPU 协议及设置/UI回归已通过,尚未在 RX 7000 实卡推理验收。测试入口和证据见 [接入记录](AMD_RDNA3_NR_PLAN_2026-10-29.md)。未合并main、未push/发布,正式版仍2.1.1。2026-10-28/29当前任务:隔离分支`codex/nvidia-low-latency-20261028`完善“英伟达低延迟”三档(关/开/开+增强),基线为下述合并后的main4351bbd。直接NVAPI,生成帧不重复Sleep;DLSS/VFG/FSR与提供方回退、GUI/保存验证见[执行记录](NVIDIA_LOW_LATENCY_2026-10-28.md)。2026-10-29 Claude复查后在同分支工作区修正非英伟达显卡低排队关不掉、状态翻译、专业页摘要与未补帧通知降级,并做屏幕采集延迟对比(已提交到本分支,结果见执行记录末节)。尚未合并main或发布,正式版仍2.1.1。diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 851b1651..e243ceb3 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -159,3 +159,15 @@ A/B(GTA VI原生4K两帧,全部质量4,完整表见DUAL_SR_PLAN“复查验证(脚本`tmp/claude-nvidia-ll-review-20261029/review.py`,每项≤300秒):RepairContract 300项0失败(新增7项:归属规则4项、通知失败3项);i18n 0失败(新增英文状态两项);QtQuick 117/0/1既有跳过。真实GUI:AMD核显上关低排队后`requested=false effective=false`,英伟达控件显示“关”;切回英伟达重开后开+增强恢复且驱动已启用;英文界面关/开/开+增强在自动与垂直同步下状态无中文残留,摘要“NVIDIA Low Latency · On + Boost”。两次GUI前后原配置SHA不变、Main.qml复原,无QML错误。GPU回归9组(plain开/增强、DLSS 2X/6X、VFG、FSR、XeSS回退、NR+SR+DLSS、生命周期)全部通过;驱动Sleep平均约0.002毫秒、最长0.13毫秒。效果实测(`review.py latency <场景> <倍率> 10 <显示同步>`,档位-1关/0仅低排队/1开/2开+增强各两轮,窗口采集60fps代替采集卡;拆分脚本`latency_split.py`):驱动Sleep平均约0.003毫秒;DLSS 2X窗口采集四档采集到呈现p50 16.87–17.03毫秒,SR 4K+DLSS 2X 17.93–18.15毫秒,档位差别<0.2毫秒;GPU处理各档相同。无补帧窗口采集另发现与本功能无关的旧问题:呈现按首帧锚定,整场固定多等3.1–52毫秒(读到GPU完成<1毫秒),因此无补帧绝对延迟不用于档位比较。垂直同步DLSS 2X四档p50 16.87–17.05毫秒,同样无差别。未测采集卡、串流、30/40系与屏幕光电延迟。++## 2026-10-29/30 RX7000 NR接入++用户明确授权加入7000系。基线e7a9ae1,checkpoint/pre-amd-rdna3-nr-20261029;隔离分支codex/amd-rdna3-nr-20261029,不合并main、不push/Release。代码/运行协议/来源/许可/失败记录与完整命令读docs/AMD_RDNA3_NR_PLAN_2026-10-29.md,最终回执E:/项目/Veyra/reports/amd-rdna3-nr-20261029/FINAL.json。++复用RedDuke固定MIT网络层ab455d1、ZLUDA b135e23,每层独立worker,D3D12/CUDA原生共享纹理/fence;主进程不加载兼容替身。不使用ReShade/OptiScaler、游戏代理或旧帧残差。输入RGBA16F显示代理,网络每帧reset/零guide,Veyra原有HDR基底/残差/保护/历史合成保留;强度用解码混合,不随滑条重建Feature。RX7000和RX9000按真硬件选择不同后端,保存runtime数字ID4不变。Small性能模型和Original、25–100%手动内部比例在列表/节点独立保存。现有AMD1080p像素预算保持,未给7000虚开FSR4。++最终构建6.1秒退出0(logs/codex-amd-rdna3-nr-20261029/build-20261030-005622/compile.log);CPU能力72、repair300、原lmxxf fake ABI66、GPU协议与parity54项均0失败;QtQuick123通过/0失败/1既有跳过;设置/导出冻结兼容和i18n2712条通过。真实GUI保存与重启通过,无QML错误,原用户配置SHA未变。复用原NVIDIA runner测NR+SR+DLSS2X+Boost,22.47秒通过,149处理帧/源速0.987573,回执真实位于reports/nvidia-low-latency-20261028/gpu-native-effects-2-2-rdna3-regression.json。失败夹具/编译记录完整保留,未篡改历史验收。++本地复用tests/claude-sr-stage-20261028/app,新增审计27项RX7000组件及guard shader;原NVIDIA runtime97项、正式供体manifest1730项核验不变。五个固定外部源码SHA与prepared源码核验,native worker和EXE与构建一致,未把测试copy worker装入产品runtime。310.9.16.0网络原件Valid/NVIDIA,SHA2bc19bc09a7b89dd44f73e2ac0108fcc586e2154bdd0830f242f4f040e28789f;保留本地依赖/manifest/许可,不扩展正式Release白名单。入口tests/amd-rdna3-nr-20261029/启动RX7000-NR测试.cmd,独立interactive-profile、默认不自动开媒体;启动冒烟退出0,原配置SHA不变。++本机没有RX7000,54项GPU检查使用明确copy测试worker,不是AMD推理。没有实测RX7000画质、性能、HDR、导出、采集、VRR或长时稳定;没有重跑原8K最终输出+NR+VFG危险组合。不改真实配置/驱动/已有SDK与运行组件;Lecram继续暂停。本轮清理仅自己的重复下载ZIP及数字TEMP,删除身份/路径检查与逻辑字节另记cleanup.json,不宣称物理净回收。\ No newline at end of filediff --git a/i18n/catalog.json b/i18n/catalog.jsonindex 6d472243..0f41cd6a 100644--- a/i18n/catalog.json+++ b/i18n/catalog.json@@ -687,11 +687,11 @@"ja": "AMD NR のプレビューと動画書き出しは内部で最大 1080p まで処理し、動画の出力サイズを維持します。画像書き出しはモデルのサイズ制限内である必要があります。"},{- "zh": "AMD NR(实验):需要 RX 9000 驱动及 lmxxf 运行组件,内部最高 1080p 像素预算。支持模型强度、残差与保护;风格使用运行时配置。原生 HDR 保留原图基底,通过 SDR 代理增强后还原;AMD 实卡效果仍待验证。",+ "zh": "AMD NR(实验):RX 7000 / 9000 使用各自运行组件,需要 HIP 7 驱动。性能模式使用 Small,关闭使用原模型;内部最高 1080p 像素预算,支持百分比尺寸。7000 系风格固定默认,9000 系沿用运行时配置。原生 HDR 保留基底,通过 SDR 代理增强后还原。7000 系仍需实卡验收。","src": "qml/NrLayerEditor.qml",- "zh-TW": "AMD NR(實驗):需要 RX 9000 驅動及 lmxxf 執行元件,內部最高 1080p 像素預算。支援模型強度、殘差與保護;風格使用執行環境設定。原生 HDR 保留原圖基底,透過 SDR 代理增強後還原;AMD 實卡效果仍待驗證。",- "en": "AMD NR (experimental): requires an RX 9000 driver and lmxxf runtime, with an internal 1080p pixel budget. Model strength, residual and protection are supported; style uses the runtime configuration. Native HDR retains its original base and restores enhancement from an SDR proxy; results on AMD hardware still need verification.",- "ja": "AMD NR(実験):RX 9000 ドライバーと lmxxf ランタイムが必要です。内部処理は最大1080p相当のピクセル数です。モデル強度、残差、保護に対応し、スタイルはランタイム設定を使用します。ネイティブHDRの原画を保持し、SDRプロキシの補正差分を復元します。AMD実機での効果は未検証です。"+ "zh-TW": "AMD NR(實驗):RX 7000 / 9000 使用各自執行元件,需要 HIP 7 驅動。效能模式使用 Small,關閉使用原模型;內部最高 1080p 像素預算,支援百分比尺寸。7000 系風格固定預設,9000 系沿用執行時設定。原生 HDR 保留基底,透過 SDR 代理增強後還原。7000 系仍需實卡驗收。",+ "en": "AMD NR (experimental): RX 7000 / 9000 use separate runtimes and require HIP 7. Performance mode selects Small; off selects Original. Internal processing supports percentages within a 1080p pixel budget. RX 7000 uses the default style; RX 9000 retains runtime configuration. Native HDR preserves its base and reconstructs the SDR-proxy enhancement. RX 7000 hardware validation is still required.",+ "ja": "AMD NR(実験):RX 7000 / 9000 は専用ランタイムと HIP 7 が必要です。性能モードは Small、オフは元のモデルを使用します。内部処理は 1080p 相当の画素数内で割合を指定できます。7000 系は標準スタイル固定、9000 系はランタイム設定を使用します。ネイティブ HDR のベースを保持し、SDR プロキシの強化を復元します。7000 系の実機検証は未実施です。"},{"zh": "AMD 光流",@@ -1954,8 +1954,22 @@"ja": "RTX Video SR。基本超解像とは独立した品質設定"},{- "zh": "RX 9000 · lmxxf(实验)",+ "zh": "RX 7000 / 9000 · AMD NR(实验)","src": "qml/NrLayerEditor.qml",+ "zh-TW": "RX 7000 / 9000 · AMD NR(實驗)",+ "en": "RX 7000 / 9000 · AMD NR (experimental)",+ "ja": "RX 7000 / 9000 · AMD NR(実験)"+ },+ {+ "zh": "RX 7000 · RedDuke(实验)",+ "src": "src/ui/bridge/Hardware.cpp",+ "zh-TW": "RX 7000 · RedDuke(實驗)",+ "en": "RX 7000 · RedDuke (experimental)",+ "ja": "RX 7000 · RedDuke(実験)"+ },+ {+ "zh": "RX 9000 · lmxxf(实验)",+ "src": "src/ui/bridge/Hardware.cpp","zh-TW": "RX 9000 · lmxxf(實驗)","en": "RX 9000 · lmxxf (experimental)","ja": "RX 9000 · lmxxf(実験)"@@ -8240,6 +8254,13 @@"en": "Current offset","ja": "現在のずれ"},+ {+ "zh": "当前包缺少 RX 7000 NR 运行组件",+ "src": "src/ui/bridge/Hardware.cpp",+ "zh-TW": "目前套件缺少 RX 7000 NR 執行元件",+ "en": "This package is missing the RX 7000 NR runtime components",+ "ja": "このパッケージには RX 7000 NR ランタイムがありません"+ },{"zh": "当前包缺少此功能的运行组件","src": "src/ui/bridge/Hardware.cpp",@@ -17516,6 +17537,13 @@"en": "Requires the AMD HIP 7 driver runtime","ja": "AMD HIP 7 ドライバーランタイムが必要です"},+ {+ "zh": "需要 AMD RX 7000 / 9000",+ "src": "src/ui/bridge/Hardware.cpp",+ "zh-TW": "需要 AMD RX 7000 / 9000",+ "en": "Requires AMD RX 7000 / 9000",+ "ja": "AMD RX 7000 / 9000 が必要です"+ },{"zh": "需要 AMD RX 9000","src": "src/ui/bridge/Hardware.cpp",diff --git a/include/veyra/engine/EnhancementSettings.h b/include/veyra/engine/EnhancementSettings.hindex 3c2e16c0..c1a65cd9 100644--- a/include/veyra/engine/EnhancementSettings.h+++ b/include/veyra/engine/EnhancementSettings.h@@ -113,7 +113,7 @@ constexpr std::string_view nrRuntimeName(NrRuntime runtime) {case NrRuntime::Community:return "community-SF-RTX20-RTX50-legacy40";case NrRuntime::Ampere:return "community-SF-RTX20-RTX50";case NrRuntime::NvidiaOriginal:return "NVIDIA-original-RTX50-310.8.0";- case NrRuntime::LmxxfAmd:return "lmxxf-AMD-RDNA4";+ case NrRuntime::LmxxfAmd:return "AMD-NR-auto"; // persisted legacy ID4, RX7000/9000 providers route by actual adapter}return "unknown";}diff --git a/include/veyra/pipeline/AmdNrBackend.h b/include/veyra/pipeline/AmdNrBackend.hnew file mode 100644index 00000000..530f9f16--- /dev/null+++ b/include/veyra/pipeline/AmdNrBackend.h@@ -0,0 +1,19 @@+// SPDX-License-Identifier: GPL-3.0-only+#pragma once+#include <d3d12.h>+#include <cstdint>+#include <string>+namespace veyra::pipeline {+// Same-frame linear input/output contract shared by independent AMD providers.+class AmdNrBackend {+public:+ virtual ~AmdNrBackend()=default;+ virtual bool ready()const=0;+ virtual bool admits(uint32_t,uint32_t)const=0;+ virtual bool recordInputs(ID3D12GraphicsCommandList*,ID3D12Resource*,uint64_t,bool,float)=0;+ virtual bool enqueue()=0;+ virtual bool recordOutputs(ID3D12GraphicsCommandList*,ID3D12Resource*)=0;+ virtual bool retireSubmitted()=0;+ virtual const std::string& error()const=0;+};+}diff --git a/include/veyra/pipeline/AmdNrProvider.h b/include/veyra/pipeline/AmdNrProvider.hnew file mode 100644index 00000000..1087eadc--- /dev/null+++ b/include/veyra/pipeline/AmdNrProvider.h@@ -0,0 +1,18 @@+// SPDX-License-Identifier: GPL-3.0-only+#pragma once+#include <cstdint>+#include <string_view>+namespace veyra::pipeline {+enum class AmdNrProvider { Unsupported, LmxxfRdna4, RedDukeRdna3 };+// Hardware routing only. Runtime/driver initialization is checked separately.+constexpr AmdNrProvider amdNrProvider(uint32_t vendor,std::wstring_view name){+ if(vendor!=0x1002)return AmdNrProvider::Unsupported;+ for(size_t i=0;i+2<name.size();++i){+ if((name[i]!=L'R'&&name[i]!=L'r')||(name[i+1]!=L'X'&&name[i+1]!=L'x'))continue;+ size_t n=i+2;while(n<name.size()&&(name[n]==L' '||name[n]==L'\t'))++n;+ if(n<name.size()&&name[n]==L'7')return AmdNrProvider::RedDukeRdna3;+ if(n+1<name.size()&&name[n]==L'9'&&name[n+1]==L'0')return AmdNrProvider::LmxxfRdna4;+ }+ return AmdNrProvider::Unsupported;+}+}diff --git a/include/veyra/pipeline/LmxxfNrBackend.h b/include/veyra/pipeline/LmxxfNrBackend.hindex dd31597e..88fe762d 100644--- a/include/veyra/pipeline/LmxxfNrBackend.h+++ b/include/veyra/pipeline/LmxxfNrBackend.h@@ -6,9 +6,10 @@#include <cstdint>#include <string>#include "../../../third_party/lmxxf/LmxxfNrApi.h"+#include "veyra/pipeline/AmdNrBackend.h"namespace veyra::pipeline {-class LmxxfNrBackend {+class LmxxfNrBackend : public AmdNrBackend {public:~LmxxfNrBackend() { close(); }LmxxfNrBackend() = default;diff --git a/include/veyra/pipeline/NrInstance.h b/include/veyra/pipeline/NrInstance.hindex 6d9d03f2..85fd5d2c 100644--- a/include/veyra/pipeline/NrInstance.h+++ b/include/veyra/pipeline/NrInstance.h@@ -90,7 +90,7 @@ public:// direct-to-target path.bool stabilised = false;bool enabled = true;- std::unique_ptr<LmxxfNrBackend> amd;+ std::unique_ptr<AmdNrBackend> amd;// Bumped when an upstream layer's settings or output change. A layer whose// input revision moved drops its history, the same contract Magpie's// inputRevision enforces between passes.diff --git a/include/veyra/pipeline/Rdna3NrBackend.h b/include/veyra/pipeline/Rdna3NrBackend.hnew file mode 100644index 00000000..ebb60f33--- /dev/null+++ b/include/veyra/pipeline/Rdna3NrBackend.h@@ -0,0 +1,31 @@+// SPDX-License-Identifier: GPL-3.0-only+#pragma once+#include "veyra/pipeline/AmdNrBackend.h"+#include <filesystem>+#include <memory>+namespace veyra::pipeline {+class Rdna3NrBackend final:public AmdNrBackend {+public:+ Rdna3NrBackend();+ ~Rdna3NrBackend() override;+ Rdna3NrBackend(const Rdna3NrBackend&)=delete;+ Rdna3NrBackend& operator=(const Rdna3NrBackend&)=delete;+ bool open(const std::filesystem::path&,ID3D12Device*,ID3D12CommandQueue*,uint32_t,uint32_t,bool);+ // Explicit test binary; the product never calls this or loads it by fallback.+ bool openContractTest(const std::filesystem::path&,ID3D12Device*,ID3D12CommandQueue*,uint32_t,uint32_t,bool);+ void close() noexcept;+ bool ready()const override;+ bool admits(uint32_t,uint32_t)const override;+ bool recordInputs(ID3D12GraphicsCommandList*,ID3D12Resource*,uint64_t,bool,float) override;+ bool enqueue() override;+ bool recordOutputs(ID3D12GraphicsCommandList*,ID3D12Resource*) override;+ bool retireSubmitted() override;+ const std::string& error()const override;+ static bool runtimeAvailable(const std::filesystem::path&);+ static bool hipRuntimeAvailable();+ ID3D12Resource* diagnosticProxyForTest()const;+private:+ bool start(const std::filesystem::path&,ID3D12Device*,ID3D12CommandQueue*,uint32_t,uint32_t,bool,bool);+ struct Impl;std::unique_ptr<Impl> impl_;+};+}diff --git a/include/veyra/pipeline/Rdna3NrProtocol.h b/include/veyra/pipeline/Rdna3NrProtocol.hnew file mode 100644index 00000000..f3e2cb6c--- /dev/null+++ b/include/veyra/pipeline/Rdna3NrProtocol.h@@ -0,0 +1,25 @@+// SPDX-License-Identifier: GPL-3.0-only+#pragma once+#include <array>+#include <cstdint>+#include <type_traits>+namespace veyra::pipeline::rdna3 {+constexpr uint32_t kMagic=0x33524e56, kVersion=1;+enum class Op:uint32_t { Init=1, Evaluate=2, Stop=3, Reply=4 };+struct Header {uint32_t magic=kMagic,version=kVersion,bytes=0;Op op=Op::Init;uint64_t sequence=0;};+struct Init {+ Header h{ kMagic,kVersion,sizeof(Init),Op::Init,0 };+ uint64_t adapterLuid=0;+ uint32_t width=0,height=0,preset=2,reserved=0;+ // Display-proxy input/output RGBA16F (the upstream CUDA network contract),+ // zero depth R32F, zero motion RG16F, producer/done fences.+ // Last handle: GPU-written validity buffer; cleared by each producer.+ std::array<uint64_t,7> handles{};+ std::array<wchar_t,1024> runtime{},data{},log{};+};+struct Evaluate {Header h{kMagic,kVersion,sizeof(Evaluate),Op::Evaluate,0};float intensity=1; /* host transfer strength, not feature recreation */ uint32_t reset=1;};+struct Reply {Header h{kMagic,kVersion,sizeof(Reply),Op::Reply,0};int32_t result=0;std::array<char,768> message{};};+constexpr bool validHeader(const Header& h,Op op,uint32_t bytes){return h.magic==kMagic&&h.version==kVersion&&h.op==op&&h.bytes==bytes;}+constexpr bool validExtent(uint32_t w,uint32_t h){return w&&h&&w<=2560&&h<=1080&&uint64_t(w)*h<=1920ull*1080;}+static_assert(std::is_trivially_copyable_v<Init> && sizeof(Init)<16384);+}diff --git a/include/veyra/ui/EffectAvailability.h b/include/veyra/ui/EffectAvailability.hindex c635fe14..32ce34c8 100644--- a/include/veyra/ui/EffectAvailability.h+++ b/include/veyra/ui/EffectAvailability.h@@ -10,6 +10,7 @@ struct EffectGpu {uint32_t vendor = 0;bool rtx = false, blackwell = false, ada = false, rx9000 = false;uint32_t deviceId = 0;+ bool rx7000 = false;};constexpr bool hardwareSupports(HardwareEffect effect, EffectGpu gpu) {switch (effect) {@@ -17,7 +18,8 @@ constexpr bool hardwareSupports(HardwareEffect effect, EffectGpu gpu) {case HardwareEffect::NvidiaNr50: return gpu.vendor == 0x10DE && gpu.blackwell;case HardwareEffect::NvidiaNrSf: return gpu.vendor == 0x10DE && gpu.rtx;case HardwareEffect::Vfg: return gpu.vendor == 0x10DE && (gpu.ada || gpu.blackwell);- case HardwareEffect::AmdNr: case HardwareEffect::Fsr4: return gpu.vendor == 0x1002 && gpu.rx9000;+ case HardwareEffect::AmdNr: return gpu.vendor == 0x1002 && (gpu.rx9000 || gpu.rx7000);+ case HardwareEffect::Fsr4: return gpu.vendor == 0x1002 && gpu.rx9000;case HardwareEffect::CrossVendor: return gpu.vendor == 0x10DE || gpu.vendor == 0x1002 || gpu.vendor == 0x8086;}return false;diff --git a/qml/Veyra/NrLayerEditor.qml b/qml/Veyra/NrLayerEditor.qmlindex 5cdb2bb5..3e0d4b39 100644--- a/qml/Veyra/NrLayerEditor.qml+++ b/qml/Veyra/NrLayerEditor.qml@@ -18,6 +18,11 @@ ColumnLayout {signal removeRequested(int nodeIndex)signal orderEdited(bool enabled)readonly property bool amdNr: layerData.runtime === 4+ readonly property string amdRuntimeLabel: {+ const choices = veyra.nrRuntimeChoices || []+ const choice = choices.find(entry => String(entry.id) === "4")+ return choice ? choice.label : qsTr("RX 7000 / 9000 · AMD NR(实验)")+ }property string autoReason: ""readonly property bool manualSize: layerData.manualSize ?? falseproperty int lastManualPercent: 100@@ -89,10 +94,10 @@ ColumnLayout {hint: qsTr("全链共享 · 切换会重建 NR 管线")VSelect {objectName: "nr-runtime"- value: editor.layerData.runtime === 4 ? qsTr("RX 9000 · lmxxf(实验)")+ value: editor.layerData.runtime === 4 ? editor.amdRuntimeLabel: editor.layerData.runtime === 3 ? qsTr("RTX 50 · NVIDIA 原版"): "RTX 20–50 · SF 310.9.16"- options: veyra.nrRuntimeChoices || [{id:"2",label:"RTX 20–50 · SF 310.9.16"},{id:"3",label:qsTr("RTX 50 · NVIDIA 原版")},{id:"4",label:qsTr("RX 9000 · lmxxf(实验)")}]+ options: veyra.nrRuntimeChoices || [{id:"2",label:"RTX 20–50 · SF 310.9.16"},{id:"3",label:qsTr("RTX 50 · NVIDIA 原版")},{id:"4",label:qsTr("RX 7000 / 9000 · AMD NR(实验)")}]onPicked: id => editor.edited(editor.layerData.index, "runtime", Number(id))}}@@ -194,7 +199,7 @@ ColumnLayout {Text {Layout.fillWidth: truevisible: editor.amdNr || !Support.available(veyra, "nr" + editor.layerData.runtime)- text: !Support.available(veyra, "nr" + editor.layerData.runtime) ? Support.reason(veyra, "nr" + editor.layerData.runtime) : qsTr("AMD NR(实验):需要 RX 9000 驱动及 lmxxf 运行组件,内部最高 1080p 像素预算。支持模型强度、残差与保护;风格使用运行时配置。原生 HDR 保留原图基底,通过 SDR 代理增强后还原;AMD 实卡效果仍待验证。")+ text: !Support.available(veyra, "nr" + editor.layerData.runtime) ? Support.reason(veyra, "nr" + editor.layerData.runtime) : qsTr("AMD NR(实验):RX 7000 / 9000 使用各自运行组件,需要 HIP 7 驱动。性能模式使用 Small,关闭使用原模型;内部最高 1080p 像素预算,支持百分比尺寸。7000 系风格固定默认,9000 系沿用运行时配置。原生 HDR 保留基底,通过 SDR 代理增强后还原。7000 系仍需实卡验收。")color: Theme.t3; font.pixelSize: 11; wrapMode: Text.WordWrap}VSubGroup {diff --git a/scripts/acceptance/amd-rdna3-ui.qml b/scripts/acceptance/amd-rdna3-ui.qmlnew file mode 100644index 00000000..c119b1f4--- /dev/null+++ b/scripts/acceptance/amd-rdna3-ui.qml@@ -0,0 +1,42 @@+import QtQuick+Item {+ id: test+ property bool verifyOnly:false+ property int step:0+ property int ticks:0+ function check(ok,message){if(!ok)throw Error(message);veyra.logUi("rdna3-ui-test","PASS "+message)}+ function currentNrLayer(){const rows=veyra.nrLayers;check(rows.length>0,"NR layer exists");return rows[0]}+ function finish(){console.log("RDNA3_UI_PASS");Qt.quit()}+ Timer {+ interval:200;repeat:true;running:true+ onTriggered:{try{+ ++test.ticks+ if(test.ticks>100)throw Error("UI fixture timeout")+ if(test.step===0){+ const amd=veyra.nrRuntimeChoices.find(x=>String(x.id)==="4")+ check(amd!==undefined&&amd.disabled,"AMD runtime files never make RX7000 NR available on this NVIDIA adapter")+ veyra.nrEnabled=false+ if(test.verifyOnly){+ veyra.nodeMode=1;veyra.navigate("node");test.step=9;return+ }+ const nr=currentNrLayer()+ check(veyra.setNrLayerParameter(nr.index,"performance",0),"save Original model choice through the real bridge")+ check(veyra.setNrLayerParameter(nr.index,"sizePercent",62),"save manual processing percentage independently")+ test.step=1;return+ }+ if(test.step===1){+ const nr=currentNrLayer();check(!nr.performance&&nr.sizePercent===62,"list model and percentage reflect saved values")+ veyra.nodeMode=1;if(!veyra.nrLayers.length)check(veyra.addEffect("nr")>=0,"create NR in an empty node graph");veyra.navigate("node");test.step=2;return+ }+ if(test.step===2){+ const nr=currentNrLayer()+ check(veyra.setNrLayerParameter(nr.index,"performance",0),"node saves its independent Original choice")+ check(veyra.setNrLayerParameter(nr.index,"sizePercent",37),"node saves its independent 37 percent")+ test.step=3;return+ }+ if(test.step===3){const nr=currentNrLayer();check(!nr.performance&&nr.sizePercent===37,"node retains both choices");test.step=4;return}+ if(test.step===4&&test.ticks>8){finish();return}+ if(test.step===9){const nr=currentNrLayer();check(!nr.performance&&nr.sizePercent===37,"node model and percent survive a full application restart");finish()}+ }catch(e){veyra.logUi("rdna3-ui-test","RDNA3_UI_FAIL "+e.message);console.log("RDNA3_UI_FAIL "+e.message);Qt.quit()}}+ }+}diff --git a/scripts/amd-nr/prepare-rdna3-source.py b/scripts/amd-nr/prepare-rdna3-source.pynew file mode 100644index 00000000..08ba2c4c--- /dev/null+++ b/scripts/amd-nr/prepare-rdna3-source.py@@ -0,0 +1,55 @@+"""Fetch/prepare only RedDuke's MIT network layer at a fixed commit, outside Git.+No NVIDIA SDK, DLL, model, translation cache or full game mod is fetched here.+"""+import argparse,hashlib,json,urllib.request+from pathlib import Path+PIN='ab455d179922adc11f65675d399e1d553bf423f0'+BLOBS={"runtime/core/network.cpp":"aa8628396dfe5d70d9f56e77072ad34596540552","runtime/core/network.h":"037a6463060c561e5baa6b66aaac26d65ccf81c1","runtime/common/cuda_min.h":"54ba01035ae482db84cd5a45aa0930025d355d67","runtime/common/ngx_cuda.h":"52593d310f2b7c3ed189e7a88c4b4aa197eeda9c","LICENSE":"ad7bd58931ae2ca601959041fdd8fb94390f04c0"}+FILES=['runtime/core/network.cpp','runtime/core/network.h','runtime/common/cuda_min.h','runtime/common/ngx_cuda.h','LICENSE']+p=argparse.ArgumentParser();p.add_argument('--out',type=Path,required=True);a=p.parse_args()+a.out.resolve().relative_to(Path('E:/项目/Veyra').resolve())+rows=[]+for name in FILES:+ source=a.out/'source-pinned'/name;source.parent.mkdir(parents=True,exist_ok=True)+ if not source.exists():+ url=f'https://raw.githubusercontent.com/RedDukeDev/dlss5-nr-amd-custom/{PIN}/{name}'+ source.write_bytes(urllib.request.urlopen(url,timeout=30).read())+ raw=source.read_bytes();blob=hashlib.sha1(b'blob '+str(len(raw)).encode()+b'\0'+raw).hexdigest()+ if blob!=BLOBS[name]:raise SystemExit(f'pinned Git blob differs: {name} {blob}')+ text=source.read_text('utf8').replace('\r\n','\n')+ if name.endswith('network.h'):+ text=text.replace(' std::wstring data_dir;',' uint64_t adapter_luid = 0; // Veyra: the host D3D12 adapter\n std::wstring data_dir;',1)+ text=text.replace(' bool staged_by_list = false;',' bool staged_by_list = false;\n bool synchronise = true; // Veyra: native GPU-fence path may enqueue without a CPU wait',1)+ elif name.endswith('network.cpp'):+ before=''' CUdevice device = 0;+ if (!cu_ok(g.cu.cuDeviceGet(&device, 0), "cuDeviceGet", error)) return false;'''+ after=''' CUdevice device = 0;+ int count = 0;+ if (!cu_ok(g.cu.cuDeviceGetCount(&count), "cuDeviceGetCount", error) || count < 1) return false;+ using GetLuid = CUresult (*)(char*, unsigned*, CUdevice);+ auto get_luid = reinterpret_cast<GetLuid>(GetProcAddress(g.gate, "cuDeviceGetLuid"));+ bool matched = false;+ for (int index=0; get_luid && index<count; ++index) {+ CUdevice candidate=0; unsigned node=0; uint64_t luid=0;+ if (g.cu.cuDeviceGet(&candidate,index)==CUDA_SUCCESS &&+ get_luid(reinterpret_cast<char*>(&luid),&node,candidate)==CUDA_SUCCESS &&+ luid==paths.adapter_luid) { device=candidate; matched=true; break; }+ }+ // A single ROCm GPU is also admitted, but only after the worker's+ // real D3D12 shared-image import has succeeded on the selected LUID.+ if (!matched && count==1) {+ if (!cu_ok(g.cu.cuDeviceGet(&device,0), "cuDeviceGet", error)) return false;+ } else if (!matched) {+ error="cannot match the selected D3D12 LUID among multiple CUDA/HIP devices"; return false;+ }'''+ assert text.count(before)==1,'pinned adapter-selection source differs'+ text=text.replace(before,after)+ before='if (!cu_ok(g.cu.cuCtxSynchronize(), "cuCtxSynchronize", error)) return false;'+ pos=text.index('bool Network::evaluate(const EvaluateDesc &d, std::string &error)')+ tail=text[pos:];assert before in tail+ text=text[:pos]+tail.replace(before,'if (d.synchronise && !cu_ok(g.cu.cuCtxSynchronize(), "cuCtxSynchronize", error)) return false;',1)+ dest=a.out/'prepared'/name;dest.parent.mkdir(parents=True,exist_ok=True)+ dest.write_text(text,encoding='utf8',newline='\n')+ rows.append(dict(path=name,originalSha256=hashlib.sha256(source.read_bytes()).hexdigest(),preparedSha256=hashlib.sha256(dest.read_bytes()).hexdigest()))+(a.out/'source-manifest.json').write_text(json.dumps(dict(repository='RedDukeDev/dlss5-nr-amd-custom',commit=PIN,license='MIT',changes=['select host adapter LUID or reject ambiguous multi-device mapping','optional asynchronous enqueue paired with mandatory native GPU semaphore by Veyra worker'],files=rows),indent=2),encoding='utf8')+print(json.dumps(dict(prepared=str(a.out/'prepared'),files=len(rows),commit=PIN)))diff --git a/scripts/amd-nr/stage-rdna3-runtime.py b/scripts/amd-nr/stage-rdna3-runtime.pynew file mode 100644index 00000000..55f94f09--- /dev/null+++ b/scripts/amd-nr/stage-rdna3-runtime.py@@ -0,0 +1,54 @@+"""Audit/stage a local RX7000 runtime; does not publish or alter publisher locks.+Only the declared NR subset is admitted. Real driver/HIP DLLs, game proxies,+OptiScaler, ReShade, SR/RR/FG modules and SDKs are never copied by this script.+"""+import argparse,hashlib,json,os,shutil,subprocess+from pathlib import Path+p=argparse.ArgumentParser()+for name in ('dependency-root','components','build-dir','app','report'):p.add_argument('--'+name,type=Path,required=True)+a=p.parse_args();base=Path('E:/项目/Veyra').resolve()+for x in (a.dependency_root,a.build_dir,a.app,a.report):x.resolve().relative_to(base)+def sha(p):+ with p.open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest()+source=a.dependency_root/'runtime';manifest=json.loads(a.components.read_text('utf8'))+assert manifest['archiveSha256']=='779b7d375bbe6d2419bcbd68e3d229c84acf09c74206837cfb0e12a253da1b00'+for row in manifest['files']:+ path=source/row['path'];path.resolve().relative_to(source.resolve())+ assert path.stat().st_size==row['size'] and sha(path)==row['sha256'],row['path']+nr=source/'nvngx_dlssnr.dll'+assert nr.stat().st_size==266424944 and sha(nr)=='2bc19bc09a7b89dd44f73e2ac0108fcc586e2154bdd0830f242f4f040e28789f'+env={k:v for k,v in os.environ.items() if k.upper()!='PSMODULEPATH'}+env['VEYRA_RDNA3_AUDIT_FILE']=str(nr)+script="$p=$env:VEYRA_RDNA3_AUDIT_FILE; $s=Get-AuthenticodeSignature -LiteralPath $p; $v=(Get-Item -LiteralPath $p).VersionInfo; [pscustomobject]@{signature=[string]$s.Status;signer=$s.SignerCertificate.Subject;version=\"$($v.FileMajorPart).$($v.FileMinorPart).$($v.FileBuildPart).$($v.FilePrivatePart)\"}|ConvertTo-Json"+identity=json.loads(subprocess.check_output(['powershell.exe','-NoProfile','-NonInteractive','-Command',script],env=env,timeout=30).decode('utf-8-sig'))+assert identity['signature']=='Valid' and 'NVIDIA' in identity['signer'] and identity['version']=='310.9.16.0'+worker=a.build_dir/'veyra_amd_nr_worker.exe';assert worker.is_file()+assert b'CONTRACT TEST WORKER' not in worker.read_bytes(),'never stage the test worker as a product'+target=a.app/'runtime/amd-nr-rdna3';target.mkdir(parents=True,exist_ok=True)+rows=[]+for row in manifest['files']:+ rel=row['path'];src=source/rel;dst=target/rel;dst.parent.mkdir(parents=True,exist_ok=True)+ if dst.exists():assert sha(dst)==row['sha256'],'refuse overwriting existing runtime assets: '+rel+ elif rel.startswith('cache/') or src.suffix.lower() not in {'.dll','.hsaco'}:shutil.copyfile(src,dst)+ else:os.link(src,dst) # read-only components; writable cache is a fresh file+ rows.append(dict(row,classification='proprietary-NVIDIA-original' if rel=='nvngx_dlssnr.dll' else 'pretranslated-cache' if rel.endswith('.db') else 'open-source-component-or-notice'))+for name in ('ZLUDA-LICENSE-MIT','ZLUDA-LICENSE-APACHE'):+ src=source/'licenses'/name;dst=target/'licenses'/name;dst.parent.mkdir(exist_ok=True)+ if not dst.exists():shutil.copyfile(src,dst)+ assert sha(src)==sha(dst)+ rows.append(dict(path='licenses/'+name,size=dst.stat().st_size,sha256=sha(dst),classification='open-source-license'))+dst=target/worker.name+if dst.exists():+ # Only update our previously recorded host, never an unknown existing file.+ prior=json.loads((target/'veyra-rdna3-runtime-manifest.json').read_text('utf8'))+ old=next(r for r in prior['files'] if r['path']==worker.name);assert sha(dst)==old['sha256']+ dst.unlink()+shutil.copyfile(worker,dst);rows.append(dict(path=worker.name,size=dst.stat().st_size,sha256=sha(dst),classification='Veyra-open-source-host'))+shader=a.build_dir/'shaders/Rdna3NrDecode.dxil';shaderOut=a.app/'shaders'/shader.name+if shaderOut.exists():shaderOut.unlink()+shutil.copyfile(shader,shaderOut)+for filename in ('source-manifest.json',):shutil.copyfile(a.dependency_root/filename,target/filename)+out=dict(localOnly=True,releaseAuthorized=False,backend='RX7000 RedDuke, same-frame, isolated worker',sourceCommit='ab455d179922adc11f65675d399e1d553bf423f0',zludaCommit='b135e233bb7a6ff7f8690e49701f87f4944adcee',networkIdentity=identity,driverIncluded=False,mainProcessDriverReplaced=False,files=rows,guardShaderSha256=sha(shaderOut))+(target/'veyra-rdna3-runtime-manifest.json').write_text(json.dumps(out,ensure_ascii=False,indent=2)+'\n',encoding='utf8')+a.report.parent.mkdir(parents=True,exist_ok=True);a.report.write_text(json.dumps(out,ensure_ascii=False,indent=2)+'\n',encoding='utf8')+print(json.dumps(dict(files=len(rows),root=str(target),workerSha256=sha(dst),networkIdentity=identity),ensure_ascii=False))diff --git a/shaders/Rdna3NrDecode.hlsl b/shaders/Rdna3NrDecode.hlslnew file mode 100644index 00000000..b892dafb--- /dev/null+++ b/shaders/Rdna3NrDecode.hlsl@@ -0,0 +1,11 @@+// Same shared colour math, with a GPU-written same-frame completion guard.+#define main ParityDecodeBody+#include "ParityDecode.hlsl"+#undef main+ByteAddressBuffer completedResult : register(t8);+[numthreads(16,16,1)]+void main(uint3 id:SV_DispatchThreadID) {+ if(id.x>=parityDimensions.x||id.y>=parityDimensions.y)return;+ if(completedResult.Load(0)!=1) { finalTex[id.xy]=originalTex[id.xy];return; }+ ParityDecodeBody(id);+}diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cppindex e76a7315..e541fe6a 100644--- a/src/pipeline/EnhanceGraph.cpp+++ b/src/pipeline/EnhanceGraph.cpp@@ -7,6 +7,8 @@// views are created last. Per-frame execution uses the shared command slot// ring (NR evaluates on a fresh list - snippet constraint).#include "veyra/pipeline/EnhanceGraph.h"+#include "veyra/pipeline/Rdna3NrBackend.h"+#include "veyra/pipeline/AmdNrProvider.h"#include "veyra/pipeline/VfgBackend.h"#include "veyra/engine/GraphDescription.h"#include "veyra/engine/ColorLut.h"@@ -1512,9 +1514,18 @@ bool EnhanceGraph::initNgxFeatures()// restores its delta over the untouched HDR base before the// same shared residual/protection/temporal composite.if(desc_.hdrWorking()&&!instance->createAmdHdrProxy(context_.device()))return false;- instance->amd=std::make_unique<LmxxfNrBackend>();- const auto directory=std::filesystem::path(desc_.runtimeAbsPath)/L".."/L"amd-nr";- if(!instance->amd->open(directory.lexically_normal(),context_.device(),ring_.queue(),context_.adapter().vendorId,instance->model.performance) || !instance->amd->admits(extent.width,extent.height))return false;+ if(amdNrProvider(context_.adapter().vendorId,context_.adapter().description)==AmdNrProvider::RedDukeRdna3){+ auto backend=std::make_unique<Rdna3NrBackend>();+ const auto directory=std::filesystem::path(desc_.runtimeAbsPath)/L".."/L"amd-nr-rdna3";+ if(!backend->open(directory.lexically_normal(),context_.device(),ring_.queue(),extent.width,extent.height,instance->model.performance))return false;+ instance->amd=std::move(backend);+ }else{+ auto backend=std::make_unique<LmxxfNrBackend>();+ const auto directory=std::filesystem::path(desc_.runtimeAbsPath)/L".."/L"amd-nr";+ if(!backend->open(directory.lexically_normal(),context_.device(),ring_.queue(),context_.adapter().vendorId,instance->model.performance))return false;+ instance->amd=std::move(backend);+ }+ if(!instance->amd->admits(extent.width,extent.height))return false;}veyra::log::info("resolution",std::format("NR layer={} internal={}x{} composite={}x{} sharedMotion={}",index+1,extent.width,extent.height,fullW,fullH,motion!=nullptr));diff --git a/src/pipeline/Rdna3NrBackend.cpp b/src/pipeline/Rdna3NrBackend.cppnew file mode 100644index 00000000..c23f05a9--- /dev/null+++ b/src/pipeline/Rdna3NrBackend.cpp@@ -0,0 +1,237 @@+// SPDX-License-Identifier: GPL-3.0-only+#include "veyra/pipeline/Rdna3NrBackend.h"+#include "veyra/pipeline/Rdna3NrProtocol.h"+#include "veyra/pipeline/GpuPassUtils.h"+#include <atomic>+#include <chrono>+#include <cmath>+#include <thread>+#include <algorithm>++namespace veyra::pipeline {+namespace {+using namespace rdna3;+bool hrFailed(int line,HRESULT hr){if(SUCCEEDED(hr))return false;log::error("amd-nr-rdna3",std::format("parent line={} hr=0x{:08X}",line,unsigned(hr)));return true;}+void drop(HANDLE& h){if(h&&h!=INVALID_HANDLE_VALUE)CloseHandle(h);h=nullptr;}+void barrier(ID3D12GraphicsCommandList* l,ID3D12Resource* r,D3D12_RESOURCE_STATES a,D3D12_RESOURCE_STATES b){+ if(a==b)return;D3D12_RESOURCE_BARRIER v{};v.Type=D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;+ v.Transition={r,D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,a,b};l->ResourceBarrier(1,&v);+}+bool send(HANDLE pipe,const void* p,DWORD size){DWORD n=0;return WriteFile(pipe,p,size,&n,nullptr)&&n==size;}+template<size_t N> bool pathTo(std::array<wchar_t,N>& dest,const std::filesystem::path& p){+ const auto s=p.wstring();if(s.size()>=N)return false;std::copy(s.begin(),s.end(),dest.begin());return true;+}+constexpr auto kCommon=D3D12_RESOURCE_STATE_COMMON;+constexpr auto kRead=D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;+constexpr auto kUav=D3D12_RESOURCE_STATE_UNORDERED_ACCESS;+}+struct Rdna3NrBackend::Impl {+ ComPtr<ID3D12Device> device;ComPtr<ID3D12CommandQueue> queue;+ ComPtr<ID3D12Resource> image[4],decoded,valid;+ ComPtr<ID3D12Fence> producer,done;+ ComputePass encode,decode;DescriptorStager views;+ ComPtr<ID3D12DescriptorHeap> clearHeap;+ ID3D12Resource* boundColor=nullptr;+ HANDLE process=nullptr,job=nullptr,toWorker=nullptr,fromWorker=nullptr,stop=nullptr;+ std::jthread monitor;+ std::atomic<bool> failed=false;+ std::atomic<bool> closing=false;+ std::atomic<uint64_t> queued=0,queuedAt=0;+ uint32_t w=0,h=0;uint64_t sequence=0,sourceFrame=0;+ rdna3::Evaluate pending;+ bool opened=false,prepared=false,enqueued=false,outputs=false,bound=false;+ std::string error;+ bool fail(std::string s){error=std::move(s);log::error("amd-nr-rdna3",error);return false;}+ bool healthy(){return !failed.load()&&process&&WaitForSingleObject(process,0)==WAIT_TIMEOUT;}+ bool reply(uint64_t seq,DWORD timeout){+ Reply r{};size_t got=0;const auto end=GetTickCount64()+timeout;+ while(got<sizeof(r)&&GetTickCount64()<end){+ DWORD available=0,n=0;+ if(!PeekNamedPipe(fromWorker,nullptr,0,nullptr,&available,nullptr))return fail("RDNA3 worker status pipe failed");+ if(!available){if(!healthy())return fail("RDNA3 inference worker exited or timed out; NR is unavailable");Sleep(2);continue;}+ if(!ReadFile(fromWorker,reinterpret_cast<char*>(&r)+got,DWORD(std::min<size_t>(available,sizeof(r)-got)),&n,nullptr)||!n)return fail("RDNA3 worker reply truncated");+ got+=n;+ }+ if(got!=sizeof(r))return fail("RDNA3 worker response exceeded its deadline");+ if(!validHeader(r.h,Op::Reply,sizeof(r))||r.h.sequence!=seq)return fail("RDNA3 worker protocol/version/frame mismatch");+ if(r.result)return fail(std::string(r.message.data(),strnlen(r.message.data(),r.message.size())));+ return true;+ }+ void watch(){+ while(WaitForSingleObject(stop,50)==WAIT_TIMEOUT){+ const auto q=queued.load();const auto at=queuedAt.load();+ const bool exited=WaitForSingleObject(process,0)!=WAIT_TIMEOUT;+ if(exited&&closing.load())break;+ const bool expired=q&&at&&done->GetCompletedValue()<q&&GetTickCount64()-at>5000;+ if(!exited&&!expired)continue;+ failed=true;+ log::error("amd-nr-rdna3",expired?"worker GPU job exceeded 5s; stopping only this worker":"inference worker exited; releasing the owned queue wait for teardown");+ if(!exited){TerminateProcess(process,125);WaitForSingleObject(process,1000);}+ // Never leave the shared D3D12 queue waiting for a dead process.+ // Input is seeded into output before enqueue; the engine rejects the+ // failed provider on its next operation. This is failure teardown.+ const auto hr=done->Signal(UINT64_MAX-1);+ if(hrFailed(__LINE__,hr))log::error("amd-nr-rdna3",std::format("failed to release worker wait hr=0x{:X}",unsigned(hr)));+ break;+ }+ }+};+Rdna3NrBackend::Rdna3NrBackend():impl_(std::make_unique<Impl>()){}+Rdna3NrBackend::~Rdna3NrBackend(){close();}+bool Rdna3NrBackend::runtimeAvailable(const std::filesystem::path& p){+ std::error_code ec;+ for(const auto* n:{L"veyra_amd_nr_worker.exe",L"nvngx_dlssnr.dll",L"zluda/nvcuda.dll",L"zluda/nvngx.dll",L"zluda/nvapi64.dll",L"zluda/zluda_real.dll",L"kernels/kernels.txt",L"cache/ComputeCache/coverage.txt",L"cache/ComputeCache/zluda2.db"})+ if(!std::filesystem::is_regular_file(p/n,ec))return false;+ return true;+}+bool Rdna3NrBackend::hipRuntimeAvailable(){+ if(GetModuleHandleW(L"amdhip64_7.dll"))return true;+ wchar_t system[MAX_PATH]{};std::error_code ec;+ if(GetSystemDirectoryW(system,MAX_PATH)&&std::filesystem::is_regular_file(std::filesystem::path(system)/L"amdhip64_7.dll",ec))return true;+ wchar_t sdk[32768]{};const auto n=GetEnvironmentVariableW(L"HIP_PATH",sdk,DWORD(std::size(sdk)));+ const std::filesystem::path root=sdk;+ return n&&n<std::size(sdk)&&root.is_absolute()&&std::filesystem::is_regular_file(root/L"bin"/L"amdhip64_7.dll",ec);+}+bool Rdna3NrBackend::open(const std::filesystem::path& p,ID3D12Device* d,ID3D12CommandQueue* q,uint32_t w,uint32_t h,bool smallModel){return start(p,d,q,w,h,smallModel,false);}+bool Rdna3NrBackend::openContractTest(const std::filesystem::path& p,ID3D12Device* d,ID3D12CommandQueue* q,uint32_t w,uint32_t h,bool smallModel){return start(p,d,q,w,h,smallModel,true);}+bool Rdna3NrBackend::start(const std::filesystem::path& directory,ID3D12Device* device,ID3D12CommandQueue* queue,uint32_t w,uint32_t h,bool smallModel,bool test){+ close();impl_=std::make_unique<Impl>();auto& s=*impl_;+ if(!device||!queue||!directory.is_absolute()||!validExtent(w,h))return s.fail("invalid RDNA3 device, queue, absolute runtime path or internal size");+ if(!test&&!runtimeAvailable(directory))return s.fail("RX7000 NR runtime is incomplete; install the RDNA3 worker, original NR network, kernels and translation cache");+ s.device=device;s.queue=queue;s.w=w;s.h=h;+ const DXGI_FORMAT formats[]={DXGI_FORMAT_R16G16B16A16_FLOAT,DXGI_FORMAT_R16G16B16A16_FLOAT,DXGI_FORMAT_R32_FLOAT,DXGI_FORMAT_R16G16_FLOAT};+ for(unsigned i=0;i<4;++i){+ D3D12_HEAP_PROPERTIES heap{};heap.Type=D3D12_HEAP_TYPE_DEFAULT;+ D3D12_RESOURCE_DESC r{};r.Dimension=D3D12_RESOURCE_DIMENSION_TEXTURE2D;r.Width=w;r.Height=h;r.DepthOrArraySize=r.MipLevels=1;+ r.Format=formats[i];r.SampleDesc.Count=1;r.Flags=D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;+ const auto hr=device->CreateCommittedResource(&heap,D3D12_HEAP_FLAG_SHARED,&r,kCommon,nullptr,IID_PPV_ARGS(&s.image[i]));+ if(hrFailed(__LINE__,hr))return s.fail(std::format("RDNA3 shared texture {} allocation hr=0x{:X}",i,unsigned(hr)));+ }+ s.decoded=makeTexture(device,w,h,DXGI_FORMAT_R16G16B16A16_FLOAT,true);+ D3D12_HEAP_PROPERTIES validityHeap{};validityHeap.Type=D3D12_HEAP_TYPE_DEFAULT;+ D3D12_RESOURCE_DESC validityDesc{};validityDesc.Dimension=D3D12_RESOURCE_DIMENSION_BUFFER;validityDesc.Width=16;validityDesc.Height=validityDesc.DepthOrArraySize=validityDesc.MipLevels=1;validityDesc.SampleDesc.Count=1;validityDesc.Layout=D3D12_TEXTURE_LAYOUT_ROW_MAJOR;validityDesc.Flags=D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;+ if(hrFailed(__LINE__,device->CreateCommittedResource(&validityHeap,D3D12_HEAP_FLAG_SHARED,&validityDesc,kCommon,nullptr,IID_PPV_ARGS(&s.valid))))return s.fail("RDNA3 shared validity buffer allocation failed");+ std::vector<uint8_t> code;+ if(!s.decoded||!s.encode.loadShader("ParityEncode.dxil",code)||!s.encode.create(device,code,5,1,1)||+ !s.decode.loadShader("Rdna3NrDecode.dxil",code)||!s.decode.create(device,code,5,3,1,8,1)||!s.views.initialize(device,8))return s.fail("RDNA3 shared parity shader setup failed");+ D3D12_DESCRIPTOR_HEAP_DESC clearDesc{};clearDesc.Type=D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;clearDesc.NumDescriptors=3;+ if(hrFailed(__LINE__,device->CreateDescriptorHeap(&clearDesc,IID_PPV_ARGS(&s.clearHeap))))return s.fail("RDNA3 clear descriptor heap failed");+ if(hrFailed(__LINE__,device->CreateFence(0,D3D12_FENCE_FLAG_SHARED,IID_PPV_ARGS(&s.producer)))||hrFailed(__LINE__,device->CreateFence(0,D3D12_FENCE_FLAG_SHARED,IID_PPV_ARGS(&s.done))))return s.fail("RDNA3 shared fence creation failed");+ HANDLE readChild=nullptr,writeChild=nullptr;SECURITY_ATTRIBUTES sa{sizeof(sa),nullptr,TRUE};+ if(!CreatePipe(&readChild,&s.toWorker,&sa,65536)||!CreatePipe(&s.fromWorker,&writeChild,&sa,65536)){drop(readChild);drop(writeChild);return s.fail("RDNA3 control pipe creation failed");}+ SetHandleInformation(s.toWorker,HANDLE_FLAG_INHERIT,0);SetHandleInformation(s.fromWorker,HANDLE_FLAG_INHERIT,0);+ STARTUPINFOEXW startup{};startup.StartupInfo.cb=sizeof(startup);+ SIZE_T bytes=0;InitializeProcThreadAttributeList(nullptr,1,0,&bytes);std::vector<unsigned char> storage(bytes);+ startup.lpAttributeList=reinterpret_cast<LPPROC_THREAD_ATTRIBUTE_LIST>(storage.data());+ HANDLE inherited[]={readChild,writeChild};+ if(!InitializeProcThreadAttributeList(startup.lpAttributeList,1,0,&bytes)||!UpdateProcThreadAttribute(startup.lpAttributeList,0,PROC_THREAD_ATTRIBUTE_HANDLE_LIST,inherited,sizeof(inherited),nullptr,nullptr)){+ drop(readChild);drop(writeChild);return s.fail("RDNA3 inherited-handle allowlist failed");+ }+ const auto executable=directory/(test?L"veyra_amd_nr_test_worker.exe":L"veyra_amd_nr_worker.exe");+ auto command=std::format(L"\"{}\" {} {}",executable.wstring(),uintptr_t(readChild),uintptr_t(writeChild));+ PROCESS_INFORMATION process{};+ const bool created=CreateProcessW(executable.c_str(),command.data(),nullptr,nullptr,TRUE,CREATE_NO_WINDOW|CREATE_SUSPENDED|EXTENDED_STARTUPINFO_PRESENT,nullptr,directory.c_str(),&startup.StartupInfo,&process)!=FALSE;+ DeleteProcThreadAttributeList(startup.lpAttributeList);drop(readChild);drop(writeChild);+ if(!created)return s.fail(std::format("RDNA3 worker launch failed win32={}",GetLastError()));+ s.process=process.hProcess;s.job=CreateJobObjectW(nullptr,nullptr);+ JOBOBJECT_EXTENDED_LIMIT_INFORMATION limits{};limits.BasicLimitInformation.LimitFlags=JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;+ if(!s.job||!SetInformationJobObject(s.job,JobObjectExtendedLimitInformation,&limits,sizeof(limits))||!AssignProcessToJobObject(s.job,s.process)){+ TerminateProcess(s.process,126);drop(process.hThread);return s.fail("RDNA3 worker could not be confined to its owned job");+ }+ Init init;const auto luid=device->GetAdapterLuid();init.adapterLuid=uint64_t(uint32_t(luid.HighPart))<<32|luid.LowPart;+ init.width=w;init.height=h;init.preset=smallModel?2:1;+ std::error_code ec;const auto data=directory/L"cache";std::filesystem::create_directories(data/L"tmp",ec);+ if(!pathTo(init.runtime,directory)||!pathTo(init.data,data)||!pathTo(init.log,data/std::format(L"worker-{}.log",process.dwProcessId))){TerminateProcess(s.process,126);drop(process.hThread);return s.fail("RDNA3 runtime path exceeds protocol limit");}+ ID3D12DeviceChild* shared[]={s.image[0].Get(),s.image[1].Get(),s.image[2].Get(),s.image[3].Get(),s.producer.Get(),s.done.Get(),s.valid.Get()};+ for(unsigned i=0;i<7;++i){+ HANDLE local=nullptr,remote=nullptr;+ const auto hr=device->CreateSharedHandle(shared[i],nullptr,GENERIC_ALL,nullptr,&local);+ const bool ok=SUCCEEDED(hr)&&DuplicateHandle(GetCurrentProcess(),local,s.process,&remote,0,FALSE,DUPLICATE_SAME_ACCESS);+ drop(local);if(!ok){TerminateProcess(s.process,126);drop(process.hThread);return s.fail(std::format("RDNA3 shared handle {} transfer hr=0x{:X} win32={}",i,unsigned(hr),GetLastError()));}+ init.handles[i]=uintptr_t(remote);+ }+ ResumeThread(process.hThread);drop(process.hThread);+ if(!send(s.toWorker,&init,sizeof(init))||!s.reply(0,180000))return false;+ s.stop=CreateEventW(nullptr,TRUE,FALSE,nullptr);if(!s.stop)return s.fail("RDNA3 worker monitor event failed");+ s.monitor=std::jthread([&s]{s.watch();});s.opened=true;+ log::info("amd-nr-rdna3",std::format("{}worker ready pid={} model={} internal={}x{} same-frame GPU interop; Veyra owns history",test?"CONTRACT TEST (not inference) ":"",process.dwProcessId,smallModel?"Small":"Original",w,h));+ return true;+}+bool Rdna3NrBackend::ready()const{return impl_->opened&&!impl_->failed.load();}+ID3D12Resource* Rdna3NrBackend::diagnosticProxyForTest()const{return impl_->image[0].Get();}+bool Rdna3NrBackend::admits(uint32_t w,uint32_t h)const{return ready()&&validExtent(w,h)&&w==impl_->w&&h==impl_->h;}+const std::string& Rdna3NrBackend::error()const{static const std::string dead="RX7000 NR worker failed; see amd-nr-rdna3 log";return impl_->failed&&impl_->error.empty()?dead:impl_->error;}+bool Rdna3NrBackend::recordInputs(ID3D12GraphicsCommandList* list,ID3D12Resource* color,uint64_t frame,bool reset,float intensity){+ auto& s=*impl_;if(!ready()||!s.healthy()||s.prepared||!list||!color||!frame||!std::isfinite(intensity))return s.fail("invalid/failed RDNA3 source transaction");+ const auto d=color->GetDesc();if(d.Width!=s.w||d.Height!=s.h||d.Format!=DXGI_FORMAT_R16G16B16A16_FLOAT)return s.fail("RDNA3 needs the selected linear RGBA16F internal extent");+ if(s.bound&&s.boundColor!=color)return s.fail("RDNA3 layer input resource changed without rebuilding the provider");+ if(!s.bound){+ D3D12_SHADER_RESOURCE_VIEW_DESC srv{};srv.ViewDimension=D3D12_SRV_DIMENSION_TEXTURE2D;srv.Shader4ComponentMapping=D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;srv.Texture2D.MipLevels=1;+ auto bindSrv=[&](ComputePass& pass,UINT i,ID3D12Resource* r){srv.Format=r->GetDesc().Format;s.views.stageSrv(r,&srv,pass.heap.Get(),i);};+ auto bindUav=[&](ComputePass& pass,UINT i,ID3D12Resource* r){D3D12_UNORDERED_ACCESS_VIEW_DESC u{};u.ViewDimension=D3D12_UAV_DIMENSION_TEXTURE2D;u.Format=r->GetDesc().Format;auto c=pass.heap->GetCPUDescriptorHandleForHeapStart();c.ptr+=i*pass.increment;s.device->CreateUnorderedAccessView(r,nullptr,&u,c);if(&pass==&s.encode&&i>=2){auto clear=s.clearHeap->GetCPUDescriptorHandleForHeapStart();clear.ptr+=(i-2)*pass.increment;s.device->CreateUnorderedAccessView(r,nullptr,&u,clear);}};+ bindSrv(s.encode,0,color);bindUav(s.encode,1,s.image[0].Get());bindUav(s.encode,2,s.image[2].Get());bindUav(s.encode,3,s.image[3].Get());+ bindSrv(s.decode,0,color);bindSrv(s.decode,1,s.image[0].Get());bindSrv(s.decode,2,s.image[1].Get());bindUav(s.decode,3,s.decoded.Get());s.bound=true;s.boundColor=color;+ D3D12_UNORDERED_ACCESS_VIEW_DESC flagUav{};flagUav.Format=DXGI_FORMAT_R32_UINT;flagUav.ViewDimension=D3D12_UAV_DIMENSION_BUFFER;flagUav.Buffer.NumElements=4;+ auto flagCpu=s.clearHeap->GetCPUDescriptorHandleForHeapStart();flagCpu.ptr+=2*s.encode.increment;s.device->CreateUnorderedAccessView(s.valid.Get(),nullptr,&flagUav,flagCpu);+ auto flagVisible=s.encode.heap->GetCPUDescriptorHandleForHeapStart();flagVisible.ptr+=4*s.encode.increment;s.device->CopyDescriptorsSimple(1,flagVisible,flagCpu,D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);+ D3D12_SHADER_RESOURCE_VIEW_DESC flagSrv{};flagSrv.Format=DXGI_FORMAT_R32_TYPELESS;flagSrv.ViewDimension=D3D12_SRV_DIMENSION_BUFFER;flagSrv.Shader4ComponentMapping=D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;flagSrv.Buffer.NumElements=4;flagSrv.Buffer.Flags=D3D12_BUFFER_SRV_FLAG_RAW;s.views.stageSrv(s.valid.Get(),&flagSrv,s.decode.heap.Get(),4);+ }+ barrier(list,s.image[0].Get(),kCommon,kUav);+ float constants[8]={1,1,1,0};memcpy(constants+4,&s.w,4);memcpy(constants+5,&s.h,4);+ const auto gpu=s.encode.heap->GetGPUDescriptorHandleForHeapStart();s.encode.bind(list,constants,gpu.ptr,gpu.ptr+s.encode.increment);list->Dispatch((s.w+15)/16,(s.h+15)/16,1);+ // Zero guidance deliberately starts the network over every frame. Estimated+ // temporal guidance/composition remains Veyra's, like the existing AMD route.+ ID3D12DescriptorHeap* heaps[]={s.encode.heap.Get()};list->SetDescriptorHeaps(1,heaps);+ const float zeros[4]={};+ for(unsigned i=2;i<4;++i){barrier(list,s.image[i].Get(),kCommon,kUav);auto g=gpu;g.ptr+=i*s.encode.increment;auto c=s.clearHeap->GetCPUDescriptorHandleForHeapStart();c.ptr+=(i-2)*s.encode.increment;+ list->ClearUnorderedAccessViewFloat(g,c,s.image[i].Get(),zeros,0,nullptr);barrier(list,s.image[i].Get(),kUav,kCommon);}+ barrier(list,s.valid.Get(),kCommon,kUav);auto flagGpu=gpu;flagGpu.ptr+=4*s.encode.increment;auto flagCpu=s.clearHeap->GetCPUDescriptorHandleForHeapStart();flagCpu.ptr+=2*s.encode.increment;const UINT clearFlag[4]={};list->ClearUnorderedAccessViewUint(flagGpu,flagCpu,s.valid.Get(),clearFlag,0,nullptr);barrier(list,s.valid.Get(),kUav,kCommon);+ barrier(list,s.image[0].Get(),kUav,D3D12_RESOURCE_STATE_COPY_SOURCE);barrier(list,s.image[1].Get(),kCommon,D3D12_RESOURCE_STATE_COPY_DEST);+ list->CopyResource(s.image[1].Get(),s.image[0].Get());+ barrier(list,s.image[0].Get(),D3D12_RESOURCE_STATE_COPY_SOURCE,kCommon);barrier(list,s.image[1].Get(),D3D12_RESOURCE_STATE_COPY_DEST,kCommon);+ ++s.sequence;s.sourceFrame=frame;s.prepared=true;s.enqueued=s.outputs=false;+ // Parameters are part of this source transaction, not process-global flags.+ rdna3::Evaluate request;request.h.sequence=s.sequence;request.intensity=std::clamp(intensity,0.f,1.f);request.reset=1;+ // Only send after producer commands have actually been submitted (enqueue).+ static_assert(sizeof(request)<=64); // stored without pointers+ s.error.clear();+ // Preserve controls between record and enqueue without touching another layer.+ s.pending=request;+ (void)reset;return true;+}+bool Rdna3NrBackend::enqueue(){+ auto& s=*impl_;if(!ready()||!s.prepared||s.enqueued||!s.healthy())return s.fail("RDNA3 enqueue without a prepared source");+ const auto hr=s.queue->Signal(s.producer.Get(),s.sequence);if(hrFailed(__LINE__,hr))return s.fail(std::format("RDNA3 producer signal hr=0x{:X}",unsigned(hr)));+ if(!send(s.toWorker,&s.pending,sizeof(s.pending))||!s.reply(s.sequence,5000))return false;+ const auto completed=s.done->GetCompletedValue();if(completed==UINT64_MAX)return s.fail("RDNA3 device removed");+ if(completed>=s.queued.load())s.queuedAt=GetTickCount64();s.queued=s.sequence;+ const auto wait=s.queue->Wait(s.done.Get(),s.sequence);if(hrFailed(__LINE__,wait))return s.fail(std::format("RDNA3 consumer wait hr=0x{:X}",unsigned(wait)));+ s.enqueued=true;return true;+}+bool Rdna3NrBackend::recordOutputs(ID3D12GraphicsCommandList* list,ID3D12Resource* destination){+ auto& s=*impl_;if(!ready()||!s.enqueued||s.outputs||!list||!destination)return s.fail("RDNA3 output without current-frame evaluation");+ barrier(list,s.image[0].Get(),kCommon,kRead);barrier(list,s.image[1].Get(),kCommon,kRead);barrier(list,s.decoded.Get(),kCommon,kUav);barrier(list,s.valid.Get(),kCommon,kRead);+ // Same AMD host contract as transfer_strength in the existing runtime:+ // strength changes mix the full model result, never churn model instances.+ float constants[8]={1,s.pending.intensity,1,0};memcpy(constants+4,&s.w,4);memcpy(constants+5,&s.h,4);+ const auto gpu=s.decode.heap->GetGPUDescriptorHandleForHeapStart();s.decode.bind(list,constants,gpu.ptr,gpu.ptr+3*s.decode.increment,gpu.ptr+4*s.decode.increment);list->Dispatch((s.w+15)/16,(s.h+15)/16,1);+ barrier(list,s.decoded.Get(),kUav,D3D12_RESOURCE_STATE_COPY_SOURCE);list->CopyResource(destination,s.decoded.Get());+ barrier(list,s.decoded.Get(),D3D12_RESOURCE_STATE_COPY_SOURCE,kCommon);barrier(list,s.image[0].Get(),kRead,kCommon);barrier(list,s.image[1].Get(),kRead,kCommon);+ barrier(list,s.valid.Get(),kRead,kCommon);+ s.outputs=true;return true;+}+bool Rdna3NrBackend::retireSubmitted(){auto& s=*impl_;if(!s.outputs)return true;if(!ready())return false;s.prepared=s.enqueued=s.outputs=false;return true;}+void Rdna3NrBackend::close()noexcept{+ if(!impl_)return;auto& s=*impl_;+ s.closing=true;+ if(s.process&&WaitForSingleObject(s.process,0)==WAIT_TIMEOUT){+ // This signal follows the last output consumer on the actual graph queue.+ Header end{kMagic,kVersion,sizeof(Header),Op::Stop,s.queued.load()+1};+ if(s.queue&&s.producer)s.queue->Signal(s.producer.Get(),end.sequence);+ send(s.toWorker,&end,sizeof(end));+ if(WaitForSingleObject(s.process,3000)==WAIT_TIMEOUT){log::warn("amd-nr-rdna3","worker close timed out; terminating owned worker");TerminateProcess(s.process,125);WaitForSingleObject(s.process,1000);if(s.done)s.done->Signal(UINT64_MAX-1);}+ }+ if(s.stop)SetEvent(s.stop);if(s.monitor.joinable())s.monitor.join();+ drop(s.toWorker);drop(s.fromWorker);drop(s.process);drop(s.job);drop(s.stop);s.opened=false;+}+}diff --git a/src/pipeline/Rdna3NrWorker.cpp b/src/pipeline/Rdna3NrWorker.cppnew file mode 100644index 00000000..dea7f707--- /dev/null+++ b/src/pipeline/Rdna3NrWorker.cpp@@ -0,0 +1,207 @@+// SPDX-License-Identifier: GPL-3.0-only+// Isolated host for RedDukeDev's MIT network layer. Never a game proxy/add-on.+#define WIN32_LEAN_AND_MEAN+#include <windows.h>+#include <d3d12.h>+#include <dxgi1_6.h>+#include <wrl/client.h>+#include "veyra/pipeline/Rdna3NrProtocol.h"+#include "veyra/pipeline/AmdNrProvider.h"+#ifndef VEYRA_RDNA3_CONTRACT_WORKER+#include "runtime/core/network.h"+#endif+#include <cstdio>+#include <filesystem>+#include <string>+#include <algorithm>+#include <cmath>+#include <vector>+#include <cstring>++using Microsoft::WRL::ComPtr;+using namespace veyra::pipeline::rdna3;+namespace {+FILE* logfile=nullptr;+bool hrFailed(int line,HRESULT hr){if(SUCCEEDED(hr))return false;if(logfile){fprintf(logfile,"worker line=%d hr=0x%08X\n",line,unsigned(hr));fflush(logfile);}return true;}+void logLine(int level,const char* message){if(logfile){fprintf(logfile,"level=%d %s\n",level,message);fflush(logfile);}}+bool readAll(HANDLE pipe,void* data,DWORD size){DWORD offset=0;while(offset<size){DWORD n=0;if(!ReadFile(pipe,static_cast<char*>(data)+offset,size-offset,&n,nullptr)||!n)return false;offset+=n;}return true;}+bool answer(HANDLE pipe,uint64_t sequence,int result,const std::string& message){Reply r;r.h.sequence=sequence;r.result=result;memcpy(r.message.data(),message.data(),std::min(message.size(),r.message.size()-1));DWORD n=0;return WriteFile(pipe,&r,sizeof(r),&n,nullptr)&&n==sizeof(r);}+bool safePath(const std::array<wchar_t,1024>& s){return s.back()==0&&std::filesystem::path(s.data()).is_absolute();}+void transition(ID3D12GraphicsCommandList* list,ID3D12Resource* resource,D3D12_RESOURCE_STATES from,D3D12_RESOURCE_STATES to){D3D12_RESOURCE_BARRIER b{};b.Type=D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;b.Transition={resource,D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,from,to};list->ResourceBarrier(1,&b);}+bool waitCpu(ID3D12Fence* fence,uint64_t value,DWORD timeout){+ if(fence->GetCompletedValue()>=value)return true;HANDLE event=CreateEventW(nullptr,FALSE,FALSE,nullptr);if(!event)return false;+ const bool ok=SUCCEEDED(fence->SetEventOnCompletion(value,event))&&WaitForSingleObject(event,timeout)==WAIT_OBJECT_0;CloseHandle(event);return ok;+}+struct Worker {+ Init init;+ ComPtr<ID3D12Device> device;+ ComPtr<ID3D12Resource> image[4],valid;+ ComPtr<ID3D12Fence> producer,done;+ ComPtr<ID3D12CommandQueue> queue;+ ComPtr<ID3D12CommandAllocator> allocator;+ ComPtr<ID3D12GraphicsCommandList> list;+ std::array<ComPtr<ID3D12CommandAllocator>,8> resultAlloc;+ std::array<ComPtr<ID3D12GraphicsCommandList2>,8> resultList;+ uint64_t last=0;bool started=false;+ std::string error;+#ifndef VEYRA_RDNA3_CONTRACT_WORKER+ dlss5nr::Network network;+ dlss5nr::SharedImage shared[4];+ void* producerSem=nullptr;void* doneSem=nullptr;+ ComPtr<ID3D12Fence> cudaDone;+ HANDLE cudaDoneHandle=nullptr;+ dlss5nr::NetworkControls controls;+#endif+ bool open(){+ 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;}+ 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+ ComPtr<IDXGIFactory4> factory;ComPtr<IDXGIAdapter1> adapter;+ const LUID luid{uint32_t(init.adapterLuid),LONG(init.adapterLuid>>32)};+ if(hrFailed(__LINE__,CreateDXGIFactory1(IID_PPV_ARGS(&factory)))||hrFailed(__LINE__,factory->EnumAdapterByLuid(luid,IID_PPV_ARGS(&adapter)))||+ hrFailed(__LINE__,D3D12CreateDevice(adapter.Get(),D3D_FEATURE_LEVEL_12_0,IID_PPV_ARGS(&device)))){error="selected D3D12 adapter LUID is unavailable";return false;}+ DXGI_ADAPTER_DESC1 desc{};adapter->GetDesc1(&desc);+#ifndef VEYRA_RDNA3_CONTRACT_WORKER+ if(veyra::pipeline::amdNrProvider(desc.VendorId,desc.Description)!=veyra::pipeline::AmdNrProvider::RedDukeRdna3){error="this worker requires the selected AMD RX7000 adapter";return false;}+ // HIP SDK installs may set HIP_PATH without changing global PATH. Load+ // the actual HIP7 library absolutely in this worker only.+ wchar_t system[MAX_PATH]{},sdk[32768]{};GetSystemDirectoryW(system,MAX_PATH);+ auto hip=std::filesystem::path(system)/L"amdhip64_7.dll";+ if(!std::filesystem::is_regular_file(hip)){+ const auto n=GetEnvironmentVariableW(L"HIP_PATH",sdk,DWORD(std::size(sdk)));+ if(!n||n>=std::size(sdk)||!std::filesystem::path(sdk).is_absolute()){error="AMD HIP7 is unavailable in the driver or HIP_PATH";return false;}+ hip=std::filesystem::path(sdk)/L"bin"/L"amdhip64_7.dll";+ }+ if(!LoadLibraryExW(hip.c_str(),nullptr,LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR|LOAD_LIBRARY_SEARCH_SYSTEM32)){error="AMD HIP7 load failed win32="+std::to_string(GetLastError());return false;}+ const auto snippet=std::filesystem::path(init.runtime.data())/L"nvngx_dlssnr.dll";+ DWORD ignored=0;const DWORD size=GetFileVersionInfoSizeW(snippet.c_str(),&ignored);std::vector<uint8_t> version(size);VS_FIXEDFILEINFO* info=nullptr;UINT count=0;+ if(!size||!GetFileVersionInfoW(snippet.c_str(),0,size,version.data())||!VerQueryValueW(version.data(),L"\\",reinterpret_cast<void**>(&info),&count)||+ !info||info->dwFileVersionMS!=MAKELONG(9,310)||info->dwFileVersionLS!=MAKELONG(0,16)){error="RDNA3 packaged kernels/cache require NR 310.9.16.0 (Small and Original)";return false;}+#endif+ for(unsigned i=0;i<4;++i){+ const HANDLE handle=reinterpret_cast<HANDLE>(uintptr_t(init.handles[i]));+ const auto hr=device->OpenSharedHandle(handle,IID_PPV_ARGS(&image[i]));if(hrFailed(__LINE__,hr)){error="shared texture could not be opened on the selected adapter";return false;}+ const auto d=image[i]->GetDesc();const DXGI_FORMAT formats[]={DXGI_FORMAT_R16G16B16A16_FLOAT,DXGI_FORMAT_R16G16B16A16_FLOAT,DXGI_FORMAT_R32_FLOAT,DXGI_FORMAT_R16G16_FLOAT};+ if(d.Dimension!=D3D12_RESOURCE_DIMENSION_TEXTURE2D||d.Width!=init.width||d.Height!=init.height||d.Format!=formats[i]){error="shared texture extent/format mismatch";return false;}+ }+ if(hrFailed(__LINE__,device->OpenSharedHandle(reinterpret_cast<HANDLE>(uintptr_t(init.handles[4])),IID_PPV_ARGS(&producer)))||+ hrFailed(__LINE__,device->OpenSharedHandle(reinterpret_cast<HANDLE>(uintptr_t(init.handles[5])),IID_PPV_ARGS(&done)))){error="shared fence open failed";return false;}+ if(hrFailed(__LINE__,device->OpenSharedHandle(reinterpret_cast<HANDLE>(uintptr_t(init.handles[6])),IID_PPV_ARGS(&valid)))||valid->GetDesc().Dimension!=D3D12_RESOURCE_DIMENSION_BUFFER||valid->GetDesc().Width<16){error="shared validity buffer is missing or malformed";return false;}+ D3D12_FEATURE_DATA_D3D12_OPTIONS3 features{};+ if(hrFailed(__LINE__,device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS3,&features,sizeof(features)))||!(features.WriteBufferImmediateSupportFlags&D3D12_COMMAND_LIST_SUPPORT_FLAG_DIRECT)){error="direct-queue GPU completion markers are unavailable";return false;}+ D3D12_COMMAND_QUEUE_DESC q{};q.Type=D3D12_COMMAND_LIST_TYPE_DIRECT;+ if(hrFailed(__LINE__,device->CreateCommandQueue(&q,IID_PPV_ARGS(&queue)))||hrFailed(__LINE__,device->CreateCommandAllocator(q.Type,IID_PPV_ARGS(&allocator)))||+ hrFailed(__LINE__,device->CreateCommandList(0,q.Type,allocator.Get(),nullptr,IID_PPV_ARGS(&list)))){error="worker initialization queue creation failed";return false;}+ for(size_t i=0;i<resultAlloc.size();++i){+ ComPtr<ID3D12GraphicsCommandList> commands;+ if(hrFailed(__LINE__,device->CreateCommandAllocator(q.Type,IID_PPV_ARGS(&resultAlloc[i])))||hrFailed(__LINE__,device->CreateCommandList(0,q.Type,resultAlloc[i].Get(),nullptr,IID_PPV_ARGS(&commands)))||hrFailed(__LINE__,commands.As(&resultList[i]))||hrFailed(__LINE__,resultList[i]->Close())){error="bounded worker result queue creation failed";return false;}+ }+ // Initialization only: deterministic blank warm-up. There is no pixel+ // readback and the steady-state inference path has no CPU fence wait.+ ComPtr<ID3D12DescriptorHeap> gpuHeap,cpuHeap;D3D12_DESCRIPTOR_HEAP_DESC hd{};hd.Type=D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;hd.NumDescriptors=4;+ if(hrFailed(__LINE__,device->CreateDescriptorHeap(&hd,IID_PPV_ARGS(&cpuHeap))))return false;hd.Flags=D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;+ if(hrFailed(__LINE__,device->CreateDescriptorHeap(&hd,IID_PPV_ARGS(&gpuHeap))))return false;+ const auto increment=device->GetDescriptorHandleIncrementSize(hd.Type);ID3D12DescriptorHeap* heaps[]={gpuHeap.Get()};list->SetDescriptorHeaps(1,heaps);const float zero[4]={};+ for(unsigned i=0;i<4;++i){+ auto cpu=cpuHeap->GetCPUDescriptorHandleForHeapStart();cpu.ptr+=i*increment;auto visible=gpuHeap->GetCPUDescriptorHandleForHeapStart();visible.ptr+=i*increment;auto gpu=gpuHeap->GetGPUDescriptorHandleForHeapStart();gpu.ptr+=i*increment;+ D3D12_UNORDERED_ACCESS_VIEW_DESC u{};u.ViewDimension=D3D12_UAV_DIMENSION_TEXTURE2D;u.Format=image[i]->GetDesc().Format;+ device->CreateUnorderedAccessView(image[i].Get(),nullptr,&u,cpu);device->CopyDescriptorsSimple(1,visible,cpu,hd.Type);+ transition(list.Get(),image[i].Get(),D3D12_RESOURCE_STATE_COMMON,D3D12_RESOURCE_STATE_UNORDERED_ACCESS);list->ClearUnorderedAccessViewFloat(gpu,cpu,image[i].Get(),zero,0,nullptr);+ transition(list.Get(),image[i].Get(),D3D12_RESOURCE_STATE_UNORDERED_ACCESS,D3D12_RESOURCE_STATE_COMMON);+ }+ if(hrFailed(__LINE__,list->Close()))return false;ID3D12CommandList* commands[]={list.Get()};queue->ExecuteCommandLists(1,commands);+ ComPtr<ID3D12Fence> initial;if(hrFailed(__LINE__,device->CreateFence(0,D3D12_FENCE_FLAG_NONE,IID_PPV_ARGS(&initial)))||hrFailed(__LINE__,queue->Signal(initial.Get(),1))||!waitCpu(initial.Get(),1,30000)){error="worker blank warm-up submission failed";return false;}+#ifndef VEYRA_RDNA3_CONTRACT_WORKER+ dlss5nr::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;}+ network.set_copy_mode(false);controls.preset=int(init.preset);+ if(!network.create_feature(init.width,init.height,controls,error))return false;+ 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;}+ 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;+ if(!network.evaluate(warm,error))return false;+ logLine(2,"native Small/Original warm-up complete; shared GPU semaphores required, no async old-frame residual");+#else+ logLine(2,"CONTRACT TEST WORKER: copies proxy; does not execute NR or validate Radeon inference");+#endif+ started=true;return true;+ }+ bool publish(uint64_t sequence,bool copy){+ const size_t index=size_t((sequence-1)%resultAlloc.size());+ if(sequence>resultAlloc.size()&&done->GetCompletedValue()<sequence-resultAlloc.size()){error="worker exceeded its bounded GPU result queue";return false;}+ auto* commands=resultList[index].Get();+ if(hrFailed(__LINE__,resultAlloc[index]->Reset())||hrFailed(__LINE__,commands->Reset(resultAlloc[index].Get(),nullptr))){error="worker result allocator reset failed";return false;}+#ifdef VEYRA_RDNA3_CONTRACT_WORKER+ if(hrFailed(__LINE__,queue->Wait(producer.Get(),sequence))){error="test producer GPU wait failed";return false;}+#else+ if(hrFailed(__LINE__,queue->Wait(cudaDone.Get(),sequence))){error="network completion GPU wait failed";return false;}+#endif+ if(copy){+ transition(commands,image[0].Get(),D3D12_RESOURCE_STATE_COMMON,D3D12_RESOURCE_STATE_COPY_SOURCE);transition(commands,image[1].Get(),D3D12_RESOURCE_STATE_COMMON,D3D12_RESOURCE_STATE_COPY_DEST);+ commands->CopyResource(image[1].Get(),image[0].Get());transition(commands,image[0].Get(),D3D12_RESOURCE_STATE_COPY_SOURCE,D3D12_RESOURCE_STATE_COMMON);transition(commands,image[1].Get(),D3D12_RESOURCE_STATE_COPY_DEST,D3D12_RESOURCE_STATE_COMMON);+ }+ bool mark=true;+#ifdef VEYRA_RDNA3_CONTRACT_WORKER+ mark=!std::filesystem::exists(std::filesystem::path(init.runtime.data())/L"contract-no-result");+#endif+ if(mark){+ transition(commands,valid.Get(),D3D12_RESOURCE_STATE_COMMON,D3D12_RESOURCE_STATE_COPY_DEST);+ D3D12_WRITEBUFFERIMMEDIATE_PARAMETER marker{valid->GetGPUVirtualAddress(),1};+ commands->WriteBufferImmediate(1,&marker,nullptr);+ transition(commands,valid.Get(),D3D12_RESOURCE_STATE_COPY_DEST,D3D12_RESOURCE_STATE_COMMON);+ }+ if(hrFailed(__LINE__,commands->Close())){error="result marker list close failed";return false;}+ ID3D12CommandList* submitted[]={commands};queue->ExecuteCommandLists(1,submitted);+ if(hrFailed(__LINE__,queue->Signal(done.Get(),sequence))){error="validated result fence signal failed";return false;}+ return true;+ }+ bool evaluate(const Evaluate& e){+ if(!validHeader(e.h,Op::Evaluate,sizeof(e))||e.h.sequence!=last+1||e.reset!=1||!std::isfinite(e.intensity)||e.intensity<0||e.intensity>1){error="invalid/stale source frame transaction";return false;}+#ifdef VEYRA_RDNA3_CONTRACT_WORKER+ if(!publish(e.h.sequence,true))return false;+#else+ // Like the existing AMD provider's transfer_strength, model strength is+ // applied by the host decoder. Create once: upstream explicitly warns+ // that rebuilding a feature on every slider update can hang the driver.+ if(!network.wait_fence(producerSem,e.h.sequence,error))return false;+ dlss5nr::EvaluateDesc d;d.color=&shared[0];d.output=&shared[1];d.depth=&shared[2];d.motion=&shared[3];d.controls=controls;d.reset=true;d.synchronise=false;+ if(!network.evaluate(d,error)||!network.signal_fence(doneSem,e.h.sequence,error)||!publish(e.h.sequence,false))return false;+#endif+ last=e.h.sequence;return true;+ }+ void close(uint64_t finalConsumer){+ // The parent signals producer after its final output consumer. Releasing+ // HIP imports before that would race another queue's read of the image.+ if(started&&finalConsumer&&!waitCpu(producer.Get(),finalConsumer,5000))logLine(0,"final consumer drain failed");+#ifndef VEYRA_RDNA3_CONTRACT_WORKER+ if(started){for(auto& image:shared)network.release(image);network.destroy_fence(producerSem);network.destroy_fence(doneSem);network.shutdown();}+ if(cudaDoneHandle)CloseHandle(cudaDoneHandle);+#endif+ for(auto h:init.handles)if(h)CloseHandle(reinterpret_cast<HANDLE>(uintptr_t(h)));+ if(logfile){fclose(logfile);logfile=nullptr;}+ }+};+}+int wmain(int argc,wchar_t** argv){+ if(argc!=3)return 2;+ 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;+ 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;}+ if(!validHeader(h,Op::Evaluate,sizeof(Evaluate)))return 6;+ Evaluate e;e.h=h;if(!readAll(input,reinterpret_cast<char*>(&e)+sizeof(h),sizeof(e)-sizeof(h)))return 7;+ const bool ok=w.evaluate(e);if(!answer(output,e.h.sequence,ok?0:1,w.error)||!ok)return 8;+#ifdef VEYRA_RDNA3_CONTRACT_WORKER+ if(std::filesystem::exists(std::filesystem::path(w.init.runtime.data())/L"contract-crash-after-ack"))return 99;+#endif+ }+}diff --git a/src/ui/bridge/Hardware.cpp b/src/ui/bridge/Hardware.cppindex 97ea3204..d863cf0d 100644--- a/src/ui/bridge/Hardware.cpp+++ b/src/ui/bridge/Hardware.cpp@@ -1,5 +1,7 @@// QML bridge: Hardware responsibilities.#include "../QmlPlayerBridge_p.h"+#include "veyra/pipeline/Rdna3NrBackend.h"+#include "veyra/pipeline/AmdNrProvider.h"namespace veyra::ui {@@ -60,6 +62,7 @@ ui::EffectGpu effectGpu() {result.blackwell = name.contains("RTX 50", Qt::CaseInsensitive) || name.contains("Blackwell", Qt::CaseInsensitive);result.ada = name.contains("RTX 40", Qt::CaseInsensitive) || name.contains("Ada", Qt::CaseInsensitive);result.rx9000 = name.contains("RX 90", Qt::CaseInsensitive);+ result.rx7000 = pipeline::amdNrProvider(d->VendorId,d->Description)==pipeline::AmdNrProvider::RedDukeRdna3;return result;}@@ -81,9 +84,14 @@ static QVariantMap scanEffectCapabilities() {out["nrAuto"]=QVariantMap{{"available",gpu.vendor==0x10DE&&gpu.deviceId==0x2f04&&out.value("nr0").toMap().value("available").toBool()},{"reason",gpu.deviceId!=0x2f04?QObject::tr("自动 NR 当前仅验证 RTX 5070"):!out.value("nr0").toMap().value("available").toBool()?QObject::tr("当前包缺少此功能的运行组件"):QString{}}};add("nr3", H::NvidiaNr50, exists(nr / "nr-original/nvngx_dlssnr.dll"), QObject::tr("需要 NVIDIA RTX 50 / Blackwell"));- add("nr4", H::AmdNr, exists(nr / "../amd-nr/LmxxfNrRuntime.dll"), QObject::tr("需要 AMD RX 9000"));+ const auto rdna3Directory=(nr/"../amd-nr-rdna3").lexically_normal();+ const bool amdNrFiles=gpu.rx7000?pipeline::Rdna3NrBackend::runtimeAvailable(rdna3Directory):exists(nr / "../amd-nr/LmxxfNrRuntime.dll");+ add("nr4", H::AmdNr, amdNrFiles, QObject::tr("需要 AMD RX 7000 / 9000"));+ if(gpu.rx7000&&!amdNrFiles){auto cap=out.value("nr4").toMap();cap["reason"]=QObject::tr("当前包缺少 RX 7000 NR 运行组件");out["nr4"]=cap;}wchar_t systemDir[MAX_PATH]{};- if (GetSystemDirectoryW(systemDir, MAX_PATH) && !exists(std::filesystem::path(systemDir) / "amdhip64_7.dll") && !GetModuleHandleW(L"amdhip64_7.dll")) {+ const bool hipMissing=gpu.rx7000?!pipeline::Rdna3NrBackend::hipRuntimeAvailable():+ GetSystemDirectoryW(systemDir, MAX_PATH)&&!exists(std::filesystem::path(systemDir)/"amdhip64_7.dll")&&!GetModuleHandleW(L"amdhip64_7.dll");+ if (hipMissing) {auto cap = out.value("nr4").toMap();if (cap.value("available").toBool()) { cap["available"] = false; cap["reason"] = QObject::tr("需要 AMD HIP 7 驱动运行组件"); out["nr4"] = cap; }}@@ -200,7 +208,7 @@ QVariantMap QmlPlayerBridge::effectAvailability(const QString& id) const {QVariantList QmlPlayerBridge::nrRuntimeChoices() const {QVariantList choices;const auto caps = effectCapabilities();- for (const auto& entry : std::initializer_list<std::pair<int, QString>>{{2, "RTX 20–50 · SF 310.9.16"}, {3, tr("RTX 50 · NVIDIA 原版")}, {4, tr("RX 9000 · lmxxf(实验)")}}) {+ for (const auto& entry : std::initializer_list<std::pair<int, QString>>{{2, "RTX 20–50 · SF 310.9.16"}, {3, tr("RTX 50 · NVIDIA 原版")}, {4, effectGpu().rx7000?tr("RX 7000 · RedDuke(实验)"):tr("RX 9000 · lmxxf(实验)")}}) {const auto cap = caps.value("nr" + QString::number(entry.first)).toMap();choices << QVariantMap{{"id", QString::number(entry.first)}, {"label", entry.second}, {"disabled", !cap.value("available").toBool()}, {"note", cap.value("reason")}};}diff --git a/tests/integration/Rdna3NrContractTests.cpp b/tests/integration/Rdna3NrContractTests.cppnew file mode 100644index 00000000..05dd8e78--- /dev/null+++ b/tests/integration/Rdna3NrContractTests.cpp@@ -0,0 +1,121 @@+// SPDX-License-Identifier: GPL-3.0-only+// Real D3D12 cross-process GPU-contract tests. The test worker copies the proxy:+// these results are deliberately NOT Radeon NR/model inference evidence.+#include "veyra/pipeline/Rdna3NrBackend.h"+#include "veyra/pipeline/GpuPassUtils.h"+#include "veyra/gfx/D3D12DeviceContext.h"+#include "veyra/gfx/CommandSlotRing.h"+#include "veyra/parity/RenoDxParityCodec.h"+#include <cstdio>+#include <vector>+#include <array>+#include <fstream>+#include <chrono>+#include <cmath>+using namespace veyra;+namespace {+int checks=0,failures=0;+void check(bool ok,const char* name){++checks;if(!ok)++failures;printf("%s %s\n",ok?"PASS":"FAIL",name);fflush(stdout);}+void transition(ID3D12GraphicsCommandList* l,ID3D12Resource* r,D3D12_RESOURCE_STATES a,D3D12_RESOURCE_STATES b){D3D12_RESOURCE_BARRIER v{};v.Type=D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;v.Transition={r,D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,a,b};l->ResourceBarrier(1,&v);}+double halfValue(uint16_t h){const auto exponent=(h>>10)&31;const double v=exponent?std::ldexp(1.+(h&1023)/1024.,int(exponent)-15):std::ldexp(double(h&1023),-24);return h&0x8000?-v:v;}+double halfQuantise(double value){if(value==0)return 0;const int scale=std::min(24,10-std::ilogb(std::abs(value)));return std::ldexp(std::nearbyint(std::ldexp(value,scale)),-scale);}+}+int wmain(int argc,wchar_t** argv){+ if(argc!=3)return 2;+ const auto root=std::filesystem::absolute(argv[1]),worker=std::filesystem::absolute(argv[2]);+ if(std::filesystem::exists(root))return 2;std::filesystem::create_directories(root);+ gfx::D3D12DeviceContext ctx;gfx::DeviceContextDesc cd{};cd.enableDebugLayer=true;Status st=Status::Ok;+ if(!ctx.initialize(cd,st))return 2;+ gfx::CommandSlotRing ring;if(!ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),4,st))return 2;+ constexpr uint32_t w=160,h=90;const uint32_t pitch=(w*8+255)&~255u;+ auto input=pipeline::makeTexture(ctx.device(),w,h,DXGI_FORMAT_R16G16B16A16_FLOAT,true);+ auto destination=pipeline::makeTexture(ctx.device(),w,h,DXGI_FORMAT_R16G16B16A16_FLOAT,true);+ auto upload=pipeline::makeUploadBuffer(ctx.device(),uint64_t(pitch)*h);+ if(!input||!destination||!upload)return 2;+ auto inputState=D3D12_RESOURCE_STATE_COMMON;auto outputState=D3D12_RESOURCE_STATE_COMMON;+ auto fill=[&](std::array<uint16_t,4> color){+ if(!ring.drainQueue())return false;+ void* data=nullptr;if(FAILED(upload->Map(0,nullptr,&data)))return false;+ for(uint32_t y=0;y<h;++y)for(uint32_t x=0;x<w;++x)memcpy(static_cast<char*>(data)+y*pitch+x*8,color.data(),8);upload->Unmap(0,nullptr);+ uint32_t slot=0;auto* list=ring.acquireNext(slot,st);if(!list)return false;+ transition(list,input.Get(),inputState,D3D12_RESOURCE_STATE_COPY_DEST);+ D3D12_TEXTURE_COPY_LOCATION src{},dst{};src.pResource=upload.Get();src.Type=D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;src.PlacedFootprint.Footprint={DXGI_FORMAT_R16G16B16A16_FLOAT,w,h,1,pitch};dst.pResource=input.Get();dst.Type=D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;+ list->CopyTextureRegion(&dst,0,0,0,&src,nullptr);transition(list,input.Get(),D3D12_RESOURCE_STATE_COPY_DEST,D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);inputState=D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;+ return ring.submitAndSignal(slot);+ };+ auto verify=[&](std::array<uint16_t,4> color,bool raw=false,ID3D12Resource* encoded=nullptr,float strength=1){+ D3D12_HEAP_PROPERTIES hp{};hp.Type=D3D12_HEAP_TYPE_READBACK;D3D12_RESOURCE_DESC d{};d.Dimension=D3D12_RESOURCE_DIMENSION_BUFFER;d.Width=uint64_t(pitch)*h;d.Height=d.DepthOrArraySize=d.MipLevels=1;d.SampleDesc.Count=1;d.Layout=D3D12_TEXTURE_LAYOUT_ROW_MAJOR;+ pipeline::ComPtr<ID3D12Resource> readback;if(FAILED(ctx.device()->CreateCommittedResource(&hp,D3D12_HEAP_FLAG_NONE,&d,D3D12_RESOURCE_STATE_COPY_DEST,nullptr,IID_PPV_ARGS(&readback))))return false;+ uint32_t slot=0;auto* list=ring.acquireNext(slot,st);if(!list)return false;+ transition(list,destination.Get(),outputState,D3D12_RESOURCE_STATE_COPY_SOURCE);outputState=D3D12_RESOURCE_STATE_COPY_SOURCE;+ D3D12_TEXTURE_COPY_LOCATION src{},dst{};src.pResource=destination.Get();src.Type=D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;dst.pResource=readback.Get();dst.Type=D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;dst.PlacedFootprint.Footprint={DXGI_FORMAT_R16G16B16A16_FLOAT,w,h,1,pitch};list->CopyTextureRegion(&dst,0,0,0,&src,nullptr);+ if(!ring.submitAndSignal(slot)||!ring.drainQueue())return false;+ // Compare against the independent double-precision CPU golden, with+ // the FP16 proxy quantisation of the actual upstream CUDA interface.+ const parity::RgbF original{halfValue(color[0]),halfValue(color[1]),halfValue(color[2])};+ const auto proxy=parity::encodeProxyLinear(original,{});+ double stored[]={halfQuantise(proxy.r),halfQuantise(proxy.g),halfQuantise(proxy.b)};+ if(encoded){+ D3D12_RESOURCE_DESC ed=d;ed.Width=256;pipeline::ComPtr<ID3D12Resource> proxyReadback;+ if(FAILED(ctx.device()->CreateCommittedResource(&hp,D3D12_HEAP_FLAG_NONE,&ed,D3D12_RESOURCE_STATE_COPY_DEST,nullptr,IID_PPV_ARGS(&proxyReadback))))return false;+ uint32_t es=0;auto* el=ring.acquireNext(es,st);if(!el)return false;+ transition(el,encoded,D3D12_RESOURCE_STATE_COMMON,D3D12_RESOURCE_STATE_COPY_SOURCE);+ D3D12_TEXTURE_COPY_LOCATION from{},to{};from.pResource=encoded;from.Type=D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;to.pResource=proxyReadback.Get();to.Type=D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;to.PlacedFootprint.Footprint={DXGI_FORMAT_R16G16B16A16_FLOAT,1,1,1,256};const D3D12_BOX box{0,0,0,1,1,1};el->CopyTextureRegion(&to,0,0,0,&from,&box);+ transition(el,encoded,D3D12_RESOURCE_STATE_COPY_SOURCE,D3D12_RESOURCE_STATE_COMMON);+ if(!ring.submitAndSignal(es)||!ring.drainQueue())return false;+ void* ep=nullptr;if(FAILED(proxyReadback->Map(0,nullptr,&ep)))return false;+ for(unsigned c=0;c<3;++c){uint16_t value=0;memcpy(&value,static_cast<char*>(ep)+c*2,2);stored[c]=halfValue(value);}proxyReadback->Unmap(0,nullptr);+ const auto encodingError=std::max({std::abs(stored[0]-proxy.r),std::abs(stored[1]-proxy.g),std::abs(stored[2]-proxy.b)});+ printf("diagnostic encoded=(%.9f,%.9f,%.9f) FP64=(%.9f,%.9f,%.9f) maxError=%.9f\n",stored[0],stored[1],stored[2],proxy.r,proxy.g,proxy.b,encodingError);+ check(encodingError<=0.0005,"FP16 proxy encoding matches independent FP64 transfer within one FP16 ULP");+ }+ const parity::RgbF decodedProxy{parity::srgbDecode(stored[0]),parity::srgbDecode(stored[1]),parity::srgbDecode(stored[2])};+ const auto expected=raw?original:parity::parityDecode(original,decodedProxy,decodedProxy,{1,strength,1});const double golden[]={expected.r,expected.g,expected.b,1};+ void* data=nullptr;if(FAILED(readback->Map(0,nullptr,&data)))return false;double maximum=0;+ for(uint32_t y=0;y<h;++y)for(uint32_t x=0;x<w;++x)for(unsigned c=0;c<4;++c){uint16_t value=0;memcpy(&value,static_cast<char*>(data)+y*pitch+x*8+c*2,2);maximum=std::max(maximum,std::abs(halfValue(value)-golden[c]));}+ readback->Unmap(0,nullptr);printf("diagnostic maximum error against CPU parity golden=%.9f\n",maximum);return maximum<=(raw?0:0.0005);+ };+ auto prepareDir=[&](const wchar_t* name){const auto p=root/name;std::filesystem::create_directories(p);std::filesystem::copy_file(worker,p/L"veyra_amd_nr_test_worker.exe");return p;};+ const auto smallDir=prepareDir(L"small"),originalDir=prepareDir(L"original");+ pipeline::Rdna3NrBackend smallNr,originalNr;+ check(!pipeline::Rdna3NrBackend::runtimeAvailable(root),"missing package is never advertised as NR available");+ check(!smallNr.open(root,ctx.device(),ctx.directQueue(),w,h,true),"product refuses incomplete runtime before launching");+ check(smallNr.openContractTest(smallDir,ctx.device(),ctx.directQueue(),w,h,true),"Small contract worker opens on exact host GPU LUID");+ check(originalNr.openContractTest(originalDir,ctx.device(),ctx.directQueue(),w,h,false),"Original contract worker coexists independently");+ if(!smallNr.ready()||!originalNr.ready())return 1;+ check(!smallNr.admits(w+1,h)&&smallNr.admits(w,h),"provider accepts only its selected internal extent");+ check(!smallNr.enqueue(),"enqueue without prepared source is rejected");+ const std::array<std::array<uint16_t,4>,4> colors={{{0x3400,0x3800,0x3a00,0x3c00},{0x3800,0x3000,0x3400,0x3c00},{0x3a00,0x3400,0x3800,0x3c00},{0x3000,0x3a00,0x3400,0x3c00}}};+ for(unsigned index=0;index<colors.size();++index){+ auto& nr=index%2?originalNr:smallNr;+ check(fill(colors[index]),"upload distinct current source frame (diagnostic only)");+ uint32_t slot=0;auto* list=ring.acquireNext(slot,st);if(!list)return 2;+ check(!nr.recordOutputs(list,destination.Get()),"stale result cannot be consumed before current evaluation");+ check(nr.recordInputs(list,input.Get(),index+1,index!=0,index%2?.5f:1.f),"prepare current source and reset boundary");+ check(!nr.recordInputs(list,input.Get(),index+2,false,1.f),"duplicate unretired source is rejected");+ check(ring.submitAndSignal(slot)&&nr.enqueue(),"producer -> other process GPU work -> consumer fence queued");+ list=ring.acquireNext(slot,st);if(!list)return 2;+ transition(list,destination.Get(),outputState,D3D12_RESOURCE_STATE_COPY_DEST);outputState=D3D12_RESOURCE_STATE_COPY_DEST;+ check(nr.recordOutputs(list,destination.Get()),"decode same-frame output into stable graph target");+ check(ring.submitAndSignal(slot)&&nr.retireSubmitted(),"retire only after consumer is submitted");+ check(verify(colors[index],false,nr.diagnosticProxyForTest(),index%2?.5f:1.f),"all pixels belong to this source frame and match the CPU parity golden within FP16 precision");+ }+ smallNr.close();originalNr.close();check(!smallNr.ready()&&!originalNr.ready(),"both workers and models close independently");+ check(smallNr.openContractTest(smallDir,ctx.device(),ctx.directQueue(),w,h,false),"model switch/rebuild can reopen after closing");smallNr.close();+ const auto crashDir=prepareDir(L"crash");std::ofstream(crashDir/L"contract-crash-after-ack")<<"test-only";+ check(smallNr.openContractTest(crashDir,ctx.device(),ctx.directQueue(),w,h,true),"abnormal-exit test worker opens");+ check(fill(colors[0]),"abnormal-exit source submitted");uint32_t slot=0;auto* list=ring.acquireNext(slot,st);if(!list)return 2;+ check(smallNr.recordInputs(list,input.Get(),1,true,1)&&ring.submitAndSignal(slot),"prepare one source before owned worker exits");+ (void)smallNr.enqueue();const auto start=std::chrono::steady_clock::now();+ while(smallNr.ready()&&std::chrono::steady_clock::now()-start<std::chrono::seconds(2))Sleep(10);+ check(!smallNr.ready(),"worker exit changes provider to failed, never enhancement success");+ check(ring.drainQueue(),"dead worker cannot leave the host GPU queue permanently waiting");smallNr.close();+ const auto noResultDir=prepareDir(L"no-result");std::ofstream(noResultDir/L"contract-no-result")<<"test-only";+ check(smallNr.openContractTest(noResultDir,ctx.device(),ctx.directQueue(),w,h,true),"GPU completion-guard test worker opens");+ check(fill(colors[1]),"fresh source before unvalidated-result test");list=ring.acquireNext(slot,st);if(!list)return 2;+ check(smallNr.recordInputs(list,input.Get(),1,true,1)&&ring.submitAndSignal(slot)&&smallNr.enqueue(),"queue completion alone does not certify an NR result");+ list=ring.acquireNext(slot,st);if(!list)return 2;transition(list,destination.Get(),outputState,D3D12_RESOURCE_STATE_COPY_DEST);outputState=D3D12_RESOURCE_STATE_COPY_DEST;+ check(smallNr.recordOutputs(list,destination.Get())&&ring.submitAndSignal(slot)&&smallNr.retireSubmitted(),"unvalidated result passes through the guarded decoder");+ check(verify(colors[1],true),"missing GPU result marker preserves the exact current linear source, not an old/partial result");smallNr.close();+ printf("%d checks %d failures (GPU protocol/parity only; no NR inference)\n",checks,failures);return failures?1:0;+}diff --git a/tests/qml/QuickSmokeTests.cpp b/tests/qml/QuickSmokeTests.cppindex 2673469c..f1406381 100644--- a/tests/qml/QuickSmokeTests.cpp+++ b/tests/qml/QuickSmokeTests.cpp@@ -52,7 +52,7 @@ public slots:snapshot.setData(R"qml(import QtQmlQtObject {property var effectCapabilities: ({nr2:{available:true},nr3:{available:true},nr4:{available:true}})- property var nrRuntimeChoices: [{id:"2",label:"RTX 20–50 · SF 310.9.16"},{id:"3",label:"RTX 50 · NVIDIA original"}]+ property var nrRuntimeChoices: [{id:"2",label:"RTX 20–50 · SF 310.9.16"},{id:"3",label:"RTX 50 · NVIDIA original"},{id:"4",label:"RX 7000 · RedDuke (experimental)"}]property var nrLayers: [{index:1}]property int nrMotionSource: 1property string nrAutoStatus: ""@@ -74,6 +74,8 @@ QtObject {if (!model) qFatal("Cannot create explicit component snapshot: %s", qPrintable(snapshot.errorString()));model->setParent(engine);engine->rootContext()->setContextProperty(QStringLiteral("veyra"), model);+ qmlRegisterType(QUrl::fromLocalFile(QDir(QCoreApplication::applicationDirPath()).filePath(+ QStringLiteral("qml/Veyra/NrLayerEditor.qml"))), "VeyraTest", 1, 0, "NrLayerEditor");// ProPage is private to the production shell's directory, not exported// by Veyra/qmldir. Register it only here to test its real inline controls.qmlRegisterType(QUrl::fromLocalFile(QDir(QCoreApplication::applicationDirPath()).filePath(diff --git a/tests/qml/quick/tst_nr_amd_editor.qml b/tests/qml/quick/tst_nr_amd_editor.qmlnew file mode 100644index 00000000..b6713195--- /dev/null+++ b/tests/qml/quick/tst_nr_amd_editor.qml@@ -0,0 +1,62 @@+// UI-only snapshot. This never claims a Radeon or a neural network was run.+import QtQuick+import QtTest+import Veyra+import VeyraTest 1.0+Item {+ id: root+ width: 1100; height: 1400+ readonly property var defaults: ({index:1,runtime:4,sizePolicy:0,manualSize:true,sizePercent:37,+ performance:true,intensity:1,tone:1,structure:1,skin:-1,style:0,autoMask:true,uiCorrection:false,+ total:1,darken:1,brighten:1,color:1,luminance:1,temporal:false,antiFlicker:0,+ correctionEnabled:false,correctionAuto:true,correctionAmount:1})+ property var params: defaults+ property var edits: []+ NrLayerEditor {+ id: listEditor+ x:10; y:10; width:500+ layerData: root.params+ onEdited: (index,key,amount) => {const e=root.edits.slice();e.push({index:index,key:key,amount:amount});root.edits=e}+ }+ NrLayerEditor {+ id: nodeEditor+ x:560; y:10; width:500+ listControls:false+ layerData:root.params+ onEdited: (index,key,amount) => {const e=root.edits.slice();e.push({index:index,key:key,amount:amount});root.edits=e}+ }+ TestCase {+ name: "AmdNrEditorSnapshot"+ when: windowShown+ function init(){root.params=Object.assign({},root.defaults);root.edits=[]}+ function control(editor,name){const child=findChild(editor,name);verify(child!==null,name);return child}+ function test_both_modes_use_actual_provider_label(){+ compare(listEditor.amdNr,true);compare(nodeEditor.amdNr,true)+ verify(listEditor.amdRuntimeLabel.indexOf("RX 7000")>=0)+ compare(nodeEditor.amdRuntimeLabel,listEditor.amdRuntimeLabel)+ compare(control(listEditor,"nr-performance").checked,true)+ compare(control(nodeEditor,"nr-performance").checked,true)+ }+ function test_small_original_and_percent_are_independent(){+ for(const editor of [listEditor,nodeEditor]){+ const sw=control(editor,"nr-performance")+ mouseClick(sw,sw.width/2,sw.height/2)+ compare(root.edits[root.edits.length-1].key,"performance")+ compare(root.edits[root.edits.length-1].amount,0)+ compare(control(editor,"nr-size-percent").value,37)+ }+ }+ function test_saved_original_and_percentage_restore_in_both_modes(){+ root.params=Object.assign({},root.defaults,{performance:false,sizePercent:62})+ for(const editor of [listEditor,nodeEditor]){+ compare(control(editor,"nr-performance").checked,false)+ compare(control(editor,"nr-size-percent").value,62)+ compare(control(editor,"nr-manual-size-row").visible,true)+ }+ }+ function test_list_buttons_follow_editor_owner(){+ compare(control(listEditor,"nr-copy").visible,true)+ compare(control(nodeEditor,"nr-copy").visible,false)+ }+ }+}diff --git a/tests/unit/EffectAvailabilityTests.cpp b/tests/unit/EffectAvailabilityTests.cppindex d90a0cfb..35132f55 100644--- a/tests/unit/EffectAvailabilityTests.cpp+++ b/tests/unit/EffectAvailabilityTests.cpp@@ -1,4 +1,6 @@#include "veyra/ui/EffectAvailability.h"+#include "veyra/pipeline/AmdNrProvider.h"+#include "veyra/pipeline/Rdna3NrProtocol.h"#include <iostream>using namespace veyra::ui;int main() {@@ -15,6 +17,25 @@ int main() {if (hardwareSupports(HardwareEffect(feature),devices[device])!=expected[device][feature]) ++failures;}}+ auto verify=[&](bool ok){++checks;if(!ok)++failures;};+ using namespace veyra::pipeline;+ verify(amdNrProvider(0x1002,L"AMD Radeon RX 7900 XTX")==AmdNrProvider::RedDukeRdna3);+ verify(amdNrProvider(0x1002,L"amd radeon rx7800 xt")==AmdNrProvider::RedDukeRdna3);+ verify(amdNrProvider(0x1002,L"AMD Radeon RX 7600M")==AmdNrProvider::RedDukeRdna3);+ verify(amdNrProvider(0x1002,L"AMD Radeon RX 9070 XT")==AmdNrProvider::LmxxfRdna4);+ verify(amdNrProvider(0x1002,L"AMD Radeon RX 9060")==AmdNrProvider::LmxxfRdna4);+ verify(amdNrProvider(0x1002,L"AMD Radeon RX 6800 XT")==AmdNrProvider::Unsupported);+ verify(amdNrProvider(0x1002,L"AMD Radeon 780M")==AmdNrProvider::Unsupported);+ verify(amdNrProvider(0x10de,L"RX 7900 XTX")==AmdNrProvider::Unsupported);+ EffectGpu rdna3Gpu{};rdna3Gpu.vendor=0x1002;rdna3Gpu.rx7000=true;+ verify(hardwareSupports(HardwareEffect::AmdNr,rdna3Gpu));+ verify(!hardwareSupports(HardwareEffect::Fsr4,rdna3Gpu));+ verify(!hardwareSupports(HardwareEffect::NvidiaNrSf,rdna3Gpu));+ verify(rdna3::validExtent(1920,1080)&&rdna3::validExtent(2560,800));+ verify(!rdna3::validExtent(3840,2160)&&!rdna3::validExtent(2560,1080)&&!rdna3::validExtent(0,1080));+ rdna3::Evaluate packet;verify(rdna3::validHeader(packet.h,rdna3::Op::Evaluate,sizeof(packet)));+ packet.h.version++;verify(!rdna3::validHeader(packet.h,rdna3::Op::Evaluate,sizeof(packet)));+ packet={};packet.h.bytes=UINT32_MAX;verify(!rdna3::validHeader(packet.h,rdna3::Op::Evaluate,sizeof(packet)));std::cout<<checks<<" checks, "<<failures<<" failures\n";return failures ? 1 : 0;}diff --git a/third_party/redduke/LICENSE b/third_party/redduke/LICENSEnew file mode 100644index 00000000..ad7bd589--- /dev/null+++ b/third_party/redduke/LICENSE@@ -0,0 +1,25 @@+MIT License++Copyright (c) 2026 RedDukeDev++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.++This licence covers kernels/, runtime/ and docs/. The optiscaler/ submodule is+a fork of OptiScaler and is licensed under the GNU GPL version 3, as its+upstream is. third_party/ZLUDA keeps its own licence (MIT or Apache-2.0).diff --git a/third_party/redduke/VEYRA_ORIGIN.md b/third_party/redduke/VEYRA_ORIGIN.mdnew file mode 100644index 00000000..5c7cbe08--- /dev/null+++ b/third_party/redduke/VEYRA_ORIGIN.md@@ -0,0 +1,13 @@+# RX 7000 NR source and runtime provenance++The independent network layer comes from [RedDukeDev/dlss5-nr-amd-custom](https://github.com/RedDukeDev/dlss5-nr-amd-custom), commit `ab455d179922adc11f65675d399e1d553bf423f0`. Its `runtime/` and NR `kernels/` are MIT, Copyright (c) 2026 RedDukeDev; see LICENSE in this directory. ZLUDA is separately MIT OR Apache-2.0, pinned at `b135e233bb7a6ff7f8690e49701f87f4944adcee`.++Only five source files are fetched to an external dependency directory: `runtime/core/network.cpp`, `network.h`, `runtime/common/cuda_min.h`, `ngx_cuda.h`, and LICENSE. `scripts/amd-nr/prepare-rdna3-source.py` checks their exact Git blob IDs and records original/prepared SHA256. It patches selection of the host's D3D12 adapter LUID, rejects ambiguous multi-GPU mappings, and allows asynchronous enqueue only when our worker uses native shared GPU fences. Upstream synchronization remains the default for initialization.++Veyra's GPLv3 implementation is `Rdna3NrBackend.cpp`, `Rdna3NrWorker.cpp`, their headers/protocol, and `Rdna3NrDecode.hlsl`. One isolated worker owns each layer's network; Veyra owns temporal history, proxy conversion, strength, residual and protection. The network uses zero depth/motion and reset on every frame. This is same-frame inference, not upstream's game wrapper or asynchronous old-frame residual reprojection.++The local runtime subset contains the raw network DLL, eleven NR kernels, translation cache, ZLUDA compatibility shims and notices. No OptiScaler, ReShade, game proxy, SR/RR/FG kernel, driver or HIP SDK is staged. The private `zluda/nvcuda.dll` is an open-source compatibility shim loaded only in the owned worker, never a replacement for the main process's NVIDIA driver.++The NVIDIA DLL/model and translated cache are not relicensed under MIT. The selected original DLL is version 310.9.16.0, 266424944 bytes, valid NVIDIA signature, SHA256 `2bc19bc09a7b89dd44f73e2ac0108fcc586e2154bdd0830f242f4f040e28789f`. Local assets remain outside source Git. This task does not add this subset to the formal Release whitelist or authorize publication. Existing release guards remain in force.++See [execution and validation](../../docs/AMD_RDNA3_NR_PLAN_2026-10-29.md). Local D3D12 contract tests use an explicitly identified copy worker, not AMD inference. Actual RX 7000 inference, quality, speed, HDR, export and long-duration behavior require Radeon hardware validation.