Commit Graph

21 Commits

Author SHA1 Message Date
tetrisgm 2641f7c59b overlay/perf/pgxp: fix silent overlay-DLL breakage, variant-scoped captures, PGXP shared edges
Framework fixes surfaced while bringing up a title that stresses overlays, HD
texture replacement and PGXP at a doubled CRTC rate. All are general; the
title's own configuration stays in its game repository.

CORRECTNESS

* Overlay DLL shim was deleted by the preprocessor. compile_overlays.py injected
  overlay_dispatch_preamble.c.inc after the syntactically LAST #include. A
  conditional i-cache include moved that anchor inside an #else, and DLL builds
  define PSX_OVERLAY_DLL_BUILD, so the callback definitions preprocessed away and
  every overlay DLL failed to link. Any title using overlays would silently fall
  back to per-instruction interpretation. The shim is now anchored to the
  unconditional #include "psx_runtime.h" and raises if that anchor is absent.

* Overlay capture kept stale PC bitmaps when executed code later became data, so
  one variant's PC set could be compiled against another variant's bytes.
  overlay_watch_note_write now retires the whole page's execution/dispatch epoch
  when any executed word is overwritten; static demand is keyed by
  (load_addr, size, bytes) and resolved only against matching range identities.

* VRAM-to-VRAM copies only invalidated the destination and never registered it as
  a replacement candidate, so textures arriving by copy could not be dumped or
  replaced at all. gr_copy_rect now calls tex_pack_on_copy with the same
  (texture,palette) key semantics as CPU uploads.

* PGXP shared-edge seams: a per-primitive all-or-nothing gate cannot stop two
  adjacent primitives disagreeing about a shared endpoint, so the edge is
  submitted at two sub-pixel positions. Adds a frame-stamped canonical endpoint
  cache keyed by final integer screen position: the first use fixes the
  coordinates and every later occurrence reuses them.

* PGXP provenance: PGXPValue carries per-component X/Y/Z projection ids, so a
  value assembled from different projections can no longer arm correction.
  Destructive AND/XOR/NOR/SLT, link and COP0 writes now invalidate shadows, and
  the SXYP shadow FIFO shifts with guest SXY.

* Precise NCLIP no longer replaces guest MAC0. It is telemetry only, so face
  visibility stays bit-exact with the integer GTE.

* Removed two counters that were reported as correctness evidence but were never
  incremented anywhere.

PERFORMANCE

* PSX_ENABLE_LTO plus a noinline guard on the shared cycle wrappers. Unguarded
  ThinLTO clones hot interlock bodies and REGRESSES the hot path; guarded, it
  becomes a win. Adds runtime/tests/bench_psx_runtime_hotpath.c, which verifies
  variant equivalence by digest so codegen changes are measurable.

* Cycle accounting: emitters select specialized arity-0/1/2/3 helpers at
  generation time instead of a generic dependency-mask loop; main-RAM loads
  combine base/wait/completion into one exact charge. Exactness is covered by
  pipeline-state, load-state, deadline-crossing and cross-device causality tests.

* HD texture invalidation replaced a linear scan of up to 8192 upload records per
  VRAM write with a tile-refcount index; out-of-domain writes early-out.

* Translation/text-substitution dispatch is gated behind a monotonic mutation
  epoch instead of running a callback on every dispatch.

* card_data_writes_check no longer runs on every RAM write.

CAPABILITY

* fixed_outer_aspect: the outer presentation aspect becomes a function of user
  configuration only. Scene classification selects content transforms, never the
  outer viewport, so menus/FMV stay centred undistorted inside a wide canvas.

VERIFICATION AND LIMITS

docs/UPSTREAM_2026-08-20.md audits each change against the diff, marks
unsupported claims UNKNOWN, and lists a suggested PR split and review focus.
Unit and structural tests accompany each item, but this body of work has NOT
been validated end-to-end against a fixed reproducible workload -- reviewers
should treat the timing-exactness and PGXP changes as the highest-risk areas.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-20 11:47:23 -07:00
tetrisgm 18272616a1 savestate: dynamic section count; refuse cross-mod-config loads; tex_pack section
The file header's section count was HARDCODED to 16, so ANY appended
section made the loader stop early and poisoned every later section - the
long-standing "adding a section breaks a later one" trap. BsOut now counts
sections and backpatches the header (file via fseek, memory in place).

New BS_SEC_MODSET rides FIRST: the resolved mod-plan fingerprint. A load
whose fingerprint differs from the running plan is refused before any state
is applied, with a message naming both plans - previously such loads
half-applied and died at a null PC. Old saves without the section still
load (best effort), matching the skip-unknown policy.

BS_SEC_TEXPACK (dormant since the count trap) is enabled: tracked-upload
rects+hashes persist, pixels rebuilt from restored VRAM and hash-verified,
so HD texture substitution survives savestate loads. Full save->load->run
roundtrip verified live.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-18 13:53:46 -07:00
Alex Vanderveen 76945d3a65 8mb ram patches + toolchain windows hotfix 2026-08-16 21:19:05 -04:00
Alex Vanderveen 16bfa4144f 8mb support 2026-08-16 17:59:20 -04:00
Alex Vanderveen 8fb75061b4 8mb mod for wipeout and recomp-net bump, rb engine bump, mods in netplay enabled. 2026-08-16 13:35:48 -04:00
Matthew Stanley f44f56bfdc mods: let games expose loading speed as a free integer, plus disabled_by
Players asked for CD speeds beyond the curated 2x/4x list and for the two
loading accelerators to stop being one control (GH TombaRecomp#5: a
speedrunner wants shorter loads but NOT the host speed-up, which runs past
the loading screen and breaks a skip).

