Commit Graph

609 Commits

Author SHA1 Message Date
Matthew Stanley 27de42d073 vulkan: fix draw-area batching and enable builds by default 2026-07-22 12:07:32 -07:00
Matthew Stanley e558c971ab runtime: restore native Tomba FMV overlays 2026-07-22 00:35:26 -07:00
Matthew Stanley 1ea7e28b10 runtime: fix debug cycle throttle symbols 2026-07-21 22:37:43 -07:00
Matthew Stanley d482ab67a2 runtime: resume compiled code after patched FMV entries 2026-07-21 22:32:07 -07:00
Matthew Stanley 6c914a763f runtime: quiet high-frequency diagnostics during FMV 2026-07-21 22:24:55 -07:00
Matthew Stanley f1bdefad20 runtime: batch faithful FMV load-cycle charges 2026-07-21 22:23:15 -07:00
Matthew Stanley 87491cb035 launcher: integrate recomp-ui netplay flow 2026-07-21 21:39:28 -07:00
Matthew Stanley 0527806ce3 Repair netplay PR rebase for MotK bring-up 2026-07-21 21:38:05 -07:00
Alex Vanderveen b6850026a4 Restore missing cycle/icache link symbols for MotK.
Re-add watchdog/PC-sample fire wrappers and overlay icache_fetch_fn;
stop shadowing the inlined psx_advance_cycles with a missing extern.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 21:38:05 -07:00
Alex Vanderveen 30df7acaf2 Restore missing cycle/icache link symbols for MotK.
Re-add watchdog/PC-sample fire wrappers and overlay icache_fetch_fn;
pull inlined psx_advance_cycles via psx_cycles.h.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 21:38:05 -07:00
Alex Vanderveen fe7913cbca Fix psx_cycles / audio linkage for MotK CI.
Export service_to_now, rename advance to *_slow for the header inline,
and give g_audio_host_rate C linkage.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 21:38:05 -07:00
Alex Vanderveen 916b8ca7d3 Fix incomplete load/icache refactor for MotK CI.
Rename out-of-line load helpers to *_slow to match psx_cyc.h inlines,
declare psx_icache_fetch/reset, and wire overlay callbacks to slow paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 21:38:05 -07:00
Alex Vanderveen 7cf9958135 FMV optimizations 2026-07-21 21:38:04 -07:00
Alex Vanderveen 0b890cdc13 lobby game version control 2026-07-21 21:38:04 -07:00
Alex Vanderveen 31015ceab1 feat: launcher polish and recomp-net lobby netplay
Wire MotK-style lobby (recomp-net submodule, WS client, match_caps),
netplay delay-sync, and launcher UX so host sim settings stay aligned
across peers.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 21:37:57 -07:00
Claudio Varandas 55120e102e runtime: implement COP0 software interrupts (CAUSE.IP0/IP1 vs SR.IM0/IM1)
Jackie Chan Stuntmaster (SLUS-00684) hard-blackscreens after the intro
logos: the game's exception dispatcher is re-entrant by design. Its
stage-1 handler saves SR/EPC to a single save slot, then executes
mtc0 CAUSE,0x100 + mtc0 SR,0x101 and relies on the resulting COP0
SOFTWARE interrupt (CAUSE.IP0 & SR.IM0 & IEc) to vector into its
stage-2, which acks the CD INT at the controller, delivers events, and
restores the saved SR. The runtime only ever considered the INTC line
(i_stat & i_mask) gated by SR.IM2, so the sw-int was never taken:
stage-2 never ran, CD INT3 stayed unacked (process_pending freezes the
completion countdown while irq_flag != 0), and the machine deadlocked
with the display disabled and SR parked at 0x101 (IM2 stripped -> all
hardware interrupts dead).

Three changes, all architectural (no per-game logic):

1. interrupts.c psx_check_interrupts(): a pending software interrupt
   (CAUSE & SR & 0x0300, plus IEc) is now a deliverable source. The
   fast path, the pending check, and the SR gate each consider it; the
   INTC path still requires IM2, the sw path only its own IM bit.
   Exception entry sets CAUSE.IP2 only when the hardware line is what
   is being delivered, so a pure sw-int presents the guest-written
   IP0/IP1 bits unmodified (the dispatcher discriminates its stages by
   exactly these bits).

