Menu and start-up edge cases: a chosen GPU that is gone, held Esc, the boot screen, and upscaler-dependent rows.

- A GPU index or name that is not usable, or no longer there, falls back to the best usable GPU with a log line instead
  of stopping the game before the menu can change it (vk_device.c pick_device).
- A held Esc no longer opens the menu and closes it again on its first key repeat (menu_win.cpp, menu_sdl.cpp).
- The menu does not open on the boot screen, where it was not drawn while its keys queued up and changed settings once
  the game ran.
- The DLSS render scale follows the upscaler that runs: a DLSS or FSR 3.1 mode picked in the menu, which applies after
  a restart, or DLSS where NGX is not available, no longer shrinks the scene with nothing to scale it back up.
- Upscaling without DLSS or FSR 3.1 also turns frame generation off, which needs their motion vectors.
- The HDR peak brightness slider reaches the setting's 10000 nits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-07 18:44:47 -05:00
parent 9dcfc5723b
commit 1f016a774e
5 changed files with 31 additions and 9 deletions

View File

@@ -101,9 +101,12 @@ static int change_open(int want) {
static void set_open(int open) { change_open(open); }
static int g_failed_flag();
// The boot screen is up (menu_boot_set): the menu does not open, as it would not be drawn while its keys queued up and
// changed settings once the game ran.
static std::atomic<int> g_booting{0};
extern "C" int menu_is_open(void) { return g_open.load(std::memory_order_relaxed); }
extern "C" void menu_toggle(void) {
if (!g_failed_flag()) change_open(-1);
if (!g_failed_flag() && !g_booting.load(std::memory_order_acquire)) change_open(-1);
}
// ---- events from the window adapter, queued while the menu is open; the present path hands them to ImGui
@@ -753,6 +756,7 @@ static void row_upscaling(void) {
if (nv < 0) return;
opt_apply("NX2NAVI_UPSCALER", nv == 1 ? "fsr" : "bilinear");
opt_apply("NX2NAVI_DLAA", nv >= 2 ? "1" : "0");
if (nv < 2) opt_apply("NX2NAVI_FRAMEGEN", "off"); // it needs DLSS's or FSR 3.1's motion vectors (row_framegen)
if (nv >= 2) opt_apply("NX2NAVI_DLSS", modes[(nv - 2) % 5]);
if (nv >= 2) opt_apply("NX2NAVI_TAA", nv >= 7 ? "fsr3" : "dlss");
}
@@ -764,7 +768,7 @@ static void row_hdr(void) {
const char *names[] = {menu_text(UI_MENU_FRAMEGEN_OFF), menu_text(UI_MENU_HDR_ENHANCED), menu_text(UI_MENU_HDR_NATIVE)};
opt_choice_list("NX2NAVI_HDR", UI_MENU_HDR, values, names, 3, UI_MENU_HDR_DESC, -1, menu_text(UI_MENU_HDR_NOTE));
if (!cfg_bool("NX2NAVI_HDR")) return;
opt_slider("NX2NAVI_HDR_PEAK_NITS", UI_MENU_HDR_PEAK, 400, 4000, UI_MENU_HDR_PEAK_DESC, 50, "%.0f nits");
opt_slider("NX2NAVI_HDR_PEAK_NITS", UI_MENU_HDR_PEAK, 400, 10000, UI_MENU_HDR_PEAK_DESC, 50, "%.0f nits");
opt_slider("NX2NAVI_HDR_GAME_NITS", UI_MENU_HDR_GAME, 80, 500, UI_MENU_HDR_GAME_DESC, 5, "%.0f nits");
opt_slider("NX2NAVI_HDR_UI_NITS", UI_MENU_HDR_UI, 80, 500, UI_MENU_HDR_UI_DESC, 5, "%.0f nits");
// no hue slider: the hue correction belonged to the runtime's replacement tonemap, and Enhanced now extends the
@@ -1501,6 +1505,7 @@ extern "C" void menu_boot_set(int phase, long long done, long long total) {
g_boot_done.store(done, std::memory_order_relaxed);
g_boot_total.store(total, std::memory_order_relaxed);
g_boot_phase.store(phase, std::memory_order_release);
g_booting.store(phase >= 0, std::memory_order_release);
}
// A panel in the middle of the screen in the menu's colours: the title, the step with its count and a bar, and why it

View File

@@ -53,6 +53,8 @@ extern "C" void menu_sdl_event(const SDL_Event *e) {
if (!e->key.repeat) menu_perf_cycle();
return;
}
// a held Esc's repeats: the press that opened the menu is not queued, so its first repeat would close it
if (e->key.scancode == SDL_SCANCODE_ESCAPE && e->key.repeat) return;
[[fallthrough]];
case SDL_EVENT_KEY_UP:
if (!menu_is_open()) return;

View File

@@ -57,6 +57,8 @@ extern "C" int menu_window_msg(HWND h, UINT m, WPARAM w, LPARAM l, LRESULT *res)
*res = 0;
return 1;
}
// a held Esc's repeats: the press that opened the menu is not queued, so its first repeat would close it
if (w == VK_ESCAPE && (l & (1 << 30))) return 0;
[[fallthrough]];
case WM_KEYUP:
case WM_SYSKEYUP:

View File

@@ -152,12 +152,14 @@ static int pick_device(void) {
const char *e = cfg_get("NX2NAVI_GPU_INDEX"); // no fixed default: the best device when unset
int want = e && *e ? atoi(e) : -1;
const char *name = cfg_get("NX2NAVI_GPU_NAME");
int best = -1, best_score = -1;
int best = -1, best_score = -1, listed = 0;
retry:
for (uint32_t i = 0; i < n; i++) {
VkPhysicalDeviceProperties p;
vkGetPhysicalDeviceProperties(pd[i], &p);
rt_log("vk: gpu %u: %s (type %d, api %u.%u.%u)", i, p.deviceName, (int)p.deviceType, VK_API_VERSION_MAJOR(p.apiVersion),
VK_API_VERSION_MINOR(p.apiVersion), VK_API_VERSION_PATCH(p.apiVersion));
if (!listed)
rt_log("vk: gpu %u: %s (type %d, api %u.%u.%u)", i, p.deviceName, (int)p.deviceType,
VK_API_VERSION_MAJOR(p.apiVersion), VK_API_VERSION_MINOR(p.apiVersion), VK_API_VERSION_PATCH(p.apiVersion));
if (want >= 0 && (int)i != want) continue;
if (name && *name && !name_has(p.deviceName, name)) continue;
if (p.apiVersion < VK_API_VERSION_1_3) { rt_log("vk: gpu %u skipped: Vulkan below 1.3", i); continue; }
@@ -174,10 +176,16 @@ static int pick_device(void) {
: p.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU ? 2 : 1;
if (score > best_score) { best_score = score; best = (int)i; }
}
// A chosen GPU that is not usable or no longer there (the menu's GPU row, an unplugged card, a driver that lists the
// devices in another order): the best usable one instead, so the game still starts and the choice can be changed
if (best < 0 && (want >= 0 || (name && *name))) {
if (want >= 0) rt_log("vk: NX2NAVI_GPU_INDEX=%d is not usable (see above): the best usable gpu instead", want);
else rt_log("vk: no usable gpu matches NX2NAVI_GPU_NAME=%s (see above): the best usable gpu instead", name);
want = -1, name = NULL, listed = 1;
goto retry;
}
if (best < 0) {
if (want >= 0) rt_log("vk: NX2NAVI_GPU_INDEX=%d is not usable (see above)", want);
else if (name && *name) rt_log("vk: no usable gpu matches NX2NAVI_GPU_NAME=%s (see above)", name);
else rt_log("vk: no device with Vulkan 1.3 and the required extensions (see above)");
rt_log("vk: no device with Vulkan 1.3 and the required extensions (see above)");
free(pd);
return 0;
}

View File

@@ -26,6 +26,7 @@
#include "host.h"
#include "layout.h"
#include "ui/menu.h"
#include "vk_dlaa.h"
#define GAME_W 2560 // the picture, main+0x1202ee0 and main+0x31f39f4
#define GAME_H 1440
@@ -75,8 +76,12 @@ static unsigned picture_height(void) {
// picks. The share is written to +240 at every change of the setting (the menu switches the mode live); the set goes on
// RES_FIXED_AFTER presents after the first, once the controller has filled the fields the fixed path keeps.
#define RES_FIXED_AFTER 120
// The share follows the upscaler that runs, not the setting: DLSS and FSR 3.1 start only after a restart
// (vk_dlaa_wanted is read once) and DLSS only where NGX came up (vk_dlaa_available), so a mode picked in the menu, or one
// this PC cannot run, no longer shrinks the scene with nothing to scale it back up. A mode change while one runs still
// applies at once.
static double dlss_share(void) {
if (!cfg_bool("NX2NAVI_DLAA")) return 0;
if (!vk_dlaa_wanted() || (!vk_dlaa_fsr3() && !vk_dlaa_available())) return 0;
const char *m = cfg_value("NX2NAVI_DLSS");
return !strcmp(m, "quality") ? 2.0 / 3 : !strcmp(m, "balanced") ? 0.58 : !strcmp(m, "performance") ? 0.5
: !strcmp(m, "ultra_performance") ? 1.0 / 3 : 1.0;