From 30472ae195679ec9d7eb7a527682f6f360465bd4 Mon Sep 17 00:00:00 2001 From: woutermans Date: Sun, 11 Oct 2026 00:06:49 +0200 Subject: [PATCH] Fix the rebase onto the native engine: Vulkan frontend staging, RR gating, lazy RR debug stages The native Vulkan frontend stages packed rows and refuses Ray Reconstruction, whose guides it does not stage. make_ptx loads the denoiser's per-layer debug stages only when one is requested, so builds without the denoiser's PTX corpus (preset L's texture kernels) work. --- kernels/tex/make_ptx.py | 21 +++++++++++---------- tools/d4r_nvngx_shim.cpp | 3 ++- tools/d4r_vulkan_frontend.inl | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/kernels/tex/make_ptx.py b/kernels/tex/make_ptx.py index ec8a753..e06ec36 100755 --- a/kernels/tex/make_ptx.py +++ b/kernels/tex/make_ptx.py @@ -708,16 +708,16 @@ SWIN_DEBUG_STAGES = { # Per-layer extra debug stages, so a layer can add its own without editing this file: # kernels/rr/swin__debug_stages.py exposing stages() -> {name: (line, [regs])}. They are keyed # by (layer, stage) because two layers can use the same stage name; the entries above stay unkeyed -# and belong to enc0. -for _extra in sorted((Path(__file__).resolve().parent.parent / "rr").glob("swin_*_debug_stages.py")): - _layer = _extra.stem[len("swin_"):-len("_debug_stages")] - _spec = importlib.util.spec_from_file_location(_extra.stem, _extra) - _mod = importlib.util.module_from_spec(_spec) - _spec.loader.exec_module(_mod) - for _stage, _where in _mod.stages().items(): - SWIN_DEBUG_STAGES[(_layer, _stage)] = _where - - +# and belong to enc0. Loaded only when a debug stage is requested: some read the denoiser's PTX +# corpus, which builds that do not touch the denoiser do not have. +def load_layer_debug_stages(): + for extra in sorted((Path(__file__).resolve().parent.parent / "rr").glob("swin_*_debug_stages.py")): + layer = extra.stem[len("swin_"):-len("_debug_stages")] + spec = importlib.util.spec_from_file_location(extra.stem, extra) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + for stage, where in module.stages().items(): + SWIN_DEBUG_STAGES[(layer, stage)] = where def swin_debug_block(regs, entry="cuda_dldn_engine_swin_enc0_kernel", base=None): @@ -762,6 +762,7 @@ def swin_debug(name): match = re.fullmatch(r"cuda_dldn_engine_swin_(\w+)_kernel", name) if not stage or match is None: return None + load_layer_debug_stages() where = SWIN_DEBUG_STAGES.get((match.group(1), stage)) if where is None: where = SWIN_DEBUG_STAGES.get(stage) diff --git a/tools/d4r_nvngx_shim.cpp b/tools/d4r_nvngx_shim.cpp index 923178f..64b6fc1 100644 --- a/tools/d4r_nvngx_shim.cpp +++ b/tools/d4r_nvngx_shim.cpp @@ -7231,7 +7231,8 @@ static NgxResult create_feature(unsigned int featureId, void* parameters, NgxHan // feature 13; the NGX core dispatches the second to the denoiser it loaded, and is // offered feature 13 only once it has reported that denoiser working. const bool rayReconstruction = featureId == NGX_FEATURE_RAY_RECONSTRUCTION; - if (featureId != NGX_FEATURE_SUPER_SAMPLING && !rayReconstruction) + // The native Vulkan frontend stages only Super Sampling's four inputs, not the denoiser's guides. + if ((featureId != NGX_FEATURE_SUPER_SAMPLING && !rayReconstruction) || (rayReconstruction && nativeVulkan)) { logf("NVSDK_NGX_D3D12_CreateFeature(feature=%u) unsupported", featureId); return NGX_FAIL_FEATURE_NOT_SUPPORTED; diff --git a/tools/d4r_vulkan_frontend.inl b/tools/d4r_vulkan_frontend.inl index fbec1d8..c20b6ed 100644 --- a/tools/d4r_vulkan_frontend.inl +++ b/tools/d4r_vulkan_frontend.inl @@ -441,7 +441,7 @@ static void native_vk_run(Feature* feature, NativeVkFrame* frame) staging.width = p.image.width; staging.height = p.image.height; staging.format = p.format; staging.layout.Footprint.RowPitch = static_cast(p.rowBytes); - stage_plane(static_cast(i), staging, slot.host[i], nullptr, i); + stage_plane(static_cast(i), staging, slot.host[i], nullptr, i, 0); } auto& p = frame->params; const auto staged = ProfileClock::now();