OverviewFilesCommitsIssuesDocsReleasesPeers

nvidia-rtx-godot commits / 275819b

Recreate the NGX feature when switching between Ray Reconstruction and SR
Ray Reconstruction and Super Resolution are separate NGX features with separate handles. Creation was gated purely on feature_created, so once either existed the creation block was skipped forever -- but the evaluate path branches on the CURRENTLY requested mode: if (use_dlss_rr && ctx->dlss_rr_handle) { ...RR... } else { NGX_VULKAN_EVALUATE_DLSS_EXT(vk_cmd, ctx->dlss_sr_handle, ...) } Select Ray Reconstruction first and dlss_sr_handle is never created. Switch to Super Resolution and creation is skipped as already-done, the else branch runs, and NGX is handed a null handle -- crash. Reported switching to Super Resolution after using Ray Reconstruction. Track which feature the context holds (feature_is_rr) and release it when the requested mode no longer matches, so the next frame creates the right one. Adds a defensive null check on the SR evaluate as well. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
275819be34e81e7a269b9cf7d0056a02ac2e36ed
by plankatron <fleeky@gmail.com> · 2026-07-29T18:52:26.000Z

Changed files (1) +25 -1

servers/rendering/renderer_rd/effects/dlss.cpp +25 -1
……@@ -620,7 +620,13 @@ public:
620620 uint32_t output_width = 0;
621621 uint32_t output_height = 0;
622622
623 virtual ~NGXDLSSContext() {
623 // Which kind of feature feature_created refers to. RR and SR are distinct NGX
624 // features with separate handles, so switching between them at runtime has to
625 // tear the old one down -- otherwise the evaluate path picks the branch for
626 // the newly requested mode and finds a null handle.
627 bool feature_is_rr = false;
628
629 void release_feature() {
624630 if (dlss_rr_handle) {
625631 NVSDK_NGX_VULKAN_ReleaseFeature(dlss_rr_handle);
626632 dlss_rr_handle = nullptr;
……@@ -629,6 +635,11 @@ public:
629635 NVSDK_NGX_VULKAN_ReleaseFeature(dlss_sr_handle);
630636 dlss_sr_handle = nullptr;
631637 }
638 feature_created = false;
639 }
640
641 virtual ~NGXDLSSContext() {
642 release_feature();
632643 }
633644};
634645} // namespace RendererRD
……@@ -934,6 +945,14 @@ void DLSSEffect::_upscale_internal(RDD::CommandBufferID cmdid, const DLSSContext
934945
935946 bool use_dlss_rr = p_params.dlss_rr && g_ngx_dlss_rr_available;
936947
948 // Ray Reconstruction and Super Resolution are separate NGX features with
949 // separate handles. Toggling between them at runtime (a settings change) must
950 // destroy the existing one, or creation is skipped as already-done and the
951 // evaluate branch for the newly requested mode dereferences a null handle.
952 if (ctx->feature_created && ctx->feature_is_rr != use_dlss_rr) {
953 ctx->release_feature();
954 }
955
937956 // Create NGX feature on first use
938957 if (!ctx->feature_created) {
939958 NVSDK_NGX_Result result;
……@@ -959,6 +978,7 @@ void DLSSEffect::_upscale_internal(RDD::CommandBufferID cmdid, const DLSSContext
959978
960979 if (NVSDK_NGX_SUCCEED(result)) {
961980 ctx->feature_created = true;
981 ctx->feature_is_rr = true;
962982 print_line("[NGX DLSS] DLSS-RR feature created successfully");
963983 } else {
964984 WARN_PRINT(vformat("[NGX DLSS] DLSS-RR creation failed (0x%x), falling back to DLSS-SR", (uint32_t)result));
……@@ -989,6 +1009,7 @@ void DLSSEffect::_upscale_internal(RDD::CommandBufferID cmdid, const DLSSContext
9891009 return;
9901010 }
9911011 ctx->feature_created = true;
1012 ctx->feature_is_rr = false;
9921013 use_dlss_rr = false;
9931014 print_line("[NGX DLSS] DLSS-SR feature created successfully");
9941015 }
……@@ -1089,6 +1110,9 @@ void DLSSEffect::_upscale_internal(RDD::CommandBufferID cmdid, const DLSSContext
10891110 eval.InMVScaleX = (float)ctx->render_width;
10901111 eval.InMVScaleY = (float)ctx->render_height;
10911112
1113 // Defensive: the mode-change path above should always have recreated the
1114 // feature, but never hand NGX a null handle.
1115 ERR_FAIL_NULL_MSG(ctx->dlss_sr_handle, "[NGX DLSS] SR evaluate with no SR feature.");
10921116 NVSDK_NGX_Result result = NGX_VULKAN_EVALUATE_DLSS_EXT(vk_cmd, ctx->dlss_sr_handle, g_ngx_params, &eval);
10931117 if (NVSDK_NGX_FAILED(result)) {
10941118 ERR_PRINT(vformat("[NGX DLSS] DLSS-SR evaluate failed: 0x%x", (uint32_t)result));