From 191a439fe4249503cad300e3f9c31b528cf18c52 Mon Sep 17 00:00:00 2001 From: chrg6 Date: Thu, 12 Nov 2026 22:28:32 -0500 Subject: [PATCH] Add a Low latency row to the menu's Screen tab. Off, On, and On with boost where the mode is NVIDIA's, in English, Russian, Brazilian Portuguese and Simplified Chinese. The row is greyed out with the reason where the mode cannot run: a driver with neither extension, a run in which DLSS frame generation brings its own low latency, and NVIDIA's while a frame generation presents the frames. A mode the driver refused says so under the value. Co-Authored-By: Claude Fable 5.2 --- runtime/ui/menu.cpp | 20 ++++++++++++++++++++ runtime/ui_text.c | 35 +++++++++++++++++++++++++++++++++++ runtime/ui_text.h | 5 +++++ 3 files changed, 60 insertions(+) diff --git a/runtime/ui/menu.cpp b/runtime/ui/menu.cpp index 11c2ee17..b1df9f86 100644 --- a/runtime/ui/menu.cpp +++ b/runtime/ui/menu.cpp @@ -58,6 +58,7 @@ extern "C" { #include "ui/menu.h" #include "ui_text.h" #include "vk_dlssg.h" +#include "vk_lowlat.h" // host.h and vk.h pull in cpu.h, which is C only: the functions the menu needs from them, as declared there. void rt_log(const char *fmt, ...) __attribute__((format(printf, 1, 2))); void vk_queue_lock(void); @@ -878,6 +879,24 @@ static const char *vsync_note(void) { return note; } +// Low latency without frame generation (NX2NAVI_LOW_LATENCY, vk_lowlat.c, at once): off, on, and on with boost where +// the driver's mode is NVIDIA's (AMD's has no boost; a 2 set there shows as on, which is what it does). Greyed out with +// the reason where it cannot run: a driver with neither mode, a run in which DLSS frame generation brings its own, and +// NVIDIA's while a frame generation presents the frames (vk_lowlat_status). Set and refused by the driver, it says so. +static void row_low_latency(void) { + static const char *const values[] = {"0", "1", "2"}; + const char *names[] = {menu_text(UI_MENU_OFF), menu_text(UI_MENU_ON), menu_text(UI_MENU_LOW_LATENCY_BOOST)}; + const int st = vk_lowlat_status(), n = st == VK_LOWLAT_AMD ? 2 : 3; + int cur = cfg_int("NX2NAVI_LOW_LATENCY"); + cur = cur < 0 ? 0 : cur >= n ? n - 1 : cur; + if (st == VK_LOWLAT_NO_DRIVER) opt_disable_next(UI_MENU_LOW_LATENCY_NO_DRIVER); + else if (st == VK_LOWLAT_DLSSG) opt_disable_next(UI_MENU_LOW_LATENCY_DLSSG); + else if (st == VK_LOWLAT_FG) opt_disable_next(UI_MENU_LOW_LATENCY_FG); + const char *note = st == VK_LOWLAT_FAILED && cur ? menu_text(UI_MENU_LOW_LATENCY_FAILED) : nullptr; + int nv = opt_choice_index("NX2NAVI_LOW_LATENCY", UI_MENU_LOW_LATENCY, names, n, cur, 0, UI_MENU_LOW_LATENCY_DESC, note); + if (nv >= 0 && nv < n) opt_apply("NX2NAVI_LOW_LATENCY", values[nv]); +} + // ---- the tabs // The PCI vendor of the GPU the game renders on (menu_overlay_frame reads it from the device it is given; 0 before the @@ -1271,6 +1290,7 @@ static void tab_screen(float scale) { // On is the default mode, mailbox with its fallbacks (gfx_present.c pick_present_mode): plain fifo would drop the // game to 30 at every slow frame on a 60 Hz display. A fifo already saved also reads as on. opt_toggle_value("NX2NAVI_VK_PRESENT", UI_MENU_PRESENT_VSYNC, UI_MENU_PRESENT_DESC, "mailbox", "immediate", vsync_note()); + row_low_latency(); row_gpu(); static const UiTextId perf[] = {UI_MENU_PERF_OFF, UI_MENU_PERF_FPS, UI_MENU_PERF_FULL}; opt_choice("NX2NAVI_PERF_OVERLAY", UI_MENU_PERF_OVERLAY, perf, 3, UI_MENU_PERF_OVERLAY_DESC); diff --git a/runtime/ui_text.c b/runtime/ui_text.c index 789e35d3..29aa15e8 100644 --- a/runtime/ui_text.c +++ b/runtime/ui_text.c @@ -55,6 +55,15 @@ static const char *const text_en[UI_TEXT_COUNT] = { [UI_MENU_PRESENT_DESC] = "Stops screen tearing. Off lowers input delay slightly.", [UI_MENU_PRESENT_MAILBOX] = "Mailbox", [UI_MENU_PRESENT_VSYNC] = "VSync", [UI_MENU_PRESENT_IMMEDIATE] = "Immediate", [UI_MENU_PRESENT_IN_USE] = "in use: %s", + [UI_MENU_LOW_LATENCY] = "Low latency", + [UI_MENU_LOW_LATENCY_DESC] = "The graphics driver holds each frame's start, so the controller is read as late as " + "possible (NVIDIA Reflex, AMD Anti-Lag). It keeps the frame rate limit too. Boost " + "keeps the graphics card at full clock.", + [UI_MENU_LOW_LATENCY_BOOST] = "On + Boost", + [UI_MENU_LOW_LATENCY_NO_DRIVER] = "this graphics driver has no low-latency mode", + [UI_MENU_LOW_LATENCY_DLSSG] = "DLSS frame generation uses its own", + [UI_MENU_LOW_LATENCY_FG] = "off while frame generation runs on this card", + [UI_MENU_LOW_LATENCY_FAILED] = "in use: off, the driver refused it (see lowlat in the log)", [UI_MENU_GPU] = "Graphics card", [UI_MENU_GPU_DESC] = "The graphics card that runs the game.", [UI_MENU_GPU_AUTO] = "Automatic", [UI_MENU_PERF_OVERLAY] = "Performance overlay", @@ -851,6 +860,15 @@ static const char *const text_ru[UI_TEXT_COUNT] = { [UI_MENU_PRESENT_MAILBOX] = "Mailbox", [UI_MENU_PRESENT_VSYNC] = "Вертикальная синхронизация", [UI_MENU_PRESENT_IMMEDIATE] = "Без ожидания", [UI_MENU_PRESENT_IN_USE] = "сейчас: %s", + [UI_MENU_LOW_LATENCY] = "Низкая задержка", + [UI_MENU_LOW_LATENCY_DESC] = "Драйвер видеокарты задерживает начало каждого кадра, чтобы ввод считывался как " + "можно позже (NVIDIA Reflex, AMD Anti-Lag). Он же держит ограничение частоты кадров. " + "Boost не даёт видеокарте снижать частоту.", + [UI_MENU_LOW_LATENCY_BOOST] = "Вкл. + Boost", + [UI_MENU_LOW_LATENCY_NO_DRIVER] = "у этого драйвера нет режима низкой задержки", + [UI_MENU_LOW_LATENCY_DLSSG] = "генерация кадров DLSS использует свой режим", + [UI_MENU_LOW_LATENCY_FG] = "выключено, пока на этой видеокарте работает генерация кадров", + [UI_MENU_LOW_LATENCY_FAILED] = "сейчас: выкл., драйвер отказал (см. lowlat в журнале)", [UI_MENU_GPU] = "Видеокарта", [UI_MENU_GPU_DESC] = "Видеокарта, на которой работает игра.", [UI_MENU_GPU_AUTO] = "Автоматически", [UI_MENU_PERF_OVERLAY] = "Индикатор производительности", @@ -1548,6 +1566,15 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = { [UI_MENU_PRESENT_DESC] = "Evita cortes na imagem. Desligado reduz um pouco o atraso.", [UI_MENU_PRESENT_MAILBOX] = "Mailbox", [UI_MENU_PRESENT_VSYNC] = "VSync", [UI_MENU_PRESENT_IMMEDIATE] = "Imediato", [UI_MENU_PRESENT_IN_USE] = "em uso: %s", + [UI_MENU_LOW_LATENCY] = "Baixa latência", + [UI_MENU_LOW_LATENCY_DESC] = "O driver de vídeo segura o início de cada quadro, para ler o controle o mais tarde " + "possível (NVIDIA Reflex, AMD Anti-Lag). Ele também mantém o limite de quadros. Boost " + "mantém a placa de vídeo em frequência máxima.", + [UI_MENU_LOW_LATENCY_BOOST] = "Ligado + Boost", + [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_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", [UI_MENU_PERF_OVERLAY] = "Indicador de desempenho", @@ -2246,6 +2273,14 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = { [UI_MENU_PRESENT_VSYNC] = "垂直同步", [UI_MENU_PRESENT_IMMEDIATE] = "立即", [UI_MENU_PRESENT_IN_USE] = "使用中:%s", + [UI_MENU_LOW_LATENCY] = "低延迟", + [UI_MENU_LOW_LATENCY_DESC] = "显卡驱动推迟每一帧的开始,尽可能晚地读取手柄输入(NVIDIA Reflex、AMD Anti-Lag)," + "并由它保持帧率上限。增强让显卡保持最高频率。", + [UI_MENU_LOW_LATENCY_BOOST] = "开启 + 增强", + [UI_MENU_LOW_LATENCY_NO_DRIVER] = "此显卡驱动没有低延迟模式", + [UI_MENU_LOW_LATENCY_DLSSG] = "DLSS 帧生成使用自带的低延迟", + [UI_MENU_LOW_LATENCY_FG] = "此显卡运行帧生成时关闭", + [UI_MENU_LOW_LATENCY_FAILED] = "使用中:关闭,驱动拒绝了(见日志中的 lowlat)", [UI_MENU_GPU] = "显卡", [UI_MENU_GPU_DESC] = "运行游戏所用的显卡。", [UI_MENU_GPU_AUTO] = "自动", diff --git a/runtime/ui_text.h b/runtime/ui_text.h index 243d7dc1..9c160211 100644 --- a/runtime/ui_text.h +++ b/runtime/ui_text.h @@ -30,6 +30,11 @@ typedef enum { UI_MENU_WINDOW_SIZE, UI_MENU_WINDOW_SIZE_DESC, UI_MENU_WINDOW_SIZE_CUSTOM, UI_MENU_PRESENT_DESC, UI_MENU_PRESENT_MAILBOX, UI_MENU_PRESENT_VSYNC, UI_MENU_PRESENT_IMMEDIATE, UI_MENU_PRESENT_IN_USE, // "in use: %s" under the value when the swapchain got another mode than the setting + // Low latency without frame generation (ui/menu.cpp row_low_latency, vk_lowlat.c). The last four are the row's + // notes: why it is greyed out (no such driver mode, DLSS frame generation's own, a frame generation presents the + // frames) or set and not in use (the driver refused it) + UI_MENU_LOW_LATENCY, UI_MENU_LOW_LATENCY_DESC, UI_MENU_LOW_LATENCY_BOOST, + UI_MENU_LOW_LATENCY_NO_DRIVER, UI_MENU_LOW_LATENCY_DLSSG, UI_MENU_LOW_LATENCY_FG, UI_MENU_LOW_LATENCY_FAILED, UI_MENU_GPU, UI_MENU_GPU_DESC, UI_MENU_GPU_AUTO, UI_MENU_PERF_OVERLAY, UI_MENU_PERF_OVERLAY_DESC, UI_MENU_PERF_OFF, UI_MENU_PERF_FPS, UI_MENU_PERF_FULL, UI_PERF_LINE_FPS,