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

test(nr): probe several Feature-18 handles on one snippet session

Veyra Goal Agent8cbf052752bd
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 436f453a..dc8763c2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -220,6 +220,18 @@ if(VEYRA_ENABLE_EXPERIMENTAL_DLSSNR)
add_dependencies(veyra_nr_harness veyra_shader_test_pattern
veyra_shader_parity_encode veyra_shader_parity_decode)
+ # NR stacking probe: several Feature-18 handles on one snippet session.
+ add_executable(veyra_nr_probe
+ tools/nr_probe/main.cpp
+ tools/nr_harness/harness_util.cpp
+ )
+ veyra_apply_warnings(veyra_nr_probe)
+ target_compile_features(veyra_nr_probe PRIVATE cxx_std_20)
+ target_compile_definitions(veyra_nr_probe PRIVATE
+ UNICODE _UNICODE WIN32_LEAN_AND_MEAN NOMINMAX
+ VEYRA_SHADER_DIR="${CMAKE_BINARY_DIR}/shaders")
+ target_link_libraries(veyra_nr_probe PRIVATE veyra_gfx veyra_ngx)
+
# Phase 6: DLSSG truth harness + WASAPI audio probe.
add_executable(veyra_fg_harness
tools/fg_harness/main.cpp
diff --git a/docs/UI_MIGRATION_EXECUTION_2026-09-25.md b/docs/UI_MIGRATION_EXECUTION_2026-09-25.md
index 009740cf..c3a34956 100644
--- a/docs/UI_MIGRATION_EXECUTION_2026-09-25.md
+++ b/docs/UI_MIGRATION_EXECUTION_2026-09-25.md
@@ -23,6 +23,7 @@
| S1.5 | 导出携带效果链 | 完成 | `checkpoint/ui-mig-s1.4` | 共享内存版本 2→3,接收端反算校验 |
| S1.6 | 统一预设库 | 完成 | `checkpoint/ui-mig-s1.6` | 33 项单元检查全过;旧文件只读导入 |
| S1.8 | 界面接口层 `PlayerUiFacade` | 完成 | `checkpoint/ui-mig-s1.8` | 快照按差异推送、命令排队、预设与最近文件集中 |
+| S2.0 | NR 叠层可行性探针 | 完成 | `checkpoint/ui-mig-s2.0` | **4/6/8 个句柄全部成功** |
## 发现并修复的 bug
@@ -35,6 +36,22 @@
## 日志
+### S2.0(2026-09-25)NR 叠层可行性探针(结论:可行)
+新增 `tools/nr_probe/main.cpp`(目标 `veyra_nr_probe`):在一个 NR 片段会话上创建 N 个 Feature 18 句柄,各自绑定独立的色彩/光流/深度/输出纹理并逐句柄执行,最后全部释放。
+
+本机 RTX 5070 + `nvngx_dlssnr.dll` 310.8.0.0(NVIDIA 原版)实测:
+
+| 请求实例数 | 创建 | 执行 | 释放 | 结果 |
+|---|---|---|---|---|
+| 2 | 2 | 2 | 2 | 成功 |
+| 4 | 4 | 4 | 4 | 成功 |
+| 6 | 6 | 6 | 6 | 成功 |
+| 8 | 8 | 8 | 8 | 成功 |
+
+结论:**一个片段会话 + 每层独立句柄/参数块/纹理 的结构在本机可用**,与 Magpie(`DLSSNRMultiPass.h`:每个 pass 各自 `CreateFeature`)的做法一致。界面里“最多 4 层”因此是产品选择,不是运行时限制。
+
+未验证:社区兼容版与 RTX 30 兼容版的多种子;每层的显存与 GPU 耗时叠加;多层时域历史的画质表现。这三点在 S2.1 实现后单独测。
+
### S1.4 切换 + S1.8(2026-09-25)重建判断切换与界面接口层
- **S1.4 切换**:影子模式跑过 6 个 settings 类 smoke 用例(master / settings / fg-only / view / output-cap / rollback)确认 0 处不一致后,`EngineController` 改用 `requiresGraphRebuild()`,旧的手写字段判断已删除。仍保留三类**设置本身表达不了**的条件:有效 HDR 输出(取决于显示器)、各阶段实际尺寸(来自 `ResolutionPlan`)、非 NVIDIA 显卡的能力归一化。
- 重新验证:13 项抓帧哈希 0 差异;交付门槛 PASS;smoke 用例按各自正确参数复跑全部通过(`--smoke-fg-only` 必须不带 `--nr` 启动、`--smoke-output-cap` 需要帧率值、`--smoke-rollback` 需要 `VEYRA_TEST_REJECT_NR_STYLE2=1`,我最初传错了参数,不是产品问题)。
diff --git a/tools/nr_probe/main.cpp b/tools/nr_probe/main.cpp
new file mode 100644
index 00000000..03938100
--- /dev/null
+++ b/tools/nr_probe/main.cpp
@@ -0,0 +1,212 @@
+// Multi-instance NR probe: can one snippet session hold several Feature-18
+// handles at once, evaluate each, and release them cleanly?
+//
+// This is the decisive question for NR stacking. Magpie (GPLv3, commit
+// 3841698) stacks DLSSNR passes, each with its own feature handle on one shared
+// snippet session and one IAT shim. This probe verifies the same contract on
+// this machine before EnhanceGraph is restructured: if the runtime refuses a
+// second handle, stacking is off the table and the UI must not offer it.
+//
+// Usage: veyra_nr_probe --runtime-dir <runtime_local\nvidia> [--count N] [--width W] [--height H]
+#include <windows.h>
+
+#include <cstdio>
+#include <string>
+#include <vector>
+
+#include "veyra/Log.h"
+#include "veyra/RuntimePaths.h"
+#include "veyra/gfx/CommandSlotRing.h"
+#include "veyra/gfx/D3D12DeviceContext.h"
+#include "veyra/ngx/DlssNrParameters.h"
+#include "veyra/ngx/NgxParameters.h"
+#include "veyra/pipeline/GpuPassUtils.h"
+#include "veyra/ngx/DlssNrRuntimeAdapter.h"
+#include "veyra/ngx/NgxCoreHost.h"
+
+#include <fstream>
+#include <iterator>
+
+using namespace veyra;
+
+namespace {
+struct Options {
+ std::wstring runtimeDir;
+ uint32_t count = 4;
+ uint32_t width = 1920;
+ uint32_t height = 1080;
+};
+bool parse(int argc, wchar_t** argv, Options& options) {
+ for (int i = 1; i < argc; ++i) {
+ const std::wstring arg = argv[i];
+ auto next = [&]() -> std::wstring { return i + 1 < argc ? argv[++i] : std::wstring(); };
+ if (arg == L"--runtime-dir") options.runtimeDir = next();
+ else if (arg == L"--count") options.count = uint32_t(wcstoul(next().c_str(), nullptr, 10));
+ else if (arg == L"--width") options.width = uint32_t(wcstoul(next().c_str(), nullptr, 10));
+ else if (arg == L"--height") options.height = uint32_t(wcstoul(next().c_str(), nullptr, 10));
+ else { std::fwprintf(stderr, L"unknown arg %s\n", arg.c_str()); return false; }
+ }
+ if (options.runtimeDir.empty() || options.count == 0 || options.count > 8) return false;
+ return true;
+}
+} // namespace
+
+int wmain(int argc, wchar_t** argv) {
+ Options options;
+ if (!parse(argc, argv, options)) {
+ std::fprintf(stderr, "usage: --runtime-dir <dir> [--count N] [--width W] [--height H]\n");
+ return 2;
+ }
+ const auto runtimeDir = std::wstring(runtime::localRuntimeDirectory().wstring());
+ const auto probeDir = options.runtimeDir.empty() ? runtimeDir : options.runtimeDir;
+
+ gfx::D3D12DeviceContext context;
+ gfx::DeviceContextDesc desc;
+ desc.commandSlotCount = 4;
+ Status status = Status::Ok;
+ if (!context.initialize(desc, status)) { std::fprintf(stderr, "device init failed\n"); return 1; }
+ gfx::CommandSlotRing ring;
+ if (!ring.initialize(context.device(), context.directQueue(), context.fence(), context.fenceEvent(), 4, status)) return 1;
+
+ // The local NGX project identity lives beside the runtime directory, in
+ // runtime_local/config/ngx-local.json -- the same file the product reads.
+ std::string projectId, engineVersion;
+ {
+ std::ifstream stream(probeDir + L"\\..\\config\\ngx-local.json", std::ios::binary);
+ if (!stream) { std::fprintf(stderr, "no local NGX identity beside the runtime dir\n"); return 1; }
+ const std::string text((std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>());
+ auto field = [&text](const char* name) -> std::string {
+ const std::string key = std::string("\"") + name + "\"";
+ const auto at = text.find(key);
+ if (at == std::string::npos) return {};
+ const auto first = text.find('"', at + key.size() + 1);
+ if (first == std::string::npos) return {};
+ const auto last = text.find('"', first + 1);
+ return last == std::string::npos ? std::string{} : text.substr(first + 1, last - first - 1);
+ };
+ projectId = field("ngxProjectId");
+ engineVersion = field("engineVersion");
+ }
+ if (projectId.empty() || engineVersion.empty()) { std::fprintf(stderr, "local NGX identity is incomplete\n"); return 1; }
+ ngx::NgxCoreHost coreHost;
+ if (!coreHost.initialize(context.device(), probeDir, projectId.c_str(), engineVersion.c_str(), status)) return 1;
+
+ ngx::DlssNrRuntimeAdapter adapter;
+ if (!adapter.load(probeDir, status) || !adapter.installCallerCompatibility(status)) {
+ std::fprintf(stderr, "snippet load or caller-compat shim failed\n");
+ return 1;
+ }
+ uint64_t result = 0;
+ uint32_t seh = 0;
+ if (!adapter.snippetInitExt(context.device(), probeDir, result, seh) ||
+ result != uint64_t(NVSDK_NGX_Result_Success)) {
+ std::fprintf(stderr, "snippet Init_Ext failed\n");
+ adapter.unload();
+ return 1;
+ }
+
+ // One parameter block per handle, matching the product's create contract.
+ std::vector<NVSDK_NGX_Parameter*> parameters;
+ std::vector<NVSDK_NGX_Handle*> handles;
+ int created = 0, evaluated = 0, released = 0;
+ for (uint32_t n = 0; n < options.count; ++n) {
+ auto* params = coreHost.allocateParameters(status);
+ if (params == nullptr) break;
+ {
+ ngx::ParameterBlock pb(params);
+ namespace p = ngx::dlssnr;
+ pb.setU32(p::kWidth, options.width); pb.setU32(p::kHeight, options.height);
+ pb.setU32(p::kInputWidth, options.width); pb.setU32(p::kInputHeight, options.height);
+ pb.setU32(p::kOutputWidth, options.width); pb.setU32(p::kOutputHeight, options.height);
+ pb.setU32(p::kOutputDotWidth, options.width); pb.setU32(p::kOutputDotHeight, options.height);
+ pb.setU32(p::kUpscaling, 0);
+ pb.setF32(p::kScale, 1.0f); pb.setF32(p::kScalingRatio, 1.0f);
+ pb.setVoid(p::kComputeScalingRatioCallback, reinterpret_cast<void*>(&ngx::DlssNrRuntimeAdapter::scalingRatioCallback));
+ pb.setI32(p::kHintRenderPreset, 0);
+ pb.setU32(p::kStdWidth, options.width); pb.setU32(p::kStdHeight, options.height);
+ pb.setI32(p::kPerfQualityValue, 1);
+ pb.setU32(p::kCreationNodeMask, 1); pb.setU32(p::kVisibilityNodeMask, 1);
+ }
+ NVSDK_NGX_Handle* handle = nullptr;
+ auto* list = ring.acquire(0, status);
+ if (list == nullptr) break;
+ const bool ok = adapter.snippetCreateFeature(list, params, &handle, result, seh) &&
+ result == uint64_t(NVSDK_NGX_Result_Success) && handle != nullptr;
+ if (!ring.submitAndSignal(0) || !ring.waitIdle()) break;
+ std::printf("create #%u: %s handle=%s\n", n + 1, ok ? "OK" : "FAILED", handle ? "non-null" : "null");
+ if (!ok) break;
+ parameters.push_back(params);
+ handles.push_back(handle);
+ ++created;
+ }
+
+ // Evaluate every handle on the shared ring with real bound resources.
+ // CreateFeature alone does not prove stacking: the runtime has to accept
+ // each handle's own colour/motion/depth/output set.
+ if (uint32_t(created) == options.count) {
+ using pipeline::ComPtr;
+ std::vector<ComPtr<ID3D12Resource>> keepAlive;
+ auto bindTextures = [&](size_t index) {
+ namespace p = ngx::dlssnr;
+ auto color = pipeline::makeTexture(context.device(), options.width, options.height, DXGI_FORMAT_R8G8B8A8_UNORM, true);
+ auto output = pipeline::makeTexture(context.device(), options.width, options.height, DXGI_FORMAT_R8G8B8A8_UNORM, true);
+ auto mvec = pipeline::makeTexture(context.device(), options.width, options.height, DXGI_FORMAT_R16G16_FLOAT, true);
+ auto depth = pipeline::makeTexture(context.device(), options.width, options.height, DXGI_FORMAT_R32_FLOAT, true);
+ if (!color || !output || !mvec || !depth) return false;
+ ngx::ParameterBlock pb(parameters[index]);
+ pb.setD3D12Resource(p::kColor, color.Get());
+ pb.setD3D12Resource(p::kOutput, output.Get());
+ pb.setD3D12Resource(p::kMVec, mvec.Get());
+ pb.setD3D12Resource(p::kDepth, depth.Get());
+ pb.setU32(p::kColorSubrectWidth, options.width); pb.setU32(p::kColorSubrectHeight, options.height);
+ pb.setU32(p::kOutputSubrectWidth, options.width); pb.setU32(p::kOutputSubrectHeight, options.height);
+ pb.setU32(p::kMVecSubrectWidth, options.width); pb.setU32(p::kMVecSubrectHeight, options.height);
+ pb.setU32(p::kDepthSubrectWidth, options.width); pb.setU32(p::kDepthSubrectHeight, options.height);
+ pb.setF32(p::kMVecScaleX, 1.0f); pb.setF32(p::kMVecScaleY, 1.0f);
+ pb.setI32(p::kDepthInverted, 1);
+ pb.setI32(p::kIndicatorInvertX, 0); pb.setI32(p::kIndicatorInvertY, 0);
+ pb.setI32(p::kEnabled, 1);
+ pb.setI32(p::kReset, index == 0 ? 1 : 0);
+ pb.setI32(p::kStyle, 0);
+ pb.setF32(p::kIntensity, 1.0f);
+ pb.setF32(p::kLocalToneStrength, 1.0f);
+ pb.setF32(p::kLocalStructureStrength, 1.0f);
+ pb.setF32(p::kSkinStructureStrength, -1.0f);
+ pb.setI32(p::kUseAutoMask, 0);
+ pb.setI32(p::kUICorrection, 0);
+ keepAlive.push_back(color); keepAlive.push_back(output);
+ keepAlive.push_back(mvec); keepAlive.push_back(depth);
+ return true;
+ };
+ for (size_t n = 0; n < handles.size(); ++n) {
+ if (!bindTextures(n)) { std::printf("evaluate #%zu: bind failed\n", n + 1); break; }
+ auto* list = ring.acquire(0, status);
+ if (list == nullptr) break;
+ uint64_t er = 0;
+ uint32_t es = 0;
+ const bool ok = adapter.snippetEvaluateFeature(list, handles[n], parameters[n], er, es) &&
+ er == uint64_t(NVSDK_NGX_Result_Success);
+ if (!ring.submitAndSignal(0) || !ring.waitIdle()) break;
+ std::printf("evaluate #%zu: %s\n", n + 1, ok ? "OK" : "FAILED");
+ if (!ok) break;
+ ++evaluated;
+ }
+ }
+
+ for (auto* handle : handles) {
+ uint64_t rr = 0;
+ uint32_t rs = 0;
+ if (adapter.snippetReleaseFeature(handle, rr, rs) && rr == uint64_t(NVSDK_NGX_Result_Success)) ++released;
+ }
+ std::printf("RESULT requested=%u created=%d evaluated=%d released=%d\n",
+ options.count, created, evaluated, released);
+
+ adapter.restoreCallerCompatibility();
+ adapter.unload();
+ coreHost.shutdown();
+ ring.shutdown();
+ context.shutdown();
+
+ const bool pass = created == int(options.count) && evaluated == created && released == created;
+ return pass ? 0 : 1;
+}