Files
NX2navi/tests/tex_release_check.py
chrg6 08ad7402f7 Keep released textures by how long they went unused instead of by a small size bound.
A released texture now goes once nothing has used it for three minutes (six for content only the GPU made), measured
in wall seconds from a clock of the presents. In two players' sessions the game took released textures back within a
minute of the release or never, so the hold drops nothing it would ask for again. The size bound stays as the safety
net for a burst of area changes, and young textures may pass it, up to twice it, while the card and the system's
commit have room. vram_use defaults to low, which now means this hold; high turns it off and keeps the released
textures up to the bound as before, and balanced reads as low. The old low's values stay available as their own keys.
The reuse log line counts drops past the hold and splits its ages around it. tests/tex_release_check checks the rules
and the clock, and simulates sessions shaped by the logs against the old and new defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 00:12:31 -05:00

42 lines
1.5 KiB
Python

"""Build and run tests/tex_release_check.c: runtime/vk_tex_release.h, which says how long a released texture is kept,
how much the released ones may hold past the size bound, and how many seconds ago a present was. The check also runs
simulated sessions shaped by the take-back figures of two players' logs against the old and new defaults.
No GPU, no game files, any Python.
Usage: tex_release_check.py
"""
import os
import shutil
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
MSYS_BIN = Path(r'C:\msys64\ucrt64\bin')
def compiler():
"""$CC, else MSYS2 UCRT64's clang, else clang on PATH (as tests/diff/common.py picks it, without its Unicorn)."""
if os.environ.get('CC'):
return os.environ['CC']
if os.name == 'nt' and (MSYS_BIN / 'clang.exe').exists():
return str(MSYS_BIN / 'clang.exe')
return shutil.which('clang') or 'clang'
def main():
work = ROOT / 'build' / 'test' / 'tex_release'
work.mkdir(parents=True, exist_ok=True)
exe = work / ('tex_release_check.exe' if os.name == 'nt' else 'tex_release_check')
env = dict(os.environ)
if os.name == 'nt' and MSYS_BIN.exists():
env['PATH'] = str(MSYS_BIN) + os.pathsep + env.get('PATH', '')
subprocess.check_call([compiler(), '-std=gnu11', '-O1', '-Wall', '-Werror', '-I', str(ROOT / 'runtime'),
str(ROOT / 'tests' / 'tex_release_check.c'), '-o', str(exe)], env=env)
return subprocess.run([str(exe)], env=env).returncode
if __name__ == '__main__':
sys.exit(main())