From e89cc4d4302b75beb43cf486662c00dc0c9cc70e Mon Sep 17 00:00:00 2001 From: chrg6 Date: Fri, 13 Nov 2026 00:48:07 -0500 Subject: [PATCH] Let frame generation run without a temporal upscaler, from inputs made for it alone. With frame generation running and no DLSS or FSR upscaling, vk_dlaa.c arms and ends the frame in the same places and, where the upscaler's evaluation would run, makes only frame generation's inputs (fg_only_frame): the scene's depth and camera found as before, motion vectors from the same pass at the scene's size, no jitter at all, and the picture without the HUD copied from the game's own scaled picture. DLSS Frame Generation and AMD's frame generation no longer need an upscaler set; NVIDIA's through NGX still needs DLSS at the start and then keeps running when the upscaler is switched off. The menu's Frame generation row stays usable with every Upscaling choice and the Upscaling row keeps frame generation as set, with texts in all four menu languages. The log says at the start and at each change whether frame generation takes its inputs from the upscaler or runs without one. Co-Authored-By: Claude Opus 5.5 --- nx2navi.ini.example | 6 +- runtime/ui/menu.cpp | 43 ++++---- runtime/ui_text.c | 21 ++++ runtime/ui_text.h | 3 + runtime/vk_dlaa.c | 198 +++++++++++++++++++++++++++++++++---- runtime/vk_dlaa.h | 11 ++- runtime/vk_dlssg.c | 19 ++-- runtime/vk_dlssg.h | 2 +- runtime/vk_exec_draw.c | 3 +- runtime/vk_fg.cpp | 23 ++--- runtime/vk_fg.h | 2 +- runtime/vk_mvprev.c | 7 +- runtime/vk_skin_motion.inc | 2 +- runtime/vk_usnap.c | 4 +- 14 files changed, 271 insertions(+), 73 deletions(-) diff --git a/nx2navi.ini.example b/nx2navi.ini.example index f0a77ea6..2376a6a8 100644 --- a/nx2navi.ini.example +++ b/nx2navi.ini.example @@ -709,13 +709,15 @@ # Frame generation: off, fsr3 (AMD FSR 3.1 on any GPU where amd_fidelityfx_vk.dll loads, so not on Linux: one generated # frame between every two the game draws, the HUD kept out of it) or dlss (NVIDIA DLSS Frame Generation on GeForce RTX # 40 and 50 GPUs, paced with Reflex; it needs nx2navi_dlssg.dll and NVIDIA Streamline's files next to the executable, -# which the setup puts there). Both need DLSS or FSR 3.1 upscaling (dlaa = 1). While frame generation runs, fps_limit +# which the setup puts there). Both run with any upscaling: with DLSS or FSR 3.1 (dlaa = 1) they take its depth and +# motion vectors, and without one (dlaa = 0) the same ones made for them alone, with no jitter (the log's "dlaa: frame +# generation runs" line says which). While frame generation runs, fps_limit # counts the frames the game draws and the screen shows that times the multiplier (2 for fsr3); fps_limit = display # alone holds the screen to the monitor's rate and the game to that rate divided by the multiplier. # fsr3 takes effect at once, dlss (on or off) at the next start. # framegen = off # On Linux dlss runs through NVIDIA's NGX itself, without Streamline: it needs dlaa = 1 with DLSS when the game starts -# and NVIDIA's libnvidia-ngx-dlssg.so. (from NVIDIA's DLSS SDK repository) beside the game, then switches at +# (it keeps running when dlaa is switched off later) and NVIDIA's libnvidia-ngx-dlssg.so. (from NVIDIA's DLSS SDK repository) beside the game, then switches at # once, and its multiplier is fg_mult: 2 to 6 (above 2 needs an RTX 50 GPU) or dynamic, which generates only the frames # needed to reach the display's refresh rate at the rate the game draws. framegen_multiplier is not used there. # fg_mult = 2 diff --git a/runtime/ui/menu.cpp b/runtime/ui/menu.cpp index bae7c379..3ce1a069 100644 --- a/runtime/ui/menu.cpp +++ b/runtime/ui/menu.cpp @@ -1061,7 +1061,6 @@ static void row_upscaling(void) { const Entry e = list[nv]; opt_apply("NX2NAVI_UPSCALER", e.kind == FSR1 ? "fsr" : "bilinear"); opt_apply("NX2NAVI_DLAA", e.kind >= DLSS ? "1" : "0"); - if (e.kind < DLSS) opt_apply("NX2NAVI_FRAMEGEN", "off"); // it needs DLSS's or FSR 3.1's motion vectors (row_framegen) // Native is scene_share = 1. Leaving it unsets the key (the game's own share, widescreen.c PLAIN_SHARE); a share of // the whole picture set by hand beside DLSS or FSR stays while one of their modes is chosen if (e.kind == NATIVE) opt_apply("NX2NAVI_SCENE_SHARE", "1"); @@ -1210,27 +1209,31 @@ static const char *fg4_label(void) { snprintf(s, sizeof s, *v ? "AMD FSR 4 library (%s)" : "AMD FSR 4 library", v); return s; } -// It is the one in use: set (NX2NAVI_FSR4_FG) with FSR 4 as the upscaler, where it runs (vk_fg.cpp use4). +// It is the one in use: set (NX2NAVI_FSR4_FG) with FSR 4 as the upscaler, where it runs (vk_fg.cpp use4). Without an +// upscaler (dlaa = 0) the FSR 3.1 library's runs. static bool fg4_chosen(void) { - return cfg_bool("NX2NAVI_FSR4_FG") && vk_ffx_fsr4() && vk_fg4_available() && !vk_fg4_failed(); + return cfg_bool("NX2NAVI_FSR4_FG") && cfg_bool("NX2NAVI_DLAA") && vk_ffx_fsr4() && vk_fg4_available() && + !vk_fg4_failed(); } -// Frame generation (vk_fg.cpp, at once; NVIDIA's after a restart); it needs a temporal upscaler's motion vectors +// Frame generation (vk_fg.cpp, at once; NVIDIA's after a restart), with any Upscaling choice: vk_dlaa.c makes its depth, +// motion vectors and picture without the HUD with an upscaler or without one (fg_only_frame) static void row_framegen(void) { - // the generated frames are made from DLSS's or FSR 3.1's motion vectors: without one of them it would do nothing, - // and FSR 3.1 set where it cannot load (vk_ffx_available) is none + // FSR 3.1 set where it cannot load (vk_ffx_available) has no frame generation const bool dlss = dlss_offered(), fsr = vk_ffx_framegen_available(); - const bool upscaled = cfg_bool("NX2NAVI_DLAA") && (strcmp(cfg_value("NX2NAVI_TAA"), "fsr3") || vk_ffx_available()); + // Through NGX (every build but the Windows one) NVIDIA's needs NGX, which comes up only with DLSS upscaling on when + // the game starts (vk_ngxfg_wanted): before such a start it waits for a DLSS mode under Upscaling and a restart + const bool via_ngx = framegen_ngx() && dlss; + const bool dlss_set = cfg_bool("NX2NAVI_DLAA") && strcmp(cfg_value("NX2NAVI_TAA"), "fsr3"); const char *v = cfg_value("NX2NAVI_FRAMEGEN"); int cur = !strcmp(v, "fsr3") ? 1 : !strcmp(v, "dlss") ? 2 : 0; - // what the texts promise follows what runs here: DLSS's frame generation, AMD's, both or neither - const UiTextId desc = dlss ? (fsr ? UI_MENU_FRAMEGEN_DESC : UI_MENU_FRAMEGEN_DESC_DLSS) - : (fsr ? UI_MENU_FRAMEGEN_DESC_FSR : UI_MENU_FRAMEGEN_DESC_NONE); - UiTextId note = dlss ? (fsr ? UI_MENU_FRAMEGEN_NOTE : UI_MENU_FRAMEGEN_NOTE_DLSS) - : (fsr ? UI_MENU_FRAMEGEN_NOTE_FSR : UI_MENU_FRAMEGEN_NOTE); // neither: the general note + // what the texts promise follows what runs here: frame generation with any choice, NGX's start rule, or none + const UiTextId desc = !dlss && !fsr ? UI_MENU_FRAMEGEN_DESC_NONE : via_ngx ? UI_MENU_FRAMEGEN_DESC_NGX + : UI_MENU_FRAMEGEN_DESC_ANY; + // UI_TEXT_COUNT: no note + UiTextId note = !dlss && !fsr ? UI_MENU_FRAMEGEN_NOTE : via_ngx ? UI_MENU_FRAMEGEN_NOTE_NGX : UI_TEXT_COUNT; if (!dlss && !fsr && cur == 0) opt_disable_next(UI_MENU_FRAMEGEN_NEEDS_NONE); - else if (!upscaled) opt_disable_next(dlss ? (fsr ? UI_MENU_FRAMEGEN_NEEDS : UI_MENU_FRAMEGEN_NEEDS_DLSS) - : (fsr ? UI_MENU_FRAMEGEN_NEEDS_FSR : UI_MENU_FRAMEGEN_NEEDS_NONE)); + else if (via_ngx && !fsr && !vk_ngxfg_wanted() && !dlss_set) opt_disable_next(UI_MENU_FRAMEGEN_NEEDS_DLSS); // Off, AMD's where FSR 3.1 loads and NVIDIA DLSS (vk_dlssg.c, through Streamline and nx2navi_dlssg.dll) on NVIDIA GPUs, // now that Reflex paces it from the frame's start and generated frames are presented; elsewhere one stays listed // while it is set @@ -1239,7 +1242,8 @@ static void row_framegen(void) { // upscaler to FSR 4 as well; both are NX2NAVI_FRAMEGEN = fsr3, told apart by NX2NAVI_FSR4_FG. enum { OFF, FSR3, FSR4LIB, DLSS }; const bool four = cur == 1 && fg4_chosen(); - const bool four_offered = fsr && vk_ffx4_available() && vk_fg4_available() && !vk_fg4_failed(); + const bool four_offered = fsr && cfg_bool("NX2NAVI_DLAA") && vk_ffx4_available() && vk_fg4_available() && + !vk_fg4_failed(); // beside FSR 4 upscaling only: not offered without an upscaler const int now = cur == 2 ? DLSS : cur == 1 ? (four ? FSR4LIB : FSR3) : OFF; const char *all_names[] = {menu_text(UI_MENU_FRAMEGEN_OFF), "AMD FSR 3.1", fg4_label(), "NVIDIA DLSS"}; int kinds[4]; @@ -1261,8 +1265,9 @@ static void row_framegen(void) { const int st = cur != 2 || restart ? DLSSG_RUNS : ngx ? (vk_ngxfg_max() ? DLSSG_RUNS : DLSSG_NO_FILES) : vk_dlssg_status(); if (st == DLSSG_UNAVAILABLE) note = UI_MENU_FRAMEGEN_UNAVAILABLE; else if (st == DLSSG_NO_FILES) note = UI_MENU_FRAMEGEN_OFF_FILES; - // the note under AMD's names FSR 3.1 as what it needs; the FSR 4 library's runs beside FSR 4, so it has none - int nv = opt_choice_index("NX2NAVI_FRAMEGEN", UI_MENU_FRAMEGEN, names, n, at, 0, desc, four && !restart ? NULL : menu_text(note)); + // the FSR 4 library's runs beside FSR 4 and has no note of its own + int nv = opt_choice_index("NX2NAVI_FRAMEGEN", UI_MENU_FRAMEGEN, names, n, at, 0, desc, + (four && !restart) || note == UI_TEXT_COUNT ? NULL : menu_text(note)); if (nv >= 0 && nv < n) { const int k = kinds[nv]; opt_apply("NX2NAVI_FRAMEGEN", k == OFF ? "off" : k == DLSS ? "dlss" : "fsr3"); @@ -1273,8 +1278,8 @@ static void row_framegen(void) { opt_apply("NX2NAVI_FSR4_FG", "0"); } } - else if (cur == 2 && upscaled && dlss && ngx) row_framegen_mult_ngx(); - else if (cur == 2 && upscaled && dlss) row_framegen_mult(restart); + else if (cur == 2 && dlss && ngx) row_framegen_mult_ngx(); // nothing while NGX's frame generation cannot run + else if (cur == 2 && dlss) row_framegen_mult(restart); } // One Resolution row for the picture's height (NX2NAVI_GAME_RES, widescreen.c picture_height: 1080, the game's 1440 or diff --git a/runtime/ui_text.c b/runtime/ui_text.c index 6ec1df44..3435abcd 100644 --- a/runtime/ui_text.c +++ b/runtime/ui_text.c @@ -863,6 +863,10 @@ static const char *const text_en[UI_TEXT_COUNT] = { [UI_MENU_FRAMEGEN_MULT_OLD_DLL] = "2x only: update the DLSS frame generation files", [UI_MENU_FRAMEGEN_UNAVAILABLE] = "in use: off: it needs an RTX 40 or newer; if you have one, see dlssg in the log", [UI_MENU_FRAMEGEN_OFF_FILES] = "in use: off, its files are missing", + [UI_MENU_FRAMEGEN_DESC_ANY] = "Adds generated frames for smoother motion, with any Upscaling choice.", + [UI_MENU_FRAMEGEN_DESC_NGX] = "Adds generated frames for smoother motion. NVIDIA DLSS needs a DLSS mode under " + "Upscaling when the game starts; it then runs with any Upscaling choice.", + [UI_MENU_FRAMEGEN_NOTE_NGX] = "needs DLSS when the game starts", [UI_MENU_GAME_RES] = "Resolution", [UI_MENU_GAME_RES_DESC] = "Size of the game's picture; outside fullscreen the window takes it too. Higher is sharper " "but costs more GPU power.", @@ -909,6 +913,13 @@ static const char *const text_ru[UI_TEXT_COUNT] = { [UI_MENU_LOW_LATENCY_NO_DRIVER] = "у этого драйвера нет режима низкой задержки", [UI_MENU_LOW_LATENCY_DLSSG] = "генерация кадров DLSS использует свой режим", [UI_MENU_LOW_LATENCY_FG] = "выключено, пока на этой видеокарте работает генерация кадров", + [UI_MENU_FRAMEGEN_DESC_ANY] = "Добавляет сгенерированные кадры для более плавного движения, с любым выбором в " + "Upscaling.", + [UI_MENU_FRAMEGEN_DESC_NGX] = "Добавляет сгенерированные кадры для более плавного движения. Для NVIDIA DLSS " + "нужен режим DLSS в Upscaling при запуске игры; после этого генерация работает с " + "любым " + "выбором в Upscaling.", + [UI_MENU_FRAMEGEN_NOTE_NGX] = "нужен DLSS при запуске игры", [UI_MENU_LOW_LATENCY_FAILED] = "сейчас: выкл., драйвер отказал (см. lowlat в журнале)", [UI_MENU_GPU] = "Видеокарта", [UI_MENU_GPU_DESC] = "Видеокарта, на которой работает игра.", [UI_MENU_GPU_AUTO] = "Автоматически", @@ -1633,6 +1644,12 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = { [UI_MENU_LOW_LATENCY_NO_DRIVER] = "este driver de vídeo não tem modo de baixa latência", [UI_MENU_LOW_LATENCY_DLSSG] = "a geração de quadros DLSS usa o seu próprio", [UI_MENU_LOW_LATENCY_FG] = "desligado enquanto a geração de quadros roda nesta placa", + [UI_MENU_FRAMEGEN_DESC_ANY] = "Adiciona quadros gerados para um movimento mais suave, com qualquer opção em " + "Upscaling.", + [UI_MENU_FRAMEGEN_DESC_NGX] = "Adiciona quadros gerados para um movimento mais suave. O NVIDIA DLSS precisa de um " + "modo DLSS em Upscaling quando o jogo inicia; depois funciona com qualquer opção em " + "Upscaling.", + [UI_MENU_FRAMEGEN_NOTE_NGX] = "precisa do DLSS ao iniciar o jogo", [UI_MENU_LOW_LATENCY_FAILED] = "em uso: desligado, o driver recusou (veja lowlat no log)", [UI_MENU_GPU] = "Placa de vídeo", [UI_MENU_GPU_DESC] = "A placa de vídeo usada pelo jogo.", [UI_MENU_GPU_AUTO] = "Automática", @@ -2355,6 +2372,10 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = { [UI_MENU_LOW_LATENCY_NO_DRIVER] = "此显卡驱动没有低延迟模式", [UI_MENU_LOW_LATENCY_DLSSG] = "DLSS 帧生成使用自带的低延迟", [UI_MENU_LOW_LATENCY_FG] = "此显卡运行帧生成时关闭", + [UI_MENU_FRAMEGEN_DESC_ANY] = "添加生成的帧,使动作更流畅,可搭配 Upscaling 中的任意选项。", + [UI_MENU_FRAMEGEN_DESC_NGX] = "添加生成的帧,使动作更流畅。NVIDIA DLSS 需要在游戏启动时于 Upscaling 中选择 DLSS " + "模式;之后可搭配 Upscaling 中的任意选项。", + [UI_MENU_FRAMEGEN_NOTE_NGX] = "需要在游戏启动时开启 DLSS", [UI_MENU_LOW_LATENCY_FAILED] = "使用中:关闭,驱动拒绝了(见日志中的 lowlat)", [UI_MENU_GPU] = "显卡", [UI_MENU_GPU_DESC] = "运行游戏所用的显卡。", diff --git a/runtime/ui_text.h b/runtime/ui_text.h index 95029dc7..32b4183c 100644 --- a/runtime/ui_text.h +++ b/runtime/ui_text.h @@ -350,6 +350,9 @@ typedef enum { UI_MENU_FRAMEGEN_MULT_UPTO, // printf: "%d", the highest multiplier this GPU and driver allow UI_MENU_FRAMEGEN_MULT_OLD_DLL, // nx2navi_dlssg.dll is older than multi frame generation UI_MENU_FRAMEGEN_UNAVAILABLE, UI_MENU_FRAMEGEN_OFF_FILES, + // frame generation with any Upscaling choice, an upscaler or none (vk_dlaa.c fg_only_frame); through NGX (every + // build but the Windows one) NVIDIA's needs DLSS upscaling on at the start, its note and description there + UI_MENU_FRAMEGEN_DESC_ANY, UI_MENU_FRAMEGEN_DESC_NGX, UI_MENU_FRAMEGEN_NOTE_NGX, // the settings of the low-end GPU mode (ui/menu.cpp rows_low_end), English only UI_MENU_LOWEND_INTRO, UI_MENU_LOWEND_RESTART, UI_MENU_LOWEND_NOT_FOR_CARD, UI_MENU_LOWEND_MEMORY, UI_MENU_LOWEND_RENDER, UI_MENU_LOWEND_BUILD, UI_MENU_LOWEND_DIAG, diff --git a/runtime/vk_dlaa.c b/runtime/vk_dlaa.c index d92b478f..f18b301c 100644 --- a/runtime/vk_dlaa.c +++ b/runtime/vk_dlaa.c @@ -29,7 +29,9 @@ #include "platform/platform.h" #include "vk.h" #include "vk_dlaa.h" +#include "vk_dlssg.h" #include "vk_exec.h" +#include "vk_fg.h" #include "vk_ffx.h" #include "vk_rec.h" #include "dlaa_mv_spv.h" @@ -551,6 +553,7 @@ static struct { uint64_t seq_present; // vk_exec_submit_seq at the last present (vk_dlaa_frame) uint64_t seconds; // present intervals with a second scene after DLSS ran int on; // the dlaa setting, read at each present (the menu switches it live) + int fgo; // frame generation runs and no upscaler does: inputs alone (fg_only_frame), read at each present 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; @@ -652,7 +655,8 @@ int vk_dlaa_fg_inputs(VkFfxImage *depth, VkFfxImage *mv, float *jx, float *jy, i if (!D.fg_fresh || D.failed) return 0; D.fg_fresh = 0; if (!fg_current(D.fg_at)) return 0; - // reset: DLSS started a new history on this frame (evaluate). Handed out as 0 before, so frame generation was never + // reset: DLSS started a new history on this frame (evaluate; fg_only_frame by the same rules without an upscaler). + // jx, jy: 0 without an upscaler, whose frames are not jittered. Handed out as 0 before, so frame generation was never // told of a camera cut, another scene size or another target, and interpolated across them: an area load // generated frames between two unrelated pictures. *depth = D.fg_depth, *mv = D.fg_mv, *jx = D.fg_jx, *jy = D.fg_jy, *reset = D.fg_reset; @@ -666,6 +670,10 @@ static int dl_active(void) { return N.available && !D.failed && D.on; } // The same for vk_exec_draw.c untranslated_dispatch_fallback: while it holds, DLSS or FSR 3.1 scales the scene and the // stand-in of the game's own upscaler does not make the picture the screen shows (vk_dlaa_upscaler). int vk_dlaa_active(void) { return dl_active(); } +// The frame is armed and ended (vk_dlaa_draw, vk_dlaa_pass, vk_dlaa_upscaler): the upscaler runs, or frame generation +// takes the scene's inputs without one (D.fgo, fg_only_frame). +static int inputs_on(void) { return dl_active() || D.fgo; } +int vk_dlaa_fg_only(void) { return D.fgo; } // The upscaler this frame runs with, as vk_dlaa_frame read it. The menu can set NX2NAVI_TAA to dlss between that and // evaluate; read again there while NGX is not up (DLSS starts only after a restart), it sent evaluate to DLSS's path // with NGX's functions not loaded, a call to address 0 (issue #325). @@ -1321,7 +1329,7 @@ static int mv_pass(VkExec *ex, struct Size *e, VkImageView zv, float jx, float j // Last frame's camera block for the per-object motion pass, recorded before this frame's mv_pass: that pass writes // this frame's into slot cam_slot and leaves the other slot, last frame's, as it is. 0: none (no history). int vk_dlaa_prev_camera(VkDescriptorBufferInfo *out, float jitter[2]) { - if (!dl_active() || !D.cam_prev_ok || !D.camb) return 0; + if (!inputs_on() || !D.cam_prev_ok || !D.camb) return 0; if (D.cam_size != CAM_BLOCK) return 0; // the per-object pass knows the deferred engine's block only *out = (VkDescriptorBufferInfo){D.camb, (VkDeviceSize)(D.cam_slot ^ 1) * CAM_SLOT, CAM_BLOCK}; jitter[0] = D.jit_ok ? D.jx : 0.0f, jitter[1] = D.jit_ok ? D.jy : 0.0f; @@ -1650,7 +1658,7 @@ static int scene_color(VkFormat f); static void dlaa_draw_locked(VkExec *ex); void vk_dlaa_draw(VkExec *ex) { - if (!dl_active() || D.ended) return; + if (!inputs_on() || D.ended) return; static PlatMutex lock = PLAT_MUTEX_INIT; // the replay workers' scene draws count at once (vk_exec.c chunks) int lk = vk_exec_shared(); if (lk) plat_mutex_lock(&lock); @@ -2181,7 +2189,13 @@ static struct Size *range_host(struct Size *e) { // Set when the scene the upscaler runs on has another size than the last one; vk_dlaa_resized_take reads it. static volatile int32_t size_changed; +static void fg_only_frame(VkExec *ex, const VkExecTarget *dst); + static void evaluate(VkExec *ex, const VkExecTarget *dst) { + if (D.fgo) { // no upscaler: frame generation's inputs alone, at the same point of the frame + fg_only_frame(ex, dst); + return; + } const VkExecTarget *t = &D.color, *z = &D.depth; if (!dst) dst = t; uint32_t w = t->width, h = t->height, ow = dst->width, oh = dst->height; @@ -2440,10 +2454,16 @@ evaluated: // HDR (NX2NAVI_HDR = 1) the game's picture stays float and linear up to the present, which encodes it to PQ // (vk_hdr_encode): DLSS's output is kept as RGBA16F for the same encode. The game's own HDR (native) encodes inside the // game, which this cannot follow: no HUD-less picture there. +// hudless_from: the same from any picture of that kind, src (GENERAL, level and layer of w x h, a format that can be +// blitted from), which fg_only_frame takes from the game's own scaling where no upscaler runs. int vk_dlaa_hudless_wanted; // src: the picture without the HUD, linear, w x h, in GENERAL: DLSS's output where the upscaler ran at the game's -// upscaler, the game's upscaler's output where it ran before the bloom (vk_dlaa_upscaler). -static void hudless(VkCommandBuffer cb, VkImage src, uint32_t w, uint32_t h) { +// upscaler, the game's upscaler's output where it ran before the bloom (vk_dlaa_upscaler). hudless_from takes a level +// and a layer of src as well: the game's own scaled picture where frame generation runs without an upscaler +// (fg_only_frame). +static void hudless_from(VkCommandBuffer cb, VkImage src, uint32_t level, uint32_t layer, uint32_t w, uint32_t h); +static void hudless(VkCommandBuffer cb, VkImage src, uint32_t w, uint32_t h) { hudless_from(cb, src, 0, 0, w, h); } +static void hudless_from(VkCommandBuffer cb, VkImage src, uint32_t level, uint32_t layer, uint32_t w, uint32_t h) { const VkCtx *c = vk_ctx(); int hdr = vk_hdr_wanted() && !vk_hdr_native(); if (vk_hdr_native()) return; @@ -2481,7 +2501,7 @@ static void hudless(VkCommandBuffer cb, VkImage src, uint32_t w, uint32_t h) { .pImageMemoryBarriers = ib}; vkCmdPipelineBarrier2(cb, &di); } - VkImageBlit b = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, .srcOffsets = {{0, 0, 0}, {(int32_t)w, (int32_t)h, 1}}, + VkImageBlit b = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, level, layer, 1}, .srcOffsets = {{0, 0, 0}, {(int32_t)w, (int32_t)h, 1}}, .dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, .dstOffsets = {{0, 0, 0}, {(int32_t)w, (int32_t)h, 1}}}; vkCmdBlitImage(cb, src, VK_IMAGE_LAYOUT_GENERAL, hdr ? D.hl : D.hl_srgb, VK_IMAGE_LAYOUT_GENERAL, 1, &b, VK_FILTER_NEAREST); @@ -2762,9 +2782,9 @@ static void prebloom_upscaler(VkExec *ex, VkImage out, uint32_t w, uint32_t h) { void vk_dlaa_upscaler(VkExec *ex, VkImage out, VkFormat fmt, uint32_t w, uint32_t h) { static int on = -1; if (on < 0) on = rt_knob("DLAA_AT_UPSCALER", "1"); - if (!dl_active() || !out || fmt != VK_FORMAT_B10G11R11_UFLOAT_PACK32) return; + if (!inputs_on() || !out || fmt != VK_FORMAT_B10G11R11_UFLOAT_PACK32) return; if (D.armed && !D.gbuf && w >= D.color.width && h >= D.color.height) D.pic_w = w, D.pic_h = h; // prebloom_run - if (D.pre) { + if (D.pre) { // set only where the upscaler runs (vk_dlaa_pass: prebloom needs dl_active) prebloom_upscaler(ex, out, w, h); return; } @@ -2784,7 +2804,7 @@ void vk_dlaa_upscaler(VkExec *ex, VkImage out, VkFormat fmt, uint32_t w, uint32_ void vk_dlaa_pass(VkExec *ex) { const VkExecTarget *c = &ex->color[0], *z = &ex->depth; - if (!dl_active()) return; + if (!inputs_on()) return; if (D.done) { // diagnostics: another scene drawn into a light target in the same present interval // (not before the bloom: the flares and the composite after it are of that shape, and expected) if (!D.pre && ex->pass_ncolor == 1 && c->image && scene_color(c->format) && z->image && z->format == VK_FORMAT_D32_SFLOAT && @@ -2835,7 +2855,7 @@ void vk_dlaa_pass(VkExec *ex) { if (!D.armed) return; if (!deferred) { // Ocarina's shape: the output pass ends the scene and runs DLSS // NX2NAVI_DLSS_PREBLOOM: before the bloom chain's first pass instead, where there is one (prebloom_run) - if (D.pre_on && prebloom_start(ex) && prebloom_run(ex)) return; + if (D.pre_on && dl_active() && prebloom_start(ex) && prebloom_run(ex)) return; // not for frame generation alone int one = ex->pass_ncolor == 1 && c->image && !z->image && c->image != D.color.image && c->samples <= 1 && !c->is3d; if (one) F.one_n++, F.one_w = c->width, F.one_h = c->height, F.one_fmt = c->format; @@ -2980,16 +3000,141 @@ static void idle_release(void) { } if (D.on || D.presents - off_at < IDLE_FREE_PRESENTS) return; int n = 0; - for (int i = 0; i < DLSS_SIZES; i++) - if (D.sizes[i].out || D.sizes[i].feat) { - rt_log("dlaa: the DLSS size %ux%u -> %ux%u went unused for %d presents with the upscaler off: freed", - D.sizes[i].w, D.sizes[i].h, D.sizes[i].ow, D.sizes[i].oh, IDLE_FREE_PRESENTS); - destroy_size(&D.sizes[i]), n++; + for (int i = 0; i < DLSS_SIZES; i++) { + struct Size *s = &D.sizes[i]; + if (D.fgo && s == D.last) { // frame generation's motion images without an upscaler (fg_only_frame) stay + if (s->feat) { // a DLSS feature made for the same sizes (DLAA) does not + rt_log("dlaa: the DLSS feature at %ux%u went unused for %d presents with the upscaler off: released; " + "its size's motion images stay for frame generation", s->w, s->h, IDLE_FREE_PRESENTS); + N.release(s->feat), s->feat = NULL, feat_released = 1; + } + if (D.host == s) D.host = NULL; + continue; } - if (n) // frame generation's motion vectors were a size's (evaluate); none is handed out this late (fg_current) + if (s->out || s->feat) { + rt_log("dlaa: the DLSS size %ux%u -> %ux%u went unused for %d presents with the upscaler off: freed", + s->w, s->h, s->ow, s->oh, IDLE_FREE_PRESENTS); + destroy_size(s), n++; + } + } + // frame generation's motion vectors were a size's (evaluate); none is handed out this late (fg_current). Without an + // upscaler they are the size kept above, which this frame's inputs may still be. + if (n && !D.fgo) D.last = NULL, D.host = NULL, D.fg_fresh = 0, D.fg_mv_view = VK_NULL_HANDLE, D.fg_mv = (VkFfxImage){0}; } +// ---------------------------------------------------------------- frame generation without an upscaler +// Frame generation (vk_dlssg.c, vk_fg.cpp, vk_fg4.cpp, gfx_present.c's NGX presenter) takes the frame's depth, motion +// vectors, camera and picture without the HUD from this file. With an upscaler they are what its evaluation used +// (evaluate). With frame generation running and no upscaler (dlaa = 0, or DLSS set where it is not available: D.fgo, +// vk_dlaa_frame) the frame is armed and ended in the same places (vk_dlaa_draw, vk_dlaa_pass, vk_dlaa_upscaler), and +// evaluate hands it to fg_only_frame, which leaves the upscaler's evaluation out: +// - the camera is the scene context the scene's draws use (vk_dlaa_draw), and the motion vectors come from the same pass +// at the scene's size (mv_pass, the per-object motion included), into a size's images made for the scene's size +// alone: no DLSS feature, and the image the upscaler's picture would go to has the scene's size; +// - nothing is jittered: next_jitter is never called, so jit_ok stays 0 and no viewport moves (vk_dlaa_viewport). A +// jittered frame that nothing resolves shakes on screen. The vectors and frame generation get a jitter of 0; +// - the picture without the HUD is copied from the target the upscaler's picture would have gone to, which the game's +// own scaling (vk_exec_draw.c untranslated_dispatch_fallback, vk_tonemap.c) has just written at the picture's size, +// or from the light target itself where the frame ends in place. A deferred frame's scaling pass (vk_dlaa_pass) +// draws its picture inside the pass that ends the scene, so its target does not hold it yet: such a frame has none; +// - nothing is drawn over the frame: the game's scaling draw stays (D.up 0) and no pass reads another picture +// (vk_dlaa_swap_img). +// The scene can then be smaller than the picture (the game's own render scale), as in the upscaler's scaling modes: +// the depth and the vectors have the scene's size and the picture without the HUD the picture's, which every frame +// generation takes as it does there (vk_dlssg.c vk_dlssg_frame: the vectors scaled by the depth's size, the output by +// the swapchain's; vk_fg.cpp vk_fg_frame: the depth's size as the render size, the context made for up to the +// picture's; vk_dlaa.c vk_ngxfg_evaluate: the vectors' and the depth's own rectangles; gfx_present.c hudless_record: +// the picture without the HUD scaled to the swapchain like the picture). + +// Frame generation that takes this frame's inputs: NVIDIA's through Streamline (vk_dlssg.c, set up with the device), +// AMD's swapchain in place (vk_fg.cpp, either library) or NVIDIA's through NGX, set now (vk_ngxfg_on). +static int fg_runs(void) { return vk_dlssg_active() || vk_fg_active() || vk_ngxfg_on(); } + +// One line at the first present and one at each change: whether frame generation runs, and where its inputs come from. +static void fg_state_line(int on, int fgo) { + static int last = -1; + const int st = !fg_runs() ? 0 : fgo ? 2 : on && !D.failed ? 1 : 3; + if (st == last) return; + last = st; + if (st == 0) rt_log("dlaa: frame generation does not run: no inputs are made for it"); + else if (st == 1) rt_log("dlaa: frame generation runs with its inputs from the upscaler (%s)", use_fsr() ? "FSR" : "DLSS"); + else if (st == 2) + rt_log("dlaa: frame generation runs without an upscaler: the scene's depth, motion vectors and camera, no " + "jitter, and the picture without the HUD from the game's own scaling"); + else rt_log("dlaa: frame generation runs, but the upscaler or its inputs failed earlier in this run: none are made"); +} + +// vkCmdBlitImage reads an image of format f with optimal tiling into hudless_from's float, UNORM or sRGB images: the +// format must have BLIT_SRC, and an integer format may only be blitted into another integer one, which linear +// filtering (no integer format has it) rules out. The upscaler's targets (B10G11R11, RGBA16F, RGBA8) have all of that by +// the Vulkan spec's required formats; anything else is asked once per format. +static int blit_from(VkFormat f) { + static VkFormat known[8]; + static int ok[8], n; + for (int i = 0; i < n; i++) + if (known[i] == f) return ok[i]; + VkFormatProperties fp; + vkGetPhysicalDeviceFormatProperties(vk_ctx()->phys, f, &fp); + const VkFormatFeatureFlags need = VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT; + int r = (fp.optimalTilingFeatures & need) == need; + if (!r) rt_log("dlaa: the picture's format %d cannot be copied for frame generation: no picture without the HUD", (int)f); + if (n < 8) known[n] = f, ok[n++] = r; + return r; +} + +static void fg_only_frame(VkExec *ex, const VkExecTarget *dst) { + const VkExecTarget *t = &D.color, *z = &D.depth; + const uint32_t w = t->width, h = t->height; + D.up = 0; // the game's scaling draw makes the picture (vk_dlaa_skip_draw) + D.stepped = 0; + vk_exec_barrier(ex); // what drew the scene, and the game's scaling into dst, is done (no pass is open here) + VkCommandBuffer cb = ex->cb; + struct Size *e = size_for(cb, w, h, w, h); + if (!e) { + rt_log("dlaa: the motion images for frame generation could not be made: none for the rest of this run"); + D.failed = 1; + return; + } + // another size: its own distances and masks are from another moment, and the vectors start anew + if (e != D.last) D.reset = 1, D.why[0]++, e->chars_ok = e->dist_ok = 0; + VkImageView zv = vk_exec_target_view(z->img, z->format, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_DEPTH_BIT, z->level, + z->base_layer, 1, 0); + static int no_mv = -1; + if (no_mv < 0) no_mv = !rt_knob("DLAA_MV", "1"); // NX2NAVI_DLAA_MV=0: zero motion (test), as in evaluate + // no jitter, and bias 0: the bias mask is DLSS's alone + int masked = 0, mv = no_mv ? 0 : mv_pass(ex, e, zv, 0.0f, 0.0f, 0.0f, &masked); + if (mv != 1) { + 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); + full_barrier(cb); + if (!no_mv && mv == 0) D.reset = 1, D.why[1]++; // no camera: frame generation starts anew + } + if (D.last_color != t->image) target_changed(t, mv == 1); + if (mv == 1) fcam_probe(cb, e, w, h); // mv_pass's distances, behind its barrier + const VkExecTarget *pic = dst ? dst : t; + int hl = vk_dlaa_hudless_wanted && (!dst || !D.gbuf) && blit_from(pic->format); + if (hl) hudless_from(cb, pic->image, pic->level, pic->base_layer, pic->width, pic->height); + D.fg_reset = D.reset; + D.reset = 0; + D.last = e, e->used = D.evals + 1, D.evals++; + ex->recorded += 2; + vk_exec_draw_new_cb(); // the motion pass bound a pipeline and descriptors of its own: the next draw binds all again + D.jdepth = z->image, D.jw = z->width, D.jh = z->height; // the scene depth the camera's draws go to (vk_dlaa_draw) + D.fg_depth = (VkFfxImage){z->image, z->format, w, h, 0}; + D.fg_mv = (VkFfxImage){e->mv, VK_FORMAT_R16G16_SFLOAT, w, h, 1}; + D.fg_depth_view = zv, D.fg_mv_view = e->mv_view; + D.fg_jx = D.fg_jy = 0.0f, D.fg_at = D.presents, D.fg_fresh = 1; + D.jit_ok = 0; + static uint64_t frames, still; + frames++, still += mv != 1; + if (frames == 1 || frames == 300 || frames % 3600 == 0) + rt_log("dlaa: frame generation without an upscaler: %llu frames prepared (scene %ux%u, picture %ux%u%s), %llu " + "without camera motion", (unsigned long long)frames, w, h, pic->width, pic->height, + hl ? "" : ", no picture without the HUD", (unsigned long long)still); +} + void vk_dlaa_frame(void) { static unsigned cfg_seen; static int cfg_known; @@ -3011,6 +3156,19 @@ void vk_dlaa_frame(void) { N.available = fsr_frame && cfg_bool("NX2NAVI_DLAA") && vk_ffx_load(); } int on = N.available && cfg_bool("NX2NAVI_DLAA"); + // Frame generation without an upscaler takes this frame's inputs alone (fg_only_frame); switching in either + // direction starts anew as switching the upscaler does below, and the frame before gets nothing to frame generation. + int fgo = !on && !D.failed && fg_runs(); + fg_state_line(on, fgo); + if (fgo != D.fgo) { + D.fgo = fgo; + off_at = D.presents; // idle_release: the upscaler's sizes count as unused from here + D.reset = 1, D.cam_prev_ok = 0, D.jit_ok = D.jit_used = D.armed = D.done = D.gbuf = D.ended = D.up = 0; + D.hold = 0; + D.fg_fresh = D.hl_fresh = 0; + memset(&F, 0, sizeof F); + if (on == D.on) return; + } if (on != D.on) { rt_log("dlaa: %s", on ? "on" : "off"); D.on = on; @@ -3023,7 +3181,7 @@ void vk_dlaa_frame(void) { return; } idle_release(); - if (!dl_active()) return; + if (!inputs_on()) return; if (D.share_off) D.share_off--; if (!D.done && D.armed) D.share_off = 120; // vk_dlaa_pass: the output pass without the mode's share for a while if (!D.done) { @@ -3133,7 +3291,9 @@ int vk_dlaa_skip_draw(VkExec *ex, const GfxShader *fs) { // generates count frames between the previous call's picture and this one into out[0..count-1] (MultiFrameIndex 1 to // count) and a copy of bb into real; gfx_present.c's presenter shows them in that order, then the rendered one. The // inputs are the ones the Streamline path gets (vk_dlssg.c): the depth, motion vectors, jitter and camera of the frame -// DLSS last ran on, and the picture without the HUD. +// DLSS last ran on, and the picture without the HUD. NGX comes up only with DLSS upscaling on at the start +// (vk_ngxfg_wanted); switched off in the menu after that, the frames armed for frame generation alone give the same +// (fg_only_frame, no jitter). int vk_ngxfg_max(void) { return vk_ngxfg_wanted() && N.available && !FG.failed ? FG.max : 0; } int vk_ngxfg_on(void) { return vk_ngxfg_max() && !strcmp(cfg_value("NX2NAVI_FRAMEGEN"), "dlss"); } void vk_ngxfg_reset(void) { FG.reset = 1; } @@ -3148,7 +3308,7 @@ int vk_ngxfg_evaluate(VkCommandBuffer cb, const VkNgxImage *bb, const VkNgxImage float jx = 0, jy = 0; int reset = 0; if (!vk_dlaa_fg_inputs(&d, &m, &jx, &jy, &reset) || !vk_dlaa_fg_views(&dv, &mvv) || !vk_dlaa_fg_camera(&c)) { - FG.reset = 1; // a frame without DLSS's inputs: the next generation has no valid previous frame + FG.reset = 1; // a frame without its inputs: the next generation has no valid previous frame return 0; } if (!FG.p && !NGX_OK(N.alloc_params(&FG.p))) { diff --git a/runtime/vk_dlaa.h b/runtime/vk_dlaa.h index 5380b257..63aabf05 100644 --- a/runtime/vk_dlaa.h +++ b/runtime/vk_dlaa.h @@ -23,8 +23,13 @@ int vk_dlaa_fsr3(void); // the setting is on and its upscaler is AMD FSR 3.1, int vk_dlaa_needs_restart(void); // the menu's upscaler cannot start in this run // Frame generation (vk_fg.cpp): the depth and motion vectors of the frame DLSS or FSR 3.1 last ran on, with its jitter // and whether its history reset; 1 once per evaluation (0: none since the last call). The images stay valid until the -// next frame's scene draws over them, after this present. +// next frame's scene draws over them, after this present. Without an upscaler, while frame generation runs, the same +// of the last frame armed for it alone (vk_dlaa.c fg_only_frame): the scene's size, a jitter of 0. int vk_dlaa_fg_inputs(VkFfxImage *depth, VkFfxImage *mv, float *jx, float *jy, int *reset); +// 1 while frame generation runs without an upscaler and the frame is armed for its inputs alone (vk_dlaa.c +// fg_only_frame): the motion passes run as for the upscaler (vk_usnap.c, vk_exec_draw.c, vk_mvprev.c), nothing is +// jittered. Read at each present. +int vk_dlaa_fg_only(void); // ... their views, and this frame's camera for DLSS Frame Generation (vk_dlssg.c): matrices for row vectors (v * M, the // rows stored in order), as Streamline takes them; 0 without a camera that frame. // znear and zfar: the view distances the depth buffer holds as 0 and 1 (1 and 0 when inverted), from the frame's own @@ -40,8 +45,8 @@ typedef struct { } VkDlaaCamera; int vk_dlaa_fg_views(VkImageView *depth, VkImageView *mv); // The picture without the HUD at the size of the game's picture, in *fmt: RGBA8 UNORM bytes like it (sRGB-encoded), or -// RGBA16F linear with HDR on; made at each evaluation while vk_dlaa_hudless_wanted (frame generation sets it); 1 once per -// evaluation. +// RGBA16F linear with HDR on; made at each evaluation while vk_dlaa_hudless_wanted (frame generation sets it), from the +// upscaler's picture or, without an upscaler, from the game's own scaled picture; 1 once per evaluation. extern int vk_dlaa_hudless_wanted; int vk_dlaa_fg_hudless(VkImage *img, VkImageView *view, uint32_t *w, uint32_t *h, VkFormat *fmt); int vk_dlaa_fg_camera(VkDlaaCamera *c); // ... and its temporal upscaler is AMD FSR 3.1 (NX2NAVI_TAA = fsr3) instead of DLSS diff --git a/runtime/vk_dlssg.c b/runtime/vk_dlssg.c index 2cc68d5c..dae83a62 100644 --- a/runtime/vk_dlssg.c +++ b/runtime/vk_dlssg.c @@ -1,6 +1,7 @@ // DLSS Frame Generation (NX2NAVI_FRAMEGEN = dlss; applies after a restart) through nx2navi_dlssg.dll -// (runtime/dlssg/nx2_sl.cpp), which drives NVIDIA Streamline. Like AMD's frame generation (vk_fg.cpp) it needs DLSS or -// FSR 3.1 upscaling on, whose depth, motion vectors and camera it hands over, and an RTX 40 or 50 GPU. +// (runtime/dlssg/nx2_sl.cpp), which drives NVIDIA Streamline. Like AMD's frame generation (vk_fg.cpp) it takes the +// depth, motion vectors and camera vk_dlaa.c makes for DLSS or FSR 3.1 upscaling, or without an upscaler for frame +// generation alone (vk_dlaa.c fg_only_frame: the same pass at the scene's size, no jitter); it needs an RTX 40 or 50 GPU. // // The DLL and Streamline (sl.interposer.dll and its plugins, nvngx_dlssg.dll) sit next to the game. The instance and // device are created through Streamline's proxies (vk_device.c), so it can add the extensions, features and queues @@ -73,14 +74,10 @@ static int reflex_mode(void) { return m; } +// With any upscaler or none: vk_dlaa.c makes the inputs either way (vk_dlaa_frame says which, at the start and at each +// change). int vk_dlssg_wanted(void) { - if (S.wanted < 0) { - S.wanted = !strcmp(cfg_value("NX2NAVI_FRAMEGEN"), "dlss"); - if (S.wanted && !vk_dlaa_wanted()) { - rt_log("dlssg: frame generation needs DLSS or FSR 3.1 upscaling (any mode): off"); - S.wanted = 0; - } - } + if (S.wanted < 0) S.wanted = !strcmp(cfg_value("NX2NAVI_FRAMEGEN"), "dlss"); return S.wanted; } @@ -312,7 +309,9 @@ void vk_dlssg_frame(VkCommandBuffer cb, VkExtent2D ext) { static int told; if (c.inverted && !told++) rt_log("dlssg: the scene's depth is inverted, which Streamline is not told"); k.jitter[0] = jx, k.jitter[1] = jy; - k.mv_scale[0] = 1.0f / (float)d.width, k.mv_scale[1] = 1.0f / (float)d.height; // render pixels + // render pixels: the scene's size, which is the output's or smaller (an upscaling mode, or the game's own scale + // without an upscaler); Streamline takes the depth and the vectors at their own size and the output at ext + k.mv_scale[0] = 1.0f / (float)d.width, k.mv_scale[1] = 1.0f / (float)d.height; k.reset = reset; } // the frames to generate between two rendered ones: the multiplier less the rendered one, 0 off diff --git a/runtime/vk_dlssg.h b/runtime/vk_dlssg.h index 8f0c91ab..cc9365bf 100644 --- a/runtime/vk_dlssg.h +++ b/runtime/vk_dlssg.h @@ -3,7 +3,7 @@ #include #include -int vk_dlssg_wanted(void); // NX2NAVI_FRAMEGEN = dlss with DLSS or FSR 3.1 upscaling on (read once) +int vk_dlssg_wanted(void); // NX2NAVI_FRAMEGEN = dlss, with any upscaler or none (read once) int vk_dlssg_early(void); // before the instance exists: loads the DLL and Streamline; 1 when its proxies are there // vk_device.c: the instance and device through Streamline's proxies when vk_dlssg_early succeeded, else the loader's VkResult vk_dlssg_create_instance(const VkInstanceCreateInfo *ci, VkInstance *out); diff --git a/runtime/vk_exec_draw.c b/runtime/vk_exec_draw.c index 517392cd..bd0ecc4a 100644 --- a/runtime/vk_exec_draw.c +++ b/runtime/vk_exec_draw.c @@ -5154,7 +5154,8 @@ static PlatMutex mo_lock = PLAT_MUTEX_INIT; static void mvobj_draw(VkExec *ex, const p_draw_idx *d, VkBuffer ib, VkDeviceSize ib_off) { if (MO.failed || !ex->dc->B.st_valid) return; if (RT_V111) { - if (!vk_dlaa_available() || (!pose_enabled() && !skin_enabled())) return; + // the upscaler, or frame generation without one (vk_dlaa_fg_only), takes the motion + if (!(vk_dlaa_available() || vk_dlaa_fg_only()) || (!pose_enabled() && !skin_enabled())) return; } else if (!vk_mvprev_on()) return; static int timed = -1; if (timed < 0) timed = rt_knob("MVOBJ_TIMES", "0"); // NX2NAVI_MVOBJ_TIMES=1: the summary's times (the clock reads cost) diff --git a/runtime/vk_fg.cpp b/runtime/vk_fg.cpp index d0a57455..85a53d86 100644 --- a/runtime/vk_fg.cpp +++ b/runtime/vk_fg.cpp @@ -4,9 +4,9 @@ // queue and pacing threads, so the screen shows twice the game's frame rate. // // The generated frame is built from the presented picture and the scene's depth and camera motion vectors, which -// vk_dlaa.c makes for DLSS and FSR 3.1 upscaling: frame generation needs one of those on (DLAA or Native AA included). -// The HUD is interpolated with the picture (it hardly moves); the menu is not, since generation pauses while it is -// open. The device creates two more queues of the graphics family for it (vk_device.c, vk_fg_queue_count). +// vk_dlaa.c makes for DLSS and FSR 3.1 upscaling, and without an upscaler for frame generation alone (vk_dlaa.c +// fg_only_frame: the same pass at the scene's size, no jitter). The HUD is kept out through the picture without it +// (vk_dlaa.c hudless); the menu is not generated, since generation pauses while it is open. The device creates two more queues of the graphics family for it (vk_device.c, vk_fg_queue_count). #ifdef _WIN32 #include #endif @@ -86,8 +86,8 @@ void fail(const char *what, unsigned r) { } // namespace // Follows the setting: gfx_present.c's window_settings_live remakes the swapchain when this stops matching vk_fg_active. -// It needs DLSS's or FSR 3.1's motion vectors, so it also needs one of them on, and the FSR 3.1 library: a build -// without it keeps the plain swapchain whatever the setting says, with one line in the log. Not on a device made through +// With or without an upscaler (vk_dlaa.c makes the motion vectors either way, fg_only_frame), and with the FSR 3.1 +// library: a build without it keeps the plain swapchain whatever the setting says, with one line in the log. Not on a device made through // Streamline's proxies (NVIDIA's frame generation set at the start, vk_dlssg_dpa): AMD's swapchain there crashed in // NVIDIA's driver when the menu switched from NVIDIA's frame generation to AMD's. That switch waits for a restart, // as the menu says (menu.cpp row_framegen). Not after a failure (fail): the present code then takes AMD's swapchain @@ -97,13 +97,14 @@ void fail(const char *what, unsigned r) { // setting asks for it while FSR 4 is the upscaler (use4). The swapchain in place is wanted only while its library is // still the one to use: a change of that setting or of the upscaler between FSR 3.1 and FSR 4, or a failure of the SDK // 2.4 path, takes it down as switching frame generation off does, and the next present makes it with the other library. +// FSR 4 is the upscaler only while one is set (dlaa): without an upscaler the FSR 3.1 library's runs. static int use4(void) { // NX2NAVI_FSR4_FG (default 0, live): 1 takes the SDK 2.4's frame generation with FSR 4 - return cfg_bool("NX2NAVI_FSR4_FG") && vk_ffx_fsr4() && !vk_fg4_failed() && vk_fg4_available(); + return cfg_bool("NX2NAVI_FSR4_FG") && cfg_bool("NX2NAVI_DLAA") && vk_ffx_fsr4() && !vk_fg4_failed() && + vk_fg4_available(); } extern "C" int vk_fg_wanted(void) { - if (strcmp(cfg_value("NX2NAVI_FRAMEGEN"), "fsr3") || !cfg_bool("NX2NAVI_DLAA") || !vk_dlaa_wanted() || vk_dlssg_dpa()) - return 0; + if (strcmp(cfg_value("NX2NAVI_FRAMEGEN"), "fsr3") || vk_dlssg_dpa()) return 0; int four = use4(); if (vk_fg4_active()) return four; if (F.sc) return !F.failed && !four; @@ -229,8 +230,8 @@ extern "C" void vk_fg_frame(VkCommandBuffer cb, VkSwapchainKHR sc, VkFormat fmt, float jx = 0, jy = 0; int reset = 0; int have = vk_dlaa_fg_inputs(&depth, &mv, &jx, &jy, &reset); - // The context's largest render size covers the depth and motion vectors it is given. They have the scene's size, - // which DLAA and the widescreen pictures make larger than the window, and a context made for the window's size alone + // The context's largest render size covers the depth and motion vectors it is given. They have the scene's size + // (with an upscaler or without), which DLAA and the widescreen pictures make larger than the window, and a context made for the window's size alone // wrote past its own resources: a crash in amd_fidelityfx_vk.dll, device faults, striped frames. The scene is never // larger than the picture (widescreen.c wide_picture), so the context is made for that once; remaking it while the // swapchain still generated from the old one hung the present. A frame with a larger depth anyway is not generated. @@ -282,7 +283,7 @@ extern "C" void vk_fg_frame(VkCommandBuffer cb, VkSwapchainKHR sc, VkFormat fmt, else if (!hudless) F.no_hudless++; else if (!on) F.paused++; F.frame++; - // A cut: DLSS started a new history (vk_dlaa_fg_inputs), or the frame before was not prepared (generation off for + // A cut: DLSS started a new history, or without an upscaler the same cases did (vk_dlaa_fg_inputs), or the frame before was not prepared (generation off for // the menu, no inputs), so the frame between the two would be made from a stale depth and motion fgr_note(&F.cuts, F.frame, reset || !F.prepared); if ((reset || !F.prepared) && on) F.cut_frames++; diff --git a/runtime/vk_fg.h b/runtime/vk_fg.h index 54771529..a6adb75a 100644 --- a/runtime/vk_fg.h +++ b/runtime/vk_fg.h @@ -3,7 +3,7 @@ #include #include -int vk_fg_wanted(void); // NX2NAVI_FRAMEGEN = fsr3 with DLSS or FSR 3.1 upscaling on (live), where FSR 3.1 loads +int vk_fg_wanted(void); // NX2NAVI_FRAMEGEN = fsr3 (live), where FSR 3.1 loads, with any upscaler or none uint32_t vk_fg_queue_count(void); // graphics-family queues the device creates // vk_device.c, after the device exists: the queues AMD's swapchain presents and acquires on, and their families (the // graphics family's own where it has three queues, else queues of another family: AMD's Windows driver gives one) diff --git a/runtime/vk_mvprev.c b/runtime/vk_mvprev.c index 31c506cc..ecf29d78 100644 --- a/runtime/vk_mvprev.c +++ b/runtime/vk_mvprev.c @@ -183,8 +183,9 @@ static void mvprev_draw_locked(VkExec *ex) { } void vk_mvprev_frame(void) { - // without DLSS (no NGX, no RTX GPU, dlaa = 0) nothing reads last frame's blocks: P.on stays 0, no tables - if (!vk_dlaa_available()) return; + // without DLSS (no NGX, no RTX GPU, dlaa = 0) and without frame generation alone (vk_dlaa_fg_only) nothing reads + // last frame's blocks: P.on stays 0, no tables + if (!vk_dlaa_available() && !vk_dlaa_fg_only()) return; if (P.knob < 0) { P.knob = rt_knob("DLAA_OBJMV", "1"); if (P.knob) { @@ -197,7 +198,7 @@ void vk_mvprev_frame(void) { P.timed = rt_knob("MVOBJ_TIMES", "0"); } } - int on = P.knob && cfg_bool("NX2NAVI_DLAA"); + int on = P.knob && (cfg_bool("NX2NAVI_DLAA") || vk_dlaa_fg_only()); if (on != (P.on > 0)) { P.on = on ? 1 : -1; if (P.t[0]) memset(P.t[0], 0, TABLE * sizeof(Seen)), memset(P.t[1], 0, TABLE * sizeof(Seen)); diff --git a/runtime/vk_skin_motion.inc b/runtime/vk_skin_motion.inc index ea7cd35b..0ff7d151 100644 --- a/runtime/vk_skin_motion.inc +++ b/runtime/vk_skin_motion.inc @@ -145,7 +145,7 @@ static int skin_joint_format(uint32_t fmt) { // filter). Reads the draw's own state only: the chunks of a parallel group ask at once. static int skin_pick(VkExec *ex, SkinPick *out) { out->stride = 0; - if (!skin_enabled() || !vk_dlaa_active()) return 0; + if (!skin_enabled() || !(vk_dlaa_active() || vk_dlaa_fg_only())) return 0; // the upscaler or frame generation alone const DrawCtx *cx = ex->dc; int slot, storage; uint32_t joints; diff --git a/runtime/vk_usnap.c b/runtime/vk_usnap.c index 69b244ac..810b2eb2 100644 --- a/runtime/vk_usnap.c +++ b/runtime/vk_usnap.c @@ -38,7 +38,7 @@ typedef struct Arena { VkBuffer buf; VmaAllocation alloc; uint8_t *map; - uint8_t *cpu; // with DLSS (vk_dlaa_available), the same bytes in host memory for the CPU's reads (vk_usnap_bytes): + uint8_t *cpu; // with DLSS (vk_dlaa_available) or frame generation alone (vk_dlaa_fg_only), the same bytes in host memory for the CPU's reads (vk_usnap_bytes): // map is often device memory through the BAR, written fast but read back at about a microsecond a // cache line. Without DLSS nothing reads them back, and the bytes go into map in one copy. uint64_t size; @@ -290,7 +290,7 @@ static void copy_down(void *arg, int lo, int hi) { // Hyrule Field, half a millisecond of the submitting thread's time on one thread. static void copy_regions(Arena *a, const Reg *reg, int nreg, uint64_t total, int par) { uint8_t *dst = a->map; - if (vk_dlaa_available()) { + if (vk_dlaa_available() || vk_dlaa_fg_only()) { // the motion pass reads the camera (vk_dlaa.c mv_pass) if (!a->cpu && !(a->cpu = malloc(a->size))) rt_fatal("vk_usnap: out of memory"); dst = a->cpu; }