Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

Repair RX7000 NVAPI adapter identity for the selected CUDA context

Veyra Goal Agentb27c0df90cb0
diff --git a/AGENTS.md b/AGENTS.md
index 49ca5fb9..98f7cfe0 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,5 +1,7 @@
# Veyra Agent 工作规则
+> **2026-11-03 RX7000多GPU身份映射修复(本地待实卡)**:用户cache.zip显示7900XTX有gfx1036核显/gfx1100独显,NGX因GPU身份匹配失败报Unsupported GPU architecture 0x0。codex/rdna3-nvapi-luid-20261103基线ecfbb0f,修固定ZLUDA b135e233的nvapi/src/lib.rs:当前CUDA上下文设备LUID代替写死ordinal0,歧义/失败明确报错。只重新编译开源zluda_nvapi.dll,不改NVIDIA模型/驱动/原翻译器或缓存。原正式组件13组8失败,新组件13组全通过(含双线程64次),不等于RX7000推理已验。源码patch、MIT/Apache许可证、构建和夹具测试已记录;更新包test-packages/codex-rdna3-nvapi-luid-20261103,FINAL位于reports/rdna3-nvapi-luid-20261103。未来组RX7000包必须带此更新后的NVAPI并重做manifest,勿从旧供体回退b86425dd…;新DLL身份a7adb043…/215040字节。原app/依赖/正式包保留,不合main、不push/Release。详见docs/RDNA3_NVAPI_LUID_2026-11-03.md。测试用nvcuda.dll绝不能进入产品包。
+
> **2026-11-03 NVENC导出关键帧修复(本地)**:按用户要求先审第三方诊断,在codex/nvenc-export-keyframes-20261103(基线edad6e9)复现H.264/HEVC MP4仅首帧索引,确认低延迟preset继承无限IDR。显式同步当前codec idrPeriod到原GOP120并记录参数,不采纳I帧一律标KEY。14组生产导出/码流/原始索引及28次像素一致跳转通过;首次HDR合成素材漏PQ元数据已修正测试,保留失败。记录docs/NVENC_EXPORT_KEYFRAMES_2026-11-03.md,回执reports/nvenc-export-keyframes-20261103/FINAL.json,覆盖补丁test-packages/codex-nvenc-export-keyframes-20261103。继承全屏/VFG实验变更,不合main、不push/发布,不改真实配置、驱动或运行组件。
> **2026-11-02 用户授权RTX30 VFG适配(当前施工)**:分支codex/vfg-ampere-20261102,基线4895549,保留全屏进度条修复。按docs/VFG_AMPERE_PLAN_2026-11-02.md移植Xchen991固定07536ab(MIT):仅VFG模块、SM86设备及当前CUDA上下文,命名导入/私有kernel副本/租约和可验回滚;40/50原生无补丁。复用207321712字节原VFG和模型,不改磁盘DLL/驱动/真实配置。合同/真实模块控制及RTX5070原生回归通过,30实卡未验,UI明确实验。产物test-packages/codex-vfg-ampere-20261102,回执reports/vfg-ampere-20261102/FINAL.json;不合main、不push/发布。后续打包必须带licenses/RTX30-Broadcast-FrameGen-MIT.txt和对应源码差异。
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md
index 1bb383f4..b61b5612 100644
--- a/THIRD_PARTY_NOTICES.md
+++ b/THIRD_PARTY_NOTICES.md
@@ -6,6 +6,8 @@ RedDukeDev/dlss5-nr-amd-custom, fixed commit `ab455d179922adc11f65675d399e1d553b
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.
+2026-11-03 local multi-GPU repair: the same pinned ZLUDA `nvapi/src/lib.rs` is patched by [zluda-current-device-luid.patch](third_party/redduke/zluda-current-device-luid.patch) to obtain the adapter LUID from the current CUDA context's device. A context-free fallback is allowed only for one device; ambiguous mappings and LUID failures report errors. This fixes the stand-in reporting ordinal-zero integrated GPU identity while Veyra runs NR on a discrete GPU. `scripts/amd-nr/build-rdna3-nvapi.py` rebuilds only the open-source NVAPI crate; its output is installed as `runtime/amd-nr-rdna3/zluda/zluda_nvapi.dll` behind the original forwarder. No NVIDIA binary, GPU driver or translation cache is modified. Full upstream MIT and Apache-2.0 notices are retained in [licenses/rdna3-nvapi](licenses/rdna3-nvapi). CPU fixture validation is not Radeon inference validation. See [evidence and limits](docs/RDNA3_NVAPI_LUID_2026-11-03.md).
+
## Beauty node: face restore and skin smoothing (2026-10-18)
| Source | License | Veyra use |
diff --git a/docs/CURRENT_STATUS.md b/docs/CURRENT_STATUS.md
index 97618fff..e291aafe 100644
--- a/docs/CURRENT_STATUS.md
+++ b/docs/CURRENT_STATUS.md
@@ -1,5 +1,7 @@
# 当前项目状态
+**2026-11-03 RX7000本地兼容补丁**:发现核显+独显设备的NVAPI LUID误报,当前分支codex/rdna3-nvapi-luid-20261103修开源zluda_nvapi.dll并提供独立小更新。原正式组件实测合同失败、新组件13组通过;没有RX7000实卡推理结论,不改模型/缓存/驱动。尚未合main、未发布。[证据及未来打包要求](RDNA3_NVAPI_LUID_2026-11-03.md)。
+
**2026-11-03 本地导出修复**:codex/nvenc-export-keyframes-20261103显式覆盖NVENC低延迟preset的无限IDR,恢复每120帧真正IDR与封装索引,不把普通I标KEY。14组生产导出、28次跳转通过,继承全屏修复与RTX30 VFG实验兼容;未合main、未push/发布。[审查与证据](NVENC_EXPORT_KEYFRAMES_2026-11-03.md)。
**当前正式版2.1.2(2026-11-02)**:用户授权公开发行,main和v2.1.2/v2.1.2-sources已推送;发行准备899590f,程序构建358be8c(EXE33d8e615…),使用Claude最新去重包的原程序字节。两显卡包及源码已发布,服务端摘要、匿名下载、Latest与两张二维码核验通过。[完整更新](RELEASE_NOTES_2.1.2.md) · [构建/源码](BUILD_2.1.2.md) · [发行记录](RELEASE_2.1.2_EXECUTION_2026-11-02.md)。正式产物releases/codex-release-2.1.2-20261102,FINAL回执reports/codex-release-2.1.2-20261102。
diff --git a/docs/RDNA3_NVAPI_LUID_2026-11-03.md b/docs/RDNA3_NVAPI_LUID_2026-11-03.md
new file mode 100644
index 00000000..bd9ecfc9
--- /dev/null
+++ b/docs/RDNA3_NVAPI_LUID_2026-11-03.md
@@ -0,0 +1,37 @@
+# RX7000 NR启动失败:核显/独显LUID映射
+
+用户补充cache.zip后续接原排查。分支codex/rdna3-nvapi-luid-20261103,基线ecfbb0f(继承本地NVENC导出修复、全屏及VFG实验)。不合main、不push/Release;不修改真实配置、AMD驱动、NVIDIA网络DLL、原ZLUDA/CUDA翻译器或已发布资产。
+
+## 证据与根因
+
+原主日志三个会话52次CreateFeature均失败。补充包中52份worker日志逐字节相同:识别AMD Radeon RX7900 XTX,HIP看见gfx1036和gfx1100,缓存覆盖gfx11-generic/gfx1100,创建前可用显存24351/24560MB。NGX最新日志明确记录目标LUID 0x10100、m_gpuArch=0xe0,随后`Unsupported GPU architecture 0x0, minimum required 0x1b0`;兼容gate已登记内核。
+
+固定来源RedDukeDev/ZLUDA b135e233bb7a6ff7f8690e49701f87f4944adcee的nvapi/src/lib.rs中,cuda_device_luid硬编码cuDeviceGet(...,0),只枚举一个假NVAPI设备。Veyra的network已按选定D3D12 LUID创建CUDA上下文,但NVAPI仍把第一块(可能为核显)的LUID报给NGX,导致独显LUID匹配失败并落到GK100/0xe0。这是适配中遗漏的多GPU合同;不是用降低内部尺寸或重建缓存可以修正的身份映射。
+
+额外核对network::gpu_architectures按HIP ordinal顺序逐一输出,并非按名称排序;本例gfx1036先于gfx1100。固定ZLUDA的device::get直接调用hipDeviceGet,get_luid读取该设备HIP属性的LUID;这把实际日志顺序与源码硬编码第0设备的缺口关联起来,而非只凭“有核显”猜测。
+
+使用正式包同源的nvapi64.dll转发层与原zluda_nvapi.dll,在独立子进程载入CPU测试nvcuda.dll:模拟第0核显LUID0x12004、第1独显0x10100且当前上下文为独显,原库实测错误返回0x12004。即使模拟多GPU无上下文或LUID查询失败也错误返回成功。原库13组合同8组失败,保留shipped-before/RESULTS.json;不冒充AMD推理。
+
+## 最小修复
+
+只修MIT OR Apache-2.0开源NVAPI实现并重新编译,不patch任何原二进制:优先cuCtxGetDevice获取当前上下文的设备,再查询其LUID;无当前上下文时只允许唯一设备回退,多设备/驱动错误明确失败,LUID查询失败向NVAPI调用方返回错误。保持NR原来的Blackwell兼容身份、参数、运行库和翻译缓存不变。
+
+原nvapi64.dll是转发层,真实身份函数来自zluda_nvapi.dll;本地覆盖只替换后者,worker/主EXE/模型无需改变。补丁和完整许可证放third_party/redduke,固定源码、构建脚本、合同测试与SHA清单随本地更新提供。
+
+开发依赖E:/项目/Veyra/deps/rdna3-nvapi-luid-20261103;构建E:/项目/Veyra/build/rdna3-nvapi-luid-20261103,CARGO_HOME与TEMP均在E盘,cargo并发2、每次上限880秒;测试子进程120秒。原始日志只读,从压缩包读取小日志,不复制约100MB数据库。
+
+## 验证与交付
+
+上游未改源码首次构建48.5秒,修改后2.3秒;用源码仓库的构建脚本再从未修改源码重放patch并重建2.33秒通过。Rust1.96/MSVC、Cargo.lock保持原始版本,并发2;每次cargo进程上限880秒。DLL为215040字节,最终SHA256 `a7adb0431ed69f7245312634f08990704d839aae46f075d80f28fe85b409caeb`。同一源码重新链接的PE时间戳会改变文件SHA,因此最终合同使用最终重建DLL再次跑过,不沿用初版结果。
+
+构建:`python -X utf8 -B scripts/amd-nr/build-rdna3-nvapi.py --source E:/项目/Veyra/deps/rdna3-nvapi-luid-20261103/ZLUDA --output-root E:/项目/Veyra/build/rdna3-nvapi-luid-20261103`。构建脚本验证固定HEAD、准确源文件差异及Cargo.lock,设置任务CARGO_HOME/target/TEMP,不安装到应用。
+
+测试:MSVC分别把tests/integration/Rdna3NvapiFakeCuda.cpp编成nvcuda.dll和带VEYRA_RDNA3_NR_CALLER宏的dlssnr-contract.dll(命令回执reports/rdna3-nvapi-luid-20261103/build-fixture.py与tests同名目录fixtures/compile.log)。调用`scripts/acceptance/verify-rdna3-nvapi.py --directory <新证据目录> --nvapi <受测zluda_nvapi.dll> --forwarder <原nvapi64.dll> --cuda-fixture <夹具nvcuda.dll> --nr-caller <夹具dlssnr-contract.dll>`,每子进程上限120秒。测试夹具不能打入任何产品运行目录。
+
+原正式2.1.2 AMD包的两份NVAPI文件与本轮对照件SHA完全一致:转发层2678a451…(349696字节),真实NVAPI b86425dd…(226304字节)。不是以不同版本上游代替真实发行件复现。
+
+最终新DLL通过13组合同:核显首位/独显当前、首适配器当前、单设备无上下文兼容、多设备歧义/未知上下文/无设备/LUID失败/非法设备拒绝、双线程64次上下文隔离、NR调用方原Blackwell身份、空参数和可省略LUID缓冲。旧DLL13组中8失败,新DLL13通过。回执tests/rdna3-nvapi-luid-20261103/{shipped-before,final-fixed}/RESULTS.json。这里加载的是原转发层和实际新/旧NVAPI DLL,但CUDA是明确的CPU夹具,没有伪装成RX7000推理。
+
+本地补丁test-packages/codex-rdna3-nvapi-luid-20261103/Veyra-2.1.2-RX7000-NR-multiGPU-fix.zip:只替换runtime/amd-nr-rdna3/zluda/zluda_nvapi.dll,另带许可证、来源、源码差异、构建/验收脚本及清单。原工作app、原依赖组件和已发布ZIP不替换,主程序/模型/缓存不变;用户退出软件后覆盖2.1.2 AMD目录。未来重新组RX7000包须应用这份独立组件更新并重新生成manifest,不能从旧供体把b86425dd…带回来。大小、摘要、清理和证据总回执reports/rdna3-nvapi-luid-20261103/FINAL.json。
+
+本机无RX7000实卡,用户仍需单次验证实际模型创建/推理;如果后续出现新的错误继续依据新日志排查。本次没有重新跑无关QML、NVENC或NVIDIA推理测试,不以CPU合同宣称NR已在该用户机器跑通。
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 2dba87e2..219b0626 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -1,5 +1,11 @@
# 当前工作日志
+## 2026-11-03 RX7000 cache.zip续查与多GPU映射修复
+
+用户补充cache.zip,52份worker日志相同,NR创建前24GB显存可用、缓存覆盖gfx1100,NGX明确Unsupported GPU architecture 0x0/min0x1b0且m_gpuArch=0xe0。固定ZLUDA NVAPI源码硬编码CUDA设备0,而Veyra按独显上下文运行。使用正式包同SHA转发层及NVAPI实际复现“核显0/独显1”误报核显LUID。分支codex/rdna3-nvapi-luid-20261103基线ecfbb0f,重编译同源开源NVAPI,改用当前上下文设备并显式拒绝歧义/查询失败;不改模型/驱动/原件,未使用二进制补丁。
+
+首次原源码Cargo构建48.5秒,修复2.3秒,从原源码重新套patch的正式构建脚本2.33秒通过;每次并发2,上限880秒,CARGO_HOME/target/TEMP全在E盘。最终DLL215040字节/a7adb043…。13组合同旧8失败、新13通过,双线程64次设备隔离和原NR架构身份保持;CPU夹具不冒充实卡推理。新旧正式两NVAPI原件SHA已与2.1.2 AMD ZIP比对一致。源码/许可证/构建脚本/夹具/来源记录入Git;产品补丁只一个开源DLL,夹具nvcuda.dll绝不随包。未动原app、用户配置、依赖原件、正式ZIP,未合main/push/Release。命令、边界与最终包/清理回执见docs/RDNA3_NVAPI_LUID_2026-11-03.md及reports/rdna3-nvapi-luid-20261103/FINAL.json。后续等该用户实卡确认NR是否成功创建及推理。
+
## 2026-11-03 RX7900 XTX的NR初始化失败(只读排查)
用户提供veyra-qml(3).log并确认软件能打开、NR开不了。原日志SHA256 d92fabe719b9c33bf287dc0e81d89b5813e49b2d0413164351ec42c8dc98f8ef,共5381170字节。三个启动会话中52次NR创建均失败,首次UTC10:36:08.991、最后12:00:52.234,全部内部1920×1080;错误为NVSDK_NGX_CUDA_CreateFeature 0xBAD00001(NVIDIA定义FeatureNotSupported)。主程序随后明确回退nr=false;未出现RDNA3 worker ready。不能把错误号等同显卡永久不支持,亦无显存不足证据。
diff --git a/licenses/rdna3-nvapi/LICENSE-APACHE.txt b/licenses/rdna3-nvapi/LICENSE-APACHE.txt
new file mode 100644
index 00000000..d085c258
--- /dev/null
+++ b/licenses/rdna3-nvapi/LICENSE-APACHE.txt
@@ -0,0 +1,177 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
diff --git a/licenses/rdna3-nvapi/LICENSE-MIT.txt b/licenses/rdna3-nvapi/LICENSE-MIT.txt
new file mode 100644
index 00000000..5c6a6461
--- /dev/null
+++ b/licenses/rdna3-nvapi/LICENSE-MIT.txt
@@ -0,0 +1,24 @@
+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.
+
diff --git a/scripts/acceptance/verify-rdna3-nvapi.py b/scripts/acceptance/verify-rdna3-nvapi.py
new file mode 100644
index 00000000..d28b3e83
--- /dev/null
+++ b/scripts/acceptance/verify-rdna3-nvapi.py
@@ -0,0 +1,121 @@
+"""CPU-only DLL contract for the RX7000 selected-context NVAPI LUID repair.
+
+Compile tests/integration/Rdna3NvapiFakeCuda.cpp into nvcuda.dll and, with
+VEYRA_RDNA3_NR_CALLER, into dlssnr-contract.dll. These are private fixtures,
+never product components. Run once with the old and once with the repaired
+zluda_nvapi.dll, passing the unchanged packaged nvapi64.dll as --forwarder.
+"""
+import argparse
+import ctypes as c
+from concurrent.futures import ThreadPoolExecutor
+import hashlib
+import json
+import os
+from pathlib import Path
+import shutil
+import subprocess
+import sys
+
+
+def check(directory):
+ directory = directory.resolve()
+ os.add_dll_directory(str(directory))
+ # Clear optional architecture overrides so the original caller-sensitive
+ # identity is tested, without changing the parent/system environment.
+ for key in ('ZLUDA_NVAPI_GPU_ARCH', 'ZLUDA_NVAPI_GPU_ARCH_NEURAL'):
+ os.environ.pop(key, None)
+ cuda = c.CDLL(str(directory / 'nvcuda.dll'))
+ cuda.testState.argtypes = [c.c_int] * 4
+ cuda.testState.restype = None
+ nvapi = c.CDLL(str(directory / 'nvapi64.dll'))
+ query = nvapi.nvapi_QueryInterface
+ query.argtypes, query.restype = [c.c_uint32], c.c_void_p
+
+ class Logical(c.Structure):
+ _fields_ = [('version', c.c_uint32), ('luid', c.c_void_p), ('count', c.c_uint32),
+ ('handles', c.c_void_p * 64), ('reserved', c.c_uint32 * 8)]
+
+ info = c.CFUNCTYPE(c.c_int, c.c_void_p, c.POINTER(Logical))(query(0x842b066e))
+ rows = []
+
+ def request(count, ordinal, status=0, luid_error=0):
+ cuda.testState(count, ordinal, status, luid_error)
+ luid = c.c_uint64(0xdeadbeefdeadbeef)
+ data = Logical()
+ data.version = c.sizeof(Logical) | (1 << 16)
+ data.luid = c.addressof(luid)
+ result = info(1, c.byref(data))
+ return result, luid.value, data.count
+
+ cases = [('iGPU first, selected dGPU', 2, 1, 0, 0, 0x10100),
+ ('selected first adapter', 2, 0, 0, 0, 0x12004),
+ ('single device, no context', 1, 0, 201, 0, 0x12004),
+ ('multiple devices, no context rejected', 2, 0, 201, 0, None),
+ ('context failure rejected with one device', 1, 0, 999, 0, None),
+ ('context failure rejected with multiple devices', 2, 0, 999, 0, None),
+ ('no devices rejected', 0, 0, 201, 0, None),
+ ('LUID failure reported', 2, 1, 0, 999, None),
+ ('invalid context device rejected', 2, 5, 0, 0, None)]
+ for name, count, ordinal, status, failure, expected in cases:
+ actual = request(count, ordinal, status, failure)
+ ok = (actual == (0, expected, 1)) if expected is not None else (actual[0] != 0 and actual[1] == 0xdeadbeefdeadbeef)
+ rows.append({'name': name, 'pass': ok, 'actual': actual})
+
+ def threaded(ordinal):
+ expected = 0x12004 if ordinal == 0 else 0x10100
+ return all(request(2, ordinal) == (0, expected, 1) for _ in range(32))
+
+ with ThreadPoolExecutor(max_workers=2) as pool:
+ threaded_results = list(pool.map(threaded, (0, 1)))
+ rows.append({'name': 'two concurrent selected contexts, 64 queries', 'pass': all(threaded_results), 'actual': threaded_results})
+ caller = c.CDLL(str(directory / 'dlssnr-contract.dll'))
+ caller.testNeuralArchitecture.argtypes = [c.c_void_p, c.POINTER(c.c_uint32)]
+ caller.testNeuralArchitecture.restype = c.c_int
+ architecture = c.c_uint32()
+ result = caller.testNeuralArchitecture(c.cast(query, c.c_void_p), c.byref(architecture))
+ rows.append({'name': 'NR caller retains upstream Blackwell identity', 'pass': result == 0 and architecture.value == 0x1b0,
+ 'actual': [result, architecture.value]})
+ rows.append({'name': 'null data remains rejected', 'pass': info(1, None) != 0})
+ # A caller may omit the optional adapter LUID buffer.
+ empty = Logical()
+ empty.version = c.sizeof(Logical) | (1 << 16)
+ rows.append({'name': 'optional LUID pointer remains supported', 'pass': info(1, c.byref(empty)) == 0 and empty.count == 1})
+ for row in rows:
+ print(('PASS ' if row['pass'] else 'FAIL ') + row['name'] + ' ' + str(row.get('actual', '')), flush=True)
+ result = {'mode': 'CPU fixture, not Radeon inference', 'pass': all(row['pass'] for row in rows), 'checks': rows,
+ 'files': [{'path': p.name, 'size': p.stat().st_size, 'sha256': hashlib.sha256(p.read_bytes()).hexdigest()}
+ for p in directory.glob('*.dll')]}
+ (directory / 'RESULTS.json').write_text(json.dumps(result, indent=2), encoding='utf-8')
+ return 0 if result['pass'] else 1
+
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('--directory', type=Path, required=True)
+ parser.add_argument('--nvapi', type=Path)
+ parser.add_argument('--forwarder', type=Path)
+ parser.add_argument('--cuda-fixture', type=Path)
+ parser.add_argument('--nr-caller', type=Path)
+ parser.add_argument('--child', action='store_true')
+ args = parser.parse_args()
+ if args.child:
+ return check(args.directory)
+ args.directory.mkdir(parents=True, exist_ok=True)
+ assert not (args.directory / 'RESULTS.json').exists(), 'Use a fresh evidence directory'
+ for source, name in ((args.nvapi, 'zluda_nvapi.dll'), (args.forwarder, 'nvapi64.dll'),
+ (args.cuda_fixture, 'nvcuda.dll'), (args.nr_caller, 'dlssnr-contract.dll')):
+ assert source and source.is_file(), source
+ shutil.copyfile(source, args.directory / name)
+ env = os.environ.copy()
+ (args.directory / 'tmp').mkdir(exist_ok=True)
+ env['TEMP'] = env['TMP'] = str((args.directory / 'tmp').resolve())
+ result = subprocess.run([sys.executable, '-X', 'utf8', '-B', str(Path(__file__).resolve()),
+ '--child', '--directory', str(args.directory.resolve())], env=env,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT, timeout=120)
+ (args.directory / 'console.log').write_bytes(result.stdout)
+ print(result.stdout.decode('utf-8', 'replace'))
+ return result.returncode
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/scripts/amd-nr/build-rdna3-nvapi.py b/scripts/amd-nr/build-rdna3-nvapi.py
new file mode 100644
index 00000000..032a0df4
--- /dev/null
+++ b/scripts/amd-nr/build-rdna3-nvapi.py
@@ -0,0 +1,78 @@
+"""Build only the open-source RX7000 NVAPI LUID repair at a pinned ZLUDA commit.
+
+Prepare a private checkout of RedDukeDev/ZLUDA at PIN outside the Veyra source
+tree. This script applies the checked-in patch, uses E-drive Cargo/TEMP/target
+directories, and emits zluda_nvapi.dll plus identity/build receipts. It never
+installs to an app, loads CUDA/HIP, or touches a driver/model/cache.
+"""
+import argparse
+import hashlib
+import json
+import os
+from pathlib import Path
+import subprocess
+import time
+
+PIN = 'b135e233bb7a6ff7f8690e49701f87f4944adcee'
+BASE = Path('E:/项目/Veyra').resolve()
+
+
+def sha(data):
+ return hashlib.sha256(data).hexdigest()
+
+
+def main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('--source', type=Path, required=True)
+ parser.add_argument('--output-root', type=Path, required=True)
+ args = parser.parse_args()
+ source, out = args.source.resolve(), args.output_root.resolve()
+ assert source.is_relative_to(BASE / 'deps'), 'Use a task checkout under E:/项目/Veyra/deps'
+ assert out.is_relative_to(BASE / 'build'), 'Build output must be under E:/项目/Veyra/build'
+ patch = Path(__file__).resolve().parents[2] / 'third_party/redduke/zluda-current-device-luid.patch'
+ def git(*command):
+ return subprocess.check_output(['git', *command], cwd=source)
+ assert git('rev-parse', 'HEAD').decode().strip() == PIN, 'Wrong ZLUDA revision'
+ assert (source / 'Cargo.lock').read_bytes().replace(b'\r\n', b'\n') == git('show', PIN + ':Cargo.lock'), 'Unexpected dependency lock edits'
+ target = source / 'nvapi/src/lib.rs'
+ # Only the exact upstream file or the exact expected patched file is admitted.
+ original = git('show', PIN + ':nvapi/src/lib.rs')
+ current = target.read_bytes().replace(b'\r\n', b'\n')
+ if current == original:
+ subprocess.run(['git', 'apply', '--check', str(patch)], cwd=source, check=True)
+ subprocess.run(['git', 'apply', str(patch)], cwd=source, check=True)
+ # Canonical diff equality also protects a resumed private build from an
+ # unrelated edit being passed off as this small dependency repair.
+ assert git('diff', '--', 'nvapi/src/lib.rs').replace(b'\r\n', b'\n') == patch.read_bytes().replace(b'\r\n', b'\n'), 'Unexpected NVAPI edits'
+ out.mkdir(parents=True, exist_ok=True)
+ tmp = BASE / 'tmp' / out.name
+ cargo = source.parent / 'cargo'
+ tmp.mkdir(parents=True, exist_ok=True)
+ cargo.mkdir(parents=True, exist_ok=True)
+ env = os.environ.copy()
+ env['CARGO_HOME'] = str(cargo)
+ env['CARGO_TARGET_DIR'] = str(out)
+ env['TEMP'] = env['TMP'] = str(tmp)
+ env['CARGO_BUILD_JOBS'] = '2'
+ command = tmp / 'nvapi-build.cmd'
+ command.write_text('@echo off\ncall "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat" >nul 2>&1\nif errorlevel 1 exit /b 4\ncargo build --release -p nvapi --locked -j 2\n', encoding='ascii')
+ start = time.monotonic()
+ with (out / 'nvapi-build.log').open('wb') as log:
+ result = subprocess.run(['cmd.exe', '/d', '/c', str(command)], cwd=source, env=env,
+ stdout=log, stderr=subprocess.STDOUT, timeout=880)
+ receipt = {'upstream': 'RedDukeDev/ZLUDA', 'commit': PIN, 'license': 'MIT OR Apache-2.0',
+ 'patch_sha256': sha(patch.read_bytes()), 'original_source_sha256': sha(original),
+ 'patched_source_sha256': sha(target.read_bytes()), 'cargo_lock_sha256': sha((source / 'Cargo.lock').read_bytes()),
+ 'command': str(command), 'code': result.returncode, 'seconds': time.monotonic() - start}
+ if result.returncode == 0:
+ compiled = out / 'release/nvapi64.dll'
+ data = compiled.read_bytes()
+ (out / 'zluda_nvapi.dll').write_bytes(data)
+ receipt['file'] = {'name': 'zluda_nvapi.dll', 'size': len(data), 'sha256': sha(data)}
+ (out / 'nvapi-build.json').write_text(json.dumps(receipt, indent=2), encoding='utf-8')
+ print(json.dumps(receipt, indent=2))
+ return result.returncode
+
+
+if __name__ == '__main__':
+ raise SystemExit(main())
diff --git a/tests/integration/Rdna3NvapiFakeCuda.cpp b/tests/integration/Rdna3NvapiFakeCuda.cpp
new file mode 100644
index 00000000..e4e05a84
--- /dev/null
+++ b/tests/integration/Rdna3NvapiFakeCuda.cpp
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-3.0-only
+// CPU-only fixture. Never install this DLL in a product runtime/driver directory.
+#include <windows.h>
+#include <atomic>
+#include <cstdint>
+#include <cstring>
+
+#ifdef VEYRA_RDNA3_NR_CALLER
+struct ArchInfo { uint32_t version,architecture,implementation,revision; };
+using Query = void* (*)(uint32_t);
+extern "C" __declspec(dllexport) int testNeuralArchitecture(Query query,uint32_t* architecture) {
+ auto fn=reinterpret_cast<int (*)(void*,ArchInfo*)>(query(0xd8265d24));
+ if(!fn||!architecture)return -1;
+ ArchInfo info{uint32_t(sizeof(ArchInfo))|(1u<<16),0,0,0};
+ volatile int result=fn(reinterpret_cast<void*>(1),&info); // retain this caller's stack frame
+ *architecture=info.architecture;
+ return result;
+}
+#else
+namespace {
+std::atomic<int> deviceCount=2;
+thread_local int currentDevice=101,currentStatus=0,luidStatus=0;
+}
+extern "C" __declspec(dllexport) void testState(int count,int ordinal,int status,int luidError) {
+ deviceCount=count;currentDevice=100+ordinal;currentStatus=status;luidStatus=luidError;
+}
+extern "C" __declspec(dllexport) int cuCtxGetDevice(int* device) {
+ if(currentStatus)return currentStatus;
+ if(!device)return 1;
+ *device=currentDevice;return 0;
+}
+extern "C" __declspec(dllexport) int cuDeviceGetCount(int* count) {
+ if(!count)return 1;
+ *count=deviceCount;return 0;
+}
+extern "C" __declspec(dllexport) int cuDeviceGet(int* device,int ordinal) {
+ if(!device||ordinal<0||ordinal>=deviceCount)return 101;
+ *device=100+ordinal;return 0;
+}
+extern "C" __declspec(dllexport) int cuDeviceGetLuid(char* luid,unsigned* nodeMask,int device) {
+ if(luidStatus)return luidStatus;
+ if(!luid||!nodeMask||device<100||device>=100+deviceCount)return 101;
+ const uint64_t value=device==100?0x12004ull:0x10100ull;
+ std::memcpy(luid,&value,sizeof(value));*nodeMask=1;return 0;
+}
+#endif
diff --git a/third_party/redduke/VEYRA_ORIGIN.md b/third_party/redduke/VEYRA_ORIGIN.md
index 5c7cbe08..cf6f2da5 100644
--- a/third_party/redduke/VEYRA_ORIGIN.md
+++ b/third_party/redduke/VEYRA_ORIGIN.md
@@ -11,3 +11,5 @@ The local runtime subset contains the raw network DLL, eleven NR kernels, transl
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.
+
+2026-11-03: [zluda-current-device-luid.patch](zluda-current-device-luid.patch) modifies only `nvapi/src/lib.rs` in RedDukeDev/ZLUDA at the fixed revision above. The previous LUID query always chose CUDA ordinal zero; the patch follows `cuCtxGetDevice`, retains an unambiguous single-device fallback, and reports lookup failure. This is a source rebuild of an MIT OR Apache-2.0 component, not binary modification of a vendor runtime. Full upstream license texts are in [licenses/rdna3-nvapi](../../licenses/rdna3-nvapi). Build via `scripts/amd-nr/build-rdna3-nvapi.py` with a private pinned checkout; install the resulting `zluda_nvapi.dll` in a local RX7000 test package only. The existing `nvapi64.dll` forwarder and every other SDK/model/runtime file retain their original bytes. Test CUDA/caller DLLs from `Rdna3NvapiFakeCuda.cpp` are strictly private CPU fixtures and must never enter a product package.
diff --git a/third_party/redduke/zluda-current-device-luid.patch b/third_party/redduke/zluda-current-device-luid.patch
new file mode 100644
index 00000000..2a2a1c97
--- /dev/null
+++ b/third_party/redduke/zluda-current-device-luid.patch
@@ -0,0 +1,69 @@
+diff --git a/nvapi/src/lib.rs b/nvapi/src/lib.rs
+index 2a61335..d9e263c 100644
+--- a/nvapi/src/lib.rs
++++ b/nvapi/src/lib.rs
+@@ -675,15 +675,38 @@ unsafe fn cuda_device_luid(luid: &mut [i8; 8], node_mask: &mut u32) -> bool {
+ return false;
+ }
+ let get_luid = winapi_get_proc(nvcuda, b"cuDeviceGetLuid\0");
+- let device_get = winapi_get_proc(nvcuda, b"cuDeviceGet\0");
+- if get_luid.is_null() || device_get.is_null() {
++ if get_luid.is_null() {
+ return false;
+ }
+- let device_get: unsafe extern "C" fn(*mut i32, i32) -> i32 = std::mem::transmute(device_get);
+ let get_luid: unsafe extern "C" fn(*mut i8, *mut u32, i32) -> i32 = std::mem::transmute(get_luid);
++ // Veyra selects the D3D12 adapter before creating the network's CUDA/HIP
++ // context. Ordinal zero may be an iGPU: report the current context's device
++ // so NGX can match its LUID to the adapter that actually runs the network.
++ let ctx_get_device = winapi_get_proc(nvcuda, b"cuCtxGetDevice\0");
+ let mut dev = 0i32;
+- if device_get(&mut dev, 0) != 0 {
+- return false;
++ let context_status = if ctx_get_device.is_null() {
++ 201 // CUDA_ERROR_INVALID_CONTEXT: no current-context query available
++ } else {
++ let ctx_get_device: unsafe extern "C" fn(*mut i32) -> i32 = std::mem::transmute(ctx_get_device);
++ ctx_get_device(&mut dev)
++ };
++ if context_status != 0 {
++ // Retain context-free single-GPU callers, but never guess ordinal zero
++ // in a multi-GPU process or conceal another context/driver error.
++ if context_status != 201 {
++ return false;
++ }
++ let device_get = winapi_get_proc(nvcuda, b"cuDeviceGet\0");
++ let device_count = winapi_get_proc(nvcuda, b"cuDeviceGetCount\0");
++ if device_get.is_null() || device_count.is_null() {
++ return false;
++ }
++ let device_get: unsafe extern "C" fn(*mut i32, i32) -> i32 = std::mem::transmute(device_get);
++ let device_count: unsafe extern "C" fn(*mut i32) -> i32 = std::mem::transmute(device_count);
++ let mut count = 0i32;
++ if device_count(&mut count) != 0 || count != 1 || device_get(&mut dev, 0) != 0 {
++ return false;
++ }
+ }
+ get_luid(luid.as_mut_ptr(), node_mask, dev) == 0
+ }
+@@ -749,13 +772,14 @@ unsafe extern "C" fn NvAPI_GPU_GetLogicalGpuInfo(
+ if !data.pOSAdapterId.is_null() {
+ let mut luid = [0i8; 8];
+ let mut node_mask: u32 = 0;
+- if cuda_device_luid(&mut luid, &mut node_mask) {
+- std::ptr::copy_nonoverlapping(
+- luid.as_ptr().cast::<u8>(),
+- data.pOSAdapterId.cast::<u8>(),
+- 8,
+- );
++ if !cuda_device_luid(&mut luid, &mut node_mask) {
++ return _NvAPI_Status_NVAPI_ERROR;
+ }
++ std::ptr::copy_nonoverlapping(
++ luid.as_ptr().cast::<u8>(),
++ data.pOSAdapterId.cast::<u8>(),
++ 8,
++ );
+ }
+ data.physicalGpuCount = 1;
+ data.physicalGpuHandles[0] = FAKE_PHYSICAL_GPU;