From 1e908362eae4e321db9d6ddc2ad06b41ad45758b Mon Sep 17 00:00:00 2001 From: SchulzCode <116190857+SchulzCode@users.noreply.github.com> Date: Sat, 31 Oct 2026 16:19:27 +0100 Subject: [PATCH 1/3] Load NGX on Linux for DLSS / DLAA vk_dlaa.c reached the NGX core only through Windows: the registry, LoadLibraryA and GetModuleFileNameW. On Linux the NVIDIA driver installs the core as libnvidia-ngx.so.1 with the same Vulkan entry points; it is opened with plat_lib_open. The parameter object's vtable follows the Itanium C++ ABI there, each overload group in declaration order rather than MSVC's reverse order, so the slot enum has a Linux variant; vtable_ok confirms it at start. NGX gets the executable's folder as a 32-bit wchar_t string, converted from UTF-8 without the C locale, and loads libnvidia-ngx-dlss.so. from there. The Windows path is unchanged. resolution.c sized the scene for a DLSS mode only on Windows, where it looks for nvngx_dlss.dll; on Linux it now looks for libnvidia-ngx-dlss.so. next to totk, so quality, balanced and performance work there too. The no-op stubs vk_dlaa.c had for other platforms go, as Linux now builds the real code. --- runtime/resolution.c | 23 +++++++++-- runtime/vk_dlaa.c | 96 ++++++++++++++++++++++++++++++++------------ 2 files changed, 89 insertions(+), 30 deletions(-) diff --git a/runtime/resolution.c b/runtime/resolution.c index cd93a74c..aabe96fd 100644 --- a/runtime/resolution.c +++ b/runtime/resolution.c @@ -27,6 +27,9 @@ // rewritten table (res_heapdef_build) in place of the original; memory.c adds the amount to the application pool, so // no other heap shrinks. Without the rewritten table (a RomFS that lacks it, a format this code does not know) the // patch sets stay off and the game keeps its own sizes. +#ifndef _WIN32 +#include +#endif #include #include #include @@ -57,8 +60,8 @@ static struct { } R; // 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 (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. Off Windows vk_dlaa.c is built as no-op stubs, so there is no DLSS at all. +// 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. static int dlss_dll(void) { #ifdef _WIN32 char exe[1024], path[1024 + 32]; @@ -68,7 +71,18 @@ static int dlss_dll(void) { snprintf(path, sizeof path, "%.*s/nvngx_dlss.dll", (int)(last - exe), exe); return plat_file_exists(path); #else - return 0; + char exe[1024]; + if (!plat_exe_path(exe, sizeof exe)) return 1; + char *last = plat_last_sep(exe); + if (!last) return 1; + *last = 0; + DIR *d = opendir(exe); + if (!d) return 1; + int found = 0; + for (struct dirent *e; !found && (e = readdir(d));) + found = !strncmp(e->d_name, "libnvidia-ngx-dlss.so.", 22); + closedir(d); + return found; #endif } @@ -99,7 +113,8 @@ static void decide(void) { #ifdef _WIN32 rt_log("resolution: DLSS %s needs nvngx_dlss.dll next to totk.exe, which is missing: the scene follows render_scale", m); #else - rt_log("resolution: DLSS %s runs on Windows only: the scene follows render_scale", m); + rt_log("resolution: DLSS %s needs libnvidia-ngx-dlss.so. next to totk, which is missing: the scene " + "follows render_scale", m); #endif R.dlss_k = 0; } diff --git a/runtime/vk_dlaa.c b/runtime/vk_dlaa.c index 4872dd32..fb7d0b3f 100644 --- a/runtime/vk_dlaa.c +++ b/runtime/vk_dlaa.c @@ -1,16 +1,19 @@ // DLAA: NVIDIA DLSS at the scene's own size (TOTK_DLAA, totk.ini dlaa). NGX is loaded at run time from the driver's -// NGX core (_nvngx.dll, found through HKLM\SOFTWARE\NVIDIA Corporation\Global\NGXCore); the DLSS model -// (nvngx_dlss.dll) is loaded by NGX from the folder of totk.exe. No NVIDIA SDK code or header is compiled in: the few -// NGX types used are declared here from the SDK's documented ABI, the way the Metroid Dread recomp's dlss.c reaches -// the core (read for behaviour only). +// NGX core: on Windows _nvngx.dll, found through HKLM\SOFTWARE\NVIDIA Corporation\Global\NGXCore; on Linux +// libnvidia-ngx.so.1, which the NVIDIA driver installs on the library path. NGX loads the DLSS model from the folder of +// the executable: nvngx_dlss.dll on Windows, libnvidia-ngx-dlss.so. on Linux. No NVIDIA SDK code or header is +// compiled in: the few NGX types used are declared here from the SDK's documented ABI, the way the Metroid Dread +// recomp's dlss.c reaches the core (read for behaviour only). // -// The core's parameter object is a C++ class whose virtual functions are called through the MSVC vtable: the Set -// overloads in slots 0-7 and the Get overloads in 8-15, each group in reverse declaration order. vtable_ok checks that +// The core's parameter object is a C++ class whose virtual functions are called through its vtable: the Set overloads +// in slots 0-7 and the Get overloads in 8-15. MSVC (the Windows core) lays out each group of overloads in reverse +// declaration order, the Itanium C++ ABI (the Linux core, built with GCC) in declaration order. vtable_ok checks the // layout with a set-then-get round trip before anything relies on it. // // Where DLAA runs in the frame, the jitter and the motion vectors: see the sections below. #ifdef _WIN32 #include +#endif #include #include #include @@ -19,6 +22,7 @@ #include "cfg.h" #include "host.h" +#include "platform/platform.h" #include "vk.h" #include "vk_dlaa.h" #include "vk_exec.h" @@ -57,7 +61,7 @@ typedef NgxResult (*PFN_Evaluate)(VkCommandBuffer, const NgxHandle *, const NgxP typedef NgxResult (*PFN_Release)(NgxHandle *); static struct { - HMODULE core; + void *core; // the NGX core library (an HMODULE on Windows) PFN_Init init; PFN_ReqExt req_ext; PFN_Params caps, alloc_params; @@ -77,7 +81,13 @@ typedef NgxResult (*GetI)(const NgxParam *, const char *, int *); typedef NgxResult (*GetU)(const NgxParam *, const char *, unsigned *); typedef NgxResult (*GetF)(const NgxParam *, const char *, float *); typedef NgxResult (*GetP)(const NgxParam *, const char *, void **); +// The SDK declares Set(u64), Set(float), Set(double), Set(u32), Set(int), Set(ID3D11Resource *), Set(ID3D12Resource *), +// Set(void *), then the Get overloads in the same order, then Reset. +#ifdef _WIN32 enum { S_P = 0, S_D12, S_D11, S_I, S_U32, S_D, S_F, S_U64, G_P, G_D12, G_D11, G_I, G_U32, G_D, G_F, G_U64 }; +#else +enum { S_U64 = 0, S_F, S_D, S_U32, S_I, S_D11, S_D12, S_P, G_U64, G_F, G_D, G_U32, G_I, G_D11, G_D12, G_P }; +#endif static void p_seti(NgxParam *p, const char *n, int v) { ((SetI)p->vt->slot[S_I])(p, n, v); } static void p_setu(NgxParam *p, const char *n, unsigned v) { ((SetU)p->vt->slot[S_U32])(p, n, v); } static void p_setf(NgxParam *p, const char *n, float v) { ((SetF)p->vt->slot[S_F])(p, n, v); } @@ -87,6 +97,12 @@ 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)); } +#ifdef _WIN32 +#define DLSS_MODEL "nvngx_dlss.dll" +#else +#define DLSS_MODEL "libnvidia-ngx-dlss.so." +#endif + // 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. @@ -99,6 +115,7 @@ int vk_dlaa_wanted(void) { static int core_load(void) { if (N.tried) return N.loaded; N.tried = 1; +#ifdef _WIN32 char dir[MAX_PATH] = {0}, path[MAX_PATH + 32]; DWORD n = sizeof dir; if (RegGetValueA(HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\NGXCore", "FullPath", RRF_RT_REG_SZ, @@ -112,7 +129,17 @@ static int core_load(void) { rt_log("dlaa: cannot load %s (error %lu): DLAA off", path, GetLastError()); return 0; } -#define FN(f, name) N.f = (void *)GetProcAddress(N.core, name) +#define FN(f, name) N.f = (void *)GetProcAddress((HMODULE)N.core, name) +#else + // The driver's NGX core; the dynamic loader finds it where the driver put it (/usr/lib, /usr/lib/x86_64-linux-gnu). + const char *path = "libnvidia-ngx.so.1"; + N.core = plat_lib_open(path); + if (!N.core) { + rt_log("dlaa: cannot load %s (not an NVIDIA driver, or one without NGX): DLAA off", path); + return 0; + } +#define FN(f, name) N.f = plat_lib_sym(N.core, name) +#endif FN(init, "NVSDK_NGX_VULKAN_Init_Ext2"); FN(req_ext, "NVSDK_NGX_VULKAN_RequiredExtensions"); FN(caps, "NVSDK_NGX_VULKAN_GetCapabilityParameters"); @@ -176,12 +203,46 @@ static int vtable_ok(void) { return ok; } +#ifndef _WIN32 +// UTF-8 to UTF-32 wchar_t, without the C library's locale (the runtime never sets one, so mbstowcs would stop at the +// first non-ASCII byte). Returns 0 on malformed input or when out has no room. +static int utf8_to_wide(const char *in, wchar_t *out, size_t cap) { + const unsigned char *u = (const unsigned char *)in; + size_t n = 0; + while (*u) { + unsigned c = *u++, more = c < 0x80 ? 0 : c >= 0xF0 ? 3 : c >= 0xE0 ? 2 : c >= 0xC0 ? 1 : 4; + if (more == 4) return 0; + if (more) c &= 0x3F >> more; + for (unsigned k = 0; k < more; k++, u++) { + if ((*u & 0xC0) != 0x80) return 0; + c = c << 6 | (*u & 0x3F); + } + if (n + 1 >= cap) return 0; + out[n++] = (wchar_t)c; + } + out[n] = 0; + return 1; +} +#endif + void vk_dlaa_init(void) { if (!vk_dlaa_wanted() || !core_load()) return; +#ifdef _WIN32 wchar_t wdir[MAX_PATH]; DWORD len = GetModuleFileNameW(NULL, wdir, MAX_PATH); while (len && wdir[len - 1] != L'\\') len--; wdir[len] = 0; +#else + // The executable's folder, where NGX looks for libnvidia-ngx-dlss.so and writes its logs, as a wchar_t string: + // 32-bit code points here, as the Linux core expects. + char dir[PLAT_PATH_MAX]; + wchar_t wdir[PLAT_PATH_MAX]; + char *cut = plat_exe_path(dir, sizeof dir) ? plat_last_sep(dir) : NULL; + if (!cut || !utf8_to_wide((cut[1] = 0, dir), wdir, PLAT_PATH_MAX)) { + rt_log("dlaa: cannot name the executable's folder for NGX: DLAA off"); + return; + } +#endif // 231313132: the application id NVIDIA's DLSS samples use for builds without an NVIDIA-issued id const VkCtx *c = vk_ctx(); NgxResult r = N.init(231313132ull, wdir, c->instance, c->phys, c->device, vkGetInstanceProcAddr, @@ -198,7 +259,7 @@ void vk_dlaa_init(void) { p_geti(caps, "SuperSampling.NeedsUpdatedDriver", &driver); } N.available = avail != 0; - rt_log("dlaa: NGX up; DLSS %s%s", avail ? "available" : "NOT available (is nvngx_dlss.dll next to totk.exe?)", + rt_log("dlaa: NGX up; DLSS %s%s", avail ? "available" : "NOT available (is " DLSS_MODEL " next to the executable?)", driver ? "; the driver needs an update" : ""); } @@ -696,20 +757,3 @@ int vk_dlaa_skip_draw(VkExec *ex, const GfxShader *fs) { return !fxaa; } -#else -// NGX is loaded as a Windows DLL; elsewhere DLAA, the DLSS modes' scaling and the FXAA switch do nothing. -#include "vk_dlaa.h" - -int vk_dlaa_wanted(void) { return 0; } -void vk_dlaa_instance_exts(const char **ext, uint32_t *n, uint32_t max) { (void)ext, (void)n, (void)max; } -void vk_dlaa_device_exts(const VkExtensionProperties *have, uint32_t nhave, const char **ext, uint32_t *n, uint32_t max) { - (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; } -void vk_dlaa_viewport(VkExec *ex, VkViewport *v) { (void)ex, (void)v; } -int vk_dlaa_skip_draw(VkExec *ex, const GfxShader *fs) { (void)ex, (void)fs; return 0; } -#endif From bd54e701a82e51566900dd6d6e3263afb87aa22d Mon Sep 17 00:00:00 2001 From: SchulzCode <116190857+SchulzCode@users.noreply.github.com> Date: Sat, 31 Oct 2026 16:31:09 +0100 Subject: [PATCH 2/3] Choose the DLSS model and pass DLSS the real frame time dlss_preset (default, k or j; F1 > Screen > "DLSS model", live) sets the render preset hints when a DLSS feature is created. default leaves the choice to NGX (preset K for DLAA, Quality and Balanced in the 310 releases); j is the transformer model NVIDIA describes as slightly less ghosting at the cost of more flicker. A change recreates the features at the next DLAA run. FrameTimeDeltaInMsec now carries the time since the previous evaluation instead of a fixed 16.67 ms. The menu and totk.ini.example name the DLSS model file of the platform in use. --- runtime/cfg.c | 7 ++++--- runtime/ui/menu.cpp | 2 ++ runtime/ui_text.c | 33 ++++++++++++++++++++++++------ runtime/ui_text.h | 3 ++- runtime/vk_dlaa.c | 50 +++++++++++++++++++++++++++++++++++++++++---- totk.ini.example | 12 ++++++++--- 6 files changed, 90 insertions(+), 17 deletions(-) diff --git a/runtime/cfg.c b/runtime/cfg.c index 53f2bb98..cfac4b81 100644 --- a/runtime/cfg.c +++ b/runtime/cfg.c @@ -37,7 +37,7 @@ static const char *const known[] = { "BIND_SKIP", "BIND_STATS", "BIND_UP", "BIND_X", "BIND_Y", "BIND_ZL", "BIND_ZR", "BLOCK_VIEWS_3D", "CLOTH_REALTIME", "COLOR_BRIGHTNESS", "COLOR_CONTRAST", "COLOR_GAMMA", "COLOR_PRESET", "COLOR_SATURATION", "CONTACT_DEBUG", "CONTACT_SHADOWS", "CORE_DIAG", "CRIT", "CRIT_OUT", - "DESC_TEMPLATE", "DEVICE_PROFILE", "DLAA", "DLAA_JITTER", "DLAA_MV", "DLSS", "DUMP", "DUMP_BUF", "DUMP_DIR", + "DESC_TEMPLATE", "DEVICE_PROFILE", "DLAA", "DLAA_JITTER", "DLAA_MV", "DLSS", "DLSS_PRESET", "DUMP", "DUMP_BUF", "DUMP_DIR", "DUMP_LOG", "EXEFS", "FEEDBACK", "FIX_C0", "FIX_ZERO", "FLIGHT", "FLIGHT_AT", "FLIGHT_DIR", "FLIGHT_FRAMES", "FLIGHT_SPIKE_MS", "FLIGHT_THUMBS", "FOV", "FOV_PATCH", "FPS60", "FPS_LIMIT", "FREEZE_IDLE", "FREE_CORES", "FULLSCREEN", "FXAA", "GPL", "GPL_DRAW_BUILD", "GPU", "GPU_INDEX", "GPU_NAME", "HDR", "HDR_GAME_NITS", @@ -70,7 +70,7 @@ static const struct { const char *key, *section; } sections[] = { {"COLOR_BRIGHTNESS", "display"}, {"COLOR_CONTRAST", "display"}, {"COLOR_SATURATION", "display"}, {"COLOR_GAMMA", "display"}, {"HDR", "display"}, {"HDR_PEAK_NITS", "display"}, {"HDR_GAME_NITS", "display"}, {"HDR_UI_NITS", "display"}, {"SHADOW_RES", "display"}, - {"DLAA", "display"}, {"DLSS", "display"}, {"FXAA", "display"}, + {"DLAA", "display"}, {"DLSS", "display"}, {"DLSS_PRESET", "display"}, {"FXAA", "display"}, {"DEVICE_PROFILE", "display"}, {"ASSUME_FOCUS", "display"}, {"SHADOW_SCALE", "display"}, {"SHADOW_RANGE", "display"}, {"CONTACT_SHADOWS", "display"}, {"PCSS", "display"}, @@ -111,7 +111,8 @@ 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", RESTART}, {"DLSS", "dlaa", "dlaa|quality|balanced|performance", RESTART}, {"FXAA", "1", "0|1", LIVE}, + {"DLAA", "0", "0|1", RESTART}, {"DLSS", "dlaa", "dlaa|quality|balanced|performance", RESTART}, + {"DLSS_PRESET", "default", "default|k|j", LIVE}, {"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/menu.cpp b/runtime/ui/menu.cpp index a4a6e33d..e4407a9e 100644 --- a/runtime/ui/menu.cpp +++ b/runtime/ui/menu.cpp @@ -674,6 +674,8 @@ static void tab_screen(float scale) { static const UiTextId dlss[] = {UI_MENU_DLSS_DLAA, UI_MENU_DLSS_QUALITY, UI_MENU_DLSS_BALANCED, UI_MENU_DLSS_PERFORMANCE}; opt_choice("TOTK_DLSS", UI_MENU_DLSS, dlss, 4, UI_MENU_DLSS_DESC); + static const UiTextId preset[] = {UI_MENU_DLSS_PRESET_DEFAULT, UI_MENU_DLSS_PRESET_K, UI_MENU_DLSS_PRESET_J}; + opt_choice("TOTK_DLSS_PRESET", UI_MENU_DLSS_PRESET, preset, 3, UI_MENU_DLSS_PRESET_DESC); opt_toggle("TOTK_FXAA", UI_MENU_FXAA, UI_MENU_FXAA_DESC); rows_color(); opt_group(UI_MENU_HDR_GROUP); diff --git a/runtime/ui_text.c b/runtime/ui_text.c index 03ca1186..b7069d08 100644 --- a/runtime/ui_text.c +++ b/runtime/ui_text.c @@ -25,6 +25,15 @@ typedef struct { const char *lang; const char *const *text; } Row; [UI_SWKBD_TITLE] = title, [UI_SWKBD_PROMPT] = prompt, [UI_SWKBD_DEFAULT_NAME] = name, [UI_SWKBD_OK] = ok, \ [UI_SWKBD_CANCEL] = cancel, [UI_SWKBD_PAD_HINT] = hint, LANG_NAMES +// The DLSS model file and the executable, as the player sees them on this platform. +#ifdef _WIN32 +#define DLSS_FILE "nvngx_dlss.dll" +#define EXE_FILE "totk.exe" +#else +#define DLSS_FILE "libnvidia-ngx-dlss.so" +#define EXE_FILE "totk" +#endif + static const char *const text_en[UI_TEXT_COUNT] = { SWKBD("Text entry", "Enter a name", "Horse", "OK", "Cancel", "Controller: A = OK, B = Cancel"), @@ -123,9 +132,14 @@ static const char *const text_en[UI_TEXT_COUNT] = { "away. Spreads the shadow map over more ground: raise Shadow resolution with it. " "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. Takes effect " - "after a restart.", + [UI_MENU_DLAA_DESC] = "NVIDIA DLSS for the 3D scene (NVIDIA RTX GPUs; " DLSS_FILE " next to " EXE_FILE "): 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_DLSS_PRESET] = "DLSS model", + [UI_MENU_DLSS_PRESET_DESC] = "Which DLSS model runs. Automatic lets the driver choose (the transformer model K for DLAA, " + "Quality and Balanced). J: slightly less ghosting behind moving characters, a little more " + "flicker. K: always the sharpest model, also in Performance. Applies at once.", + [UI_MENU_DLSS_PRESET_DEFAULT] = "Automatic", [UI_MENU_DLSS_PRESET_K] = "K (sharpest)", + [UI_MENU_DLSS_PRESET_J] = "J (less ghosting)", [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 " @@ -552,9 +566,16 @@ 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_DLAA_DESC] = "NVIDIA DLSS для 3D-сцены (видеокарты NVIDIA RTX; " DLSS_FILE " рядом с " EXE_FILE "): ровнее " + "края и меньше мерцания. Интерфейс не затрагивается. Режим ниже задаёт разрешение, с которым он " + "работает. Действует после перезапуска.", + [UI_MENU_DLSS_PRESET] = "Модель DLSS", + [UI_MENU_DLSS_PRESET_DESC] = "Какая модель DLSS работает. «Автоматически» оставляет выбор драйверу (трансформерная модель " + "K для DLAA, «Качества» и «Баланса»). J: чуть меньше шлейфов за движущимися персонажами, " + "немного больше мерцания. K: всегда самая чёткая модель, и в «Производительности». " + "Действует сразу.", + [UI_MENU_DLSS_PRESET_DEFAULT] = "Автоматически", [UI_MENU_DLSS_PRESET_K] = "K (самая чёткая)", + [UI_MENU_DLSS_PRESET_J] = "J (меньше шлейфов)", [UI_MENU_DLSS] = "Режим DLSS", [UI_MENU_DLSS_DESC] = "DLAA рисует 3D-сцену в полном разрешении. «Качество», «Баланс» и «Производительность» рисуют её " "в 67, 58 и 50 % и масштабируют через DLSS ради большего числа кадров; они заменяют масштаб " diff --git a/runtime/ui_text.h b/runtime/ui_text.h index 702cdc4e..15e05c41 100644 --- a/runtime/ui_text.h +++ b/runtime/ui_text.h @@ -54,7 +54,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_DLSS, UI_MENU_DLSS_DESC, UI_MENU_DLSS_DLAA, UI_MENU_DLSS_QUALITY, - UI_MENU_DLSS_BALANCED, UI_MENU_DLSS_PERFORMANCE, UI_MENU_FXAA, UI_MENU_FXAA_DESC, + UI_MENU_DLSS_BALANCED, UI_MENU_DLSS_PERFORMANCE, 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_FXAA, UI_MENU_FXAA_DESC, // Game UI_MENU_FPS_LIMIT, UI_MENU_FPS_LIMIT_DESC, UI_MENU_FPS_30, UI_MENU_FPS_40, UI_MENU_FPS_45, UI_MENU_FPS_60, UI_MENU_FPS_90, diff --git a/runtime/vk_dlaa.c b/runtime/vk_dlaa.c index fb7d0b3f..0c1bfc92 100644 --- a/runtime/vk_dlaa.c +++ b/runtime/vk_dlaa.c @@ -319,7 +319,10 @@ static struct { int on; // the dlaa setting, read at each present (the menu switches it live) int scaler_skipped; // this frame: the game's scaling draw over DLSS's picture was skipped uint64_t scaler_missed; // frames DLSS scaled whose scaling draw was not found (vk_dlaa_skip_draw) -} D = {.mv_ok = -1}; + int preset, preset_dirty; // the DLSS model features are created with (preset_value); a change pending + unsigned cfg_seen; // cfg_version when preset was read + uint64_t last_eval_ns; // plat_now_ns of the previous evaluation (FrameTimeDeltaInMsec) +} D = {.mv_ok = -1, .cfg_seen = ~0u}; static int dl_active(void) { return N.available && !D.failed && D.on; } @@ -540,6 +543,17 @@ static void next_jitter(void) { D.jit_ok = !D.hold && !nj; } +// The DLSS model (TOTK_DLSS_PRESET, live): default leaves the choice to NGX, which in the 310 releases is the +// transformer preset K for DLAA, Quality and Balanced and M for Performance. j is the other transformer model: NVIDIA +// describes it as slightly less ghosting at the cost of extra flicker. k pins K, also in Performance. The value is an +// NVSDK_NGX_DLSS_Hint_Render_Preset, read when a feature is created; a change recreates the features (preset_check). +static int preset_value(void) { + const char *v = cfg_get("TOTK_DLSS_PRESET"); + if (v && (v[0] == 'k' || v[0] == 'K') && !v[1]) return 11; + if (v && (v[0] == 'j' || v[0] == 'J') && !v[1]) return 10; + return 0; +} + // The quality setting DLSS is created with, from the scene's share of the output width. static int perf_quality(uint32_t w, uint32_t ow) { if (w >= ow) return NGX_PERFQ_DLAA; @@ -554,6 +568,11 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) { uint32_t w = t->width, h = t->height, ow = dst->width, oh = dst->height; VkCommandBuffer cb = ex->cb; vk_exec_barrier(ex); // what drew the scene is done (no pass is open here) + if (D.preset_dirty) { // another model: features are created with it, so every size gets a new one + for (int i = 0; i < 3; i++) + if (D.sizes[i].out) free_size(&D.sizes[i]); + D.last = NULL, D.preset_dirty = 0; + } 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]++; // another size's history is from another moment @@ -583,11 +602,17 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) { // IsHDR | MVLowRes | AutoExposure: linear scene light, motion vectors at the render size, no exposure texture p_seti(p, "DLSS.Feature.Create.Flags", (1 << 0) | (1 << 1) | (1 << 6)); p_seti(p, "DLSS.Enable.Output.Subrects", 0); + static const char *const hint[] = {"DLSS.Hint.Render.Preset.DLAA", "DLSS.Hint.Render.Preset.Quality", + "DLSS.Hint.Render.Preset.Balanced", "DLSS.Hint.Render.Preset.Performance", + "DLSS.Hint.Render.Preset.UltraPerformance", + "DLSS.Hint.Render.Preset.UltraQuality"}; + for (size_t i = 0; i < sizeof hint / sizeof *hint; i++) p_setu(p, hint[i], (unsigned)D.preset); NgxResult r = N.create(cb, NGX_FEATURE_SUPERSAMPLING, p, &e->feat); if (!NGX_OK(r) || !e->feat) return dl_fail("DLSS feature creation", r); D.reset = 1; - rt_log("dlaa: DLSS feature created at %ux%u -> %ux%u, quality value %d (scene format %d, depth format %d)", w, - h, ow, oh, perf_quality(w, ow), (int)t->format, (int)z->format); + rt_log("dlaa: DLSS feature created at %ux%u -> %ux%u, quality value %d, preset %s (scene format %d, depth " + "format %d)", w, h, ow, oh, perf_quality(w, ow), D.preset == 11 ? "K" : D.preset == 10 ? "J" : "default", + (int)t->format, (int)z->format); } if (D.last_color != t->image) D.reset = 1, D.why[2]++, D.last_color = t->image; VkImageView cv = vk_exec_target_view(t->img, t->format, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT, t->level, @@ -610,7 +635,12 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) { p_setu(p, "DLSS.Render.Subrect.Dimensions.Height", h); p_setf(p, "DLSS.Pre.Exposure", 1.0f); p_setf(p, "DLSS.Exposure.Scale", 1.0f); - p_setf(p, "FrameTimeDeltaInMsec", 16.67f); + // The time since the previous evaluation, which DLSS weighs its history by; 60 fps before the first and after a + // gap (a pause, a load), where no history carries over anyway. + uint64_t now = plat_now_ns(); + double dt = D.last_eval_ns ? (now - D.last_eval_ns) / 1e6 : 0; + D.last_eval_ns = now; + p_setf(p, "FrameTimeDeltaInMsec", dt > 0 && dt < 100 ? (float)dt : 16.67f); NgxResult r = N.evaluate(cb, e->feat, p, NULL); if (!NGX_OK(r)) return dl_fail("DLSS evaluation", r); D.reset = 0; @@ -674,7 +704,19 @@ void vk_dlaa_pass(VkExec *ex) { } } +// The preset, read again when a setting changed (the menu); a different one recreates the features at the next DLAA run. +static void preset_check(void) { + unsigned v = cfg_version(); + if (v == D.cfg_seen) return; + D.cfg_seen = v; + int p = preset_value(); + if (p == D.preset) return; + if (D.evals) rt_log("dlaa: DLSS preset %s; the features are created again", p == 11 ? "K" : p == 10 ? "J" : "default"); + D.preset = p, D.preset_dirty = 1, D.reset = 1; +} + void vk_dlaa_frame(void) { + preset_check(); int on = N.available && cfg_bool("TOTK_DLAA"); if (on != D.on) { rt_log("dlaa: %s", on ? "on" : "off"); diff --git a/totk.ini.example b/totk.ini.example index e22dbbee..ed1899ca 100644 --- a/totk.ini.example +++ b/totk.ini.example @@ -191,14 +191,20 @@ # patch 0010), so the shader cache is rebuilt once after an update. Read at start. # 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. Read at start. +# NVIDIA DLSS / DLAA for the 3D scene, on NVIDIA RTX GPUs with the DLSS model from NVIDIA's DLSS SDK next to the +# executable (Windows: nvngx_dlss.dll next to totk.exe; Linux: libnvidia-ngx-dlss.so. next to totk, with the +# 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 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). They apply -# only with dlaa = 1 and nvngx_dlss.dll next to totk.exe, on Windows; otherwise the scene follows render_scale. Read at +# only with dlaa = 1 and the DLSS model next to the executable; otherwise the scene follows render_scale. Read at # start. # dlss = dlaa +# The DLSS model: default (NGX chooses: the transformer model K for dlaa, quality and balanced, M for performance), k +# (K in every mode) or j (the other transformer model: slightly less ghosting behind moving characters, a little more +# flicker). Changes while the game runs take effect at once (DLSS starts a new history). +# dlss_preset = default # 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. # fxaa = 1 From 1d49f64f3414c89e6b0f276b206751c8fd62304b Mon Sep 17 00:00:00 2001 From: SchulzCode <116190857+SchulzCode@users.noreply.github.com> Date: Sat, 31 Oct 2026 16:47:52 +0100 Subject: [PATCH 3/3] Reduce DLSS trails behind moving characters with a bias mask The motion vectors follow the camera only, so a character, animal or held item that moves on its own drags a faint copy of itself through DLSS's history. TotK's G-buffer target 0 carries an object class in green: above 64/255 for characters, creatures and held items (Link 253, others 125, held items 160), 0 for terrain and 32 for foliage, checked in the field, in Goron City and on horseback. The motion-vector pass now also writes DLSS's bias mask (DLSS.Input.Bias.Current.Color.Mask) where such an object is now or was the frame before, read through the motion vector from the previous frame's class mask, so the history that holds the moving object is weighed down there. dlss_char_mask (0, 35, 65 or 100 percent, default 65; F1 > Screen > "DLSS character trails", live) sets the strength. A 640x360 pass of the G-buffer's shape, seen while loading, no longer replaces the scene's class buffer in a frame. The status line also prints after 300 frames, with the frames that had the mask. --- runtime/cfg.c | 7 +- runtime/dlaa_mv_spv.h | 269 ++++++++++++++++++++--------------- runtime/shaders/dlaa_mv.comp | 23 +++ runtime/ui/menu.cpp | 3 + runtime/ui_text.c | 12 ++ runtime/ui_text.h | 3 +- runtime/vk_dlaa.c | 115 ++++++++++++--- totk.ini.example | 5 + 8 files changed, 297 insertions(+), 140 deletions(-) diff --git a/runtime/cfg.c b/runtime/cfg.c index cfac4b81..b212c65d 100644 --- a/runtime/cfg.c +++ b/runtime/cfg.c @@ -37,7 +37,7 @@ static const char *const known[] = { "BIND_SKIP", "BIND_STATS", "BIND_UP", "BIND_X", "BIND_Y", "BIND_ZL", "BIND_ZR", "BLOCK_VIEWS_3D", "CLOTH_REALTIME", "COLOR_BRIGHTNESS", "COLOR_CONTRAST", "COLOR_GAMMA", "COLOR_PRESET", "COLOR_SATURATION", "CONTACT_DEBUG", "CONTACT_SHADOWS", "CORE_DIAG", "CRIT", "CRIT_OUT", - "DESC_TEMPLATE", "DEVICE_PROFILE", "DLAA", "DLAA_JITTER", "DLAA_MV", "DLSS", "DLSS_PRESET", "DUMP", "DUMP_BUF", "DUMP_DIR", + "DESC_TEMPLATE", "DEVICE_PROFILE", "DLAA", "DLAA_JITTER", "DLAA_MV", "DLSS", "DLSS_CHAR_MASK", "DLSS_PRESET", "DUMP", "DUMP_BUF", "DUMP_DIR", "DUMP_LOG", "EXEFS", "FEEDBACK", "FIX_C0", "FIX_ZERO", "FLIGHT", "FLIGHT_AT", "FLIGHT_DIR", "FLIGHT_FRAMES", "FLIGHT_SPIKE_MS", "FLIGHT_THUMBS", "FOV", "FOV_PATCH", "FPS60", "FPS_LIMIT", "FREEZE_IDLE", "FREE_CORES", "FULLSCREEN", "FXAA", "GPL", "GPL_DRAW_BUILD", "GPU", "GPU_INDEX", "GPU_NAME", "HDR", "HDR_GAME_NITS", @@ -70,7 +70,7 @@ static const struct { const char *key, *section; } sections[] = { {"COLOR_BRIGHTNESS", "display"}, {"COLOR_CONTRAST", "display"}, {"COLOR_SATURATION", "display"}, {"COLOR_GAMMA", "display"}, {"HDR", "display"}, {"HDR_PEAK_NITS", "display"}, {"HDR_GAME_NITS", "display"}, {"HDR_UI_NITS", "display"}, {"SHADOW_RES", "display"}, - {"DLAA", "display"}, {"DLSS", "display"}, {"DLSS_PRESET", "display"}, {"FXAA", "display"}, + {"DLAA", "display"}, {"DLSS", "display"}, {"DLSS_PRESET", "display"}, {"DLSS_CHAR_MASK", "display"}, {"FXAA", "display"}, {"DEVICE_PROFILE", "display"}, {"ASSUME_FOCUS", "display"}, {"SHADOW_SCALE", "display"}, {"SHADOW_RANGE", "display"}, {"CONTACT_SHADOWS", "display"}, {"PCSS", "display"}, @@ -112,7 +112,8 @@ static const CfgMeta metas[] = { {"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", RESTART}, {"DLSS", "dlaa", "dlaa|quality|balanced|performance", RESTART}, - {"DLSS_PRESET", "default", "default|k|j", LIVE}, {"FXAA", "1", "0|1", LIVE}, + {"DLSS_PRESET", "default", "default|k|j", LIVE}, + {"DLSS_CHAR_MASK", "65", "0|35|65|100", LIVE}, {"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/dlaa_mv_spv.h b/runtime/dlaa_mv_spv.h index e1b31e6c..93243f1d 100644 --- a/runtime/dlaa_mv_spv.h +++ b/runtime/dlaa_mv_spv.h @@ -1,119 +1,162 @@ // Generated by tools/build_shaders.py from runtime/shaders/dlaa_mv.comp; do not edit. -// source sha256 bfa9b6d9e0f9d5cfd4382fa5080fa46f007a1a4e2b886b8fecd9adba11767686 +// source sha256 e96a6d2d0cec26c47a76280363077c5982919bedc984f20ae9f1d185dc6ae674 #pragma once #include static const uint32_t dlaa_mv_spv[] = { - 0x07230203, 0x00010600, 0x0008000b, 0x00000131, 0x00000000, 0x00020011, 0x00000001, 0x00020011, + 0x07230203, 0x00010300, 0x000d000b, 0x0000019a, 0x00000000, 0x00020011, 0x00000001, 0x00020011, 0x00000031, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, - 0x00000000, 0x00000001, 0x000b000f, 0x00000005, 0x00000004, 0x6e69616d, 0x00000000, 0x00000036, - 0x00000043, 0x0000005d, 0x00000089, 0x000000a0, 0x000000e7, 0x00060010, 0x00000004, 0x00000011, - 0x00000008, 0x00000008, 0x00000001, 0x00030003, 0x00000002, 0x000001c2, 0x00040005, 0x00000004, - 0x6e69616d, 0x00000000, 0x00080005, 0x00000036, 0x475f6c67, 0x61626f6c, 0x766e496c, 0x7461636f, - 0x496e6f69, 0x00000044, 0x00030005, 0x00000041, 0x00000050, 0x00050006, 0x00000041, 0x00000000, - 0x657a6973, 0x00000000, 0x00050006, 0x00000041, 0x00000001, 0x7474696a, 0x00007265, 0x00030005, - 0x00000043, 0x00006370, 0x00050005, 0x0000005d, 0x74706564, 0x65745f68, 0x00000078, 0x00030005, - 0x00000087, 0x00727543, 0x00040006, 0x00000087, 0x00000000, 0x00000072, 0x00030005, 0x00000089, - 0x00727563, 0x00040005, 0x0000009e, 0x76657250, 0x00000000, 0x00040006, 0x0000009e, 0x00000000, - 0x00000072, 0x00040005, 0x000000a0, 0x76657270, 0x00000000, 0x00040005, 0x000000e7, 0x6f5f766d, - 0x00007475, 0x00040047, 0x00000036, 0x0000000b, 0x0000001c, 0x00030047, 0x00000041, 0x00000002, - 0x00050048, 0x00000041, 0x00000000, 0x00000023, 0x00000000, 0x00050048, 0x00000041, 0x00000001, - 0x00000023, 0x00000008, 0x00040047, 0x0000005d, 0x00000021, 0x00000000, 0x00040047, 0x0000005d, - 0x00000022, 0x00000000, 0x00040047, 0x00000086, 0x00000006, 0x00000010, 0x00030047, 0x00000087, - 0x00000002, 0x00050048, 0x00000087, 0x00000000, 0x00000023, 0x00000000, 0x00040047, 0x00000089, - 0x00000021, 0x00000002, 0x00040047, 0x00000089, 0x00000022, 0x00000000, 0x00040047, 0x0000009d, - 0x00000006, 0x00000010, 0x00030047, 0x0000009e, 0x00000002, 0x00050048, 0x0000009e, 0x00000000, - 0x00000023, 0x00000000, 0x00040047, 0x000000a0, 0x00000021, 0x00000003, 0x00040047, 0x000000a0, - 0x00000022, 0x00000000, 0x00030047, 0x000000e7, 0x00000019, 0x00040047, 0x000000e7, 0x00000021, - 0x00000001, 0x00040047, 0x000000e7, 0x00000022, 0x00000000, 0x00020013, 0x00000002, 0x00030021, - 0x00000003, 0x00000002, 0x00030016, 0x00000006, 0x00000020, 0x00040017, 0x00000007, 0x00000006, - 0x00000004, 0x00040018, 0x00000009, 0x00000007, 0x00000004, 0x0004002b, 0x00000006, 0x00000015, - 0x3f800000, 0x0004002b, 0x00000006, 0x00000016, 0x00000000, 0x00040015, 0x0000002f, 0x00000020, - 0x00000001, 0x00040017, 0x00000030, 0x0000002f, 0x00000002, 0x00040015, 0x00000033, 0x00000020, - 0x00000000, 0x00040017, 0x00000034, 0x00000033, 0x00000003, 0x00040020, 0x00000035, 0x00000001, - 0x00000034, 0x0004003b, 0x00000035, 0x00000036, 0x00000001, 0x00040017, 0x00000037, 0x00000033, - 0x00000002, 0x00020014, 0x0000003b, 0x0004002b, 0x00000033, 0x0000003c, 0x00000000, 0x00040017, - 0x00000040, 0x00000006, 0x00000002, 0x0004001e, 0x00000041, 0x00000040, 0x00000040, 0x00040020, - 0x00000042, 0x00000009, 0x00000041, 0x0004003b, 0x00000042, 0x00000043, 0x00000009, 0x0004002b, - 0x0000002f, 0x00000044, 0x00000000, 0x00040020, 0x00000045, 0x00000009, 0x00000006, 0x0004002b, - 0x00000033, 0x0000004d, 0x00000001, 0x00090019, 0x0000005a, 0x00000006, 0x00000001, 0x00000000, - 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x0003001b, 0x0000005b, 0x0000005a, 0x00040020, - 0x0000005c, 0x00000000, 0x0000005b, 0x0004003b, 0x0000005c, 0x0000005d, 0x00000000, 0x0004002b, - 0x00000006, 0x00000067, 0x3f000000, 0x0004002b, 0x0000002f, 0x0000006a, 0x00000001, 0x00040020, - 0x0000006b, 0x00000009, 0x00000040, 0x0004002b, 0x00000006, 0x00000075, 0x40000000, 0x0004002b, - 0x00000033, 0x00000085, 0x00000010, 0x0004001c, 0x00000086, 0x00000007, 0x00000085, 0x0003001e, - 0x00000087, 0x00000086, 0x00040020, 0x00000088, 0x00000002, 0x00000087, 0x0004003b, 0x00000088, - 0x00000089, 0x00000002, 0x0004002b, 0x0000002f, 0x0000008a, 0x00000003, 0x0004002b, 0x0000002f, - 0x0000008b, 0x00000004, 0x0004002b, 0x0000002f, 0x0000008c, 0x00000005, 0x0004002b, 0x0000002f, - 0x0000008d, 0x00000006, 0x00040020, 0x0000008f, 0x00000002, 0x00000007, 0x0004001c, 0x0000009d, - 0x00000007, 0x00000085, 0x0003001e, 0x0000009e, 0x0000009d, 0x00040020, 0x0000009f, 0x00000002, - 0x0000009e, 0x0004003b, 0x0000009f, 0x000000a0, 0x00000002, 0x0005002c, 0x00000040, 0x000000b4, - 0x00000016, 0x00000016, 0x0004002b, 0x00000006, 0x000000b9, 0x2b8cbccc, 0x0004002b, 0x00000006, - 0x000000c7, 0x358637bd, 0x00090019, 0x000000e5, 0x00000006, 0x00000001, 0x00000000, 0x00000000, - 0x00000000, 0x00000002, 0x00000007, 0x00040020, 0x000000e6, 0x00000000, 0x000000e5, 0x0004003b, - 0x000000e6, 0x000000e7, 0x00000000, 0x0005002c, 0x00000040, 0x00000130, 0x00000067, 0x00000067, - 0x00050036, 0x00000002, 0x00000004, 0x00000000, 0x00000003, 0x000200f8, 0x00000005, 0x000300f7, - 0x000000f0, 0x00000000, 0x000300fb, 0x0000003c, 0x000000f1, 0x000200f8, 0x000000f1, 0x0004003d, - 0x00000034, 0x00000038, 0x00000036, 0x0007004f, 0x00000037, 0x00000039, 0x00000038, 0x00000038, - 0x00000000, 0x00000001, 0x0004007c, 0x00000030, 0x0000003a, 0x00000039, 0x00050051, 0x0000002f, - 0x0000003f, 0x0000003a, 0x00000000, 0x00060041, 0x00000045, 0x00000046, 0x00000043, 0x00000044, - 0x0000003c, 0x0004003d, 0x00000006, 0x00000047, 0x00000046, 0x0004006e, 0x0000002f, 0x00000048, - 0x00000047, 0x000500af, 0x0000003b, 0x00000049, 0x0000003f, 0x00000048, 0x000400a8, 0x0000003b, - 0x0000004a, 0x00000049, 0x000300f7, 0x0000004c, 0x00000000, 0x000400fa, 0x0000004a, 0x0000004b, - 0x0000004c, 0x000200f8, 0x0000004b, 0x00050051, 0x0000002f, 0x0000004f, 0x0000003a, 0x00000001, - 0x00060041, 0x00000045, 0x00000050, 0x00000043, 0x00000044, 0x0000004d, 0x0004003d, 0x00000006, - 0x00000051, 0x00000050, 0x0004006e, 0x0000002f, 0x00000052, 0x00000051, 0x000500af, 0x0000003b, - 0x00000053, 0x0000004f, 0x00000052, 0x000200f9, 0x0000004c, 0x000200f8, 0x0000004c, 0x000700f5, - 0x0000003b, 0x00000054, 0x00000049, 0x000000f1, 0x00000053, 0x0000004b, 0x000300f7, 0x00000056, - 0x00000000, 0x000400fa, 0x00000054, 0x00000055, 0x00000056, 0x000200f8, 0x00000055, 0x000200f9, - 0x000000f0, 0x000200f8, 0x00000056, 0x0004003d, 0x0000005b, 0x0000005e, 0x0000005d, 0x00040064, - 0x0000005a, 0x00000060, 0x0000005e, 0x0007005f, 0x00000007, 0x00000061, 0x00000060, 0x0000003a, - 0x00000002, 0x00000044, 0x00050051, 0x00000006, 0x00000062, 0x00000061, 0x00000000, 0x0004006f, - 0x00000040, 0x00000066, 0x0000003a, 0x00050081, 0x00000040, 0x00000069, 0x00000066, 0x00000130, - 0x00050041, 0x0000006b, 0x0000006c, 0x00000043, 0x0000006a, 0x0004003d, 0x00000040, 0x0000006d, - 0x0000006c, 0x00050083, 0x00000040, 0x0000006e, 0x00000069, 0x0000006d, 0x00050051, 0x00000006, - 0x00000071, 0x0000006e, 0x00000000, 0x00050088, 0x00000006, 0x00000074, 0x00000071, 0x00000047, - 0x00050085, 0x00000006, 0x00000076, 0x00000074, 0x00000075, 0x00050083, 0x00000006, 0x00000077, - 0x00000076, 0x00000015, 0x00050051, 0x00000006, 0x00000079, 0x0000006e, 0x00000001, 0x00060041, - 0x00000045, 0x0000007a, 0x00000043, 0x00000044, 0x0000004d, 0x0004003d, 0x00000006, 0x0000007b, - 0x0000007a, 0x00050088, 0x00000006, 0x0000007c, 0x00000079, 0x0000007b, 0x00050085, 0x00000006, - 0x0000007d, 0x0000007c, 0x00000075, 0x00050083, 0x00000006, 0x0000007e, 0x00000015, 0x0000007d, - 0x00050085, 0x00000006, 0x00000080, 0x00000062, 0x00000075, 0x00050083, 0x00000006, 0x00000081, - 0x00000080, 0x00000015, 0x00070050, 0x00000007, 0x00000082, 0x00000077, 0x0000007e, 0x00000081, - 0x00000015, 0x00060041, 0x0000008f, 0x00000090, 0x00000089, 0x00000044, 0x0000008a, 0x0004003d, - 0x00000007, 0x00000091, 0x00000090, 0x00060041, 0x0000008f, 0x00000093, 0x00000089, 0x00000044, - 0x0000008b, 0x0004003d, 0x00000007, 0x00000094, 0x00000093, 0x00060041, 0x0000008f, 0x00000096, - 0x00000089, 0x00000044, 0x0000008c, 0x0004003d, 0x00000007, 0x00000097, 0x00000096, 0x00060041, - 0x0000008f, 0x00000099, 0x00000089, 0x00000044, 0x0000008d, 0x0004003d, 0x00000007, 0x0000009a, - 0x00000099, 0x00070050, 0x00000009, 0x00000110, 0x00000091, 0x00000094, 0x00000097, 0x0000009a, - 0x00040054, 0x00000009, 0x00000111, 0x00000110, 0x00060041, 0x0000008f, 0x000000a2, 0x000000a0, - 0x00000044, 0x0000008a, 0x0004003d, 0x00000007, 0x000000a3, 0x000000a2, 0x00060041, 0x0000008f, - 0x000000a5, 0x000000a0, 0x00000044, 0x0000008b, 0x0004003d, 0x00000007, 0x000000a6, 0x000000a5, - 0x00060041, 0x0000008f, 0x000000a8, 0x000000a0, 0x00000044, 0x0000008c, 0x0004003d, 0x00000007, - 0x000000a9, 0x000000a8, 0x00060041, 0x0000008f, 0x000000ab, 0x000000a0, 0x00000044, 0x0000008d, - 0x0004003d, 0x00000007, 0x000000ac, 0x000000ab, 0x00070050, 0x00000009, 0x0000012c, 0x000000a3, - 0x000000a6, 0x000000a9, 0x000000ac, 0x00040054, 0x00000009, 0x0000012d, 0x0000012c, 0x0006000c, - 0x00000009, 0x000000b0, 0x00000001, 0x00000022, 0x00000111, 0x00050091, 0x00000007, 0x000000b2, - 0x000000b0, 0x00000082, 0x00050051, 0x00000006, 0x000000b7, 0x000000b2, 0x00000003, 0x0006000c, - 0x00000006, 0x000000b8, 0x00000001, 0x00000004, 0x000000b7, 0x000500ba, 0x0000003b, 0x000000ba, - 0x000000b8, 0x000000b9, 0x000300f7, 0x000000bc, 0x00000000, 0x000400fa, 0x000000ba, 0x000000bb, - 0x000000bc, 0x000200f8, 0x000000bb, 0x00070050, 0x00000007, 0x000000c2, 0x000000b7, 0x000000b7, - 0x000000b7, 0x000000b7, 0x00050088, 0x00000007, 0x000000c3, 0x000000b2, 0x000000c2, 0x00050091, - 0x00000007, 0x000000c4, 0x0000012d, 0x000000c3, 0x00050051, 0x00000006, 0x000000c6, 0x000000c4, - 0x00000003, 0x000500ba, 0x0000003b, 0x000000c8, 0x000000c6, 0x000000c7, 0x000300f7, 0x000000ca, - 0x00000000, 0x000400fa, 0x000000c8, 0x000000c9, 0x000000ca, 0x000200f8, 0x000000c9, 0x0007004f, - 0x00000040, 0x000000cd, 0x000000c4, 0x000000c4, 0x00000000, 0x00000001, 0x00050050, 0x00000040, - 0x000000d0, 0x000000c6, 0x000000c6, 0x00050088, 0x00000040, 0x000000d1, 0x000000cd, 0x000000d0, - 0x00050051, 0x00000006, 0x000000d4, 0x000000d1, 0x00000000, 0x00050085, 0x00000006, 0x000000d5, - 0x000000d4, 0x00000067, 0x00050081, 0x00000006, 0x000000d6, 0x000000d5, 0x00000067, 0x00050085, - 0x00000006, 0x000000d9, 0x000000d6, 0x00000047, 0x00050051, 0x00000006, 0x000000db, 0x000000d1, - 0x00000001, 0x00050085, 0x00000006, 0x000000dc, 0x000000db, 0x00000067, 0x00050083, 0x00000006, - 0x000000dd, 0x00000067, 0x000000dc, 0x00050085, 0x00000006, 0x000000e0, 0x000000dd, 0x0000007b, - 0x00050050, 0x00000040, 0x000000e1, 0x000000d9, 0x000000e0, 0x00050083, 0x00000040, 0x000000e4, - 0x000000e1, 0x0000006e, 0x000200f9, 0x000000ca, 0x000200f8, 0x000000ca, 0x000700f5, 0x00000040, - 0x0000012f, 0x000000b4, 0x000000bb, 0x000000e4, 0x000000c9, 0x000200f9, 0x000000bc, 0x000200f8, - 0x000000bc, 0x000700f5, 0x00000040, 0x0000012e, 0x000000b4, 0x00000056, 0x0000012f, 0x000000ca, - 0x0004003d, 0x000000e5, 0x000000e8, 0x000000e7, 0x00050051, 0x00000006, 0x000000eb, 0x0000012e, - 0x00000000, 0x00050051, 0x00000006, 0x000000ec, 0x0000012e, 0x00000001, 0x00070050, 0x00000007, - 0x000000ed, 0x000000eb, 0x000000ec, 0x00000016, 0x00000016, 0x00040063, 0x000000e8, 0x0000003a, - 0x000000ed, 0x000200f9, 0x000000f0, 0x000200f8, 0x000000f0, 0x000100fd, 0x00010038, + 0x00000000, 0x00000001, 0x0006000f, 0x00000005, 0x00000004, 0x6e69616d, 0x00000000, 0x00000036, + 0x00060010, 0x00000004, 0x00000011, 0x00000008, 0x00000008, 0x00000001, 0x00040047, 0x00000036, + 0x0000000b, 0x0000001c, 0x00030047, 0x00000041, 0x00000002, 0x00050048, 0x00000041, 0x00000000, + 0x00000023, 0x00000000, 0x00050048, 0x00000041, 0x00000001, 0x00000023, 0x00000008, 0x00050048, + 0x00000041, 0x00000002, 0x00000023, 0x00000010, 0x00050048, 0x00000041, 0x00000003, 0x00000023, + 0x00000014, 0x00040047, 0x0000005d, 0x00000021, 0x00000000, 0x00040047, 0x0000005d, 0x00000022, + 0x00000000, 0x00040047, 0x00000086, 0x00000006, 0x00000010, 0x00030047, 0x00000087, 0x00000002, + 0x00050048, 0x00000087, 0x00000000, 0x00000023, 0x00000000, 0x00040047, 0x00000089, 0x00000021, + 0x00000002, 0x00040047, 0x00000089, 0x00000022, 0x00000000, 0x00040047, 0x0000009d, 0x00000006, + 0x00000010, 0x00030047, 0x0000009e, 0x00000002, 0x00050048, 0x0000009e, 0x00000000, 0x00000023, + 0x00000000, 0x00040047, 0x000000a0, 0x00000021, 0x00000003, 0x00040047, 0x000000a0, 0x00000022, + 0x00000000, 0x00030047, 0x000000e7, 0x00000019, 0x00040047, 0x000000e7, 0x00000021, 0x00000001, + 0x00040047, 0x000000e7, 0x00000022, 0x00000000, 0x00040047, 0x000000f6, 0x00000021, 0x00000004, + 0x00040047, 0x000000f6, 0x00000022, 0x00000000, 0x00030047, 0x00000101, 0x00000019, 0x00040047, + 0x00000101, 0x00000021, 0x00000007, 0x00040047, 0x00000101, 0x00000022, 0x00000000, 0x00030047, + 0x0000012a, 0x00000018, 0x00040047, 0x0000012a, 0x00000021, 0x00000006, 0x00040047, 0x0000012a, + 0x00000022, 0x00000000, 0x00030047, 0x0000013b, 0x00000019, 0x00040047, 0x0000013b, 0x00000021, + 0x00000005, 0x00040047, 0x0000013b, 0x00000022, 0x00000000, 0x00040047, 0x00000146, 0x0000000b, + 0x00000019, 0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002, 0x00030016, 0x00000006, + 0x00000020, 0x00040017, 0x00000007, 0x00000006, 0x00000004, 0x00040018, 0x00000009, 0x00000007, + 0x00000004, 0x0004002b, 0x00000006, 0x00000015, 0x3f800000, 0x0004002b, 0x00000006, 0x00000016, + 0x00000000, 0x00040015, 0x0000002f, 0x00000020, 0x00000001, 0x00040017, 0x00000030, 0x0000002f, + 0x00000002, 0x00040015, 0x00000033, 0x00000020, 0x00000000, 0x00040017, 0x00000034, 0x00000033, + 0x00000003, 0x00040020, 0x00000035, 0x00000001, 0x00000034, 0x0004003b, 0x00000035, 0x00000036, + 0x00000001, 0x00040017, 0x00000037, 0x00000033, 0x00000002, 0x00020014, 0x0000003b, 0x0004002b, + 0x00000033, 0x0000003c, 0x00000000, 0x00040017, 0x00000040, 0x00000006, 0x00000002, 0x0006001e, + 0x00000041, 0x00000040, 0x00000040, 0x00000006, 0x00000006, 0x00040020, 0x00000042, 0x00000009, + 0x00000041, 0x0004003b, 0x00000042, 0x00000043, 0x00000009, 0x0004002b, 0x0000002f, 0x00000044, + 0x00000000, 0x00040020, 0x00000045, 0x00000009, 0x00000006, 0x0004002b, 0x00000033, 0x0000004d, + 0x00000001, 0x00090019, 0x0000005a, 0x00000006, 0x00000001, 0x00000000, 0x00000000, 0x00000000, + 0x00000001, 0x00000000, 0x0003001b, 0x0000005b, 0x0000005a, 0x00040020, 0x0000005c, 0x00000000, + 0x0000005b, 0x0004003b, 0x0000005c, 0x0000005d, 0x00000000, 0x0004002b, 0x00000006, 0x00000067, + 0x3f000000, 0x0004002b, 0x0000002f, 0x0000006a, 0x00000001, 0x00040020, 0x0000006b, 0x00000009, + 0x00000040, 0x0004002b, 0x00000006, 0x00000075, 0x40000000, 0x0004002b, 0x00000033, 0x00000085, + 0x00000010, 0x0004001c, 0x00000086, 0x00000007, 0x00000085, 0x0003001e, 0x00000087, 0x00000086, + 0x00040020, 0x00000088, 0x00000002, 0x00000087, 0x0004003b, 0x00000088, 0x00000089, 0x00000002, + 0x0004002b, 0x0000002f, 0x0000008a, 0x00000003, 0x0004002b, 0x0000002f, 0x0000008b, 0x00000004, + 0x0004002b, 0x0000002f, 0x0000008c, 0x00000005, 0x0004002b, 0x0000002f, 0x0000008d, 0x00000006, + 0x00040020, 0x0000008f, 0x00000002, 0x00000007, 0x0004001c, 0x0000009d, 0x00000007, 0x00000085, + 0x0003001e, 0x0000009e, 0x0000009d, 0x00040020, 0x0000009f, 0x00000002, 0x0000009e, 0x0004003b, + 0x0000009f, 0x000000a0, 0x00000002, 0x0005002c, 0x00000040, 0x000000b4, 0x00000016, 0x00000016, + 0x0004002b, 0x00000006, 0x000000b9, 0x2b8cbccc, 0x0004002b, 0x00000006, 0x000000c7, 0x358637bd, + 0x00090019, 0x000000e5, 0x00000006, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000002, + 0x00000007, 0x00040020, 0x000000e6, 0x00000000, 0x000000e5, 0x0004003b, 0x000000e6, 0x000000e7, + 0x00000000, 0x0004002b, 0x0000002f, 0x000000ee, 0x00000002, 0x0004003b, 0x0000005c, 0x000000f6, + 0x00000000, 0x0004002b, 0x00000006, 0x000000fc, 0x3e808081, 0x00090019, 0x000000ff, 0x00000006, + 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x0000000f, 0x00040020, 0x00000100, + 0x00000000, 0x000000ff, 0x0004003b, 0x00000100, 0x00000101, 0x00000000, 0x0004002b, 0x0000002f, + 0x00000119, 0xffffffff, 0x0004003b, 0x00000100, 0x0000012a, 0x00000000, 0x0005002c, 0x00000030, + 0x00000131, 0x00000044, 0x00000044, 0x0004003b, 0x00000100, 0x0000013b, 0x00000000, 0x0004002b, + 0x00000033, 0x00000145, 0x00000008, 0x0006002c, 0x00000034, 0x00000146, 0x00000145, 0x00000145, + 0x0000004d, 0x0005002c, 0x00000040, 0x00000197, 0x00000067, 0x00000067, 0x0005002c, 0x00000030, + 0x00000199, 0x0000006a, 0x0000006a, 0x00050036, 0x00000002, 0x00000004, 0x00000000, 0x00000003, + 0x000200f8, 0x00000005, 0x000300f7, 0x00000147, 0x00000000, 0x000300fb, 0x0000003c, 0x00000148, + 0x000200f8, 0x00000148, 0x0004003d, 0x00000034, 0x00000038, 0x00000036, 0x0007004f, 0x00000037, + 0x00000039, 0x00000038, 0x00000038, 0x00000000, 0x00000001, 0x0004007c, 0x00000030, 0x0000003a, + 0x00000039, 0x00050051, 0x0000002f, 0x0000003f, 0x0000003a, 0x00000000, 0x00060041, 0x00000045, + 0x00000046, 0x00000043, 0x00000044, 0x0000003c, 0x0004003d, 0x00000006, 0x00000047, 0x00000046, + 0x0004006e, 0x0000002f, 0x00000048, 0x00000047, 0x000500af, 0x0000003b, 0x00000049, 0x0000003f, + 0x00000048, 0x000400a8, 0x0000003b, 0x0000004a, 0x00000049, 0x000300f7, 0x0000004c, 0x00000000, + 0x000400fa, 0x0000004a, 0x0000004b, 0x0000004c, 0x000200f8, 0x0000004b, 0x00050051, 0x0000002f, + 0x0000004f, 0x0000003a, 0x00000001, 0x00060041, 0x00000045, 0x00000050, 0x00000043, 0x00000044, + 0x0000004d, 0x0004003d, 0x00000006, 0x00000051, 0x00000050, 0x0004006e, 0x0000002f, 0x00000052, + 0x00000051, 0x000500af, 0x0000003b, 0x00000053, 0x0000004f, 0x00000052, 0x000200f9, 0x0000004c, + 0x000200f8, 0x0000004c, 0x000700f5, 0x0000003b, 0x00000054, 0x00000049, 0x00000148, 0x00000053, + 0x0000004b, 0x000300f7, 0x00000056, 0x00000000, 0x000400fa, 0x00000054, 0x00000055, 0x00000056, + 0x000200f8, 0x00000055, 0x000200f9, 0x00000147, 0x000200f8, 0x00000056, 0x0004003d, 0x0000005b, + 0x0000005e, 0x0000005d, 0x00040064, 0x0000005a, 0x00000060, 0x0000005e, 0x0007005f, 0x00000007, + 0x00000061, 0x00000060, 0x0000003a, 0x00000002, 0x00000044, 0x00050051, 0x00000006, 0x00000062, + 0x00000061, 0x00000000, 0x0004006f, 0x00000040, 0x00000066, 0x0000003a, 0x00050081, 0x00000040, + 0x00000069, 0x00000066, 0x00000197, 0x00050041, 0x0000006b, 0x0000006c, 0x00000043, 0x0000006a, + 0x0004003d, 0x00000040, 0x0000006d, 0x0000006c, 0x00050083, 0x00000040, 0x0000006e, 0x00000069, + 0x0000006d, 0x00050051, 0x00000006, 0x00000071, 0x0000006e, 0x00000000, 0x00050088, 0x00000006, + 0x00000074, 0x00000071, 0x00000047, 0x00050085, 0x00000006, 0x00000076, 0x00000074, 0x00000075, + 0x00050083, 0x00000006, 0x00000077, 0x00000076, 0x00000015, 0x00050051, 0x00000006, 0x00000079, + 0x0000006e, 0x00000001, 0x00060041, 0x00000045, 0x0000007a, 0x00000043, 0x00000044, 0x0000004d, + 0x0004003d, 0x00000006, 0x0000007b, 0x0000007a, 0x00050088, 0x00000006, 0x0000007c, 0x00000079, + 0x0000007b, 0x00050085, 0x00000006, 0x0000007d, 0x0000007c, 0x00000075, 0x00050083, 0x00000006, + 0x0000007e, 0x00000015, 0x0000007d, 0x00050085, 0x00000006, 0x00000080, 0x00000062, 0x00000075, + 0x00050083, 0x00000006, 0x00000081, 0x00000080, 0x00000015, 0x00070050, 0x00000007, 0x00000082, + 0x00000077, 0x0000007e, 0x00000081, 0x00000015, 0x00060041, 0x0000008f, 0x00000090, 0x00000089, + 0x00000044, 0x0000008a, 0x0004003d, 0x00000007, 0x00000091, 0x00000090, 0x00060041, 0x0000008f, + 0x00000093, 0x00000089, 0x00000044, 0x0000008b, 0x0004003d, 0x00000007, 0x00000094, 0x00000093, + 0x00060041, 0x0000008f, 0x00000096, 0x00000089, 0x00000044, 0x0000008c, 0x0004003d, 0x00000007, + 0x00000097, 0x00000096, 0x00060041, 0x0000008f, 0x00000099, 0x00000089, 0x00000044, 0x0000008d, + 0x0004003d, 0x00000007, 0x0000009a, 0x00000099, 0x00070050, 0x00000009, 0x00000167, 0x00000091, + 0x00000094, 0x00000097, 0x0000009a, 0x00040054, 0x00000009, 0x00000168, 0x00000167, 0x00060041, + 0x0000008f, 0x000000a2, 0x000000a0, 0x00000044, 0x0000008a, 0x0004003d, 0x00000007, 0x000000a3, + 0x000000a2, 0x00060041, 0x0000008f, 0x000000a5, 0x000000a0, 0x00000044, 0x0000008b, 0x0004003d, + 0x00000007, 0x000000a6, 0x000000a5, 0x00060041, 0x0000008f, 0x000000a8, 0x000000a0, 0x00000044, + 0x0000008c, 0x0004003d, 0x00000007, 0x000000a9, 0x000000a8, 0x00060041, 0x0000008f, 0x000000ab, + 0x000000a0, 0x00000044, 0x0000008d, 0x0004003d, 0x00000007, 0x000000ac, 0x000000ab, 0x00070050, + 0x00000009, 0x00000183, 0x000000a3, 0x000000a6, 0x000000a9, 0x000000ac, 0x00040054, 0x00000009, + 0x00000184, 0x00000183, 0x0006000c, 0x00000009, 0x000000b0, 0x00000001, 0x00000022, 0x00000168, + 0x00050091, 0x00000007, 0x000000b2, 0x000000b0, 0x00000082, 0x00050051, 0x00000006, 0x000000b7, + 0x000000b2, 0x00000003, 0x0006000c, 0x00000006, 0x000000b8, 0x00000001, 0x00000004, 0x000000b7, + 0x000500ba, 0x0000003b, 0x000000ba, 0x000000b8, 0x000000b9, 0x000300f7, 0x000000bc, 0x00000000, + 0x000400fa, 0x000000ba, 0x000000bb, 0x000000bc, 0x000200f8, 0x000000bb, 0x00070050, 0x00000007, + 0x000000c2, 0x000000b7, 0x000000b7, 0x000000b7, 0x000000b7, 0x00050088, 0x00000007, 0x000000c3, + 0x000000b2, 0x000000c2, 0x00050091, 0x00000007, 0x000000c4, 0x00000184, 0x000000c3, 0x00050051, + 0x00000006, 0x000000c6, 0x000000c4, 0x00000003, 0x000500ba, 0x0000003b, 0x000000c8, 0x000000c6, + 0x000000c7, 0x000300f7, 0x000000ca, 0x00000000, 0x000400fa, 0x000000c8, 0x000000c9, 0x000000ca, + 0x000200f8, 0x000000c9, 0x0007004f, 0x00000040, 0x000000cd, 0x000000c4, 0x000000c4, 0x00000000, + 0x00000001, 0x00050050, 0x00000040, 0x000000d0, 0x000000c6, 0x000000c6, 0x00050088, 0x00000040, + 0x000000d1, 0x000000cd, 0x000000d0, 0x00050051, 0x00000006, 0x000000d4, 0x000000d1, 0x00000000, + 0x00050085, 0x00000006, 0x000000d5, 0x000000d4, 0x00000067, 0x00050081, 0x00000006, 0x000000d6, + 0x000000d5, 0x00000067, 0x00050085, 0x00000006, 0x000000d9, 0x000000d6, 0x00000047, 0x00050051, + 0x00000006, 0x000000db, 0x000000d1, 0x00000001, 0x00050085, 0x00000006, 0x000000dc, 0x000000db, + 0x00000067, 0x00050083, 0x00000006, 0x000000dd, 0x00000067, 0x000000dc, 0x00050085, 0x00000006, + 0x000000e0, 0x000000dd, 0x0000007b, 0x00050050, 0x00000040, 0x000000e1, 0x000000d9, 0x000000e0, + 0x00050083, 0x00000040, 0x000000e4, 0x000000e1, 0x0000006e, 0x000200f9, 0x000000ca, 0x000200f8, + 0x000000ca, 0x000700f5, 0x00000040, 0x00000190, 0x000000b4, 0x000000bb, 0x000000e4, 0x000000c9, + 0x000200f9, 0x000000bc, 0x000200f8, 0x000000bc, 0x000700f5, 0x00000040, 0x0000018f, 0x000000b4, + 0x00000056, 0x00000190, 0x000000ca, 0x0004003d, 0x000000e5, 0x000000e8, 0x000000e7, 0x00050051, + 0x00000006, 0x000000eb, 0x0000018f, 0x00000000, 0x00050051, 0x00000006, 0x000000ec, 0x0000018f, + 0x00000001, 0x00070050, 0x00000007, 0x000000ed, 0x000000eb, 0x000000ec, 0x00000016, 0x00000016, + 0x00040063, 0x000000e8, 0x0000003a, 0x000000ed, 0x00050041, 0x00000045, 0x000000ef, 0x00000043, + 0x000000ee, 0x0004003d, 0x00000006, 0x000000f0, 0x000000ef, 0x000500bc, 0x0000003b, 0x000000f1, + 0x000000f0, 0x00000016, 0x000300f7, 0x000000f3, 0x00000000, 0x000400fa, 0x000000f1, 0x000000f2, + 0x000000f3, 0x000200f8, 0x000000f2, 0x000200f9, 0x00000147, 0x000200f8, 0x000000f3, 0x0004003d, + 0x0000005b, 0x000000f7, 0x000000f6, 0x00040064, 0x0000005a, 0x000000f9, 0x000000f7, 0x0007005f, + 0x00000007, 0x000000fa, 0x000000f9, 0x0000003a, 0x00000002, 0x00000044, 0x00050051, 0x00000006, + 0x000000fb, 0x000000fa, 0x00000001, 0x000500ba, 0x0000003b, 0x000000fd, 0x000000fb, 0x000000fc, + 0x000600a9, 0x00000006, 0x000000fe, 0x000000fd, 0x00000015, 0x00000016, 0x0004003d, 0x000000ff, + 0x00000102, 0x00000101, 0x00070050, 0x00000007, 0x00000105, 0x000000fe, 0x000000fe, 0x000000fe, + 0x000000fe, 0x00040063, 0x00000102, 0x0000003a, 0x00000105, 0x00050041, 0x00000045, 0x00000107, + 0x00000043, 0x0000008a, 0x0004003d, 0x00000006, 0x00000108, 0x00000107, 0x000500ba, 0x0000003b, + 0x00000109, 0x00000108, 0x00000067, 0x000300f7, 0x0000010b, 0x00000000, 0x000400fa, 0x00000109, + 0x0000010a, 0x0000010b, 0x000200f8, 0x0000010a, 0x00050081, 0x00000040, 0x0000010f, 0x0000006e, + 0x0000018f, 0x0006000c, 0x00000040, 0x00000110, 0x00000001, 0x00000008, 0x0000010f, 0x0004006e, + 0x00000030, 0x00000111, 0x00000110, 0x00050041, 0x0000006b, 0x00000113, 0x00000043, 0x00000044, + 0x0004003d, 0x00000040, 0x00000114, 0x00000113, 0x0004006e, 0x00000030, 0x00000115, 0x00000114, + 0x00050082, 0x00000030, 0x00000117, 0x00000115, 0x00000199, 0x000200f9, 0x0000011a, 0x000200f8, + 0x0000011a, 0x000700f5, 0x00000006, 0x00000193, 0x00000016, 0x0000010a, 0x00000196, 0x0000011d, + 0x000700f5, 0x0000002f, 0x00000191, 0x00000119, 0x0000010a, 0x0000013a, 0x0000011d, 0x000500b3, + 0x0000003b, 0x00000120, 0x00000191, 0x0000006a, 0x000400f6, 0x0000011c, 0x0000011d, 0x00000000, + 0x000400fa, 0x00000120, 0x0000011b, 0x0000011c, 0x000200f8, 0x0000011b, 0x000200f9, 0x00000122, + 0x000200f8, 0x00000122, 0x000700f5, 0x00000006, 0x00000196, 0x00000193, 0x0000011b, 0x00000136, + 0x00000123, 0x000700f5, 0x0000002f, 0x00000194, 0x00000119, 0x0000011b, 0x00000138, 0x00000123, + 0x000500b3, 0x0000003b, 0x00000128, 0x00000194, 0x0000006a, 0x000400f6, 0x00000124, 0x00000123, + 0x00000000, 0x000400fa, 0x00000128, 0x00000123, 0x00000124, 0x000200f8, 0x00000123, 0x0004003d, + 0x000000ff, 0x0000012b, 0x0000012a, 0x00050050, 0x00000030, 0x0000012f, 0x00000194, 0x00000191, + 0x00050080, 0x00000030, 0x00000130, 0x00000111, 0x0000012f, 0x0008000c, 0x00000030, 0x00000133, + 0x00000001, 0x0000002d, 0x00000130, 0x00000131, 0x00000117, 0x00050062, 0x00000007, 0x00000134, + 0x0000012b, 0x00000133, 0x00050051, 0x00000006, 0x00000135, 0x00000134, 0x00000000, 0x0007000c, + 0x00000006, 0x00000136, 0x00000001, 0x00000028, 0x00000196, 0x00000135, 0x00050080, 0x0000002f, + 0x00000138, 0x00000194, 0x0000006a, 0x000200f9, 0x00000122, 0x000200f8, 0x00000124, 0x000200f9, + 0x0000011d, 0x000200f8, 0x0000011d, 0x00050080, 0x0000002f, 0x0000013a, 0x00000191, 0x0000006a, + 0x000200f9, 0x0000011a, 0x000200f8, 0x0000011c, 0x000200f9, 0x0000010b, 0x000200f8, 0x0000010b, + 0x000700f5, 0x00000006, 0x00000192, 0x00000016, 0x000000f3, 0x00000193, 0x0000011c, 0x0004003d, + 0x000000ff, 0x0000013c, 0x0000013b, 0x0007000c, 0x00000006, 0x00000140, 0x00000001, 0x00000028, + 0x000000fe, 0x00000192, 0x00050085, 0x00000006, 0x00000143, 0x00000140, 0x000000f0, 0x00070050, + 0x00000007, 0x00000144, 0x00000143, 0x00000143, 0x00000143, 0x00000143, 0x00040063, 0x0000013c, + 0x0000003a, 0x00000144, 0x000200f9, 0x00000147, 0x000200f8, 0x00000147, 0x000100fd, 0x00010038, }; diff --git a/runtime/shaders/dlaa_mv.comp b/runtime/shaders/dlaa_mv.comp index f7ced22c..dcd5e810 100644 --- a/runtime/shaders/dlaa_mv.comp +++ b/runtime/shaders/dlaa_mv.comp @@ -6,14 +6,26 @@ // The camera block is TotK's scene uniform block (bound as c4 in the scene's vertex shaders): vec4 rows 3-6 are the // view-projection, rows of a row-major 4x4 with OpenGL clip depth (-w..w). The replay's viewports have negative // heights, so window y grows downwards from ndc y = +1, and depth is z_ndc * 0.5 + 0.5. +// With pc.bias > 0 the pass also writes DLSS's bias mask (vk_dlaa.c, "characters"): G-buffer target 0 carries an object +// class in green, above 64/255 for characters, creatures and what they hold (Link 253, others 125, held items 160; +// terrain 0, foliage 32). A pixel gets pc.bias when a character covers it now, or covered the place its surface came +// from last frame (the previous class mask, read through the motion vector, 3x3): there the history holds a moving +// character that the camera-only vector does not follow, which is the trail. chars_out keeps this frame's mask for the +// next; chars_prev is last frame's (pc.prev_ok 0: none). layout(local_size_x = 8, local_size_y = 8) in; layout(binding = 0) uniform sampler2D depth_tex; layout(binding = 1, rg16f) uniform writeonly image2D mv_out; layout(binding = 2, std140) uniform Cur { vec4 r[16]; } cur; layout(binding = 3, std140) uniform Prev { vec4 r[16]; } prev; +layout(binding = 4) uniform sampler2D ids_tex; +layout(binding = 5, r8) uniform writeonly image2D mask_out; +layout(binding = 6, r8) uniform readonly image2D chars_prev; +layout(binding = 7, r8) uniform writeonly image2D chars_out; layout(push_constant) uniform P { vec2 size; // render size in pixels vec2 jitter; // this frame's jitter, pixels, as the scene was drawn (window x right, y down) + float bias; // the mask value for character pixels; 0: no mask (bindings 4-7 unused) + float prev_ok; // 1: chars_prev holds last frame's class mask at this size } pc; mat4 vp(vec4 a, vec4 b, vec4 c, vec4 d) { return transpose(mat4(a, b, c, d)); } @@ -37,4 +49,15 @@ void main() { } } imageStore(mv_out, p, vec4(mv, 0.0, 0.0)); + if (pc.bias <= 0.0) return; + float ch = texelFetch(ids_tex, p, 0).g > 64.0 / 255.0 ? 1.0 : 0.0; + imageStore(chars_out, p, vec4(ch)); + float was = 0.0; + if (pc.prev_ok > 0.5) { + ivec2 q = ivec2(floor(win + mv)), hi = ivec2(pc.size) - 1; + for (int dy = -1; dy <= 1; dy++) + for (int dx = -1; dx <= 1; dx++) + was = max(was, imageLoad(chars_prev, clamp(q + ivec2(dx, dy), ivec2(0), hi)).r); + } + imageStore(mask_out, p, vec4(max(ch, was) * pc.bias)); } diff --git a/runtime/ui/menu.cpp b/runtime/ui/menu.cpp index e4407a9e..7df24b90 100644 --- a/runtime/ui/menu.cpp +++ b/runtime/ui/menu.cpp @@ -676,6 +676,9 @@ static void tab_screen(float scale) { opt_choice("TOTK_DLSS", UI_MENU_DLSS, dlss, 4, UI_MENU_DLSS_DESC); static const UiTextId preset[] = {UI_MENU_DLSS_PRESET_DEFAULT, UI_MENU_DLSS_PRESET_K, UI_MENU_DLSS_PRESET_J}; opt_choice("TOTK_DLSS_PRESET", UI_MENU_DLSS_PRESET, preset, 3, UI_MENU_DLSS_PRESET_DESC); + static const UiTextId chars[] = {UI_MENU_DLSS_CHARS_OFF, UI_MENU_DLSS_CHARS_LIGHT, UI_MENU_DLSS_CHARS_MEDIUM, + UI_MENU_DLSS_CHARS_FULL}; + opt_choice("TOTK_DLSS_CHAR_MASK", UI_MENU_DLSS_CHARS, chars, 4, UI_MENU_DLSS_CHARS_DESC); opt_toggle("TOTK_FXAA", UI_MENU_FXAA, UI_MENU_FXAA_DESC); rows_color(); opt_group(UI_MENU_HDR_GROUP); diff --git a/runtime/ui_text.c b/runtime/ui_text.c index b7069d08..9480dffc 100644 --- a/runtime/ui_text.c +++ b/runtime/ui_text.c @@ -140,6 +140,12 @@ static const char *const text_en[UI_TEXT_COUNT] = { "flicker. K: always the sharpest model, also in Performance. Applies at once.", [UI_MENU_DLSS_PRESET_DEFAULT] = "Automatic", [UI_MENU_DLSS_PRESET_K] = "K (sharpest)", [UI_MENU_DLSS_PRESET_J] = "J (less ghosting)", + [UI_MENU_DLSS_CHARS] = "DLSS character trails", + [UI_MENU_DLSS_CHARS_DESC] = "Reduces the faint trails behind moving characters, animals and what they hold: DLSS takes " + "less of the previous frames there. Stronger removes more of the trails and leaves those " + "edges a little less smooth. Applies at once.", + [UI_MENU_DLSS_CHARS_OFF] = "Off", [UI_MENU_DLSS_CHARS_LIGHT] = "Light", [UI_MENU_DLSS_CHARS_MEDIUM] = "Medium", + [UI_MENU_DLSS_CHARS_FULL] = "Full", [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 " @@ -576,6 +582,12 @@ static const char *const text_ru[UI_TEXT_COUNT] = { "Действует сразу.", [UI_MENU_DLSS_PRESET_DEFAULT] = "Автоматически", [UI_MENU_DLSS_PRESET_K] = "K (самая чёткая)", [UI_MENU_DLSS_PRESET_J] = "J (меньше шлейфов)", + [UI_MENU_DLSS_CHARS] = "Шлейфы персонажей в DLSS", + [UI_MENU_DLSS_CHARS_DESC] = "Убирает слабые шлейфы за движущимися персонажами, животными и тем, что они держат: DLSS " + "берёт там меньше от прошлых кадров. Чем сильнее, тем меньше шлейфов и тем чуть менее " + "гладкие края. Действует сразу.", + [UI_MENU_DLSS_CHARS_OFF] = "Выкл.", [UI_MENU_DLSS_CHARS_LIGHT] = "Слабо", [UI_MENU_DLSS_CHARS_MEDIUM] = "Средне", + [UI_MENU_DLSS_CHARS_FULL] = "Полностью", [UI_MENU_DLSS] = "Режим DLSS", [UI_MENU_DLSS_DESC] = "DLAA рисует 3D-сцену в полном разрешении. «Качество», «Баланс» и «Производительность» рисуют её " "в 67, 58 и 50 % и масштабируют через DLSS ради большего числа кадров; они заменяют масштаб " diff --git a/runtime/ui_text.h b/runtime/ui_text.h index 15e05c41..cb956f1c 100644 --- a/runtime/ui_text.h +++ b/runtime/ui_text.h @@ -55,7 +55,8 @@ typedef enum { UI_MENU_PCSS, UI_MENU_PCSS_DESC, UI_MENU_DLAA, UI_MENU_DLAA_DESC, 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_PRESET, UI_MENU_DLSS_PRESET_DESC, - UI_MENU_DLSS_PRESET_DEFAULT, UI_MENU_DLSS_PRESET_K, UI_MENU_DLSS_PRESET_J, UI_MENU_FXAA, UI_MENU_FXAA_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, // Game UI_MENU_FPS_LIMIT, UI_MENU_FPS_LIMIT_DESC, UI_MENU_FPS_30, UI_MENU_FPS_40, UI_MENU_FPS_45, UI_MENU_FPS_60, UI_MENU_FPS_90, diff --git a/runtime/vk_dlaa.c b/runtime/vk_dlaa.c index 0c1bfc92..a553e422 100644 --- a/runtime/vk_dlaa.c +++ b/runtime/vk_dlaa.c @@ -290,6 +290,10 @@ static struct { VkImage out, mv; VmaAllocation out_mem, mv_mem; VkImageView out_view, mv_view; + VkImage mask, chars[2]; // the bias mask DLSS reads, the character class mask of this and last frame (R8) + VmaAllocation mask_mem, chars_mem[2]; + VkImageView mask_view, chars_view[2]; + int chars_cur, chars_ok; // chars[chars_cur] is written next; chars_ok: the other holds last frame's NgxHandle *feat; uint64_t used; // evals count when it last ran } sizes[3], *last; // last: the one the previous DLAA frame ran with @@ -314,12 +318,14 @@ static struct { VkPipeline mv_pipe; VkSampler mv_samp; int mv_ok; // -1 not built, 0 failed, 1 ready - uint64_t mv_frames, mv_none; + uint64_t mv_frames, mv_none, masked; // masked: frames with the characters' bias mask uint64_t why[3]; // history resets: scene size changed, no camera, scene target changed int on; // the dlaa setting, read at each present (the menu switches it live) int scaler_skipped; // this frame: the game's scaling draw over DLSS's picture was skipped uint64_t scaler_missed; // frames DLSS scaled whose scaling draw was not found (vk_dlaa_skip_draw) int preset, preset_dirty; // the DLSS model features are created with (preset_value); a change pending + VkExecTarget ids; // this frame's G-buffer target 0 (object classes in green), valid with ids_ok + int ids_ok; unsigned cfg_seen; // cfg_version when preset was read uint64_t last_eval_ns; // plat_now_ns of the previous evaluation (FrameTimeDeltaInMsec) } D = {.mv_ok = -1, .cfg_seen = ~0u}; @@ -353,6 +359,12 @@ static void free_size(struct Size *e) { if (e->mv_view) vkDestroyImageView(c->device, e->mv_view, NULL); if (e->out) vmaDestroyImage(c->vma, e->out, e->out_mem); if (e->mv) vmaDestroyImage(c->vma, e->mv, e->mv_mem); + if (e->mask_view) vkDestroyImageView(c->device, e->mask_view, NULL); + if (e->mask) vmaDestroyImage(c->vma, e->mask, e->mask_mem); + for (int i = 0; i < 2; i++) { + if (e->chars_view[i]) vkDestroyImageView(c->device, e->chars_view[i], NULL); + if (e->chars[i]) vmaDestroyImage(c->vma, e->chars[i], e->chars_mem[i]); + } if (e->feat) N.release(e->feat); memset(e, 0, sizeof *e); } @@ -374,12 +386,16 @@ static struct Size *size_for(VkCommandBuffer cb, uint32_t w, uint32_t h, uint32_ } VkImageUsageFlags u = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; + VkImageUsageFlags u8 = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; if (!image2d(ow, oh, VK_FORMAT_R16G16B16A16_SFLOAT, u, &e->out, &e->out_mem, &e->out_view) || - !image2d(w, h, VK_FORMAT_R16G16_SFLOAT, u, &e->mv, &e->mv_mem, &e->mv_view)) + !image2d(w, h, VK_FORMAT_R16G16_SFLOAT, u, &e->mv, &e->mv_mem, &e->mv_view) || + !image2d(w, h, VK_FORMAT_R8_UNORM, u8, &e->mask, &e->mask_mem, &e->mask_view) || + !image2d(w, h, VK_FORMAT_R8_UNORM, u8, &e->chars[0], &e->chars_mem[0], &e->chars_view[0]) || + !image2d(w, h, VK_FORMAT_R8_UNORM, u8, &e->chars[1], &e->chars_mem[1], &e->chars_view[1])) return NULL; - VkImageMemoryBarrier2 ib[2]; - VkImage im[2] = {e->out, e->mv}; - for (int i = 0; i < 2; i++) + VkImageMemoryBarrier2 ib[5]; + VkImage im[5] = {e->out, e->mv, e->mask, e->chars[0], e->chars[1]}; + for (int i = 0; i < 5; i++) ib[i] = (VkImageMemoryBarrier2){.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2, .srcStageMask = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, .dstStageMask = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, @@ -388,7 +404,7 @@ static struct Size *size_for(VkCommandBuffer cb, uint32_t w, uint32_t h, uint32_ .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .image = im[i], .subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}}; - VkDependencyInfo di = {.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO, .imageMemoryBarrierCount = 2, + VkDependencyInfo di = {.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO, .imageMemoryBarrierCount = 5, .pImageMemoryBarriers = ib}; vkCmdPipelineBarrier2(cb, &di); e->w = w, e->h = h, e->ow = ow, e->oh = oh; @@ -426,15 +442,19 @@ static int mv_init(void) { if (D.mv_ok >= 0) return D.mv_ok; D.mv_ok = 0; const VkCtx *c = vk_ctx(); - VkDescriptorSetLayoutBinding b[4] = { + VkDescriptorSetLayoutBinding b[8] = { {0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_COMPUTE_BIT, NULL}, {1, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1, VK_SHADER_STAGE_COMPUTE_BIT, NULL}, {2, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_COMPUTE_BIT, NULL}, - {3, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_COMPUTE_BIT, NULL}}; + {3, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_COMPUTE_BIT, NULL}, + {4, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_COMPUTE_BIT, NULL}, + {5, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1, VK_SHADER_STAGE_COMPUTE_BIT, NULL}, + {6, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1, VK_SHADER_STAGE_COMPUTE_BIT, NULL}, + {7, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1, VK_SHADER_STAGE_COMPUTE_BIT, NULL}}; VkDescriptorSetLayoutCreateInfo dci = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, .flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, - .bindingCount = 4, .pBindings = b}; - VkPushConstantRange pr = {VK_SHADER_STAGE_COMPUTE_BIT, 0, 16}; + .bindingCount = 8, .pBindings = b}; + VkPushConstantRange pr = {VK_SHADER_STAGE_COMPUTE_BIT, 0, 24}; VkSamplerCreateInfo si = {.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, .magFilter = VK_FILTER_NEAREST, .minFilter = VK_FILTER_NEAREST, .mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST, .addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, @@ -468,13 +488,16 @@ fail: } // The pass, recorded through the recorder like the replay's own commands. 0: no camera this frame (the vectors stay -// zero and DLSS starts a new history). -static int mv_pass(VkCommandBuffer cb, const struct Size *e, VkImageView zv, float jx, float jy) { +// zero and DLSS starts a new history). bias > 0 with this frame's G-buffer classes (D.ids) also writes e->mask, the +// bias mask (dlaa_mv.comp); *masked says whether it did. +static int mv_pass(VkCommandBuffer cb, struct Size *e, VkImageView zv, float jx, float jy, float bias, int *masked) { + *masked = 0; uint32_t w = e->w, h = e->h; VkDescriptorBufferInfo cam; if (!mv_init() || !D.cam_addr || !vk_usnap_find(D.cam_addr, CAM_BYTES, 4, &cam)) { D.mv_none++; D.cam_prev_ok = 0; + e->chars_ok = 0; return 0; } int s = D.cam_slot, had_prev = D.cam_prev_ok; @@ -482,12 +505,24 @@ static int mv_pass(VkCommandBuffer cb, const struct Size *e, VkImageView zv, flo vkCmdCopyBuffer(cb, cam.buffer, D.camb, 1, &bc); full_barrier(cb); D.cam_slot ^= 1, D.cam_prev_ok = 1; - if (!had_prev) return 0; // nothing to reproject into: zero motion, new history + if (!had_prev) { e->chars_ok = 0; return 0; } // nothing to reproject into: zero motion, new history VkDescriptorImageInfo zi = {D.mv_samp, zv, VK_IMAGE_LAYOUT_GENERAL}; VkDescriptorImageInfo oi = {VK_NULL_HANDLE, e->mv_view, VK_IMAGE_LAYOUT_GENERAL}; + // The class mask needs the G-buffer at the scene size; otherwise bindings 4-7 get the mask images as stand-ins + // (the shader returns before reading them with bias 0). + const VkExecTarget *ids = &D.ids; + int use = bias > 0 && D.ids_ok && ids->image && ids->width == w && ids->height == h && !ids->is3d; + VkImageView iv = use ? vk_exec_target_view(ids->img, ids->format, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT, + ids->level, ids->base_layer, 1, 0) + : e->mask_view; + int cur_c = e->chars_cur; + VkDescriptorImageInfo ii = {D.mv_samp, iv, VK_IMAGE_LAYOUT_GENERAL}; + VkDescriptorImageInfo mki = {VK_NULL_HANDLE, e->mask_view, VK_IMAGE_LAYOUT_GENERAL}; + VkDescriptorImageInfo cpi = {VK_NULL_HANDLE, e->chars_view[cur_c ^ 1], VK_IMAGE_LAYOUT_GENERAL}; + VkDescriptorImageInfo coi = {VK_NULL_HANDLE, e->chars_view[cur_c], VK_IMAGE_LAYOUT_GENERAL}; VkDescriptorBufferInfo cur = {D.camb, (VkDeviceSize)s * CAM_BYTES, CAM_BYTES}; VkDescriptorBufferInfo prev = {D.camb, (VkDeviceSize)(s ^ 1) * CAM_BYTES, CAM_BYTES}; - VkWriteDescriptorSet wr[4] = { + VkWriteDescriptorSet wr[8] = { {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstBinding = 0, .descriptorCount = 1, .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, .pImageInfo = &zi}, {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstBinding = 1, .descriptorCount = 1, @@ -495,14 +530,25 @@ static int mv_pass(VkCommandBuffer cb, const struct Size *e, VkImageView zv, flo {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstBinding = 2, .descriptorCount = 1, .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, .pBufferInfo = &cur}, {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstBinding = 3, .descriptorCount = 1, - .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, .pBufferInfo = &prev}}; + .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, .pBufferInfo = &prev}, + {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstBinding = 4, .descriptorCount = 1, + .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, .pImageInfo = &ii}, + {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstBinding = 5, .descriptorCount = 1, + .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, .pImageInfo = &mki}, + {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstBinding = 6, .descriptorCount = 1, + .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, .pImageInfo = &cpi}, + {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstBinding = 7, .descriptorCount = 1, + .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, .pImageInfo = &coi}}; vkCmdBindPipeline(cb, VK_PIPELINE_BIND_POINT_COMPUTE, D.mv_pipe); - rec_push(vk_pipeline_push_fn(), cb, VK_PIPELINE_BIND_POINT_COMPUTE, D.mv_layout, 0, 4, wr); - float pc[4] = {(float)w, (float)h, jx, jy}; + rec_push(vk_pipeline_push_fn(), cb, VK_PIPELINE_BIND_POINT_COMPUTE, D.mv_layout, 0, 8, wr); + float pc[6] = {(float)w, (float)h, jx, jy, use ? bias : 0.0f, use && e->chars_ok ? 1.0f : 0.0f}; vkCmdPushConstants(cb, D.mv_layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof pc, pc); vkCmdDispatch(cb, (w + 7) / 8, (h + 7) / 8, 1); full_barrier(cb); D.mv_frames++; + if (use) e->chars_cur ^= 1, e->chars_ok = 1, D.masked++; + else e->chars_ok = 0; + *masked = use; return 1; } @@ -554,6 +600,16 @@ static int preset_value(void) { return 0; } +// How strongly DLSS favours the current frame on characters and where they just were (TOTK_DLSS_CHAR_MASK, percent, +// live; 0 off). The vectors are the camera's only, so a character that moves on its own drags a faint copy of itself +// through DLSS's history; the bias mask makes DLSS take less of the history there, at the cost of some of its +// anti-aliasing on those pixels. +static float char_bias(void) { + const char *v = cfg_get("TOTK_DLSS_CHAR_MASK"); + long n = v && *v ? strtol(v, NULL, 10) : 65; + return n <= 0 ? 0.0f : n >= 100 ? 1.0f : (float)n / 100.0f; +} + // The quality setting DLSS is created with, from the scene's share of the output width. static int perf_quality(uint32_t w, uint32_t ow) { if (w >= ow) return NGX_PERFQ_DLAA; @@ -575,7 +631,7 @@ 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]++; // another size's history is from another moment + if (e != D.last) D.reset = 1, D.why[0]++, e->chars_ok = 0; // another size's history is from another moment if (!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, @@ -583,7 +639,8 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) { float jx = D.jit_used ? D.ux : 0.0f, jy = D.jit_used ? D.uy : 0.0f; static int no_mv = -1; if (no_mv < 0) no_mv = !rt_knob("DLAA_MV", "1"); // TOTK_DLAA_MV=0: zero motion (test) - if (no_mv || !mv_pass(cb, e, zv, jx, jy)) { + int masked = 0; + if (no_mv || !mv_pass(cb, e, zv, jx, jy, char_bias(), &masked)) { VkClearColorValue zero = {{0, 0, 0, 0}}; VkImageSubresourceRange all = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; vkCmdClearColorImage(cb, e->mv, VK_IMAGE_LAYOUT_GENERAL, &zero, 1, &all); @@ -629,6 +686,11 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) { p_setf(p, "Jitter.Offset.Y", jy); p_setf(p, "Sharpness", 0.0f); p_seti(p, "Reset", D.reset); + // The characters' bias mask (mv_pass), or none: the parameter object is reused, so it is cleared explicitly. + NgxResourceVK rk = res_image(e->mask_view, e->mask, VK_FORMAT_R8_UNORM, w, h, VK_IMAGE_ASPECT_COLOR_BIT, 0); + p_setp(p, "DLSS.Input.Bias.Current.Color.Mask", masked ? (void *)&rk : NULL); + p_setu(p, "DLSS.Input.Bias.Current.Color.Subrect.Base.X", 0); + p_setu(p, "DLSS.Input.Bias.Current.Color.Subrect.Base.Y", 0); p_setf(p, "MV.Scale.X", 1.0f); p_setf(p, "MV.Scale.Y", 1.0f); p_setu(p, "DLSS.Render.Subrect.Dimensions.Width", w); @@ -658,11 +720,13 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) { vk_exec_draw_new_cb(); // NGX bound pipelines and descriptor sets of its own: the next draw binds everything again D.jdepth = z->image; next_jitter(); - if (++D.evals == 1 || D.evals % 3600 == 0) + if (++D.evals == 1 || D.evals == 300 || D.evals % 3600 == 0) // 300: one early line with the frames counted rt_log("dlaa: %llu frames anti-aliased (scene %ux%u, output %ux%u; %llu frames without the DLAA point, %llu with camera " - "motion, %llu without a camera, %llu jitter holds; resets: %llu size, %llu camera, %llu target)", + "motion, %llu with the characters' mask, %llu without a camera, %llu jitter holds; resets: %llu size, %llu " + "camera, %llu target)", (unsigned long long)D.evals, w, h, ow, oh, (unsigned long long)D.frames_missed, - (unsigned long long)D.mv_frames, (unsigned long long)D.mv_none, (unsigned long long)D.holds, + (unsigned long long)D.mv_frames, (unsigned long long)D.masked, (unsigned long long)D.mv_none, + (unsigned long long)D.holds, (unsigned long long)D.why[0], (unsigned long long)D.why[1], (unsigned long long)D.why[2]); } @@ -678,6 +742,11 @@ void vk_dlaa_pass(VkExec *ex) { // and DLAA then ran at a small pass ahead of the whole scene, which reached the screen jittered. if (ex->pass_ncolor >= 3 && z->image && z->format == VK_FORMAT_D32_SFLOAT && z->width >= 640) { D.gbuf = 1, D.armed = 0; + // target 0 is the object-class buffer (RGBA8, the scene size): the characters' bias mask reads its green. A + // smaller pass of the same shape (640x360, seen while loading) does not replace the scene's in the same frame. + if (c->image && c->format == VK_FORMAT_R8G8B8A8_UNORM && c->width == z->width && c->height == z->height && + c->samples <= 1 && !c->is3d && (!D.ids_ok || c->width >= D.ids.width)) + D.ids = *c, D.ids_ok = 1; return; } // the scene depth is D32F; a D16 target of the scene size also serves one composite pass before the transparents @@ -734,7 +803,7 @@ void vk_dlaa_frame(void) { if (D.up && !D.scaler_skipped && ++D.scaler_missed == 1) rt_log("dlaa: the game's scaling draw over DLSS's picture was not found (its fragment shader is not in FXAA_FS): " "the jittered scene reaches the screen and shakes"); - D.armed = D.done = D.jit_used = D.gbuf = D.ended = D.up = D.scaler_skipped = 0; + D.armed = D.done = D.jit_used = D.gbuf = D.ended = D.up = D.scaler_skipped = D.ids_ok = 0; D.cam_addr = 0; } diff --git a/totk.ini.example b/totk.ini.example index ed1899ca..e3a73e7d 100644 --- a/totk.ini.example +++ b/totk.ini.example @@ -205,6 +205,11 @@ # (K in every mode) or j (the other transformer model: slightly less ghosting behind moving characters, a little more # flicker). Changes while the game runs take effect at once (DLSS starts a new history). # dlss_preset = default +# Characters' trails: DLSS's motion vectors follow the camera only, so a character, animal or held item that moves on +# its own can drag a faint copy of itself. The G-buffer marks those objects; on them and where they were the frame +# before, DLSS is told to favour the current frame by this percentage (0, 35, 65 or 100; 0 off). Higher removes more of +# the trails and leaves those edges a little less smooth. Changes while the game runs take effect at once. +# dlss_char_mask = 65 # 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. # fxaa = 1