diff --git a/runtime/vk_dlaa.c b/runtime/vk_dlaa.c index 04f6ac09..31eecb48 100644 --- a/runtime/vk_dlaa.c +++ b/runtime/vk_dlaa.c @@ -118,6 +118,7 @@ int vk_dlaa_wanted(void) { // The temporal upscaler behind dlaa: NVIDIA DLSS through NGX, once NGX is up, or else AMD FSR 3.1, which takes the same // inputs. The DLSS mode setting (NX2NAVI_DLSS) is the render scale for both. static int fsr3(void) { return !N.ngx_up && !strcmp(cfg_value("NX2NAVI_TAA"), "fsr3"); } +static int fsr_frame; // fsr3() as vk_dlaa_init and then vk_dlaa_frame read it: the upscaler this frame runs with int vk_dlaa_fsr3(void) { return vk_dlaa_wanted() && fsr3(); } // The upscaler the menu has set cannot start in this run: DLSS when NGX was never tried (a device made without its @@ -242,6 +243,7 @@ static int utf8_to_wide(const char *in, wchar_t *out, size_t cap) { void vk_dlaa_init(void) { if (vk_dlaa_wanted() && fsr3()) { + fsr_frame = 1; N.available = vk_ffx_load(); rt_log("dlaa: the temporal upscaler is AMD FSR 3.1%s", N.available ? "" : ", which is missing: the game's own scaling"); return; @@ -441,6 +443,10 @@ const VkTexImage *vk_dlaa_swap_img; VkImageView vk_dlaa_swap_view; static int dl_active(void) { return N.available && !D.failed && D.on; } +// The upscaler this frame runs with, as vk_dlaa_frame read it. The menu can set NX2NAVI_TAA to dlss between that and +// evaluate; read again there while NGX is not up (DLSS starts only after a restart), it sent evaluate to DLSS's path +// with NGX's functions not loaded, a call to address 0 (issue #325). +static int use_fsr(void) { return !N.ngx_up && fsr_frame; } static void dl_fail(const char *what, NgxResult r) { rt_log("dlaa: %s failed (%08x): DLAA off for this run", what, (unsigned)r); @@ -1296,7 +1302,8 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) { struct Size *e = size_for(cb, w, h, ow, oh); if (!e) return dl_fail("work image creation", 0); if (e != D.last) D.reset = 1, D.why[0]++, e->chars_ok = 0; // another size's history is from another moment - if (!fsr3() && !D.params && !NGX_OK(N.alloc_params(&D.params))) return dl_fail("parameter allocation", 0); + if (!use_fsr() && !N.ngx_up) return; // neither runs this frame: vk_dlaa_frame turns DLAA off at the next present + if (!use_fsr() && !D.params && !NGX_OK(N.alloc_params(&D.params))) return dl_fail("parameter allocation", 0); NgxParam *p = D.params; VkImageView zv = vk_exec_target_view(z->img, z->format, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_DEPTH_BIT, z->level, z->base_layer, 1, 0); @@ -1320,7 +1327,7 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) { uint64_t c0 = timed ? kern_now_ns() : 0; rec_drain(); // NGX records into the command buffer itself: the recorder thread must have made every call so far if (timed) T.cpu_drain += kern_now_ns() - c0; - if (fsr3()) { // FSR 3.1 (vk_ffx.cpp) in DLSS's place: the same images, then the same blit below + if (use_fsr()) { // FSR 3.1 (vk_ffx.cpp) in DLSS's place: the same images, then the same blit below if (t->level || t->base_layer || z->level || z->base_layer) return dl_fail("FSR 3.1 on a target that is not level 0, layer 0", 0); if (D.last_color != t->image) target_changed(t); uint64_t now = plat_now_ns(); @@ -1652,7 +1659,10 @@ void vk_dlaa_frame(void) { vk_dlaa_swap_img = NULL, vk_dlaa_swap_view = VK_NULL_HANDLE; dlss_mode(); preset_check(); - if (!N.ngx_up) N.available = fsr3() && cfg_bool("NX2NAVI_DLAA") && vk_ffx_load(); // FSR 3.1 follows the setting + if (!N.ngx_up) { // FSR 3.1 follows the setting + fsr_frame = fsr3(); + N.available = fsr_frame && cfg_bool("NX2NAVI_DLAA") && vk_ffx_load(); + } int on = N.available && cfg_bool("NX2NAVI_DLAA"); if (on != D.on) { rt_log("dlaa: %s", on ? "on" : "off");