mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 07:31:06 -04:00
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>
59 lines
3.1 KiB
C
59 lines
3.1 KiB
C
// Guest address -> host function lookup for indirect branches (rt_dispatch, declared in cpu.h).
|
|
//
|
|
// One flat table covers every module's code range: slot (pc - lo) >> 2 holds the host function for a guest
|
|
// function start, as a 32-bit offset from an anchor address. Lookup is one range check and one load. The table is
|
|
// built once by rt_dispatch_init and never written again, so threads read it without locks.
|
|
#pragma once
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include "cpu.h"
|
|
|
|
// A lifted module: its place in the guest layout and the generator's sorted function table.
|
|
typedef struct RtModule {
|
|
const char *name;
|
|
uint64_t base, size; // guest image (layout.h MOD_<NAME>_BASE / _SIZE)
|
|
const uint64_t *addrs; // <mod>_fn_addrs: guest function starts, strictly ascending
|
|
const GuestFn *fns; // <mod>_fn_ptrs: the lifted function for each start
|
|
uint64_t count; // <mod>_fn_count
|
|
} RtModule;
|
|
|
|
// The module glue that tools/build_game.py writes for each build (build/<version>/modules.c), from layout.json and
|
|
// layout.h: every module of the layout, and the modules linked into this executable.
|
|
typedef struct RtLayoutEntry { const char *name; uint64_t base, size; } RtLayoutEntry;
|
|
extern const RtLayoutEntry rt_layout[];
|
|
extern const int rt_layout_count;
|
|
int rt_linked_modules(RtModule *out, int max);
|
|
|
|
// Register a host function at a guest address outside every module (HLE entry points). Allowed only before
|
|
// rt_dispatch_init; the registry is fixed afterwards.
|
|
void rt_register_host(uint64_t addr, GuestFn fn);
|
|
|
|
// Build the table from the modules (kept by pointer; they must outlive the process). Call it once, before any guest
|
|
// thread starts: thread creation publishes the table to the threads. Fatal on a malformed table:
|
|
// unsorted or duplicate starts, a start outside its module, overlapping modules, host code spread over 4 GiB.
|
|
void rt_dispatch_init(const RtModule *mods, int count);
|
|
|
|
// The host function for a guest address, or NULL when nothing is there. Does not run guest code.
|
|
GuestFn rt_dispatch_lookup(uint64_t pc);
|
|
|
|
// "0x7000001234 (main+0x1234)" for a guest address inside a module, else the bare address. Returns buf.
|
|
const char *rt_guest_name(uint64_t pc, char *buf, int size);
|
|
|
|
typedef struct RtDispatchStats {
|
|
uint64_t lo, hi; // guest range the table covers
|
|
uint64_t slots; // (hi - lo) / 4
|
|
uint64_t table_bytes; // reserved for the table
|
|
uint64_t functions; // filled slots
|
|
uint64_t host_fns; // rt_register_host entries
|
|
} RtDispatchStats;
|
|
RtDispatchStats rt_dispatch_stats(void);
|
|
|
|
// Runtime fatal error: message to stderr, then exit. Used by the dispatcher and the stubs.
|
|
void rt_fatal(const char *fmt, ...) __attribute__((noreturn, format(printf, 1, 2)));
|
|
// Lines of context for a fatal error's report, which rt_fatal and the crash report (main.c crash_handler) write after
|
|
// their own: fn logs one with rt_log. It runs on the failing thread, which may hold any lock, so it reads only what
|
|
// needs none. At most four; adding one twice keeps one. rt_fatal_notes runs them, once per process.
|
|
void rt_fatal_note_add(void (*fn)(void));
|
|
void rt_fatal_notes(void);
|