From 90319e6c9a3afd25e253090306f53f4854f8bd4b Mon Sep 17 00:00:00 2001 From: Valiantsin Dzerakh Date: Sun, 1 Nov 2026 11:41:27 +0300 Subject: [PATCH] Load NGX only with dlaa on at start, and skip the FXAA shader lookup at the defaults vk_dlaa_wanted answered 1 on every machine, so each start on an NVIDIA driver loaded the NGX core and enabled its device extensions with DLAA off; dlaa now applies after a restart. vk_dlaa_skip_draw hashed the fragment shader of every draw through an unlocked 8192-entry table, which 1.4.3's shader variants outgrow; with fxaa on and DLSS not scaling there is nothing to skip, so it returns before the lookup. Also gives the DLSS rows their Brazilian Portuguese and Simplified Chinese text. Co-Authored-By: Claude Opus 5.5 --- runtime/cfg.c | 2 +- runtime/ui_text.c | 32 ++++++++++++++++++++++++++++++-- runtime/vk_dlaa.c | 12 +++++++++--- totk.ini.example | 3 +-- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/runtime/cfg.c b/runtime/cfg.c index dbd6a2aa..8c63b839 100644 --- a/runtime/cfg.c +++ b/runtime/cfg.c @@ -109,7 +109,7 @@ static const CfgMeta metas[] = { {"PERF_OVERLAY", "off", "off|fps|full", LIVE}, {"OUTPUT_RES", "1920x1080", NULL, RESTART}, {"RENDER_SCALE", "game", "game|50|67|75|100|125|150|200", RESTART}, {"UPSCALER", "fsr", "fsr|bilinear", LIVE}, {"SHARPNESS", "80", "0..100", LIVE}, - {"DLAA", "0", "0|1", LIVE}, {"DLSS", "dlaa", "dlaa|quality|balanced|performance", RESTART}, {"FXAA", "1", "0|1", LIVE}, + {"DLAA", "0", "0|1", RESTART}, {"DLSS", "dlaa", "dlaa|quality|balanced|performance", RESTART}, {"FXAA", "1", "0|1", LIVE}, {"ASPECT", "fit", "fit|stretch", LIVE}, {"FOV", "100", "70..140", LIVE}, {"ANISO", "game", "game|2|4|8|16", RESTART}, // vk_texture.c sampler_features // colour adjustment (vk_color.c); the preset is the menu's, the four values are what the present uses diff --git a/runtime/ui_text.c b/runtime/ui_text.c index ced42aa2..87ef14a1 100644 --- a/runtime/ui_text.c +++ b/runtime/ui_text.c @@ -123,7 +123,8 @@ static const char *const text_en[UI_TEXT_COUNT] = { "Takes effect at the next start.", [UI_MENU_DLAA] = "NVIDIA DLSS / DLAA", [UI_MENU_DLAA_DESC] = "NVIDIA DLSS for the 3D scene (NVIDIA RTX GPUs; nvngx_dlss.dll next to totk.exe): smoother edges " - "and less shimmer. The HUD is not touched. The mode below sets the resolution it works from.", + "and less shimmer. The HUD is not touched. The mode below sets the resolution it works from. Takes effect " + "after a restart.", [UI_MENU_DLSS] = "DLSS mode", [UI_MENU_DLSS_DESC] = "DLAA draws the 3D scene at full resolution. Quality, Balanced and Performance draw it at 67, 58 " "and 50 % and let DLSS scale it up, for more frames per second; they replace the 3D render " @@ -455,7 +456,8 @@ static const char *const text_ru[UI_TEXT_COUNT] = { "разрешение теней. Действует после перезапуска.", [UI_MENU_DLAA] = "NVIDIA DLSS / DLAA", [UI_MENU_DLAA_DESC] = "NVIDIA DLSS для 3D-сцены (видеокарты NVIDIA RTX; nvngx_dlss.dll рядом с totk.exe): ровнее края и " - "меньше мерцания. Интерфейс не затрагивается. Режим ниже задаёт разрешение, с которым он работает.", + "меньше мерцания. Интерфейс не затрагивается. Режим ниже задаёт разрешение, с которым он работает. " + "Действует после перезапуска.", [UI_MENU_DLSS] = "Режим DLSS", [UI_MENU_DLSS_DESC] = "DLAA рисует 3D-сцену в полном разрешении. «Качество», «Баланс» и «Производительность» рисуют её " "в 67, 58 и 50 % и масштабируют через DLSS ради большего числа кадров; они заменяют масштаб " @@ -1035,6 +1037,21 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = { [UI_MENU_PCSS] = "Sombras suaves", [UI_MENU_PCSS_DESC] = "Sombras do sol nítidas onde um objeto toca o chão e mais suaves quanto mais longe a sombra " "cai (PCSS). 0 mantém o filtro do jogo. Vale no próximo início.", + [UI_MENU_DLAA] = "NVIDIA DLSS / DLAA", + [UI_MENU_DLAA_DESC] = "NVIDIA DLSS para a cena 3D (placas NVIDIA RTX; nvngx_dlss.dll ao lado do totk.exe): bordas " + "mais suaves e menos cintilação. O HUD não é afetado. O modo abaixo define a resolução de " + "onde ele parte. Vale após reiniciar.", + [UI_MENU_DLSS] = "Modo do DLSS", + [UI_MENU_DLSS_DESC] = "DLAA desenha a cena 3D na resolução cheia. Qualidade, Equilibrado e Desempenho a desenham " + "em 67, 58 e 50 % e deixam o DLSS ampliá-la, para mais quadros por segundo; eles substituem " + "a escala 3D. Vale após reiniciar.", + [UI_MENU_DLSS_DLAA] = "DLAA (nativo)", + [UI_MENU_DLSS_QUALITY] = "Qualidade", + [UI_MENU_DLSS_BALANCED] = "Equilibrado", + [UI_MENU_DLSS_PERFORMANCE] = "Desempenho", + [UI_MENU_FXAA] = "Antisserrilhado do jogo (FXAA)", + [UI_MENU_FXAA_DESC] = "A suavização de bordas FXAA do próprio jogo. Borra um pouco os detalhes finos; com o DLAA " + "ligado não é necessária.", }; // Simplified Chinese: this row covers the software keyboard and the whole menu, so the menu and the overlay read Chinese @@ -1494,6 +1511,17 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = { [UI_MENU_CONTACT_SHADOWS_DESC] = "阴影贴图遗漏的细小太阳阴影:脚下、石头下、草丛和褶皱中。在光照之后于屏幕空间追踪。下次启动时生效。", [UI_MENU_PCSS] = "柔和阴影", [UI_MENU_PCSS_DESC] = "物体接触地面处的太阳阴影锐利,阴影投得越远越柔和(PCSS)。0 保留游戏自身的过滤。下次启动时生效。", + [UI_MENU_DLAA] = "NVIDIA DLSS / DLAA", + [UI_MENU_DLAA_DESC] = "用于 3D 场景的 NVIDIA DLSS(NVIDIA RTX 显卡;nvngx_dlss.dll 放在 totk.exe 旁):边缘更平滑,闪烁更少。HUD " + "不受影响。下方的模式决定它的工作分辨率。重启后生效。", + [UI_MENU_DLSS] = "DLSS 模式", + [UI_MENU_DLSS_DESC] = "DLAA 以全分辨率绘制 3D 场景。质量、平衡和性能分别以 67%、58% 和 50% 绘制,再由 DLSS 放大,以获得更高帧率;它们会取代 3D 渲染比例。重启后生效。", + [UI_MENU_DLSS_DLAA] = "DLAA(原生)", + [UI_MENU_DLSS_QUALITY] = "质量", + [UI_MENU_DLSS_BALANCED] = "平衡", + [UI_MENU_DLSS_PERFORMANCE] = "性能", + [UI_MENU_FXAA] = "游戏抗锯齿(FXAA)", + [UI_MENU_FXAA_DESC] = "游戏自身的 FXAA 边缘平滑。会让细节略微模糊;开启 DLAA 时不需要。", }; #define SWKBD_ONLY(name, ...) static const char *const name[UI_TEXT_COUNT] = {SWKBD(__VA_ARGS__)} diff --git a/runtime/vk_dlaa.c b/runtime/vk_dlaa.c index 41de947d..39244b0a 100644 --- a/runtime/vk_dlaa.c +++ b/runtime/vk_dlaa.c @@ -86,9 +86,14 @@ static int p_getu(const NgxParam *p, const char *n, unsigned *v) { return NGX_OK static int p_getf(const NgxParam *p, const char *n, float *v) { return NGX_OK(((GetF)p->vt->slot[G_F])(p, n, v)); } static int p_getp(const NgxParam *p, const char *n, void **v) { return NGX_OK(((GetP)p->vt->slot[G_P])(p, n, v)); } -// NGX is brought up whenever the driver has it, whatever the setting, so dlaa can be switched on while the game runs -// (its device extensions can only be asked for at device creation). Switched off, nothing else of DLAA runs. -int vk_dlaa_wanted(void) { return 1; } +// NGX is brought up only when dlaa is on at start: its device extensions can only be asked for at device creation, and +// loading the driver's NGX core on every NVIDIA machine would cost start time and change the device with DLAA off. So +// dlaa applies after a restart; switched off, nothing else of DLAA runs. +int vk_dlaa_wanted(void) { + static int wanted = -1; + if (wanted < 0) wanted = cfg_bool("TOTK_DLAA"); + return wanted; +} static int core_load(void) { if (N.tried) return N.loaded; @@ -656,6 +661,7 @@ int vk_dlaa_skip_draw(VkExec *ex, const GfxShader *fs) { static int fxaa = 1; uint64_t f = __atomic_load_n(&gfx_counters.frames, __ATOMIC_RELAXED); if (f != frame_read) frame_read = f, fxaa = cfg_bool("TOTK_FXAA"); // once a frame: the menu switches it live + if (fxaa && !D.up) return 0; // nothing to skip: no shader lookup per draw at the defaults if (!fs) return 0; uint64_t h = spirv_hash(fs); if (h != FXAA_FS[0] && h != FXAA_FS[1]) return 0; diff --git a/totk.ini.example b/totk.ini.example index 7a0c0589..d28e2cbc 100644 --- a/totk.ini.example +++ b/totk.ini.example @@ -182,8 +182,7 @@ # pcss = 0 # NVIDIA DLSS / DLAA for the 3D scene, on NVIDIA RTX GPUs with nvngx_dlss.dll (from NVIDIA's DLSS SDK) next to -# totk.exe; elsewhere the setting does nothing. The HUD is drawn after it and is not touched. Changes while the game -# runs take effect at once. +# totk.exe; elsewhere the setting does nothing. The HUD is drawn after it and is not touched. Read at start. # 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