2. interrupts.c: save/restore exception_jmpbuf across delivery. The
   sw-int nests inside the hardware-interrupt handler window; the
   nested setjmp used to overwrite the single global jmpbuf, so the
   OUTER handler's later RFE longjmp'd into the exited inner frame
   (host stack corruption, SIGSEGV).

3. dirty_ram_interp.c: deliver immediately after an interpreted MTC0
   to CAUSE or SR that makes a sw-int deliverable, with EPC = the
   committed next pc. Hardware vectors within the next instruction;
   waiting for the next block boundary opened a window in which a
   second hardware IRQ re-entered the (legitimately non-reentrant)
   guest dispatcher and destroyed its saved SR. precise_irq_deliverable
   gains the same sw-pending condition.

Verified on SLUS-00684: boots through BIOS/logos/FMV into rendered
3D gameplay at 60 fps, SR observed at the canonical 0x40000401, CD
irq_flag acked, MDEC decoding. BIOS-only boot unaffected.

Known scope limit: compiled (static) MTC0 sites do not yet trigger the
immediate check; the raising writes observed in the wild live in the
BIOS-installed, dirty-RAM-interpreted trampoline, which this covers.
2026-07-22 00:54:04 +01:00
Matthew Stanley 9228f32c00 runtime: keep Vulkan opt-in and remove old launcher
Remove the in-tree launcher implementation and its submodules now that game projects use recomp-ui for launcher support.

Keep Vulkan hidden from the launcher unless a game explicitly sets [video] offer_vulkan = true, and clamp stale Vulkan settings back to OpenGL when it is not offered.

Co-authored-by: Martin Penkava <mpenkava1337@gmail.com>
2026-07-21 16:31:36 -07:00
Matthew Stanley da64f44e82 launcher: expose the Vulkan renderer
Cycle the renderer selector through Software, OpenGL, and Vulkan while retaining OpenGL-only option gating.

Co-authored-by: Martin Penkava <mpenkava1337@gmail.com>
2026-07-21 15:55:16 -07:00
Matthew Stanley f1fd8ec848 vulkan: expose present blocking telemetry
Record queue-wait, acquire, and present durations plus presentation timestamps in the existing vk_perf ring.

Co-authored-by: Martin Penkava <mpenkava1337@gmail.com>
2026-07-21 15:55:11 -07:00
Matthew Stanley f5498f796c vulkan: prefer MAILBOX for tear-free presentation
Let the frontend remain the sole frame pacer by requesting MAILBOX for tear-free delivery, with FIFO retained as the required fallback.

Co-authored-by: Martin Penkava <mpenkava1337@gmail.com>
2026-07-21 15:55:06 -07:00
Matthew Stanley af9de64951 vulkan: reuse persistently mapped staging buffers
Cache best-fit host-visible staging allocations across queue-idle reclamation points and safely detach long-lived CPU-present buffers during teardown.

Co-authored-by: Martin Penkava <mpenkava1337@gmail.com>
2026-07-21 15:54:42 -07:00
Matthew Stanley b5e9f763fe vulkan: batch work into one command buffer
Keep a shared work command buffer open across logical GPU operations and submit it at the existing synchronization boundary.

Co-authored-by: Martin Penkava <mpenkava1337@gmail.com>
2026-07-21 15:54:29 -07:00
Matthew Stanley 92cbb1a327 vulkan: order back-to-back color passes
Add same-layout color attachment barriers before geometry and wide-surface render passes so prior writes are visible to LOAD and blend operations.

Co-authored-by: Martin Penkava <mpenkava1337@gmail.com>

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-21 15:54:17 -07:00
Matthew Stanley 7f9f59a2bb vulkan: wait for acquire before transfer writes
Include the transfer stage in the swapchain acquire wait mask because the present command buffer clears and blits the acquired image with transfer operations.

Co-authored-by: Martin Penkava <mpenkava1337@gmail.com>

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-21 15:54:12 -07:00
Matthew Stanley c25931e3b7 vulkan: align packed upload offsets
Pad each packed R16 upload region to an even texel count so subsequent VkBufferImageCopy offsets retain the required four-byte alignment.

Co-authored-by: Martin Penkava <mpenkava1337@gmail.com>

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-21 15:54:07 -07:00
Steve Gilissen 1ae1cfdaf6 runtime: add mod frame hooks
Add a small generic frame-hook surface for statically linked mod code. Mods can
register C callbacks with mod_register_frame_hook(); the runtime invokes them
after normal input sampling and before presentation/widescreen frame work.

