diff --git a/runtime/resolution.c b/runtime/resolution.c index d1941300..894ee0b6 100644 --- a/runtime/resolution.c +++ b/runtime/resolution.c @@ -36,6 +36,7 @@ #include "cfg.h" #include "host.h" +#include "platform/platform.h" #define BASE_W 1920 #define BASE_H 1080 @@ -55,6 +56,23 @@ static struct { double dlss_k; // TOTK_DLSS quality/balanced/performance: the scene's share of the output, else 0 } R; +// The scene size is decided before the device exists, so NGX cannot be asked yet. With dlaa on, NGX loads DLSS from +// nvngx_dlss.dll next to totk.exe (vk_dlaa.c vk_dlaa_init): without that file DLSS never runs, and a DLSS mode would +// leave the game's plain scaling at 50..67 % of the output. dlaa = 0 keeps the documented size with the game's scaling. +static int dlss_dll(void) { +#ifdef _WIN32 + if (!cfg_bool("TOTK_DLAA")) return 1; + char exe[1024], path[1024 + 32]; + if (!plat_exe_path(exe, sizeof exe)) return 1; + char *last = plat_last_sep(exe); + if (!last) return 1; + snprintf(path, sizeof path, "%.*s/nvngx_dlss.dll", (int)(last - exe), exe); + return plat_file_exists(path); +#else + return 1; +#endif +} + static void decide(void) { if (R.decided) return; R.decided = 1; @@ -78,6 +96,10 @@ static void decide(void) { {"quality", 2.0 / 3.0}, {"balanced", 0.58}, {"performance", 0.5}}; for (int i = 0; cfg_bool("TOTK_DLAA") && i < 3; i++) if (!strcmp(m, dlss[i].name)) R.dlss_k = dlss[i].k; + if (R.dlss_k && !dlss_dll()) { + rt_log("resolution: DLSS %s needs nvngx_dlss.dll next to totk.exe, which is missing: the scene follows render_scale", m); + R.dlss_k = 0; + } if (R.dlss_k) { k = R.dlss_k; R.scene_set = 1; diff --git a/runtime/vk_dlaa.c b/runtime/vk_dlaa.c index af926221..7acdd130 100644 --- a/runtime/vk_dlaa.c +++ b/runtime/vk_dlaa.c @@ -202,6 +202,8 @@ void vk_dlaa_init(void) { driver ? "; the driver needs an update" : ""); } +int vk_dlaa_available(void) { return vk_dlaa_wanted() && N.available; } + // ---------------------------------------------------------------- where DLAA runs in TotK's frame // Measured (TOTK_DUMP, frame 2100 at Lookout Landing, 2560x1440 scene): the G-buffer passes draw into five targets with // the scene depth (d32f at the scene size), one of them the R11G11B10F light target; lighting and the transparents @@ -680,6 +682,7 @@ void vk_dlaa_device_exts(const VkExtensionProperties *have, uint32_t nhave, cons (void)have, (void)nhave, (void)ext, (void)n, (void)max; } void vk_dlaa_init(void) {} +int vk_dlaa_available(void) { return 0; } void vk_dlaa_pass(VkExec *ex) { (void)ex; } void vk_dlaa_frame(void) {} void vk_dlaa_draw(VkExec *ex) { (void)ex; } diff --git a/runtime/vk_dlaa.h b/runtime/vk_dlaa.h index dc291b10..685a2524 100644 --- a/runtime/vk_dlaa.h +++ b/runtime/vk_dlaa.h @@ -8,6 +8,8 @@ int vk_dlaa_wanted(void); // the setting is on (the device may still lack DLSS void vk_dlaa_instance_exts(const char **ext, uint32_t *n, uint32_t max); void vk_dlaa_device_exts(const VkExtensionProperties *have, uint32_t nhave, const char **ext, uint32_t *n, uint32_t max); void vk_dlaa_init(void); +// 1 when dlaa is on and NGX came up with DLSS (after vk_dlaa_init): a DLSS mode's smaller scene is scaled up by DLSS. +int vk_dlaa_available(void); // vk_exec.c vk_exec_pass_begin, once the pass's targets are resolved and before its barrier: arms the frame on the // scene's light target or, at the first quarter-width pass after it, runs DLAA on that target. Each present ends the // frame (vk_dlaa_frame). diff --git a/runtime/vk_texture.c b/runtime/vk_texture.c index 995c613d..46abe06f 100644 --- a/runtime/vk_texture.c +++ b/runtime/vk_texture.c @@ -26,6 +26,7 @@ #include "nvn_tex.h" #include "tex.h" #include "vk.h" +#include "vk_dlaa.h" #include "vk_exec.h" #include "platform/platform.h" @@ -1680,8 +1681,9 @@ static VkSampler make_sampler(VkCtx *c, const samp_par *d) { if (si.maxLod < si.minLod) si.maxLod = si.minLod; float lim = c->props.limits.maxSamplerLodBias, bias = d->lod_bias; // DLSS upscaling (resolution.c): the scene's material textures, the filtered mipmapped ones that repeat, are - // sampled for the output's resolution; clamped ones (post effects, LUTs, the UI) keep the game's bias. - if (!d->cmp_mode && mf == NVN_MIN_FILTER_LINEAR_MIPMAP_LINEAR && + // sampled for the output's resolution; clamped ones (post effects, LUTs, the UI) keep the game's bias. Without DLSS + // running (dlaa = 0, or NGX without DLSS) nothing accumulates the extra detail, and the sharper mips only shimmer. + if (vk_dlaa_available() && !d->cmp_mode && mf == NVN_MIN_FILTER_LINEAR_MIPMAP_LINEAR && (si.addressModeU == VK_SAMPLER_ADDRESS_MODE_REPEAT || si.addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT || si.addressModeV == VK_SAMPLER_ADDRESS_MODE_REPEAT || si.addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT)) bias += res_dlss_lod_bias(); diff --git a/totk.ini.example b/totk.ini.example index 387169b2..8edc4535 100644 --- a/totk.ini.example +++ b/totk.ini.example @@ -196,7 +196,8 @@ # dlaa = 0 # What DLSS works from: dlaa (the 3D scene at full size), quality, balanced or performance (the scene at 67, 58 or # 50 % of the output, scaled up by DLSS; these replace render_scale and sharpen texture filtering to match). With dlaa -# = 0 the game's own scaling is used at that size. Read at start. +# = 0 the game's own scaling is used at that size, without the sharper filtering. With dlaa = 1 but no nvngx_dlss.dll +# next to totk.exe the scene follows render_scale. Read at start. # dlss = dlaa # The game's own FXAA after the post effects; with DLAA on it is not needed. Changes while the game runs take effect at # once.