diff --git a/docs/architecture.md b/docs/architecture.md index a6f5a8c1..2d493ccb 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -137,14 +137,15 @@ Every guest thread is a host thread. TotK assumes Horizon's scheduler: three app that computes last frame's position from last frame's blocks (the game writes them into two copies that take turns; the uniform snapshot keeps both) and writes the difference into the motion image. `TOTK_MV_CHECK` measures the vectors against the picture, `TOTK_DLAA_TIMES` times the passes on the GPU. `fxaa` switches the game's own FXAA pass. -- FSR (`vk_ffx.c`, `dlaa_backend = fsr`, Windows). The same frame, jitter, motion vectors and masks go to AMD's FSR - instead of DLSS: `vk_dlaa.c` `evaluate` calls `vk_ffx_dispatch` where it would call NGX, and everything around it is - shared. `amd_fidelityfx_loader_vk.dll` (FSR SDK 2.4) is loaded at run time from the executable's folder and finds - `amd_fidelityfx_upscaler_vk.dll` next to it; only the descriptor layouts of `ffx_api_min.h` are compiled in. At - start the upscaler's versions for the device are listed and the newest FSR 4 is pinned where the DLL offers it (the - DLL decides which GPUs get it), else its default (FSR 3.1). `vk_device.c` enables `VK_KHR_cooperative_matrix` and - `VK_EXT_shader_float8` with their features when the device has them. FSR also asks for the camera's near and far - distances and field of view, which `cam_params` reads from the projection in the scene camera block. +- FSR (`vk_ffx.c`, `dlaa_backend = fsr` or `fsr3`, Windows). The same frame, jitter, motion vectors and masks go to + AMD's FSR instead of DLSS: `vk_dlaa.c` `evaluate` calls `vk_ffx_dispatch` where it would call NGX, and everything + around it is shared. `amd_fidelityfx_loader_vk.dll` (FSR SDK 2.4) is loaded at run time from the executable's folder + and finds `amd_fidelityfx_upscaler_vk.dll` next to it; only the descriptor layouts of `ffx_api_min.h` are compiled in. + At start the upscaler's versions for the device are listed and the newest FSR 4 is pinned where the DLL offers it (the + DLL decides which GPUs get it), else its default (FSR 3.1); `fsr3` pins the newest FSR 3 instead. `vk_device.c` + enables `VK_KHR_cooperative_matrix` and `VK_EXT_shader_float8` with their features when the device has them. FSR also + asks for the camera's near and far distances and field of view, which `cam_params` reads from the projection in the + scene camera block. - Occlusion queries never block the CPU; a result that is not ready counts as visible. - ASTC textures are uploaded as they are where the device reports `textureCompressionASTC_LDR`, and decoded by a compute shader everywhere else (`vk_astc.c`, `TOTK_ASTC`). The CPU decoder (`tex_astc*.c`) is the fallback and the test oracle. - Draw state. A draw whose program, bound state and textures repeat reuses the previous draw's shaders and skips rebuilding its descriptor sets; descriptor sets are written through update templates (`vk_exec_draw.c`, `vk_pipeline.c`). diff --git a/runtime/cfg.c b/runtime/cfg.c index 81babd85..79643aa2 100644 --- a/runtime/cfg.c +++ b/runtime/cfg.c @@ -141,7 +141,7 @@ static const CfgMeta metas[] = { {"HUD_WIDTH", "full", "full|21:9|16:9", RESTART}, {"DYNAMIC_RES", "1", "0|1", LIVE}, // resolution.c res_dynres_live {"UPSCALER", "fsr", "fsr|bilinear", LIVE}, {"SHARPNESS", "80", "0..100", LIVE}, - {"DLAA", "0", "0|1", RESTART}, {"DLAA_BACKEND", "dlss", "dlss|fsr", RESTART}, {"DLSS", "dlaa", "dlaa|quality|balanced|performance|ultra_performance", LIVE}, + {"DLAA", "0", "0|1", RESTART}, {"DLAA_BACKEND", "dlss", "dlss|fsr|fsr3", RESTART}, {"DLSS", "dlaa", "dlaa|quality|balanced|performance|ultra_performance", LIVE}, {"DLSS_PRESET", "default", "default|k|j", LIVE}, {"DLSS_FIXED_EXPOSURE", "0", "0|1", LIVE}, {"DLAA_EFFECTS_AFTER", "0", "0|1", LIVE}, {"DLSS_CHAR_MASK", "65", "0|35|65|100", LIVE}, {"REFLEX", "off", "off|on|boost", RESTART}, {"FXAA", "1", "0|1", LIVE}, {"LOD_STEADY", "0", "0|1", RESTART}, // sets steady diff --git a/runtime/resolution.c b/runtime/resolution.c index 91e2d4e9..f2906f8d 100644 --- a/runtime/resolution.c +++ b/runtime/resolution.c @@ -72,15 +72,15 @@ static struct { // The scene size is decided before the device exists, so NGX cannot be asked yet. NGX loads DLSS from nvngx_dlss.dll // next to totk.exe on Windows, libnvidia-ngx-dlss.so. next to totk on Linux (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. -// With dlaa_backend = fsr the modes scale through AMD's FSR instead (vk_ffx.c), which needs its loader and upscaler -// DLLs next to totk.exe; on Linux the setting is ignored and DLSS is checked (vk_dlaa.c fsr_backend). +// With dlaa_backend = fsr or fsr3 the modes scale through AMD's FSR instead (vk_ffx.c), which needs its loader and +// upscaler DLLs next to totk.exe; on Linux the setting is ignored and DLSS is checked (vk_dlaa.c fsr_backend). static int dlss_dll(void) { #ifdef _WIN32 char exe[1024], path[1024 + 48]; if (!plat_exe_path(exe, sizeof exe)) return 1; char *last = plat_last_sep(exe); if (!last) return 1; - if (!strcmp(cfg_value("TOTK_DLAA_BACKEND"), "fsr")) { + if (!strncmp(cfg_value("TOTK_DLAA_BACKEND"), "fsr", 3)) { snprintf(path, sizeof path, "%.*s/amd_fidelityfx_loader_vk.dll", (int)(last - exe), exe); if (!plat_file_exists(path)) return 0; snprintf(path, sizeof path, "%.*s/amd_fidelityfx_upscaler_vk.dll", (int)(last - exe), exe); @@ -136,7 +136,7 @@ static double dlss_share(const char *m) { if (!strcmp(m, dlss[i].name)) { if (dll < 0 && !(dll = dlss_dll())) { #ifdef _WIN32 - if (!strcmp(cfg_value("TOTK_DLAA_BACKEND"), "fsr")) + if (!strncmp(cfg_value("TOTK_DLAA_BACKEND"), "fsr", 3)) rt_log("resolution: FSR %s needs amd_fidelityfx_loader_vk.dll and amd_fidelityfx_upscaler_vk.dll " "next to totk.exe, which are missing: the scene follows render_scale", m); else diff --git a/runtime/ui/menu.cpp b/runtime/ui/menu.cpp index 3d1a32ed..f633b54d 100644 --- a/runtime/ui/menu.cpp +++ b/runtime/ui/menu.cpp @@ -731,23 +731,26 @@ static const char *present_note(void) { return note; } -// The upscaler of the 3D scene, one row over two settings: dlaa (off or on) and dlaa_backend (NVIDIA DLSS or AMD FSR). -// AMD ships FSR's Vulkan libraries for Windows only, so Linux has DLSS alone (vk_dlaa.c fsr_backend). +// The upscaler of the 3D scene, one row over two settings: dlaa (off or on) and dlaa_backend (NVIDIA DLSS, AMD FSR 4 or +// AMD FSR 3). AMD ships FSR's Vulkan libraries for Windows only, so Linux has DLSS alone (vk_dlaa.c fsr_backend). static void row_upscalers(void) { - static const UiTextId ids[] = {UI_MENU_DLAA_OFF, UI_MENU_DLAA_BACKEND_DLSS, UI_MENU_DLAA_BACKEND_FSR}; + static const UiTextId ids[] = {UI_MENU_DLAA_OFF, UI_MENU_DLAA_BACKEND_DLSS, UI_MENU_DLAA_BACKEND_FSR, + UI_MENU_DLAA_BACKEND_FSR3}; + static const char *const backends[] = {"", "dlss", "fsr", "fsr3"}; #ifdef _WIN32 - const int n = 3; + const int n = 4; #else const int n = 2; #endif - int cur = !cfg_bool("TOTK_DLAA") ? 0 : n > 2 && !strcmp(cfg_value("TOTK_DLAA_BACKEND"), "fsr") ? 2 : 1; + const char *be = cfg_value("TOTK_DLAA_BACKEND"); + int cur = !cfg_bool("TOTK_DLAA") ? 0 : n > 3 && !strcmp(be, "fsr3") ? 3 : n > 2 && !strcmp(be, "fsr") ? 2 : 1; int step = opt_choice_step("TOTK_DLAA", UI_MENU_DLAA, menu_text(ids[cur]), cur == 0, UI_MENU_DLAA_DESC); if (!step) return; // A / click: the next value, round to the first; left / right stop at the ends (as opt_choice_list) int nv = step == 2 ? (cur + 1) % n : cur + step < 0 ? 0 : cur + step >= n ? n - 1 : cur + step; if (nv == cur) return; cfg_set("TOTK_DLAA", nv ? "1" : "0"); - if (nv) cfg_set("TOTK_DLAA_BACKEND", nv == 2 ? "fsr" : "dlss"); // off keeps the upscaler chosen last + if (nv) cfg_set("TOTK_DLAA_BACKEND", backends[nv]); // off keeps the upscaler chosen last opt_save_soon(); } diff --git a/runtime/ui_text.c b/runtime/ui_text.c index 8186f0c4..048013c0 100644 --- a/runtime/ui_text.c +++ b/runtime/ui_text.c @@ -155,14 +155,15 @@ static const char *const text_en[UI_TEXT_COUNT] = { "draws less of it. Takes effect at the next start.", [UI_MENU_DLAA] = "Upscalers", [UI_MENU_DLAA_DESC] = "What smooths and scales the 3D scene. NVIDIA DLSS: NVIDIA RTX GPUs, " DLSS_FILE " next to " EXE_FILE - ". AMD FSR: FSR 4 on AMD Radeon RX 9000, 7000 and 6000, FSR 3.1 on other GPUs " - "AMD's library supports " + ". AMD FSR 4: AMD Radeon RX 9000, 7000 and 6000 (other GPUs get FSR 3.1); AMD FSR 3: " + "FSR 3.1 on any GPU AMD's library supports " "(Windows; amd_fidelityfx_loader_vk.dll and amd_fidelityfx_upscaler_vk.dll next to " EXE_FILE "); with it the game's FXAA and its dynamic resolution are off. Smoother edges and less " "shimmer; the HUD is not touched. The mode below sets the resolution it works from. Takes " "effect after a restart.", [UI_MENU_DLAA_OFF] = "Off", - [UI_MENU_DLAA_BACKEND_DLSS] = "NVIDIA DLSS", [UI_MENU_DLAA_BACKEND_FSR] = "AMD FSR", + [UI_MENU_DLAA_BACKEND_DLSS] = "NVIDIA DLSS", [UI_MENU_DLAA_BACKEND_FSR] = "AMD FSR 4", + [UI_MENU_DLAA_BACKEND_FSR3] = "AMD FSR 3", [UI_MENU_DLSS_PRESET] = "DLSS model", [UI_MENU_DLSS_PRESET_DESC] = "Which DLSS model runs. Automatic follows NVIDIA's advice per mode: K for DLAA, Quality " "and Balanced, M for Performance, L for Ultra Performance. J: slightly less ghosting " @@ -775,14 +776,15 @@ static const char *const text_ru[UI_TEXT_COUNT] = { "перезапуска.", [UI_MENU_DLAA] = "Апскейлеры", [UI_MENU_DLAA_DESC] = "Что сглаживает и масштабирует 3D-сцену. NVIDIA DLSS: видеокарты NVIDIA RTX, " DLSS_FILE " рядом с " - EXE_FILE ". AMD FSR: FSR 4 на AMD Radeon RX 9000, 7000 и 6000, FSR 3.1 на других видеокартах, " - "которые поддерживает библиотека AMD (Windows; amd_fidelityfx_loader_vk.dll и " + EXE_FILE ". AMD FSR 4: AMD Radeon RX 9000, 7000 и 6000 (остальные получают FSR 3.1); AMD FSR 3: " + "FSR 3.1 на любой видеокарте, которую поддерживает библиотека AMD (Windows; amd_fidelityfx_loader_vk.dll и " "amd_fidelityfx_upscaler_vk.dll рядом с " EXE_FILE "); с ним FXAA игры и её динамическое разрешение выключены. Ровнее края и меньше " "мерцания; интерфейс не затрагивается. Режим ниже задаёт разрешение, с которым он работает. " "Действует после перезапуска.", [UI_MENU_DLAA_OFF] = "Выкл.", - [UI_MENU_DLAA_BACKEND_DLSS] = "NVIDIA DLSS", [UI_MENU_DLAA_BACKEND_FSR] = "AMD FSR", + [UI_MENU_DLAA_BACKEND_DLSS] = "NVIDIA DLSS", [UI_MENU_DLAA_BACKEND_FSR] = "AMD FSR 4", + [UI_MENU_DLAA_BACKEND_FSR3] = "AMD FSR 3", [UI_MENU_DLSS_PRESET] = "Модель DLSS", [UI_MENU_DLSS_PRESET_DESC] = "Какая модель DLSS работает. «Автоматически» следует совету NVIDIA для каждого режима: K " "для DLAA, «Качества» и «Баланса», M для «Производительности», L для «Макс. " @@ -1838,14 +1840,16 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = { "cai (PCSS). 0 mantém o filtro do jogo. Vale no próximo início.", [UI_MENU_DLAA] = "Upscalers", [UI_MENU_DLAA_DESC] = "O que suaviza e amplia a cena 3D. NVIDIA DLSS: placas NVIDIA RTX, nvngx_dlss.dll ao lado do " - "totk.exe. AMD FSR: FSR 4 nas AMD Radeon RX 9000, 7000 e 6000, FSR 3.1 nas outras placas que a " - "biblioteca da AMD suporta (Windows; amd_fidelityfx_loader_vk.dll e " + "totk.exe. AMD FSR 4: AMD Radeon RX 9000, 7000 e 6000 (as outras placas recebem o FSR 3.1); " + "AMD FSR 3: FSR 3.1 em qualquer placa que a biblioteca da AMD suporta " + "(Windows; amd_fidelityfx_loader_vk.dll e " "amd_fidelityfx_upscaler_vk.dll ao lado do " "totk.exe); com ele o FXAA do jogo e a resolução dinâmica ficam desligados. 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_DLAA_OFF] = "Desligado", - [UI_MENU_DLAA_BACKEND_DLSS] = "NVIDIA DLSS", [UI_MENU_DLAA_BACKEND_FSR] = "AMD FSR", + [UI_MENU_DLAA_BACKEND_DLSS] = "NVIDIA DLSS", [UI_MENU_DLAA_BACKEND_FSR] = "AMD FSR 4", + [UI_MENU_DLAA_BACKEND_FSR3] = "AMD FSR 3", [UI_MENU_DLSS] = "Modo do DLSS", [UI_MENU_DLSS_DESC] = "DLAA desenha a cena 3D na resolução cheia. Qualidade, Equilibrado, Desempenho e Ultra " "Desempenho a desenham em 67, 58, 50 e 33 % e deixam o DLSS ampliá-la, o que poupa tempo da " @@ -2582,12 +2586,13 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = { [UI_MENU_PCSS] = "柔和阴影", [UI_MENU_PCSS_DESC] = "物体接触地面处的太阳阴影锐利,阴影投得越远越柔和(PCSS)。0 保留游戏自身的过滤。下次启动时生效。", [UI_MENU_DLAA] = "超分辨率技术", - [UI_MENU_DLAA_DESC] = "平滑并放大 3D 场景的技术。NVIDIA DLSS:NVIDIA RTX 显卡,nvngx_dlss.dll 放在 totk.exe 旁。AMD FSR:AMD Radeon " - "RX 9000、7000 和 6000 系列为 FSR 4,AMD 库支持的其他显卡为 FSR 3.1(Windows;amd_fidelityfx_loader_vk.dll 和 " + [UI_MENU_DLAA_DESC] = "平滑并放大 3D 场景的技术。NVIDIA DLSS:NVIDIA RTX 显卡,nvngx_dlss.dll 放在 totk.exe 旁。AMD FSR 4:AMD Radeon " + "RX 9000、7000 和 6000 系列(其他显卡使用 FSR 3.1);AMD FSR 3:AMD 库支持的任何显卡上的 FSR 3.1(Windows;amd_fidelityfx_loader_vk.dll 和 " "amd_fidelityfx_upscaler_vk.dll 放在 totk.exe 旁);使用它时游戏的 FXAA 和动态分辨率关闭。边缘更平滑," "闪烁更少;HUD 不受影响。下方的模式决定它的工作分辨率。重启后生效。", [UI_MENU_DLAA_OFF] = "关", - [UI_MENU_DLAA_BACKEND_DLSS] = "NVIDIA DLSS", [UI_MENU_DLAA_BACKEND_FSR] = "AMD FSR", + [UI_MENU_DLAA_BACKEND_DLSS] = "NVIDIA DLSS", [UI_MENU_DLAA_BACKEND_FSR] = "AMD FSR 4", + [UI_MENU_DLAA_BACKEND_FSR3] = "AMD FSR 3", [UI_MENU_DLSS] = "DLSS 模式", [UI_MENU_DLSS_DESC] = "DLAA 以全分辨率绘制 3D 场景。质量、平衡、性能和超级性能分别以 67%、58%、50% 和 33% 绘制,再由 DLSS 放大,以节省 GPU 时间;它们会取代 3D 渲染比例。立即生效。", [UI_MENU_DLSS_DLAA] = "DLAA(原生)", diff --git a/runtime/ui_text.h b/runtime/ui_text.h index 30918d11..776ba3a5 100644 --- a/runtime/ui_text.h +++ b/runtime/ui_text.h @@ -59,7 +59,8 @@ typedef enum { UI_MENU_CONTACT_SHADOWS, UI_MENU_CONTACT_SHADOWS_DESC, UI_MENU_PCSS, UI_MENU_PCSS_DESC, UI_MENU_DLAA, UI_MENU_DLAA_DESC, UI_MENU_DLAA_OFF, UI_MENU_DLAA_BACKEND_DLSS, - UI_MENU_DLAA_BACKEND_FSR, UI_MENU_DLSS, UI_MENU_DLSS_DESC, UI_MENU_DLSS_DLAA, UI_MENU_DLSS_QUALITY, + UI_MENU_DLAA_BACKEND_FSR, UI_MENU_DLAA_BACKEND_FSR3, UI_MENU_DLSS, UI_MENU_DLSS_DESC, UI_MENU_DLSS_DLAA, + UI_MENU_DLSS_QUALITY, UI_MENU_DLSS_BALANCED, UI_MENU_DLSS_PERFORMANCE, UI_MENU_DLSS_ULTRA, UI_MENU_DLSS_PRESET, UI_MENU_DLSS_PRESET_DESC, UI_MENU_DLSS_PRESET_DEFAULT, UI_MENU_DLSS_PRESET_K, UI_MENU_DLSS_PRESET_J, UI_MENU_DLSS_CHARS, UI_MENU_DLSS_CHARS_DESC, UI_MENU_DLSS_CHARS_OFF, UI_MENU_DLSS_CHARS_LIGHT, UI_MENU_DLSS_CHARS_MEDIUM, UI_MENU_DLSS_CHARS_FULL, UI_MENU_FXAA, UI_MENU_FXAA_DESC, diff --git a/runtime/vk_dlaa.c b/runtime/vk_dlaa.c index 2bb96d07..3a54e2b8 100644 --- a/runtime/vk_dlaa.c +++ b/runtime/vk_dlaa.c @@ -12,9 +12,9 @@ // // Where DLAA runs in the frame, the jitter and the motion vectors: see the sections below. // -// dlaa_backend = fsr (TOTK_DLAA_BACKEND, read at start) hands the same frame to AMD's FSR instead (vk_ffx.c): the -// arming, the jitter, the motion vectors, the masks and the copy of the result below are shared, and only the call that -// upscales differs (evaluate). NGX is then never loaded. +// dlaa_backend = fsr or fsr3 (TOTK_DLAA_BACKEND, read at start) hands the same frame to AMD's FSR instead (vk_ffx.c): +// the arming, the jitter, the motion vectors, the masks and the copy of the result below are shared, and only the call +// that upscales differs (evaluate). NGX is then never loaded. #include #include #include @@ -114,13 +114,13 @@ int vk_dlaa_wanted(void) { return wanted; } -// FSR instead of DLSS (TOTK_DLAA_BACKEND=fsr), fixed for the run like dlaa: the backend's extensions are chosen at -// device creation. AMD ships FSR's Vulkan libraries for Windows only, so on Linux the setting is ignored (the menu has -// no row for it) and DLAA stays with DLSS. +// FSR instead of DLSS (TOTK_DLAA_BACKEND=fsr, FSR 4, or fsr3, FSR 3.1: vk_ffx_init picks the version), fixed for the +// run like dlaa: the backend's extensions are chosen at device creation. AMD ships FSR's Vulkan libraries for Windows +// only, so on Linux the setting is ignored (the menu has no row for it) and DLAA stays with DLSS. static int fsr_backend(void) { static int fsr = -1; if (fsr < 0) { - fsr = !strcmp(cfg_value("TOTK_DLAA_BACKEND"), "fsr"); + fsr = !strncmp(cfg_value("TOTK_DLAA_BACKEND"), "fsr", 3); // fsr or fsr3 #ifndef _WIN32 if (fsr && vk_dlaa_wanted()) rt_log("dlaa: dlaa_backend = fsr runs on Windows only (AMD's FSR SDK has no Linux libraries): using DLSS"); diff --git a/runtime/vk_dlaa.h b/runtime/vk_dlaa.h index 021842c3..622d7a8b 100644 --- a/runtime/vk_dlaa.h +++ b/runtime/vk_dlaa.h @@ -15,8 +15,8 @@ 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); const char *vk_dlaa_name(void); // "FSR 4.1.2" or "DLSS" once DLAA ran, NULL otherwise (the performance overlay) -// 1 while AMD FSR is the upscaler at work: dlaa is on, dlaa_backend = fsr and FSR came up (after vk_dlaa_init). The -// game's dynamic resolution (resolution.c res_dynres_live) and its FXAA (vk_dlaa_skip_draw) are off then. +// 1 while AMD FSR is the upscaler at work: dlaa is on, dlaa_backend = fsr or fsr3 and FSR came up (after vk_dlaa_init). +// The game's dynamic resolution (resolution.c res_dynres_live) and its FXAA (vk_dlaa_skip_draw) are off then. int vk_dlaa_fsr_on(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 diff --git a/runtime/vk_ffx.c b/runtime/vk_ffx.c index 72528371..0e0662d8 100644 --- a/runtime/vk_ffx.c +++ b/runtime/vk_ffx.c @@ -4,8 +4,9 @@ // code is compiled in, only the descriptor layouts of ffx_api_min.h. // // The upscaler DLL offers several versions (FSR 4.x, FSR 3.1.x) and decides by itself which ones a device can run: -// vk_ffx_init lists them and pins the newest 4.x when there is one, else leaves the DLL's default (3.1 on GPUs without -// FSR 4). Every context is created with that version (ffxOverrideVersion). +// vk_ffx_init lists them and pins the newest 4.x when there is one (dlaa_backend = fsr), or the newest 3.x +// (dlaa_backend = fsr3), else leaves the DLL's default (3.1 on GPUs without FSR 4). Every context is created with that +// version (ffxOverrideVersion). // // What FSR gets is what DLSS gets (vk_dlaa.c evaluate): the R11G11B10F light target as linear HDR colour with automatic // exposure, the D32F scene depth, motion vectors at the render size in render pixels pointing from this frame's @@ -58,7 +59,7 @@ static struct { int vk_ffx_wanted(void) { static int wanted = -1; - if (wanted < 0) wanted = cfg_bool("TOTK_DLAA") && !strcmp(cfg_value("TOTK_DLAA_BACKEND"), "fsr"); + if (wanted < 0) wanted = cfg_bool("TOTK_DLAA") && !strncmp(cfg_value("TOTK_DLAA_BACKEND"), "fsr", 3); return wanted; } @@ -130,13 +131,16 @@ void vk_ffx_init(void) { } if (count > FFX_MAX_VERSIONS) count = FFX_MAX_VERSIONS; char list[256] = ""; + // dlaa_backend = fsr takes the newest FSR 4 the DLL offers for this device, fsr3 the newest FSR 3 (3.1 in the SDK + // 2.4 libraries, on any GPU the DLL supports). Without one the DLL's default stays (FSR 3.1 on GPUs without FSR 4). + int want3 = !strcmp(cfg_value("TOTK_DLAA_BACKEND"), "fsr3"); int best = -1, best_major = 0, best_minor = 0, best_patch = 0; for (uint64_t i = 0; i < count; i++) { const char *nm = names[i] ? names[i] : "?"; size_t used = strlen(list); snprintf(list + used, sizeof list - used, "%s%s", i ? ", " : "", nm); int ma = 0, mi = 0, pa = 0; - if (sscanf(nm, "%d.%d.%d", &ma, &mi, &pa) < 1 || ma < 4) continue; + if (sscanf(nm, "%d.%d.%d", &ma, &mi, &pa) < 1 || (want3 ? ma != 3 : ma < 4)) continue; if (best < 0 || ma > best_major || (ma == best_major && (mi > best_minor || (mi == best_minor && pa > best_patch)))) best = (int)i, best_major = ma, best_minor = mi, best_patch = pa; } @@ -148,7 +152,7 @@ void vk_ffx_init(void) { } F.available = 1; rt_log("fsr: upscaler versions for this device: %s; using %s%s", list, F.version, - best >= 0 ? "" : " (FSR 4 is not offered for this GPU)"); + best >= 0 ? "" : want3 ? " (FSR 3 is not offered for this GPU)" : " (FSR 4 is not offered for this GPU)"); } int vk_ffx_available(void) { return vk_ffx_wanted() && F.available; } diff --git a/runtime/vk_ffx.h b/runtime/vk_ffx.h index 5f4f88c7..022d94e6 100644 --- a/runtime/vk_ffx.h +++ b/runtime/vk_ffx.h @@ -4,7 +4,7 @@ #pragma once #include "vk.h" -int vk_ffx_wanted(void); // dlaa and dlaa_backend = fsr at start (the device may still lack FSR) +int vk_ffx_wanted(void); // dlaa and dlaa_backend = fsr or fsr3 at start (the device may still lack FSR) // vk_device.c, while it builds the device: the extensions FSR's shaders use (cooperative matrix, 8-bit floats) join // the list when the device has them; their feature structures are chained there. void vk_ffx_device_exts(const VkExtensionProperties *have, uint32_t nhave, const char **ext, uint32_t *n, uint32_t max); diff --git a/totk.ini.example b/totk.ini.example index 9ad4f17c..e6dbce9c 100644 --- a/totk.ini.example +++ b/totk.ini.example @@ -223,8 +223,8 @@ # Dynamic resolution: 1 lets the game lower the scene to 90 or 80 % of that size, 0 keeps it at 100 %. The game decides # by a cost estimate made for the Switch, which grows with the scene's width and ignores how fast your GPU is: a # scene wider than about 3000 pixels can drop to 80 % on any GPU. 1 is the default. 1.1.0, 1.2.1 and 1.4.3. Changes in -# the menu take effect at once. While AMD FSR is at work (dlaa = 1 with dlaa_backend = fsr) the scene stays at 100 % -# whatever this says. +# the menu take effect at once. While AMD FSR is at work (dlaa = 1 with dlaa_backend = fsr or fsr3) the scene stays +# at 100 % whatever this says. # dynamic_res = 1 # Scaling to the window when it is larger than the game resolution: fsr (AMD FSR 1) or bilinear, and FSR's sharpening # from 0 (off) to 100. With dlaa_backend = fsr the same sharpness also sets how much FSR sharpens the 3D scene it @@ -292,9 +292,10 @@ # NVIDIA driver's libnvidia-ngx.so.1 installed); elsewhere the setting does nothing. The HUD is drawn after it and is not touched. # Read at start. # dlaa = 0 -# What dlaa runs: dlss (NVIDIA DLSS, above) or fsr (AMD FSR: FSR 4 on Radeon RX 9000, 7000 and 6000 GPUs, FSR 3.1 on -# others; Windows, with amd_fidelityfx_loader_vk.dll and amd_fidelityfx_upscaler_vk.dll from AMD's FSR SDK next to -# totk.exe, which the setup downloads). The dlss mode below applies to both; dlss_preset is DLSS's only. Read at start. +# What dlaa runs: dlss (NVIDIA DLSS, above), fsr (AMD FSR 4 on Radeon RX 9000, 7000 and 6000 GPUs, FSR 3.1 on others) +# or fsr3 (AMD FSR 3.1 on any GPU AMD's library supports). FSR runs on Windows, with amd_fidelityfx_loader_vk.dll and +# amd_fidelityfx_upscaler_vk.dll from AMD's FSR SDK next to totk.exe, which the setup downloads. The dlss mode below +# applies to all three; dlss_preset is DLSS's only. Read at start. # dlaa_backend = dlss # What DLSS works from: dlaa (the 3D scene at full size), quality, balanced, performance or ultra_performance (the # scene at 67, 58, 50 or 33 % of the output, scaled up by DLSS; these replace render_scale and sharpen texture filtering