diff --git a/docs/releases/v0.7.2.md b/docs/releases/v0.7.2.md index 03fe2766..744e8ae3 100644 --- a/docs/releases/v0.7.2.md +++ b/docs/releases/v0.7.2.md @@ -38,14 +38,16 @@ Draft notes for the release after 0.7.1. The version number is not decided yet. ## Changed -- **AMD RX 5000 and RX 6000 cards: the faster copy-back of 0.7.1 is off by default again.** 0.7.1 turned it on for - every card on Windows (what the game's shaders write is copied back from the video card once, and then only when - the game's CPU code touches it). None of us has one of these cards, their Windows driver is a branch of its own, - and one report from an RX 6600 lost its video device a few minutes into play with it on. We found no fault in the - code and cannot say it was the cause, so until someone has run it there the old copy-back at the end of every GPU - submission is the default with that driver; open areas run slower for it, as they did in 0.7.0. `wb_lazy = 1` in - `nx2navi.ini` turns it on: if you try it, tell us whether the game stays up, with the log. NVIDIA cards and AMD's - RX 7000 and RX 9000 cards keep it on. The log says which is in effect and why ("mem: lazy write-back ..."). +- **AMD cards: the faster copy-back of 0.7.1 is off by default again.** 0.7.1 turned it on for every card on Windows + (what the game's shaders write is copied back from the video card once, and then only when the game's CPU code + touches it). Since then two reports from AMD cards had the game end in play: an RX 6600 lost its video device a + few minutes in with it on, and a player whose game ended in fights played for hours with it off. We found no fault + in the code and cannot say it was the cause, and none of us has played a fight on an AMD card with it on. Until + someone has, the old copy-back at the end of every GPU submission is the default with AMD's Windows driver; open + areas run slower for it, as they did in 0.7.0. The RX 7900 XT figures under *Faster* come from builds that had it + on by default. `wb_lazy = 1` in `nx2navi.ini` turns it on: if you try it, play a few fights and tell us whether the + game stays up, with the log. NVIDIA cards keep it on. The log says which is in effect and why ("mem: lazy + write-back ..."). - **A line in `nx2navi.ini` that is no setting of this version is pointed out.** Such a line does nothing; the game only wrote "unknown key" into its log. The log now lists them in one line at the start, beside a line with every setting the file does set, and the settings menu shows them in its bottom row. An update or a rebuild never rewrites diff --git a/nx2navi.ini.example b/nx2navi.ini.example index de5459e9..d64ac63e 100644 --- a/nx2navi.ini.example +++ b/nx2navi.ini.example @@ -736,8 +736,8 @@ # 1: what the game's shaders write into its memory is copied back from the video card once, and after that only when # the game's CPU code touches it (most of it never is: 66 MiB a frame in Hyrule Field), for about a third more frames # a second in open areas. 0: copied back at the end of every GPU submission, as in 0.7.0. -# Default: 1 on Windows, except 0 with AMD's driver for RX 5000 and RX 6000 cards, where it has not been tried by us -# and one report lost its device with it on: set 1 there to try it, and back to 0 if the game ends in play (the log's +# Default: 1 on Windows, except 0 on AMD graphics cards (AMD's own driver), where two reports had the game end in play +# with it on and the cause is not found: set 1 there to try it, and back to 0 if the game ends in a fight (the log's # "mem: lazy write-back" line says which is in effect and why). 0 elsewhere. With shadow storage (Linux, Wine) it # stays off whatever is set. # wb_lazy = 1 diff --git a/runtime/cfg.c b/runtime/cfg.c index 3815ae6a..9941862e 100644 --- a/runtime/cfg.c +++ b/runtime/cfg.c @@ -140,8 +140,7 @@ static const struct { const char *key, *section; } sections[] = { // The lazy write-back (memory.c "Lazy write-back") is on where it has run: its fetch inside the access-fault handler // has only ever run on Windows. This is the platform's part of the default, which memory.c mem_init goes by to take // the access faults; the back end then turns it off for a driver it is not trusted on while the key is unset -// (wb_lazy_choice.h: AMD's for RX 5000 and 6000 cards), and with shadow storage whatever is set (vk_memory.c -// vk_mem_lazy_decide). +// (wb_lazy_choice.h: AMD's own), and with shadow storage whatever is set (vk_memory.c vk_mem_lazy_decide). #ifdef _WIN32 #define WB_LAZY_DEFAULT "1" #else diff --git a/runtime/memory.c b/runtime/memory.c index 2fd19de2..425df439 100644 --- a/runtime/memory.c +++ b/runtime/memory.c @@ -108,8 +108,8 @@ static void unprobe_locked(uint64_t r) { plat_dec32(&nprb); } -// Lazy write-back (NX2NAVI_WB_LAZY; unset: on under Windows except on AMD's driver for RX 5000 and 6000 cards, off -// elsewhere, as wb_lazy_choice.h decides and gives the reasons for; vk_memory.c "lazy write-back"). It was off +// Lazy write-back (NX2NAVI_WB_LAZY; unset: on under Windows except on AMD's own driver, off elsewhere, as +// wb_lazy_choice.h decides and gives the reasons for; vk_memory.c "lazy write-back"). It was off // by default in 0.7.0: with it on, single frames came out with the whole scene's shadowing missing, 10 to 180 of 1,800 // presents standing in Hyrule Field with other programs keeping the CPU busy and none found with it off. That was // not this code's doing: frames were drawn from copies taken before the game's signal that their data was written diff --git a/runtime/vk.h b/runtime/vk.h index a6bc9b92..d31c27c8 100644 --- a/runtime/vk.h +++ b/runtime/vk.h @@ -64,7 +64,6 @@ typedef struct { int amd_llpc; // AMD's own driver for RDNA 3 and newer (its driverInfo names LLPC) int mesa; // a Mesa driver the game runs on: RADV, ANV or NVK uint32_t driver_id; // the device's VkDriverId - char driver_info[256]; // and its driverInfo (VK_MAX_DRIVER_INFO_SIZE) } VkCaps; extern VkCaps vk_caps; void vk_caps_driver(VkPhysicalDevice p); // first, before vkCreateDevice: vk_caps.amd, amd_sc, amd_llpc, mesa, driver_id diff --git a/runtime/vk_caps.c b/runtime/vk_caps.c index 7d9b62de..03ce9f2f 100644 --- a/runtime/vk_caps.c +++ b/runtime/vk_caps.c @@ -45,7 +45,6 @@ void vk_caps_driver(VkPhysicalDevice p) { vkGetPhysicalDeviceProperties2(p, &p2); vk_caps.amd = p2.properties.vendorID == 0x1002; vk_caps.driver_id = (uint32_t)drv.driverID; - snprintf(vk_caps.driver_info, sizeof vk_caps.driver_info, "%s", drv.driverInfo); // AMD split RDNA 1 and 2 off into a driver branch of their own; its driverInfo reads // "26.10.1 (AMD proprietary shader compiler)" where the RDNA 3 and 4 driver names LLPC. vk_caps.amd_sc = drv.driverID == VK_DRIVER_ID_AMD_PROPRIETARY && strstr(drv.driverInfo, "shader compiler"); diff --git a/runtime/vk_device.c b/runtime/vk_device.c index 980f8670..ec421e51 100644 --- a/runtime/vk_device.c +++ b/runtime/vk_device.c @@ -690,6 +690,7 @@ int probe_vkdevice(void) { c->has_conditional_rendering, c->has_transform_feedback, c->has_provoking_vertex, c->has_robustness2, c->has_device_fault, c->has_memory_budget, c->has_buffer_device_address, c->has_fragment_shader_interlock, c->has_buffer_marker, c->has_nv_checkpoints, c->validation); + fatal_note(); // the line a fatal error or a crash would add to the log, to read it without one vk_shutdown(); printf("probe-vkdevice: %s (validation errors %ld)\n", g_errors_total ? "FAILED" : "passed", g_errors_total); return g_errors_total ? 1 : 0; diff --git a/runtime/vk_memory.c b/runtime/vk_memory.c index d6964751..1c17fd59 100644 --- a/runtime/vk_memory.c +++ b/runtime/vk_memory.c @@ -2617,7 +2617,7 @@ static const char *lz_why = ""; // the reason the log gave void vk_mem_lazy_decide(void) { const char *set = cfg_is_set("NX2NAVI_WB_LAZY") ? cfg_get("NX2NAVI_WB_LAZY") : NULL; - WblChoice ch = wb_lazy_choice(set, WBL_ON_WINDOWS, vk_caps.driver_id, vk_caps.driver_info); + WblChoice ch = wb_lazy_choice(set, WBL_ON_WINDOWS, vk_caps.driver_id); if (!vk_mirror_on) ch = (WblChoice){0, "no pool has a mirror in import mode"}; else if (shadow_on) ch = (WblChoice){0, "shadow storage keeps it off"}; else if (ch.on && cfg_bool("NX2NAVI_WB_PROBE")) ch = (WblChoice){0, "the write-back probe watches the same pages"}; diff --git a/runtime/wb_lazy_choice.h b/runtime/wb_lazy_choice.h index cf2e5fd9..ef9d31eb 100644 --- a/runtime/wb_lazy_choice.h +++ b/runtime/wb_lazy_choice.h @@ -4,23 +4,23 @@ // // The lazy write-back makes pages of guest memory inaccessible while a host-pointer import of them is bound to a buffer // the GPU writes, and copies their bytes down from inside the access-fault handler of whichever thread touched them. A -// driver is free to handle both differently, so the default is on only where it has run: -// - Windows, NVIDIA's driver: on. Measured and played there. -// - Windows, AMD's driver for RDNA 3 and newer: on. Builds with this default were measured on an RX 7900 XT (driver -// 26.10.1) standing in Hyrule Field and walking through a village (vk_exec_xfer.c oq_take and vk_exec_draw.c -// have numbers from that card). Whether fights were played on it is not recorded. -// - Windows, AMD's driver branch for RDNA 1 and 2 (RX 5000 and 6000; its driverInfo reads "AMD proprietary shader -// compiler", as vk_caps.c amd_sc tells it): off. Nobody has run it there under our eyes, and the one log of it -// there is an RX 6600 that lost its device 3.5 minutes into play (146 fetches in the 1,200 frames before; the -// GPU's last mark was inside a draw pass, not a fetch). That log does not prove the lazy write-back the cause: -// no failure path was found in the code, and cards with 8 GB lost their device the same way on NVIDIA before it -// existed. A second report, of a game that ended in fights on an AMD card of unknown model and ran for hours with -// a settings file that turns it off, changed several settings at once. Until one of these cards has run it with -// a log to compare, what shaders write goes back at the end of every submission there, as before 0.7.1, at that -// cost (about 90 fps against 65 standing in Hyrule Field on an RTX 5090; not measured on these cards). -// - Windows, any other driver: on, as 0.7.1 shipped it. No report from one. +// driver is free to handle both differently, so the default is on only where it has been played: +// - Windows, AMD's own driver: off. In the days after 0.7.1 turned it on for every card on Windows, two reports +// from AMD cards had the game end in play. An RX 6600 lost its device 3.5 minutes in with it on (146 fetches in +// the 1,200 frames before; the GPU's last mark was inside a draw pass, not a fetch). A player whose game ended in +// fights, on a card they did not name, then played for hours with a settings file that turns it off. Neither +// proves it the cause: the player changed several settings at once, cards with 8 GB lost their device the same +// way on NVIDIA before it existed, and no failure path was found in the code. But fights are where it is busiest +// (shaders write, the CPU reads back, every read faults and fetches), and nobody has played one on an AMD card +// under our eyes: builds with the default on were measured on an RX 7900 XT (driver 26.10.1) standing in Hyrule +// Field and walking through a village (vk_exec_xfer.c oq_take, vk_exec_draw.c), which says nothing about a fight, +// and none of us has a card of the driver branch for RDNA 1 and 2. Since the second report's card is unknown, the +// default is off on both of AMD's branches until a card of each has played fights with it on and a log to show. +// The cost is the frame rate in open areas, back to what it was before 0.7.1 (about 65 fps against 90 standing in +// Hyrule Field on an RTX 5090; not measured on AMD). +// - Windows, any other driver: on, as 0.7.1 shipped it. Measured and played on NVIDIA's; no report from Intel's. // - elsewhere: off, as before. The fetch inside the fault handler has only run on Windows. -// A value the player sets wins everywhere: wb_lazy = 1 turns it on for an RX 6000 card, wb_lazy = 0 off for any. +// A value the player sets wins everywhere: wb_lazy = 1 turns it on for an AMD card, wb_lazy = 0 off for any. #pragma once #include @@ -38,15 +38,9 @@ typedef struct { const char *why; // the end of the log line "mem: lazy write-back on|off: " } WblChoice; -// AMD's driver branch for RDNA 1 and 2: its own driver whose driverInfo names the older shader compiler. -static inline int wbl_amd_rdna12(uint32_t driver_id, const char *driver_info) { - return driver_id == WBL_DRIVER_AMD && driver_info && strstr(driver_info, "shader compiler") != NULL; -} - // set: the value the player gave NX2NAVI_WB_LAZY (the environment or nx2navi.ini), NULL or "" when they gave none. -// windows: the game runs on Windows (WBL_ON_WINDOWS). driver_id, driver_info: the device's VkDriverId and the -// driverInfo of its VkPhysicalDeviceDriverProperties. -static inline WblChoice wb_lazy_choice(const char *set, int windows, uint32_t driver_id, const char *driver_info) { +// windows: the game runs on Windows (WBL_ON_WINDOWS). driver_id: the device's VkDriverId. +static inline WblChoice wb_lazy_choice(const char *set, int windows, uint32_t driver_id) { if (set && *set) { if (!strcmp(set, "0")) return (WblChoice){0, "wb_lazy = 0 is set"}; return (WblChoice){1, "wb_lazy is set to on"}; @@ -54,10 +48,9 @@ static inline WblChoice wb_lazy_choice(const char *set, int windows, uint32_t dr if (!windows) return (WblChoice){0, "the default outside Windows, where its fetch inside the access-fault handler has not run " "(wb_lazy = 1 turns it on)"}; - if (wbl_amd_rdna12(driver_id, driver_info)) - return (WblChoice){0, "the default on AMD's driver for RX 5000 and 6000 cards, where it has not been tried by " - "us and a report had the game lose its device with it on; what shaders write goes back " - "at the end of every submission, which costs frame rate in open areas (wb_lazy = 1 turns " - "it on)"}; + if (driver_id == WBL_DRIVER_AMD) + return (WblChoice){0, "the default on AMD's driver, where reports had the game end in play with it on and the " + "cause is not found; what shaders write goes back at the end of every submission, which " + "costs frame rate in open areas (wb_lazy = 1 turns it on)"}; return (WblChoice){1, "the default on Windows (wb_lazy = 0 turns it off)"}; } diff --git a/tests/wb_lazy_check.c b/tests/wb_lazy_check.c index d36f3a15..f5e1deaf 100644 --- a/tests/wb_lazy_check.c +++ b/tests/wb_lazy_check.c @@ -13,69 +13,51 @@ static int fails; enum { AMD_PROPRIETARY = 1, AMD_OPEN_SOURCE = 2, MESA_RADV = 3, NVIDIA_PROPRIETARY = 4, INTEL_WINDOWS = 5, MESA_NVK = 24 }; enum { LINUX = 0, WINDOWS = 1 }; -// driverInfo as the drivers report it: AMD's branch for RDNA 1 and 2 (an RX 6600's log), its driver for RDNA 3 and -// newer, NVIDIA's, Mesa's. -static const char RDNA12[] = "26.10.2 (AMD proprietary shader compiler)"; -static const char RDNA34[] = "26.10.1 (LLPC)"; -static const char NVIDIA[] = "617.42"; -static const char MESA[] = "Mesa 26.0.1"; - -typedef struct { unsigned id; const char *info; const char *name; } Driver; -static const Driver drivers[] = { - {AMD_PROPRIETARY, RDNA12, "AMD RDNA 1/2"}, {AMD_PROPRIETARY, RDNA34, "AMD RDNA 3+"}, {AMD_OPEN_SOURCE, "", "AMD open"}, - {MESA_RADV, MESA, "RADV"}, {NVIDIA_PROPRIETARY, NVIDIA, "NVIDIA"}, {INTEL_WINDOWS, "", "Intel"}, {MESA_NVK, MESA, "NVK"}, - {0, NULL, "unknown"}, -}; -enum { ND = sizeof drivers / sizeof *drivers }; - static int has(const char *s, const char *part) { return s && strstr(s, part) != NULL; } int main(void) { - // Nothing set, Windows: on, except on AMD's driver branch for RDNA 1 and 2. - WblChoice nv = wb_lazy_choice(NULL, WINDOWS, NVIDIA_PROPRIETARY, NVIDIA); + static const unsigned drivers[] = {AMD_PROPRIETARY, AMD_OPEN_SOURCE, MESA_RADV, NVIDIA_PROPRIETARY, INTEL_WINDOWS, + MESA_NVK, 0}; + enum { ND = sizeof drivers / sizeof *drivers }; + + // Nothing set, Windows: on, except on AMD's own driver (both of its branches report this id). + WblChoice nv = wb_lazy_choice(NULL, WINDOWS, NVIDIA_PROPRIETARY); CHECK(nv.on == 1, "Windows, NVIDIA's driver, nothing set: on"); CHECK(has(nv.why, "default") && has(nv.why, "wb_lazy = 0"), "it says it is the default and how to turn it off: %s", nv.why); - CHECK(wb_lazy_choice(NULL, WINDOWS, AMD_PROPRIETARY, RDNA34).on == 1, "Windows, AMD's driver for RDNA 3 and newer: on"); - CHECK(wb_lazy_choice(NULL, WINDOWS, INTEL_WINDOWS, "").on == 1, "Windows, Intel's driver, nothing set: on"); - CHECK(wb_lazy_choice(NULL, WINDOWS, 0, NULL).on == 1, "Windows, a driver that reports nothing: on, as 0.7.1 had it"); - WblChoice amd = wb_lazy_choice(NULL, WINDOWS, AMD_PROPRIETARY, RDNA12); - CHECK(amd.on == 0, "Windows, AMD's driver for RDNA 1 and 2, nothing set: off"); - CHECK(has(amd.why, "AMD") && has(amd.why, "RX 5000 and 6000") && has(amd.why, "wb_lazy = 1"), - "it names the driver's cards and how to turn it on: %s", amd.why); + CHECK(wb_lazy_choice(NULL, WINDOWS, INTEL_WINDOWS).on == 1, "Windows, Intel's driver, nothing set: on"); + CHECK(wb_lazy_choice(NULL, WINDOWS, 0).on == 1, "Windows, a driver that reports no id: on, as 0.7.1 had it"); + WblChoice amd = wb_lazy_choice(NULL, WINDOWS, AMD_PROPRIETARY); + CHECK(amd.on == 0, "Windows, AMD's driver, nothing set: off"); + CHECK(has(amd.why, "AMD") && has(amd.why, "wb_lazy = 1"), "it names the driver and how to turn it on: %s", amd.why); CHECK(has(amd.why, "frame rate"), "it says what off costs: %s", amd.why); CHECK(has(amd.why, "default"), "it says it is a default: %s", amd.why); - // The branch is told by the driver and its driverInfo together, as vk_caps.c tells it: another driver whose - // driverInfo happened to hold the words is not AMD's. - CHECK(wbl_amd_rdna12(AMD_PROPRIETARY, RDNA12) && !wbl_amd_rdna12(AMD_PROPRIETARY, RDNA34), "the branch by driverInfo"); - CHECK(!wbl_amd_rdna12(AMD_PROPRIETARY, NULL) && !wbl_amd_rdna12(AMD_PROPRIETARY, ""), "no driverInfo: not the branch"); - CHECK(!wbl_amd_rdna12(NVIDIA_PROPRIETARY, RDNA12) && wb_lazy_choice(NULL, WINDOWS, MESA_RADV, RDNA12).on == 1, - "the words alone, under another driver: not the branch"); - // An empty value is no value (cfg.c add: "key =" leaves the setting at its default). - CHECK(wb_lazy_choice("", WINDOWS, AMD_PROPRIETARY, RDNA12).on == 0, "an empty value on the RDNA 1/2 branch: the default, off"); - CHECK(wb_lazy_choice("", WINDOWS, NVIDIA_PROPRIETARY, NVIDIA).on == 1, "an empty value on NVIDIA: the default, on"); + CHECK(wb_lazy_choice("", WINDOWS, AMD_PROPRIETARY).on == 0, "an empty value on AMD: the default, off"); + CHECK(wb_lazy_choice("", WINDOWS, NVIDIA_PROPRIETARY).on == 1, "an empty value on NVIDIA: the default, on"); // Nothing set, elsewhere: off on every driver. for (int i = 0; i < ND; i++) { - WblChoice c = wb_lazy_choice(NULL, LINUX, drivers[i].id, drivers[i].info); - CHECK(c.on == 0 && has(c.why, "wb_lazy = 1"), "Linux, %s, nothing set: off, and how to turn it on: %s", - drivers[i].name, c.why); + WblChoice c = wb_lazy_choice(NULL, LINUX, drivers[i]); + CHECK(c.on == 0 && has(c.why, "wb_lazy = 1"), "Linux, driver %u, nothing set: off, and how to turn it on: %s", + drivers[i], c.why); } // What the player sets wins on every platform and driver, and the reason says it was set. for (int os = LINUX; os <= WINDOWS; os++) for (int i = 0; i < ND; i++) { - WblChoice on = wb_lazy_choice("1", os, drivers[i].id, drivers[i].info); - WblChoice off = wb_lazy_choice("0", os, drivers[i].id, drivers[i].info); - CHECK(on.on == 1 && has(on.why, "set"), "os %d, %s, wb_lazy = 1: on (%s)", os, drivers[i].name, on.why); - CHECK(off.on == 0 && has(off.why, "set"), "os %d, %s, wb_lazy = 0: off (%s)", os, drivers[i].name, off.why); - CHECK(!has(on.why, "default") && !has(off.why, "default"), "os %d, %s: a set value is not a default", os, - drivers[i].name); + WblChoice on = wb_lazy_choice("1", os, drivers[i]), off = wb_lazy_choice("0", os, drivers[i]); + CHECK(on.on == 1 && has(on.why, "set"), "os %d driver %u, wb_lazy = 1: on (%s)", os, drivers[i], on.why); + CHECK(off.on == 0 && has(off.why, "set"), "os %d driver %u, wb_lazy = 0: off (%s)", os, drivers[i], off.why); + CHECK(!has(on.why, "default") && !has(off.why, "default"), "os %d driver %u: a set value is not a default", os, + drivers[i]); } // Any value but 0 counts as on, as cfg_bool reads it for memory.c mem_init. - CHECK(wb_lazy_choice("on", WINDOWS, AMD_PROPRIETARY, RDNA12).on == 1, "wb_lazy = on: on"); + CHECK(wb_lazy_choice("on", WINDOWS, AMD_PROPRIETARY).on == 1, "wb_lazy = on: on"); + // The exception is the driver, not the vendor: another driver for AMD cards follows its platform's default. + CHECK(wb_lazy_choice(NULL, WINDOWS, AMD_OPEN_SOURCE).on == 1 && wb_lazy_choice(NULL, WINDOWS, MESA_RADV).on == 1, + "the exception is AMD's own driver"); CHECK(WBL_DRIVER_AMD == AMD_PROPRIETARY, "WBL_DRIVER_AMD is VK_DRIVER_ID_AMD_PROPRIETARY"); // The game passes the platform it was built for.