From be5f4db3bf9538568afad74f6e5b4fadd4306b43 Mon Sep 17 00:00:00 2001 From: itaskaev2 <165683571+itaskaev2@users.noreply.github.com> Date: Wed, 11 Nov 2026 11:53:25 +0100 Subject: [PATCH] Skip 1.2.1's own scaling draw after DLSS instead of feeding it DLSS's picture (#1106) On 1.2.1 the light target is scaled to the output by an upscaler of the game's own (twelve texelFetch taps, fragment shader e6f7ae35b8479ef3), not by the FXAA draw vk_dlaa_skip_draw knows. It addresses its source in the scene's pixels, so DLSS's output-sized picture swapped in for the light target (tex_info) showed only its top-left part, two thirds at DLSS quality, stretched over the screen: the "floating camera" of #1106. #660 (169d057) made the swap reach that draw: before it, DLSS ran on another target and its picture never reached the screen on 1.2.1. DLSS already writes its picture into the scaling pass's target, so on 1.2.1 a draw in a pass larger than the light target, without depth, that samples the light target is now skipped (vk_exec_draw_samples). The HUD drawn later into the same target samples other textures and stays. 1.4.3 keeps the swap, where a tonemap can be the scaling draw. Co-Authored-By: Claude Opus 5.5 --- runtime/vk_dlaa.c | 15 +++++++++++++++ runtime/vk_exec.h | 3 +++ runtime/vk_exec_draw.c | 17 +++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/runtime/vk_dlaa.c b/runtime/vk_dlaa.c index 194c23b9..597a83bc 100644 --- a/runtime/vk_dlaa.c +++ b/runtime/vk_dlaa.c @@ -1305,6 +1305,21 @@ int vk_dlaa_skip_draw(VkExec *ex, const GfxShader *fs) { } if (fxaa && !D.up) return 0; // nothing to skip: no shader lookup per draw at the defaults if (!fs) return 0; + // 1.2.1 scales the light target to the output with an upscaler of its own (12 texelFetch taps around the source + // pixel, fragment shader e6f7ae35b8479ef3 with this build's translator), not with the FXAA one, in a pass without + // depth. It addresses its source in the scene's pixels (constant bank 3), so DLSS's output-sized picture swapped in + // (tex_info) showed only its top-left part, the scene's share of the output (two thirds at DLSS quality), over + // the whole screen (#1106). DLSS already wrote its picture into that pass's target + // (evaluate), so on 1.2.1 a draw there that samples the light target is skipped instead; the HUD drawn later into + // the same target samples other textures and stays. On 1.4.3 a tonemap can be the draw that scales (the comment + // above struct D), and it keeps the swap. + if (D.up && !RT_V143 && !ex->depth.image && vk_dlaa_swap_img && ex->pass_w > vk_dlaa_swap_img->width + 1 && + vk_exec_draw_samples(ex, fs, vk_dlaa_swap_img)) { + static int logged; + if (!logged) logged = 1, rt_log("dlaa: DLSS replaces the game's scaling draw (fragment shader %016llx)", + (unsigned long long)spirv_hash(fs)); + return 1; + } uint64_t h = spirv_hash(fs); int known = 0; for (size_t i = 0; i < sizeof FXAA_FS / sizeof FXAA_FS[0]; i++) known |= h == FXAA_FS[i]; diff --git a/runtime/vk_exec.h b/runtime/vk_exec.h index 37579804..266c8aa9 100644 --- a/runtime/vk_exec.h +++ b/runtime/vk_exec.h @@ -195,6 +195,9 @@ void vk_exec_inline_end(int reopen); // vk_exec_draw.c: forget what the command buffer being recorded has bound (pipeline, sets, dynamic state, vertex // buffers): the replay continues in a new one (vk_sync_split). void vk_exec_draw_new_cb(VkExec *ex); +// vk_exec_draw.c: the fragment stage of the draw being recorded samples img through one of its bound combined +// textures (OP_BIND_TEX, the handles tex_info swaps; vk_dlaa.c vk_dlaa_skip_draw). Takes the texture lock. +int vk_exec_draw_samples(VkExec *ex, const GfxShader *fs, const VkTexImage *img); // The recording threads of the chunked replay as this run read TOTK_REPLAY_WORKERS (0 off), -1 before the first // submission read it (the settings menu shows it). int vk_exec_replay_workers(void); diff --git a/runtime/vk_exec_draw.c b/runtime/vk_exec_draw.c index a11a8852..cfd23688 100644 --- a/runtime/vk_exec_draw.c +++ b/runtime/vk_exec_draw.c @@ -1709,6 +1709,23 @@ static Twin *twin_update(VkExec *ex, const VkTexImage *img) { return t; } +int vk_exec_draw_samples(VkExec *ex, const GfxShader *fs, const VkTexImage *img) { + const GfxShaderRes *res; + int n = fs && img ? gfx_shader_resources(fs, GFX_RES_TEX, &res) : 0, hit = 0; + if (!n) return 0; + vk_texture_lock(); + for (int i = 0; i < n && !hit; i++) { + if (res[i].separate || res[i].slot < 0) continue; + for (int k = 0; k < (res[i].count ? res[i].count : 1) && !hit; k++) { + int slot = res[i].slot + k; + uint64_t h = slot < 128 ? ex->tex[NVN_STAGE_FS][slot] : 0; + hit = h && vk_texture_by_id_locked((int)(h & 0xfffff), NULL, NULL) == img; + } + } + vk_texture_unlock(); + return hit; +} + // The image descriptor of slot h; in a dispatch, a compare-sampled colour image the driver cannot compare is swapped // for its depth twin; in a pass larger than it, the scene's light target, once DLSS scaled it this frame, for DLSS's // output (vk_dlaa.c).