Commit Graph

672 Commits

Author SHA1 Message Date
Matthew Stanley dd0ce3d365 gte: render-view projection override replaces guest projection explicitly; fix abort test count after merge
Override skips guest-formula PGXP shadows; composition with fov_scale tested and documented.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-04 11:03:01 -07:00
Matthew Stanley 7d9abcf5ff stereo: stop presenting a pair the plugin has stopped refreshing
Pair is fresh only within 24 vblanks of its capture cycle; savestate/session reset already invalidate it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-04 10:59:28 -07:00
Matthew Stanley a599d44b86 Merge branch 'review/pr494-fix' into review/pr496-fix
# Conflicts:
#	runtime/CMakeLists.txt
#	runtime/include/projection_scale_config.hpp
#	runtime/src/gte.cpp
#	runtime/src/main.cpp
#	runtime/src/projection_scale_config.cpp
#	runtime/tests/test_gte_register_access.cpp
#	runtime/tests/test_projection_scale_config.cpp
2026-10-04 10:58:21 -07:00
Matthew Stanley 8403bdf9a5 Merge branch 'review/pr493-fix' into review/pr496-fix
# Conflicts:
#	runtime/include/mod_plugins.h
#	runtime/src/main.cpp
#	runtime/src/render_pass.c
#	runtime/tests/test_gl_readback_region.c
#	runtime/tests/test_gte_register_access.cpp
#	runtime/tests/test_render_pass_sandbox.c
2026-10-04 10:57:48 -07:00
Matthew Stanley 98763d922f fov_scale config: accept integers, warn and fall back to 1.0 instead of throwing
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-04 10:55:58 -07:00
Matthew Stanley ff9777318e mod_plugins.h: document that watchdog aborts longjmp past plugin frames
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-04 10:45:30 -07:00
Matthew Stanley 95aa6e68b6 Merge review/pr492-fix into review/pr493-fix
# Conflicts:
#	runtime/src/debug_server.c
#	runtime/src/render_pass.c
#	runtime/tests/test_render_pass_abort.c
2026-10-04 10:45:21 -07:00
Matthew Stanley b6a659ca4a Merge origin/master into review/pr494-fix
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-04 10:43:41 -07:00
Matthew Stanley 0ae34cd0de Merge remote-tracking branch 'origin/master' into review/pr492-fix
# Conflicts:
#	runtime/include/gpu_gl_renderer.h
#	runtime/src/debug_server.c
#	runtime/src/render_pass.c
#	runtime/tests/test_render_pass_abort.c
#	runtime/tests/test_render_pass_sandbox.c
2026-10-04 10:41:19 -07:00
Matthew Stanley cd9981cda8 Clip proven native-wide world faces across camera and screen planes 2026-10-03 23:51:14 -07:00
Matthew Stanley d2c8f03e76 Add guarded native draw replay, motion interpolation and stable world filtering 2026-10-03 23:46:25 -07:00
Matthew Stanley 64bd153bc7 Merge commit '128684b6a3526120aa26394f2bd553f991ee03e8' into pr/medievil-quality-upstream 2026-10-03 23:26:54 -07:00
Yves 305b5485b9 render passes: add atomic stereo pairs and scoped camera views
Adapted from the original feature commits, retaining their author credit:
[0a955971](https://github.com/FractalEngineer/psxrecomp/commit/0a95597129cc2ee6d70397a8da9511831575eae4)
[0a4cf21f](https://github.com/FractalEngineer/psxrecomp/commit/0a4cf21fac88ef425ba0edd25871d7dd20ee0903)
[22bdc9e9](https://github.com/FractalEngineer/psxrecomp/commit/22bdc9e90d14f7a04b79c83b77611c4eb980fef4)
[734977c9](https://github.com/FractalEngineer/psxrecomp/commit/734977c93e80789e9210a262daa35a88f41c40d4)

Source scope and current-master validation: docs/internal/upstream/atomic-stereo-render-views.md

Co-authored-by: Yves <calibratedbeats@gmail.com>
2026-10-04 05:54:05 +08:00
Yves c17dc1a4ff gte: add opt-in projection-distance scaling
Adapted from the original feature commits, retaining their author credit:
[82695b75](https://github.com/FractalEngineer/psxrecomp/commit/82695b75d79610ca7a99783adf9dd5195edfcdd0)
[5633e868](https://github.com/FractalEngineer/psxrecomp/commit/5633e86878611a14d3a78e8f9708452a07bc7238)
[bbd01ccf](https://github.com/FractalEngineer/psxrecomp/commit/bbd01ccfc91c1d9ebe199dad071df64e5b13d06d)
[39d478db](https://github.com/FractalEngineer/psxrecomp/commit/39d478db83132815c2c8c593fc719c4bf67301b0)

Source scope and current-master validation: docs/internal/upstream/gte-projection-distance-scale.md

Co-authored-by: Yves <calibratedbeats@gmail.com>
2026-10-04 05:54:05 +08:00
Yves b491a3597f render passes: restore mod callback context after watchdog aborts
Adapted from the original feature commits, retaining their author credit:
[6d44e21d](https://github.com/FractalEngineer/psxrecomp/commit/6d44e21df7ccedd1acbfa31844a53bf8bd8b316e)
[35b209d4](https://github.com/FractalEngineer/psxrecomp/commit/35b209d406c168e14f51bb8bbd549742473c7388)

Source scope and current-master validation: docs/internal/upstream/render-pass-mod-callback-rollback.md

Co-authored-by: Yves <calibratedbeats@gmail.com>
2026-10-04 05:54:03 +08:00
Yves 2ad2725548 gte: add opt-in projection-distance scaling
Adapted from the original feature commits, retaining their author credit:
[82695b75](https://github.com/FractalEngineer/psxrecomp/commit/82695b75d79610ca7a99783adf9dd5195edfcdd0)
[5633e868](https://github.com/FractalEngineer/psxrecomp/commit/5633e86878611a14d3a78e8f9708452a07bc7238)
[bbd01ccf](https://github.com/FractalEngineer/psxrecomp/commit/bbd01ccfc91c1d9ebe199dad071df64e5b13d06d)
[39d478db](https://github.com/FractalEngineer/psxrecomp/commit/39d478db83132815c2c8c593fc719c4bf67301b0)

Source scope and current-master validation: docs/internal/upstream/gte-projection-distance-scale.md

Co-authored-by: Yves <calibratedbeats@gmail.com>
2026-10-04 05:54:03 +08:00
Yves dedbe47c97 render passes: expose refusal and framebuffer failure details over TCP
Adapted from the original feature commits, retaining their author credit:
[257a88b0](https://github.com/FractalEngineer/psxrecomp/commit/257a88b06d26bb99a9e6066b89f839af41090118)

Source scope and current-master validation: docs/internal/upstream/render-pass-refusal-diagnostics.md

Co-authored-by: Yves <calibratedbeats@gmail.com>
2026-10-04 05:54:03 +08:00
Matthew Stanley 900e18b306 Expose visible widescreen reveal separately from culling guards 2026-10-02 20:44:37 -07:00
Matthew Stanley 977c25dba3 Support explicitly owned adaptive screen masks and centred HUD packets 2026-10-02 20:42:00 -07:00
Matthew Stanley 6674024285 Merge master into feat/medievil-native-wide-guards
Reconciled with #470 (PGXP): gpu.c precise vertices take PGXP only under geometry correction and count it, then native-wide edge recovery; the PGXP triangle stat stays PGXP-only. Stubs and tests from both kept; stamps recomputed.
2026-10-02 20:00:23 -07:00
Matthew Stanley 42053afc17 Merge master into up/screen-x-edge16
recompiler/CMakeLists.txt: keep both new codegen test targets (this PR and #468).
2026-10-02 19:43:43 -07:00
Matt Stanley dec516c08b Merge pull request #476 from Alexbeav/up/netplay-start-failure-text
netplay: say why a start failed
2026-10-02 19:42:52 -07:00
Matthew Stanley 40af8a428c Merge master into feat/pgxp
Master moved the textured-dot test stubs into gpu_exec_stubs.inc; the PGXP stubs move there too. pgxp_note_rect_bypass stub takes (int). Stamps recomputed.
2026-10-02 19:30:59 -07:00
Matthew Stanley 30a4072c25 Merge master into feat/max-detail
Stamps recomputed with tools/bios_emitter_fingerprint.cmake after #480's restamp.
2026-10-02 19:22:24 -07:00
Matt Stanley 921d0b021d Merge pull request #467 from RetroPortingToolKit/feat/vs-split
GL: texture window per vertex; opt-in batching across texture windows
2026-10-02 19:20:52 -07:00
Matthew Stanley a95d8c77ee Merge remote-tracking branch 'origin/master' into feat/guarded-packed-wide-cull 2026-10-02 16:51:02 -07:00
Matthew Stanley 1ed0dfd22d Recover saturated winding at guarded native-wide rendering branches 2026-10-02 16:47:59 -07:00
Matthew Stanley 3787120488 Recover saturated horizontal projections in opt-in native-wide rendering 2026-10-02 16:00:02 -07:00
Matt Stanley 973d93a907 Merge pull request #456 from Alexbeav/up/bios-scph5500-5501-2
bios: add the SCPH-5500 and SCPH-5501 profiles
2026-10-02 15:35:49 -07:00
Matthew Stanley c29e934308 Add guarded packed-coordinate culling for native-wide adapters 2026-10-02 14:12:20 -07:00
Alexandros Mandravillis 57f0505bd2 Widen lui and bltz screen_x_sites: a screen X kept in the high half
A renderer that keeps a screen X as SX << 16 tests the right edge against
a lui-held W << 16 and the left edge with bltz on the shifted value. No
explicit [widescreen.cull] kind fits either: bltz_sites compares the whole
register with -margin, and a lui at a screen_x site was a build error.

screen_x_sites now also takes
  lui rt, W        -> rt = (W + margin) << 16
  bltz x, outside  -> taken while SX < -margin   (x = SX << 16)
Both are the identity at 4:3. The helpers are defined for native code and
for overlay shards; their math is in ws_cull_edge.h. The two prototypes are
written only for a config that lists screen_x_sites, so the generated code
of every other title is unchanged.
2026-10-02 21:27:15 +03:00
Alexandros Mandravillis c1a9e52894 netplay: say why a start failed
A failed start printed "built without recomp-net, or bind/peer invalid" for every cause. A player whose system held the UDP port read first that the build had no netplay.

The library answers a refused bind, a listen address it cannot read and a peer address it cannot use with the same -1. main.cpp now does those steps again (it reads the listen address as the library does, looks up a name, binds without address reuse) and reports the system's answer. The sentence names a cause only when the system does: address in use, access denied (a port range Windows keeps for Hyper-V or WSL, a port below 1024 elsewhere), address not available. Any other error gets the number and the system's text. The peer address is named only when the listen address opened and the peer address cannot be read. The build is named only when it has no netplay.

The sentences are in netplay_exit_reason.c with unit cases; a source guard checks the wiring in main.cpp.
2026-10-02 19:13:57 +03:00
Alex Vanderveen 1982e7dcb5 netplay: host relay for online rooms (amends §108 "online is always SFU")
An online room this build hosts asks the lobby server for transport "host"
(match_caps.relay): the host carries the match on its own UDP port and
guests dial it; the server's relay (SFU) is the fallback when a guest's
probe fails (recomp-net-server WS_LOBBY.md "Host relay"). The mechanics are
recomp-net's recomp_net/host_relay.h, pinned here (lib/recomp-net b0751b7);
this engine's own lobby-client copy gets the same glue as rnet_lobby_client:
the cap (emitted only when asked), the launch's transport ->
PsxLobbyJoinInfo.transport_host (force_input_relay 0; the host accepts
first / hubs instead of dialling the guest's LAN address), each seat's
published path / path_fresh, host_relay_step() from psx_lobby_pump, and
unmap on leave / disconnect.

psx_netplay: transport_host takes the LAN / hub path instead of the "MotK
online needs the SFU" rule. main.cpp: relay_host_get/set + relay_status
for recomp-ui (Network Settings / MATCH SETTINGS / ROOM "Match Relay"),
transport_host on the launch and into PsxNetplayConfig, and the
host==guest-advertise SFU inference skipped on a host launch; all under
RECOMP_LAUNCHER_HAS_HOST_RELAY so older recomp-ui pins still build.

Compile-checked against workspace recomp-ui 58604b0 (MOTK scratch
configure: full build and link).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-01 19:10:30 -04:00
Alex Vanderveen 35d604ab80 netplay: matches the Retro hub negotiates -- ingest_launch and --netplay-query
The hub holds the lobby seat; the game settles everything itself
(retcomm-launcher docs/NETPLAY_HANDOFF.md):
- psx_lobby_ingest_record replays the hub's seat/room/launch messages
  through handle_server_json, so fill_launch answers as in-game.
- --netplay-query answers what this build's lobby would send: disc_fp,
  set_ready (BIOS offer), start (default caps; settled from a room).
- set_ready/start builders and the host start-caps settle are factored out
  unchanged and shared by in-game PLAY and the query.
- A handed-off match ends the process (the hub holds the room).

Two CTR processes from records, local relay: all 80 live digests equal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 19:10:30 -04:00
Matthew Stanley 2163035e9a netplay local viewport: projection renderer, hi-res half present, state gate
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-01 16:02:08 -07:00
Shokunin dd5fdec6bb Add opt-in draw-distance clamps ([[draw_distance.clamp]])
Many PS1 renderers drop a primitive whose depth index falls past the end
of their ordering table. Raising that limit can write past the table, so
a title can now list such guards in game.toml with the register that
carries the index and the last safe value. While a trusted mod has called
psx_mod_set_draw_distance_clamp(1), generated main-EXE code clamps that
register before the guard runs, so far geometry is kept in the farthest
slot instead of popping in later.

- Off by default and reset at every session start, so netplay and every
  title that lists no sites run unchanged; with no sites the generated
  code and declarations are byte-identical.
- Main executable only: the full instruction word is the guard,
  generation fails on a mismatch or a load-delay hazard, captured
  overlay code keeps its own code (the sites are not part of the overlay
  config identity), and the dirty-RAM interpreter applies the clamp
  where the game's text image holds the listed word.
- Compatibility: code_generator.cpp is a codegen-hash input, so the
  codegen hash and the overlay-cache tag change for every title, sites
  or not. Savestates from earlier builds are refused, and overlay shards
  rebuild once on first visit. Generated code and behaviour are
  unchanged for a title without sites or with the switch off.
- Tests: draw_distance_codegen_test (config rules, emission, guards,
  declarations, overlay identity) and draw_distance_interp_test (store,
  switch, interpreted guards); the session-reset guard covers the switch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 11:36:48 -07:00
Matthew Stanley 85c88d269c widescreen: auto_ui_anchor = "in_place" squashes each HUD run about its own centre
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-01 11:13:30 -07:00
Shokunin 8630d3a6f8 PGXP: precise culling as a mod option; the mod as a title's one switch
With every drawn vertex precise, a title can still show cracks where the game
culled a face on its integer winding. R4's road emitter runs NCLIP on each
far row and skips rows whose native height rounds to 0. Natively their
neighbours meet at the same integer y. With PGXP they sit at their exact y,
and the skipped row becomes a strip of sky across the road beyond the start
gantry, at 4K and in 2P. tri_mixed cannot see this: the missing face draws
no triangle.

Precise culling (DuckStation's "PGXP culling", minimal footprint):
- While geometry correction is armed, gte_nclip computes the exact
  determinant of the three SXY register shadows (pgxp_gte_nclip_precise:
  live, current words, the GPU's own truncation agreement and tolerance).
  When its sign is nonzero and differs from the integer MAC0's, MAC0 takes
  that sign, with the rounded exact doubled area (at least 1) as magnitude.
  FLAG keeps the integer overflow bits.
- It changes guest-visible MAC0, so it is a `culling` option of
  psx.enhancement.pgxp, false in the builtin, with no [video] key, so netplay
  (which clears every mod) never runs it. It needs geometry correction.
  It is held off in every pass compared against another execution: the
  speculative and replay passes, and the whole overlay shadow diff
  (psx_overlay_shadow_diff_active), interpreter pass included.
- Counters whenever geometry correction is armed: nclip_precise,
  nclip_disagree (exact sign differs: the culled-face crack exposure),
  nclip_corrected. TCP pgxp {"culling":0|1}; env PSX_PGXP_CULLING.

Session arming in one place (src/pgxp_session.cpp, psx_pgxp_session_arm):
main.cpp's renderer setup now calls the same code the test drives. The arming
takes the mod request (reads and clears it), so a session with an empty plan
cannot inherit an earlier session's request even if the reset were skipped.
pgxp_session_test now links the real mod runtime, the builtin plugin and the
builtin manifest, and covers:
- a default-on override;
- a netplay clear, with and without the reset;
- the off switch;
- the options;
- env overrides;
- pgxp_mod_only.

[video] pgxp_mod_only (game.toml, default false): for a title that ships
PGXP through the mod, the mod is the one switch. The [video]
geometry_correction / perspective_texturing / pgxp_cpu_mode values are not
applied, from game.toml or the player's settings.toml. The launcher also
hides its Perspective textures row (has_geometry_precision = 0). That row
showed "off" while a default-on mod corrected textures, and it could keep
texture correction on after the player switched the mod off.

geom_correction also reports texture_correction and the culling switch.

R4, Helter Skelter: 28.7% of NCLIPs disagree in sign. With culling, the
ladder is gone in same-frame 4K captures (1P straight and crest, 2P VS), and
the game emits about 24% more triangles. Its packet buffers peak at 60%.
fp_identity over 12000 frames: stock, PGXP off, and PGXP on with culling off
are IDENTICAL; with culling on, the RAM writes differ from the attract race
on, while cyc/mmio/mc agree throughout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 06:02:52 -07:00
Shokunin 5970e30ddf PGXP: keep rectangles and out-of-window projections precise, not mixed
Two cases that could still draw a triangle with precise and native corners:

- The rectangle shortcut bypass now needs all four vertices of an
  axis-aligned textured quad to be dataflow-precise. A quad with only some
  precise corners, such as a CPU-built sprite with one corner copied from
  SXY, keeps the shortcut and counts as rect_partial; two triangles would
  have mixed precise and native corners. R4's facade quads are fully
  precise (rect_partial 0 in every R4 run).
- Under preserve-projection, RTPS now applies the GPU's truncation window
  itself (pgxp_ppp_accept): an exact projection outside it is not
  shadowed, the vertex keeps the IR path's shadow, which always agrees, and
  it draws precise instead of being rejected to native at the GPU
  (ppp_window_fallback counts these). The exact math is skipped while the
  hooks record nothing (pgxp_active(): speculative passes).

Also:
- The prepare_precise_triangle comment no longer claims a native neighbour
  can only disagree by the sub-pixel fraction. Under preserve-projection it
  can disagree by up to the window.
- gpu_textured_dot_nw_shift_exec_test links with -dead_strip on Darwin,
  as isc_store_test does. GNU --gc-sections kept it from linking on macOS,
  so the rectangle cases never ran there. The test now covers no, one and
  all four precise corners.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 06:02:26 -07:00
Shokunin a8a75cd353 PGXP: draw precise axis-aligned textured quads as triangles
A textured quad whose four packet vertices form an axis-aligned rectangle in
integer screen space and in UV takes the 2D rectangle shortcut
(gr_draw_textured_rect), which draws the native integer position with no
perspective. That is right for a CPU-built sprite, but a GTE-projected world
quad can land on such a rectangle too: a facade seen straight on. Its
neighbours are drawn precise, so at a high internal resolution the shortcut
left a background-coloured seam along the shared edges. On R4's Helter
Skelter start straight it showed as an L-shaped sky line along a building
panel at 4K, with tolerance off, both with and without preserve projection.

When geometry or texture correction is on and any of the quad's vertices
resolves to a dataflow-precise position (pgxp_probe_precise_vertex: the same
decision as pgxp_get_precise_vertex, not counted), the quad is drawn as its
two triangles like any other world quad. A CPU-built sprite has no dataflow
shadow and keeps the shortcut. With PGXP off nothing changes. geom_correction
counts the bypassed quads (rect_bypass).

Tests: gpu_textured_dot_nw_shift_exec_test gains the quad case (PGXP off,
on without a precise vertex, on with one); pgxp_test checks that the probe
does not count; gpu_gp0_history_guard_test's gpu.c stubs gain the two new
pgxp entry points.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 04:24:54 -07:00
Shokunin dd867215af PGXP: dataflow-only geometry and preserve-projection precision
Two opt-in [video] keys for titles whose build carries the PGXP hooks, both
live-tunable through the TCP pgxp verb. Defaults keep today's behaviour.

pgxp_position_fallback (default true). false skips the position-cache tier
in pgxp_get_precise_vertex and stops gte.cpp filling it. At hook-build
coverage the cache only hands unrelated 3D fractions to CPU-built 2D
polygons (a HUD needle, menus). Beetle and DuckStation leave their vertex
cache off by default.

pgxp_preserve_projection (default false). true makes RTPS/RTPT shadow the
exact projection, from the unshifted MACs and a true divide
(pgxp_project_precise), instead of the GTE's integer-IR one. That removes
the residual wobble of near geometry. Guest SXY, MAC0 and FLAG are
untouched. Only sf=1 vertices with no IR, SZ3 or divide saturation qualify,
and the rest keep the IR path. The exact position can sit a little below the
guest integer or more than a pixel above it, so truncation agreement becomes
the window -4 < precise - native < 5 px, a sanity bound over the IR path's
own error (on R4 every on-screen vertex falls within -1.9 .. +2.6 px). A
packet half at or beyond the GTE saturation limit must still agree exactly.
The tolerance clamp now measures the offset both ways. [widescreen]
precise_nclip reads the same shadows, so in a title that sets both, its
branch sign follows the exact projection too.

Observability: geom_correction reports both switches, ppp_produced, and
geometry-corrected triangles split into all-precise, mixed and native. The
mixed share is the mesh-cracking exposure of G1.1.

Tests: pgxp_test (fallback off, window edges, saturation, two-sided
tolerance, the exact projection and its qualifiers, triangle census);
gte_register_access_test (RTPS/RTPT guest state equals the oracle with the
mode on, and the shadow is the exact projection); video settings test
(defaults, parsing, type check). gpu_gp0_history_guard_test's gpu.c stubs
gain pgxp_note_triangle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 04:24:54 -07:00
Shokunin 67da069f9c GL: texture window per vertex; opt-in texture-window batching
The OpenGL textured program read the GP0(E2h) texture window from a
uniform, so every window change ended the open textured batch (batch
reason 5). Titles that tile far textures with per-primitive windows pay
for that in draws: Ridge Racer Type 4's split screen changes the window
about 515 times a game frame and drew about 180 batches, against 17 with
batching on. On the native-wide path every batch that reaches the margins
is drawn again into the wide surface; under heavy load on an M4, 2P with
widescreen at Match display ran at 39-43 guest VBlanks/s and 1P at 50,
against 50-58 and 57 with batching on.

The window now rides in each textured vertex (a_twin, the E2h low 20 bits
as one float) like texpage and CLUT already do, and the shader decodes it
there; the uniform and the window-replay queue's copy of it are gone.
With the default unchanged, batches still split at every window change,
so every vertex carries the batch's window and the image is the same as
before: the new test's oracle passes on the unmodified renderer too, with
the same digests at 1x, 4x, 9x and in the windowed 9x/18x mode.

[video] texture_window_batching = true (game.toml only, default off) lets
primitives with different windows share a batch. The image is the same:
an opaque batch draws its colour in one painter-ordered pass and
semi-transparent primitives are still drawn one per batch. While mask
checking is on the window stays a batch key, because an opaque batch
fixes the stencil for its STP=1 texels after its colour pass.
PSX_GL_TEXWIN_BATCH=0|1 overrides it for a run and the TCP command
gl_texwin_batch switches it live. Software and Vulkan are unchanged.

Tests: gl_scale_invariance_test gains mode "twin" (alternating windows
over opaque, semi-transparent, set-mask, mask-check and bilinear prims,
into the native-wide margins): off and on give the same native VRAM,
frame at S and wide surface, on draws 17 batches instead of 46 and flushes
only for the 5 mask-check window changes. Each run also checks an oracle
that does not depend on the renderer: raw rects through all four windows
into a 4-bit and a 15-bit page must give, pixel for pixel in the native
VRAM and at the centre of each pixel at S, the texel the PS1 window rule
picks from the VRAM as read back. A decode or packing error both settings
share fails it (checked with (v_twin >> 11) and with off_y left out of the
packed window). video_enhancement_settings_test checks the key's default
and opt-in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 04:15:01 -07:00
Shokunin 6d905e81bd Keep the PGXP mod's activation through renderer setup
psx.enhancement.pgxp did nothing at boot. Its activation armed geometry and
texture correction, then main.cpp's renderer setup, which runs after
activation, applied the [video] baseline and switched both back off. Only the
[video] keys could turn PGXP on.

The activation now records a request (pgxp_mod_request), cleared at every
session start in reset_mod_owned_presentation(). The renderer setup arms PGXP
from the [video] baseline OR the request (pgxp_session.h); the validation env
overrides (PSX_GEOMETRY_CORRECTION, PSX_PERSPECTIVE_TEXTURING,
PSX_PGXP_CPU_MODE) still win. The g_video_* values stay the player's
settings, so the mod never leaks into a launcher seed, and a netplay session,
whose plan is cleared, keeps the [video] keys alone, as before.

No change for a title whose mod is off. pgxp_session_test drives the real
builtin activation and the resolver in main.cpp's order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 02:55:14 -07:00
Matthew Stanley 53521866b4 SDL3: separate Windows desktop borderless and exclusive fullscreen 2026-09-30 23:30:28 -07:00
Alexandros Mandravillis ff4be21c90 bios: add the SCPH-5500 and SCPH-5501 profiles
The v3.0 Japanese (SCPH-5500, 09/09/96) and US (SCPH-5501, 11/18/96)
retail BIOS images join SCPH-1001, SCPH-101 and SCPH-5552, so every v3.0
region (J, A, E) has a profile.

Both images match SCPH-1001 v2.2 byte for byte in the kernel,
ROM [0x80, 0x18000). SCPH-5501's reset vector is identical too; SCPH-5500's
differs in 24 bytes. The shell differs in both. So each profile is
SCPH1001.toml with its own identity (name, id, rom, sha256 pin, stem): the
copy windows and install slots are kernel properties and carry over
unchanged. The shell runs through the dirty-RAM interpreter, as for
SCPH5552.

Each image gets its own seed list, derived by the same rule as
phase2_ghidra_seeds_SCPH5552.json: the SCPH-1001 corpus filtered to seeds
whose 64-byte ROM window is identical in both images (534 kept, 569
dropped), plus the two architectural vectors and 6 A0/B0/C0 kernel-table
targets. The files carry only addresses, labels and rationales, plus the
SHA-256 of both ROMs.

- psx_bios_known_images.h: CRC-32 FF3EEB8C (SCPH-5500) and 8D8CB7E4
  (SCPH-5501), both 512 KiB. A build that does not link these backends
  builds one from the player's own dump as a loadable module, like
  SCPH-5552, and the netplay lobby can name the image.
- main_cli.cpp: map SCPH5500 / SCPH5501 dumps to their profiles.
- build_cli.py: package both profiles with the CLI framework.
- docs/BIOS_SELECTION.md: list them among the module-built images.
2026-10-01 09:28:13 +03:00
Matthew Stanley 757790debe Keep large screen-space composites anchored as one group 2026-09-30 21:38:17 -07:00
Matthew Stanley 7c7133fbb4 Integrate MMX6 adaptive renderer with current framework master
Preserve current segmented dispatch, active-plan mod hooks and software scale limits. Extend function filters through the active plan, retain the last-store pointer with overlay ABI 25, and keep default config fingerprints stable. Refresh BIOS emitter stamps after byte-identical regeneration and reconcile regression fixtures.
2026-09-30 20:23:16 -07:00
Alex Vanderveen 170370a440 launcher: prepare a retail BIOS from the wizard with progress, not at Play
A buildable dump used to verify as usable and then block at Play behind a
modal while the module compiled. Now:

- ae_bios_verify reports a buildable, not-yet-cached dump as needs_regen,
  and the runtime wires recomp-ui's new bios_prepare_with_progress job
  (ae_bios_prepare) whenever the toolchain is present and no Generate host
  is: the launcher runs the build as a progress job from the wizard's
  "Prepare BIOS" button or the Play prompt, re-verifies, and resumes the
  wizard. Generate & rebuild is never offered for a BIOS in a bundled build.
- psx_bios_module.c gains a progress sink fed from the builder's output
  lines (dump / emit / compile / self-check / published map to stage
  percentages with readable messages); run_command streams lines on both
  platforms.
- The launch-time build stays as the fallback for --bios / --no-launcher.

Requires recomp-ui 9f86c49 (GameInfo.bios_prepare_with_progress).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-30 20:10:57 -04:00
Alex Vanderveen 60919f5a87 bios: build a retail backend from the player's own dump as a loadable module
Bundled releases link OpenBIOS only; retail-BIOS-derived C never ships.
"Bring your own BIOS" now works without it: when a dump matching a shipped
profile (psx_bios_known_images.h) is selected, the runtime builds that
backend on the player's machine with the overlay toolchain the release
already carries, caches it, and loads it as one more registered backend.

- runtime/include/psx_bios_module.h: the module contract. An overlay-style
  self-contained shared library (no imports from the executable) exporting
  psx_bios_module_{abi,codegen_hash,init,backend}; reaches the runtime only
  through OverlayCallbacks plus a new PsxBiosModuleCallbacks table (traps,
  dirty-RAM/kernel-bless probes, fntrace, log_probe) and pointer aliases of
  the globals the generated dispatcher touches. Its #defines rewrite the
  emitter's own extern lines, so the generated C compiles unchanged.
- runtime/include/psx_bios_module_glue.c.inc: module-side forwarders and the
  four exports, compiled after overlay_dispatch_preamble.c.inc.
- runtime/src/psx_bios_module.c: host side. Cache path
  <exe>/cache/bios/<os-arch>/bm<abi>_<codegen hash>_f<flavor>/<STEM>_<crc>,
  ABI + codegen-hash gated load, callback fill, and a blocking build via
  overlay_toolchain/bios_module_build.py (gcc via compiler.txt or PATH,
  else tcc), then psx_bios_register().
- psx_bios_backend.c: the registry is now a mutable table seeded from the
  CMake-generated psx_bios_builtin_registry by a constructor, with
  psx_bios_register(); every existing walker keeps working.
- main.cpp: validate_bios_for_launch acquires a module (announcing a first
  build) before declaring a mismatch; discovery accepts a buildable dump;
  the launcher verify reports it usable ("ready" / "compiled on first
  launch") with no Generate & rebuild; the BIOS row shows whenever the
  toolchain is present; bundled_only respects module support.
- emitter: the CPS-marker constructor is not emitted in a module build.
- overlay_api.h: OverlayCallbacks gains a struct tag;
  overlay_loader_callbacks() exposes the host table before loader init.
- tools/bios_module_build.py (ships in the toolchain): identity + profile
  SHA-256 gate, staged emitter tree, emit, three-TU compile, ctypes
  self-check, atomic publish. release_stage.py stages psxrecomp-bios, every
  bios/*.toml, the seeds and the builder into overlay_toolchain/.
- Tests: runtime/tests/test_bios_module_host.c against three fake modules
  (good / wrong ABI / wrong hash) on real dlopen; recompiler/tests/
  test_bios_module_build.py builds the bundled OpenBIOS end to end and reads
  the descriptor back; guards extended.

Verified on Twisted Metal 4 (bundled build + staged toolchain, headless):
first launch with --bios SCPH1001.BIN builds and loads the module and boots
on image=SCPH-1001; the second launch loads it from cache.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-30 19:26:29 -04:00
Matthew Stanley e63a23b74c Merge latest master for segment E; preserve completed IsC accuracy notes 2026-09-30 15:06:59 -07:00