Expose the SDL window symbol with C linkage so linked mod code can integrate
with SDL APIs such as window grab control.
2026-07-21 15:45:45 -07:00
Opok 4412bc7a7d widescreen: add per-primitive X-reject bound-load cull sites
Add opt-in [widescreen.cull] xclip_load_sites: a configured `lw rt,off(rs)`
loading a per-primitive X-reject bound (sltu-compared against ANDI-masked
u16 screen X) routes through psx_ws_xclip_bound() - INT32_MAX while the
margins are revealed (reject disabled; the wide-surface scissor clips the
overflow, wrapped off-left u16 coords pass), vanilla value at 4:3. Matched
native codegen emit and interpreter hook; overlay ABI v18 forwarder (NULL
preserves the vanilla loaded value); codegen ver 8. Parser, codegen and
overlay-mismatch regression coverage.

Split from #49: replaces the xclip_globals RAM poke with a recompile-time
instruction transform so native shards and the interpreter behave identically.
2026-07-21 15:02:20 -07:00
Matthew Stanley 2ba20f5af7 runtime: make FPS stderr logging opt-in 2026-07-21 14:53:47 -07:00
Opok a5fdf1ad9a widescreen: add side frustum-plane normal-X cull sites
Add opt-in [widescreen.cull] plane_nx_sites: a configured `lw rt,off(rs)`
loading the X component of a side frustum-plane normal (sign-tested per
corner, dot = nx*px + nz*pz) routes through psx_ws_plane_nx() — scaled by
the inverse aspect factor (4*den)/(3*num) while the margins are revealed,
widening the plane cone by exactly atan((3*num)/(4*den)*tan(theta));
identity at 4:3. Matched native codegen emit and interpreter hook; overlay
ABI v17 forwarder (NULL preserves the vanilla normal); codegen ver 7.
Parser, codegen and overlay-mismatch regression coverage.

Split from #49: replaces the plane sign-test RAM pokes with a
recompile-time instruction transform so native shards and the interpreter
behave identically.
2026-07-21 14:38:55 -07:00
Matthew Stanley e4e27f02b5 runtime: optimize MDEC FMV hot paths
Reconstruct the shareable pieces from PR #58 onto current master: add contiguous MDEC DMA input bursts, reduce per-pixel/per-byte MDEC output overhead, add sparse IDCT fast paths, and keep the MDEC activity stamp sane across rematches.

Also quiet the heavy debug trace recorders while MDEC video is active so debug builds can query state without starving FMV playback.

Regression testing was done with non-debug OpenGL builds across multiple FMV-heavy titles. Debug-tool FMV playback was also exercised with the quiet gate enabled.

Co-authored-by: Alex Vanderveen <alex@technicallycomputers.ca>

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 14:29:38 -07:00
Matthew Stanley b0e923b9b7 Exercise PR #48 savestate restore fixes
Restore user savestates to their saved CPU PC instead of the game entry PC, and clear non-serialized CPU/GTE completion deadlines after loading a state so stale absolute guest-cycle deadlines cannot stall the first post-restore unit read.

Debounce load requests for 60 frames after a successful restore. This prevents repeated load requests from stacking multiple restore/recovery cycles into a long apparent softlock while keeping normal save/load behavior unchanged.

Regression testing was done. Caveat: restores can visibly pause, especially near CD/load transitions, and worst-case recovery may take several seconds; observed long recovery cases eventually resumed rather than crashing or permanently hanging.

Co-authored-by: Henrique Guedes <henrique.guedes@porttus.com>
2026-07-21 13:52:26 -07:00
Matthew Stanley d7815862e1 runtime: use same-stem BIN for selected CUE discs 2026-07-21 11:10:21 -07:00
Matthew Stanley 647b81752f runtime: tri-state fullscreen (windowed/borderless/exclusive)
The shared recomp-ui launcher already exposes fullscreen as a universal
tri-state (RecompLauncherCSettings.fullscreen: 0 off / 1 borderless /
2 exclusive), but the PSX runtime collapsed it to a bool everywhere and
only ever used SDL_WINDOW_FULLSCREEN_DESKTOP. Widen the runtime to carry
the full tri-state end to end, matching the SNES/Genesis engines:

- config_loader: UserSettings::fullscreen is now int (0/1/2) instead of
  bool. settings.toml persists it as a bare int; loading still accepts
  the old bool form (true -> 1) for back-compat with settings.toml files
  written before this change, then clamps to [0,2].
