mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 02:11:36 -04:00
e7f7fb6cf0
Two framework bugs that made overlay variants run interpreted forever (the "agonizing lag" in overlay-heavy areas like Tomba's dwarf village): 1. Cache read/write divergence. The loader reads <exe>/cache and the runtime writes captures to <exe>/overlay_captures.json, but the gcc autocompile path used the game.toml command verbatim, whose hard-coded --out-dir/--captures pointed elsewhere (build-stable/build-modern). So compiled shards landed where the loader never looked and captures were read stale -> the variant never went native. Fix: the runtime now injects PSX_OVERLAY_CACHE_DIR / PSX_OVERLAY_CAPTURES (the canonical loader paths) into every autocompile spawn; compile_overlays.py honors them over any CLI flag (--captures now optional). One source of truth for the cache location, uniform across all games, dev or prod. gcc/tcc stay separated by the existing <compiler> namespace. 2. Overlay DLL preamble missing psx_ws_cull_sltiu. auto_screen_x emits this helper at every width-cull site into EVERY build's C (identity at 4:3), and the main EXE links it from gpu.c, but the overlay DLL preamble never defined it -> any overlay variant with cull sites failed to link -> no shard -> interpreter. Fix: provide the self-contained helper (depends only on the already-forwarded psx_ws_x_margin) in the DLL preamble. Proven on Tomba dwarf village: dispatch_native 29/s -> 11454/s (was ~97% interp, now ~97% native). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
56 lines
2.5 KiB
C
56 lines
2.5 KiB
C
/* autocompile.h — background overlay compile for variant-capture automation
|
|
* (step 2.8). Spawns the configured compile command (compile_overlays.py
|
|
* invocation from game.toml [runtime] overlay_autocompile_cmd) after an
|
|
* automatic capture, collects its output into an in-memory ring (no log
|
|
* files — CLAUDE.md §3; read it via the autocompile_status TCP command),
|
|
* and on success has the emu thread rescan the overlay-DLL cache so the new
|
|
* variant goes native in-session, without a restart. */
|
|
#ifndef PSXRECOMP_AUTOCOMPILE_H
|
|
#define PSXRECOMP_AUTOCOMPILE_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Store the command line + working directory. Empty cmd disables. */
|
|
void autocompile_configure(const char *cmd, const char *cwd);
|
|
int autocompile_configured(void);
|
|
|
|
/* Pin the canonical overlay cache dir + captures file the LOADER actually uses
|
|
* (<exe>/cache and <exe>/overlay_captures.json — computed once in main.cpp).
|
|
* autocompile injects these into every spawned compile via the environment
|
|
* (PSX_OVERLAY_CACHE_DIR / PSX_OVERLAY_CAPTURES), so the WRITE cache and the
|
|
* READ captures can never diverge from where the loader reads — for every game,
|
|
* dev or prod, gcc or tcc. compile_overlays.py / coverage_vault.py honor these
|
|
* over any CLI --out-dir/--captures. This is the single source of truth for the
|
|
* cache location: no per-game config, no drift. */
|
|
void autocompile_set_cache_paths(const char *cache_dir, const char *captures);
|
|
|
|
/* Probe whether a C compiler is actually reachable on PATH (gcc/cc/clang) — the
|
|
* REAL "developer machine" signal, distinct from autocompile_configured() which
|
|
* only reports that a command STRING is set (the shipped game.toml always sets
|
|
* one). overlay_backend_resolve uses this so `auto` picks gcc only when the
|
|
* toolchain can really build a shard, else sljit (toolchain-less production).
|
|
* Memoized; safe to call repeatedly. */
|
|
int autocompile_toolchain_available(void);
|
|
|
|
/* 1 while a compile process is running. */
|
|
int autocompile_busy(void);
|
|
|
|
/* Kick a compile if configured and idle. Returns 1 if started. */
|
|
int autocompile_request(void);
|
|
|
|
/* Emu-thread tick: applies a finished compile (cache rescan on success).
|
|
* Must be called from the same thread that owns the overlay loader. */
|
|
void autocompile_poll_main(void);
|
|
|
|
/* JSON status blob for the debug server: state, run/fail counters, last
|
|
* exit code, and the output tail. Returns bytes written. */
|
|
int autocompile_status_json(char *out, int cap);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* PSXRECOMP_AUTOCOMPILE_H */
|