From 1cf947fe4b65c1184449ae492c5be0f253e9d38f Mon Sep 17 00:00:00 2001 From: chrg6 Date: Tue, 10 Nov 2026 02:59:57 -0500 Subject: [PATCH] Release the DLSS features that stayed before one is made after a release, so the pause screen no longer comes out striped. A pause of 3,600 frames frees the gameplay feature; the unpause makes it again, and the pause screen's feature, which had stayed, drew alternating bands of rows black or noise at every later pause. A scripted pause, unpause, pause on 0.6.1.22 and 0.6.1.23 was striped in each of the 8 runs in which the gameplay feature had been freed and in none of the 12 in which it had not; setting the kept feature's sizes at each evaluation (the commit reverted before this one) changed nothing. Features made one after the other with no release in between are fine, so that is now the only way one is made. dlss_idle_free = 0 keeps every feature instead, 2 is the old behaviour. Co-Authored-By: Claude Fable 5.2 (cherry picked from commit 16acd83397d0b59904fd4c0bd96cea8285bc0a6f) --- nx2navi.ini.example | 4 ++++ runtime/cfg.c | 6 +++--- runtime/vk_dlaa.c | 39 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/nx2navi.ini.example b/nx2navi.ini.example index fc2685dd..3b611e95 100644 --- a/nx2navi.ini.example +++ b/nx2navi.ini.example @@ -325,6 +325,10 @@ # characters, a little more flicker). Any other model by its letter, a to m: on slower RTX cards the older model e is # cheaper. Changes while the game runs take effect at once (DLSS starts a new history). # dlss_preset = default +# DLSS keeps one network per picture size (gameplay, the pause screen). 1: one unused for 3,600 frames is freed, and +# the others are made again with it when it comes back. 0: none is ever freed (about 0.5 GB more video memory after +# the first pause). 2: freed, the others kept (shows striped pause screens; for tests). +# dlss_idle_free = 1 # Per-object motion vectors for DLSS: characters, animals and moving objects get their own motion instead of the # camera's, so DLSS keeps their history instead of smearing or rejecting it. Costs some CPU time each frame (about 1-2 ms # on a laptop CPU); 0 leaves camera-only motion. Read at start. diff --git a/runtime/cfg.c b/runtime/cfg.c index 34ce4563..36c58f1e 100644 --- a/runtime/cfg.c +++ b/runtime/cfg.c @@ -40,7 +40,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", "DISCORD_APP_ID", "DISCORD_IMAGE", "DISCORD_RPC", "DLAA", "DLAA_CAM_KEEP", "DLAA_JITTER", "DLAA_MV", "DLAA_MASKDEBUG", "DLAA_MVDEBUG", "DLAA_OBJMV", "DLAA_SURVEY", "DLAA_TIMES", "DLSS", "DLSS_CHAR_MASK", "DLSS_PRESET", "DLSS_REACTIVE", "DUMP", "DUMP_BUF", "DUMP_DIR", + "DESC_TEMPLATE", "DEVICE_PROFILE", "DISCORD_APP_ID", "DISCORD_IMAGE", "DISCORD_RPC", "DLAA", "DLAA_CAM_KEEP", "DLSS_IDLE_FREE", "DLAA_JITTER", "DLAA_MV", "DLAA_MASKDEBUG", "DLAA_MVDEBUG", "DLAA_OBJMV", "DLAA_SURVEY", "DLAA_TIMES", "DLSS", "DLSS_CHAR_MASK", "DLSS_PRESET", "DLSS_REACTIVE", "DUMP", "DUMP_BUF", "DUMP_DIR", "DUMP_LOG", "DUMP_FILE", "DS3", "LOG_CS_BINDS", "LOG_TEX_FLAGS", "LOG_MESH", "MESH", "POOL", "NATIVE_TENSOR", "LOG_RCOND", "LOG_RT_SIZES", "DUMP_WHITE", "DUMP_AFTER", "DUMP_MOVIE", "SUBMIT_FINISH", "ACQUIRE_WAIT", "CRASH_FILTER_GUARD", "CS_FALLBACK", "EXEFS", "FEEDBACK", "FIX_C0", "FIX_ZERO", "FLIGHT", "FLIGHT_AT", "FLIGHT_DIR", "FLIGHT_FRAMES", "FLIGHT_SPIKE_MS", "FLIGHT_THUMBS", "FLUSH_SPAN", "FLUSH_UPLOAD", "FOG_CULL", "FOLIAGE_SHADOW_CULL", "FOLIAGE_SHADOW_VRS", "FOV", "FOV_PATCH", "FG_HUDLESS_SHOW", "FPS60", "FPS_LIMIT", "FRAMEGEN", "FRAMEGEN_MULTIPLIER", "FREEZE_IDLE", "FREE_CORES", "FULLSCREEN", "FXAA", "GAME_ASPECT", "GAME_RES", "GPA", "GPA_EMPTY", "GPA_TWIN", "GPA_TWIN_MAX_KB", "GPL", "GPL_DRAW_BUILD", "GPU", "GPU_INDEX", "GPU_PASSES", "GPU_NAME", "HDR", "HDR_BLOWOUT", "HDR_CONTRAST", @@ -85,7 +85,7 @@ static const struct { const char *key, *section; } sections[] = { {"HDR_HIGHLIGHTS", "display"}, {"HDR_SHADOWS", "display"}, {"HDR_CONTRAST", "display"}, {"HDR_SATURATION", "display"}, {"HDR_HIGHLIGHT_SAT", "display"}, {"HDR_BLOWOUT", "display"}, {"HDR_FLARE", "display"}, {"HDR_HUE", "display"}, {"HDR_GRADE", "display"}, {"SHADOW_RES", "display"}, - {"DLAA", "display"}, {"DLSS", "display"}, {"DLSS_PRESET", "display"}, {"DLSS_CHAR_MASK", "display"}, {"FXAA", "display"}, + {"DLAA", "display"}, {"DLSS", "display"}, {"DLSS_PRESET", "display"}, {"DLSS_IDLE_FREE", "display"}, {"DLSS_CHAR_MASK", "display"}, {"FXAA", "display"}, {"FRAMEGEN", "display"}, {"FRAMEGEN_MULTIPLIER", "display"}, {"DEVICE_PROFILE", "display"}, {"ASSUME_FOCUS", "display"}, {"DISCORD_RPC", "discord"}, {"DISCORD_APP_ID", "discord"}, {"DISCORD_IMAGE", "discord"}, @@ -138,7 +138,7 @@ 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", LIVE}, {"DLSS", "dlaa", "dlaa|quality|balanced|performance|ultra_performance", LIVE}, - {"DLSS_PRESET", "default", "default|k|j", LIVE}, {"TAA", "dlss", "dlss|fsr3", LIVE}, // vk_dlaa.c fsr3 + {"DLSS_PRESET", "default", "default|k|j", LIVE}, {"DLSS_IDLE_FREE", "1", "0|1|2", RESTART}, {"TAA", "dlss", "dlss|fsr3", LIVE}, // vk_dlaa.c fsr3 {"FRAMEGEN", "off", "off|fsr3|dlss", LIVE}, // vk_fg.cpp, vk_dlssg.c {"FRAMEGEN_MULTIPLIER", "2", "2|3|4", LIVE}, // vk_dlssg.c: frames on screen per rendered frame with DLSS {"DLSS_CHAR_MASK", "65", "0|35|65|100", LIVE}, {"FXAA", "1", "0|1", LIVE}, diff --git a/runtime/vk_dlaa.c b/runtime/vk_dlaa.c index cb93576f..683cf8c0 100644 --- a/runtime/vk_dlaa.c +++ b/runtime/vk_dlaa.c @@ -513,6 +513,26 @@ static int image2d(uint32_t w, uint32_t h, VkFormat f, VkImageUsageFlags usage, // The images and views of a size, then its feature. The device must be idle: free_size waits for it, vk_dlaa_release // has. Whatever was not made is skipped, so a half-made size goes the same way. +// A feature was released since the last one was made (destroy_size), and what follows from it (NX2NAVI_DLSS_IDLE_FREE). +// A pause of 3,600 frames frees the gameplay feature (stale_sizes); the unpause makes it again, and the pause screen's +// feature, which had stayed, then drew alternating bands of rows black or noise at every later pause, for as long as +// the game stayed paused: in each of the 8 scripted runs of pause, unpause, pause in which the gameplay feature had +// been freed and in none of the 12 in which it had not, whatever the texture, write-back, HDR and frame generation +// settings. Giving the kept feature its own sizes again at each evaluation changed nothing. Features made one after +// the other with none released in between do not show it (the gameplay feature, then the pause screen's, at every +// first pause). So a feature is only ever made into that state: with a release since the last creation, the features +// that stayed are released first (release_kept) and made again when their size is next evaluated. +// 1 (default) idle features are freed, and the kept ones are released before the next creation +// 0 idle features are never freed +// 2 idle features are freed and the kept ones stay (as before; shows the fault) +static int feat_released; + +static int idle_free(void) { + static int m = -1; + if (m < 0) m = rt_knob("DLSS_IDLE_FREE", "1"); + return m; +} + static void destroy_size(struct Size *e) { const VkCtx *c = vk_ctx(); if (e->out_view) vkDestroyImageView(c->device, e->out_view, NULL); @@ -527,7 +547,7 @@ static void destroy_size(struct Size *e) { if (e->dist_view[i]) vkDestroyImageView(c->device, e->dist_view[i], NULL); if (e->dist[i]) vmaDestroyImage(c->vma, e->dist[i], e->dist_mem[i]); } - if (e->feat && N.release) N.release(e->feat); + if (e->feat && N.release) N.release(e->feat), feat_released = 1; memset(e, 0, sizeof *e); } @@ -1412,6 +1432,7 @@ static void query_vram(void) { // Frees the sizes other than cur that no evaluation used for SIZE_STALE evaluations: the GPU finished with them long // ago (the CPU is never that many presents ahead), so their images and feature go at once. static void stale_sizes(const struct Size *cur) { + if (!idle_free()) return; for (int i = 0; i < DLSS_SIZES; i++) { struct Size *s = &D.sizes[i]; if (s == cur || !s->out || D.evals < s->used + SIZE_STALE) continue; @@ -1422,6 +1443,20 @@ static void stale_sizes(const struct Size *cur) { } } +// Before a feature is made after a release (feat_released): the features of the other sizes go too, their images stay. +// The GPU may still be running an evaluation of theirs, so it finishes first, as in free_size. +static void release_kept(const struct Size *making) { + int n = 0; + for (int i = 0; i < DLSS_SIZES; i++) { + struct Size *s = &D.sizes[i]; + if (s == making || !s->feat) continue; + if (!n++) vk_queue_lock(), vkDeviceWaitIdle(vk_ctx()->device), vk_queue_unlock(); + N.release(s->feat), s->feat = NULL; + if (D.last == s) D.last = NULL; + } + if (n) rt_log("dlaa: %d kept DLSS feature(s) released before a new one is made after a release; made again when used", n); +} + static void evaluate(VkExec *ex, const VkExecTarget *dst) { const VkExecTarget *t = &D.color, *z = &D.depth; if (!dst) dst = t; @@ -1481,6 +1516,8 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) { goto evaluated; } if (!e->feat) { + if (feat_released && idle_free() == 1) release_kept(e); + feat_released = 0; p_setu(p, "CreationNodeMask", 1); p_setu(p, "VisibilityNodeMask", 1); p_setu(p, "Width", w);