Turn the lazy write-back off by default on AMD's driver for RX 5000 and 6000 cards, and say in the log which settings a run had.

A player on an AMD card reported crashes in fights and that a line added to nx2navi.ini cured them. That line, async_compute = 1, is no setting of the game, and neither are two more in the same file; the one line of the file that changes how memory reaches the GPU is wb_lazy = 0. A second report, an RX 6600 on 0.7.1, lost its device 3.5 minutes into play with the lazy write-back on. Neither proves it the cause: the player changed several lines at once and sent no log, the RX 6600's last pass mark is inside a draw pass and not a fetch, cards with 8 GB lost their device the same way on NVIDIA before the lazy write-back existed, and reading the fault handler, the fetch, the arming and the buffers' lifetimes found no failure path. What depends on the driver and cannot be checked without the card: pages of guest memory are inaccessible while a host-pointer import of them is bound and written by the GPU, and Vulkan calls run inside the access-fault handler.

The default is now decided once the driver is known (wb_lazy_choice.h, vk_memory.c vk_mem_lazy_decide): on under Windows as before, except on AMD's driver branch for RDNA 1 and 2, which none of us has run it on; AMD's driver for RDNA 3 and newer keeps it on, since builds with that default were measured on an RX 7900 XT. What the player sets wins everywhere, and one line at start says the choice and its reason. On those cards open areas run at the 0.7.0 frame rate again (on an RTX 5090 that was 65 fps against 90 in Hyrule Field; not measured on AMD). tests/wb_lazy_check.c checks the choice by platform, driver and setting without a GPU.

For reports of this kind the log now holds what was missing. At start: every setting nx2navi.ini sets, and in one line the keys that are no settings of this version and do nothing; the settings menu shows those in its bottom row. At a fatal error or a crash: one line with the card, its driver, the memory mode, the lazy write-back with its reason, armed ranges, fetches so far and a fetch in progress, and the texture detail (dispatch.c rt_fatal_note_add, vk_device.c fatal_note), since a report is often the end of a log alone.

--probe-cfg loads the player's file: the three lines are named, and the menu's save keeps them and every other line it does not change byte for byte. Nothing here ran on an AMD card, and no fatal error was provoked to read the new line.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-10 15:14:25 -05:00
parent e8f5f8e01e
commit caf50ecf1c
20 changed files with 504 additions and 18 deletions

View File

@@ -71,6 +71,11 @@ int probe_cfg(void) {
CHECK(cfg_get("NX2NAVI_CLOTH_REALTIME") == NULL, "absent key is NULL");
CHECK(cfg_get("NX2NAVI_comment") == NULL, "comment is not a key");
CHECK(EQ(cfg_get("NX2NAVI_NO_SUCH_SETTING"), "1"), "unknown key is still readable");
{
int n = -1;
const char *u = cfg_unknown_keys(&n);
CHECK(n == 2 && EQ(u, "no_such_setting, last"), "the keys that are no settings: listed lower-case, in the file's order");
}
cfg_setenv("NX2NAVI_FPS60", "1");
CHECK(EQ(cfg_get("NX2NAVI_FPS60"), "1"), "environment overrides the file");
cfg_setenv("NX2NAVI_FPS60", NULL);
@@ -78,6 +83,80 @@ int probe_cfg(void) {
plat_file_delete(path);
CHECK(cfg_load(path) == 0, "missing file is not an error");
CHECK(cfg_get("NX2NAVI_FPS60") == NULL, "missing file leaves no keys");
{
int n = -1;
CHECK(EQ(cfg_unknown_keys(&n), "") && n == 0, "a missing file leaves no unknown keys either");
}
// A player's file as a report showed it: settings the menu wrote, and three lines added by hand that are no
// settings of this version (the player took the first for the fix of a crash). The three are named as such, a
// repeated one once, a key of other characters is counted without being listed, and the menu's save keeps every
// line it does not change byte for byte, the three included: only the changed, the reset and the new key move.
#define PLAYER_HEAD \
"[display]\n" \
"async_compute = 1\n" \
"fullscreen = 1\n" \
"window_size = 1920x1080\n" \
"gpu_index = 0\n" \
"perf_overlay = fps\n" \
"vk_present = mailbox\n" \
"upscaler = bilinear\n" \
"dlaa = 1\n" \
"framegen = off\n" \
"taa = fsr3\n" \
"hdr = 0\n" \
"aspect = fit\n" \
"game_res = 1800\n"
#define PLAYER_MID \
"aniso = 2\n" \
"assume_focus = 1\n" \
"texture_detail = auto\n" \
"\n" \
"[input]\n" \
"bind_a = key:default, pad:south\n" \
"bind_b = key:default, pad:east\n" \
"\n" \
"[language]\n" \
"operation_mode = docked\n" \
"\n" \
"[performance]\n" \
"wb_lazy = 0\n" \
"vram_safe_mode = 1\n" \
"exception_handler = 1\n" \
"ASYNC_COMPUTE = 1\n" \
"f\xC3\xBCr sp\xC3\xA4ter = 1\n" \
"\n" \
"[frame rate]\n"
static const char player[] = PLAYER_HEAD "sharpness = 80\n" PLAYER_MID "fps_limit = 120\n";
static const char player_saved[] = PLAYER_HEAD PLAYER_MID "fps_limit = 60\n\n[audio]\nvolume = 55\n";
#undef PLAYER_HEAD
#undef PLAYER_MID
cfg_setenv("NX2NAVI_FPS_LIMIT", NULL);
cfg_setenv("NX2NAVI_VOLUME", NULL);
cfg_setenv("NX2NAVI_SHARPNESS", NULL);
cfg_setenv("NX2NAVI_WB_LAZY", NULL);
CHECK(plat_file_write(path, player, sizeof player - 1), "write the player's ini");
CHECK(cfg_load(path) == 1, "load the player's ini");
{
int n = -1;
const char *u = cfg_unknown_keys(&n);
CHECK(n == 4 && EQ(u, "async_compute, vram_safe_mode, exception_handler"),
"the player's three lines are named as no settings; a repeat counts once, a key of other characters is only counted");
CHECK(EQ(cfg_get("NX2NAVI_WB_LAZY"), "0") && cfg_is_set("NX2NAVI_WB_LAZY"), "wb_lazy = 0 is a setting, and set");
CHECK(!cfg_is_set("NX2NAVI_VK_NAN_PRESERVE"), "a key the file lacks is not set");
static const char *const reset[] = {"SHARPNESS"};
cfg_set("NX2NAVI_FPS_LIMIT", "60");
cfg_set("NX2NAVI_VOLUME", "55");
CHECK(cfg_reset(reset, 1) == 1 && cfg_save_to(path) == 1, "the menu changes, adds and resets a key and saves");
uint64_t pn = 0;
uint8_t *p = plat_file_read(path, &pn);
CHECK(p && pn == sizeof player_saved - 1 && !memcmp(p, player_saved, pn),
"the save keeps every other line byte for byte, the lines that are no settings included");
if (p && (pn != sizeof player_saved - 1 || memcmp(p, player_saved, pn))) fprintf(stderr, "---- saved:\n%s\n----\n", p);
free(p);
}
plat_file_delete(path);
CHECK(cfg_load(path) == 0, "the player's ini is gone again");
// cfg_set / cfg_save: only changed lines move, comments stay, a missing key goes under its section
static const char before[] =