Three changes, all general:

- psx_mod_set_disc_speed accepted only divisor 2 or 4. That was policy,
  not safety: cdrom.c divides the sector delay and floors the result at
  CDROM_MIN_DELAY, and apply_speed leaves XA streaming at authentic
  timing, so no positive divisor can produce a zero-delay storm or
  pitch-shift FMV audio. Accept 1..PSX_MOD_DISC_SPEED_MAX and let the
  mod's description carry the risk warning.

- psx_mod_set_load_acceleration accepted 2..16. Host pacing cannot desync
  the guest at all (every frame, CD deadline, interrupt and callback still
  happens), so the ceiling was arbitrary. Accept 1..PSX_MOD_LOAD_ACCEL_MAX,
  with 1 meaning authentic and 0 still meaning uncapped.

- New option key disabled_by: an option names a BOOLEAN sibling that
  overrides it, so "tick Instant and the speed box stops mattering" needs
  no second widget type. The parser rejects a dangling, self-referential
  or non-boolean reference rather than leaving a control silently always
  enabled, and the provider resolves the link against the live selection
  so the launcher and the plugins can never disagree about whether a
  control counts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-04 23:55:25 -07:00
Matthew Stanley 1bc84f38c6 mods: support save-safe damage override and deadzone rounding 2026-08-04 18:50:31 -07:00
Matthew Stanley 67757efac4 feat(runtime): add CHD discs and mod-owned loading modes 2026-08-03 22:32:17 -07:00
Matthew Stanley bc6b277c94 feat(mods): add GPU DMA enhancement memory 2026-08-03 15:55:47 -07:00
Matthew Stanley b2af4e89c9 feat(mods): add trusted game enhancement hooks 2026-08-03 15:17:39 -07:00
Alex Vanderveen 3da61df355 Revert "ok"
This reverts commit b836f2198c.
2026-07-29 03:18:10 -04:00
Alex Vanderveen b836f2198c ok 2026-07-29 03:15:42 -04:00
Matthew Stanley 3c67a52f95 opengl: add motion-adaptive interpolation blend 2026-07-28 14:27:40 -07:00
Matthew Stanley 64097606fb runtime: fix game-owned display and controller mods 2026-07-28 00:04:20 -07:00
Matthew Stanley eb262c4b23 feat(mods): let a trusted plugin read its own option values
The manifest schema already carries typed, validated, launcher-rendered,
persisted options ([[option]] boolean/choice/integer), and the launcher
provider already reads them. A trusted activation plugin could not: the
callback takes no arguments, so a plugin was only ever an on/off switch.

That forced a parameterised feature to be modelled as one feature per
value, and `constraint` only expresses ordered_integer WITHIN a feature, so
those pseudo-features could not even be made mutually exclusive. A game
wanting "Widescreen: 16:9 / 21:9" or "Interpolation: 90/120/144/165/240"
had no way to express it as one entry.

psx_mod_option_value(package, feature, option, out, out_size) closes the
gap against the value the player actually committed. It returns 0 with an
empty string when the plan is not committed or the ids do not resolve, so a
caller applies its own default rather than reading "" as a selection. Ids
are explicit because registration is by plugin id alone and the callback
carries no package/feature context.

Also in this commit, from the same investigation:

* Sustained overlay-autocompile failure is now LOUD. After 3 consecutive
  failed runs the runtime prints once to stdout: what failed, the exit
  code, that overlays are staying interpreted and frame times will be far
  worse than the build is capable of, what to check, and the compiler's own
  output tail. Previously the only trace was a `fails` counter reachable
  over TCP, so a wholly-interpreted title presented as "why is this slow"
  rather than as a message. Threshold is 3, not 1, because isolated
  failures (a shard racing a capture rewrite, a transient lock) are
  ordinary and self-heal. Measured cost of the silent case on Tomba!:
  p50 frame period 105ms, vs 3.1ms once shards existed.

* The autocompile child's working directory is printed at startup beside
  cache and captures. Every relative path in overlay_autocompile_cmd
  resolves against it and it comes from game.toml's detected project root,
  so a game.toml staged outside the real root silently repoints the entire
  compile command with no other symptom.

* A build tree whose cache still carries recomp-ui's OFF for
  RECOMP_UI_ENABLE_MODS now says so at configure time. 610234a's seed only
  fires on a fresh cache, and a stale OFF is indistinguishable from a
  deliberate one, so such trees kept producing Mods-less builds across
  reconfigures - the same "reads as a stale build" failure one level up,
  and invisible. The explicit-OFF contract is deliberate so this does not
  override it; it makes the state audible.

Runtime ctest 16/16. Warning verified to fire on a tree configured with
-DRECOMP_UI_ENABLE_MODS=OFF and to stay silent on a fresh configure.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 17:33:44 -07:00
Matthew Stanley d116e0da3b feat(mods): add presentation interpolation rates 2026-07-27 10:40:49 -07:00
Matthew Stanley d34af54141 feat(mods): support native VBlank rate selection 2026-07-27 10:32:33 -07:00
Matthew Stanley 964cdb3870 feat(mods): expose adaptive display activation 2026-07-27 10:19:07 -07:00
Matthew Stanley 9683a1cf8c feat(mods): support mod-owned FMV skipping 2026-07-26 20:34:20 -07:00
Matthew Stanley 99abda239f feat(mods): add pre-runtime activation plugins 2026-07-26 20:18:00 -07:00
Matthew Stanley a4afb828ac feat(mods): add trusted static vblank plugins 2026-07-26 18:59:10 -07:00