- main.cpp: removed every `!= 0` / `? 1 : 0` collapse between
  UserSettings, the seed struct, and RecompLauncherCSettings, so 0/1/2
  round-trips unchanged through the launcher and back into settings.toml.
- main.cpp: win_flags now maps 2 -> SDL_WINDOW_FULLSCREEN (exclusive
  mode change) and 1 -> SDL_WINDOW_FULLSCREEN_DESKTOP (borderless), via
  a small psx_fullscreen_flag_for_mode() helper shared with the hotkey.
- main.cpp: the Alt+Enter / Cmd+Ctrl+F hotkey now detects "currently
  fullscreen" by testing the SDL_WINDOW_FULLSCREEN bit (set in both
  SDL_WINDOW_FULLSCREEN and SDL_WINDOW_FULLSCREEN_DESKTOP) instead of
  only the DESKTOP flag, and toggles between windowed and the
  CONFIGURED tri-state mode rather than hardcoding DESKTOP.
- launcher.cpp/launcher.rml (the legacy RmlUi launcher, still built
  whenever PSX_LAUNCHER is on): fullscreen is now a 3-way cycle button
  (Off/Borderless/Exclusive) following the same cycle_*/*_label pattern
  as the existing CRT/texture-filter controls, instead of an On/Off
  toggle.

Validated with g++ -fsyntax-only (mingw64) against config_loader.cpp
standalone, and main.cpp with no launcher flags, PSX_LAUNCHER only,
RECOMP_LAUNCHER only (against the real recomp-ui RecompLauncherCSettings
header), and both together - all clean. launcher.cpp (RmlUi) was
reviewed by exact pattern-match against the file's existing cycle_crt/
crt_label code (lib/RmlUi isn't checked out in this worktree, so it
could not be compiled).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 22:34:58 -07:00
Matthew Stanley e38daa3415 fix: mirror widescreen range sites in interpreter
Register configured range_sites with the dirty-RAM interpreter so overlay-resident classifiers use the same two-margin widening already emitted by native codegen.

Co-authored-by: Opok <novelasevilliousesp@gmail.com>
2026-07-20 19:39:36 -07:00
Matthew Stanley d742a62391 fix: default generated games to OpenGL renderer 2026-07-20 17:34:12 -07:00
Matthew Stanley cd944e8c0c chore: remove tracked build artifacts 2026-07-20 16:17:02 -07:00
Matthew Stanley 8f78ddbd89 integrate interpreter hotpath and AOT sharding 2026-07-20 15:58:43 -07:00
Matthew Stanley ae3acc7db6 aot: deduplicate complete shard pairs safely 2026-07-20 14:13:46 -07:00
Matthew Stanley c2f4c8bf4b aot: close cross-variant coverage deterministically 2026-07-20 14:06:26 -07:00
Matthew Stanley 8d0081bca8 runtime: harden overlay candidate capacity 2026-07-20 14:06:25 -07:00
Matthew Stanley 75675b3f17 runtime: preserve Windows crash context 2026-07-20 13:42:12 -07:00
Matthew Stanley c37fc2d60c runtime: harden autocompile polling and result capture 2026-07-20 13:42:06 -07:00
Matthew Stanley fa626bdb4c feat: add aspect-scaled depth cull sites
Add opt-in slti/sltiu far-bound scaling with matched native and interpreter semantics, correct immediate sign extension, and an overlay ABI forwarder for live aspect state.

Co-authored-by: Opok <novelasevilliousesp@gmail.com>
2026-07-20 12:14:18 -07:00
Matthew Stanley 288926111f feat: add masked-u16 widescreen cull sites
Add a shared native/interpreter helper for sltiu classifiers operating on ANDI-masked 16-bit screen X values, preserving MIPS immediate sign extension and overlay linkage.

Co-authored-by: Opok <novelasevilliousesp@gmail.com>
2026-07-20 12:11:58 -07:00
Matt Stanley 8ba7f4efe6 Merge pull request #51 from mstan/feat/widescreen-negsub-cull
widescreen: add negsub horizontal cull widening
2026-07-20 12:09:08 -07:00
Matthew Stanley 5ded80e61e Merge master (AOT overlay generation) into perf/interpreter-hotpath
Integration branch: the interpreter-perf series (interpreter fallback +
additive shard autocompile + always-on production observability + the
fail-closed alias-body emitter fix) rebased-by-merge onto master's AOT
overlay generation (play-free extraction, bounded indirect discovery,
AOT recall, shadow-diff redesign).

Semantic-union highlights:
- gte.cpp: HEAD's direct-field marshaling fast paths kept; master's
  s_gte_replay_sandbox guards grafted onto every affected site.
- psx_icache.c: HEAD's global tag array + fetch_miss split kept;
  master's transactional shadow record/replay retargeted onto it.
- overlay_capture.c: HEAD's commit/retry/wait-pending pipeline kept;
  master's durable history + autocapture APIs wired into it
  (persist_history_snapshot fed from the immutable .d contribution).
- overlay_loader.c: master's interp-record/native-replay shadow-diff
  redesign kept as base with HEAD's scheduler-bail hardening grafted
  (new SHDIFF_SCHED divergence kind); strict manifest v2 parsing keeps
  master's P pair-id lines; always-on native-call ring preserved.
- main.cpp shutdown calls BOTH overlay_autocapture_shutdown() and
  overlay_capture_wait_pending() (the latter drains the preserve-write
  FIFO the former does not).
- recompiler: master's generate_alias_group refactor retains the
  fail-closed alias-body re-entry defaults from c85f1d1.

Validated on this tree: recompiler + runtime + tests build; all six
runtime unit tests PASS; interpreter perf guards PASS; recompiler
patch/structural tests PASS (l1 decoder oracle noise = 376 pre-existing
on both parents).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 00:43:41 -07:00
Matthew Stanley 9446038dbb autocompile: survive quoted interpreter paths + pin Windows Python in launcher
Two independent failures made every live reshard fail SILENTLY (runs
counted, shard_ok stayed 0, the game just never got shards):

- autocompile.c: the child line is executed via 'cmd.exe /C <line>'.
  When the line BEGINS with a quoted path and contains further quotes,
  cmd.exe strips the first and last quote characters and mangles the
  command ('The filename, directory name, or volume label syntax is
  incorrect'). Wrap the whole line in one extra pair of quotes -- cmd
  then strips exactly those and executes the inner command verbatim.
- launch_tomba2_interp_perf.ps1: the autocompile command used an
  unqualified 'python'; with an MSYS python first on the inherited
  PATH, it cannot open the Windows-style script path ('can't open
  file'). Use the canonical Windows Python312 explicitly and fail the
  launch loudly if it is absent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 00:07:33 -07:00
Matthew Stanley 6e2a36c4c8 observability: always-on production rings + halt-and-serve on opted-in listener
Landed while root-causing the Tomba 2 warm-cache boot death; each of these
was a hole that blocked attribution on the production binary:

- psx_fatal_halt: halt-and-serve is now keyed on the TCP listener being
  live (debug_server_get_status) instead of the build flavor. A production
  run with PSX_DEBUG_SERVER=1 + PSX_EXIT_HALT=1 now stays inspectable at
  the fatal instead of exit(1)ing the evidence away.
- debug_server_get_status: was declared in debug_server.h but never
  implemented; implemented (listener state, port, saved socket error).
- event_ring: EVENT_RING_ENABLED=1 unconditionally. The ring records
  edges only; its production disable predated the production listener and
  contradicted its own ALWAYS-ON design note.
- sp_ring (new): stack-domain (64 KB) transition ring at fntrace_record --
  one entry per dispatch whose guest SP crossed a domain, i.e. the
  provenance record for 'who installed this stack pointer'.
- disp_ring (new): 128-entry unconditional dispatch tail (target/ra/sp/
  cycle) so the final control-flow sequence before a death is always
  reconstructable post-mortem.
- overlay_loader: the native-call ring (overlay_native_ring recent[]) is
  now recorded in production too -- each entry names the requested PC and
  the claiming candidate CRC, which is what finally attributed the
  wrong-variant native run.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 00:06:51 -07:00
Matthew Stanley 156d9b9b34 Add self-contained media-to-source CLI release 2026-07-20 00:00:22 -07:00
Matthew Stanley bdeb106e5c feat: add negsub widescreen cull sites
Add an opt-in horizontal low-edge transform for subu rd,zero,rt classifiers, with matching native and dirty-RAM interpreter behavior and guarded overlay variants.

Co-authored-by: Opok <novelasevilliousesp@gmail.com>
2026-07-19 23:25:03 -07:00