Add NX2NAVI_GEN_SEED, a test switch that starts the page write generations at a given value, so a play-test can cross 2^32 in seconds instead of 15 to 66 hours.

Whether the 64-bit generations hold past 2^32 in the game, with every texture check, mirror sync and shadow copy of a
real scene, could not be seen in play: reaching 2^32 takes 15 to 66 hours. gen_wrap_check shows it for the generation
code alone. NX2NAVI_GEN_SEED=<n> (nx2navi.ini gen_seed, diagnostics, default 0) makes the run's first generation
n + 1: with 4294966000 a run passes 2^32 within its first seconds, and with 1099511627000 the low 32 bits pass
through 0 again.

The first gen_next, before anything is stamped, reads the value (gen_seed). It is parsed with strtoull, decimal or
0x hexadecimal: strtoul stops at 2^32 - 1 where unsigned long is 32 bits, as on Windows, and would turn a seed past
32 bits into 4294967295 without a word. It is capped at 2^62, far from the 64-bit end, and only ever raises the
counter, since a lower value would leave stamps newer than it that read as written at every check. A value that is
no number, or negative, is logged and ignored; a seed in use is logged as "mem: page generations start at <n>
(NX2NAVI_GEN_SEED, a test switch)". Without the switch the only cost is one compare a generation that is true once.

cfg.c gets its metas row (0, 0..4611686018427387904, read at start), its known[] name and its sections[] entry, each
on a line of its own next to the other memory test switches (STAGING_FAIL_AT, VRAM_BALLAST_MB); nx2navi.ini.example
gets a commented gen_seed entry under [diagnostics]. The settings menu does not show it.

tests/gen_wrap_check runs the generation code a second way: the counter left at 0 and the seed taken from
NX2NAVI_GEN_SEED, for 4294967288, 0xfffffffff8, 0x7ffffffffffffff8 (capped), 12abc, -8, 0 and unset, each with the
start and the log line expected of it, then the same compares across the boundary. With strtoul in place of strtoull
two of those runs fail. Checks that passed: gen_wrap_check, gen_width_check, cfg_rows_check (0 problems),
pass_cc_check on vk_memory.c and cfg.c, no new -Wall -Wextra warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-13 19:01:05 -05:00
parent 028a6ce128
commit 5ee960f811
6 changed files with 106 additions and 26 deletions

View File

@@ -7,7 +7,9 @@ From runtime/vk_memory.c it takes, verbatim, into build/test/gen_wrap/gen_sectio
- the readers of the tables outside that section: cpu_wrote_since, shadow_pool_clean, lazy_clean and page_dirty.
The program starts the generations just below each seed's boundary and checks that every compare answers across it as
below it (texture checks, the snapshot path, the region check, the CPU-side tables, mirror and shadow cleanliness),
and that gen_next logs one line when the count reaches 2^32 and no other.
and that gen_next logs one line when the count reaches 2^32 and no other. It then takes the seeds from
NX2NAVI_GEN_SEED (gen_seed) instead: decimal and 0x hexadecimal values past 32 bits, one past the cap of 2^62, values
that are no number, 0 and none.
No GPU, no game files, any Python.
@@ -28,6 +30,16 @@ END = '// ---------------------------------------------------------------- dirty
READERS = ('static int cpu_wrote_since(', 'static int shadow_pool_clean(', 'static int lazy_clean(',
'static int page_dirty(')
SEEDS = ((1 << 32) - 8, (1 << 40) - 8, (1 << 63) - 8) # the old wrap; low 32 bits through 0 again; near 2^63
# NX2NAVI_GEN_SEED's value, the start expected of it, and a part of the line it logs ('-': none)
CFG_SEEDS = (
('4294967288', (1 << 32) - 8, 'page generations start at 4294967288 (NX2NAVI_GEN_SEED, a test switch)'),
('0xfffffffff8', (1 << 40) - 8, 'start at 1099511627768 (NX2NAVI_GEN_SEED,'), # strtoul would stop at 2^32 - 1
('0x7ffffffffffffff8', 1 << 62, 'start at 4611686018427387904 (NX2NAVI_GEN_SEED capped at 2^62,'),
('12abc', 0, 'NX2NAVI_GEN_SEED=12abc is not a number'),
('-8', 0, 'NX2NAVI_GEN_SEED=-8 is not a number'),
('0', 0, '-'),
('(unset)', 0, '-'),
)
def compiler(cc):
@@ -97,11 +109,12 @@ def main():
subprocess.check_call([compiler(args.cc), '-std=gnu11', '-O1', '-Wall', '-Wno-unused-function',
'-Wno-unused-variable', '-I', str(work), str(ROOT / 'tests' / 'gen_wrap_check.c'), '-o',
str(exe)], env=env)
runs = [[str(seed)] for seed in SEEDS] + [['--cfg', v, str(start), line] for v, start, line in CFG_SEEDS]
bad = 0
for seed in SEEDS:
bad += subprocess.run([str(exe), str(seed)], env=env, timeout=120).returncode != 0
for run in runs:
bad += subprocess.run([str(exe)] + run, env=env, timeout=120).returncode != 0
if bad:
print(f'gen_wrap_check: {bad} of {len(SEEDS)} runs failed')
print(f'gen_wrap_check: {bad} of {len(runs)} runs failed')
return 1
print('gen_wrap_check: all checks passed')
return 0