Commit Graph

799 Commits

Author SHA1 Message Date
Shokunin 73bb197a03 Docs: regenerate TCP_COMMANDS.md for the new debug commands
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 14:33:33 -07:00
Shokunin bff226bea7 Docs: regenerate TCP_COMMANDS.md for the new debug commands
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 14:33:20 -07:00
Matthew Stanley 1473c66772 Merge validated renderer fixes into generic post-effect pipeline 2026-10-13 10:18:03 -07:00
Matt Stanley 6eaf078699 Merge pull request #584 from RetroPortingToolKit/feat/gl-dithering
GL: PS1 dithering by default (native grid), elective fine/off modes
2026-10-13 10:10:53 -07:00
Shokunin 8dbe2165ff bloom: cost of real and generated frames
Smooth motion lost most of its generated frames with bloom on (R4 race,
120 Hz: ~30% of bloom-off). Measured and fixed in order of cost:

- Depth-stencil blits (CPU milliseconds each on macOS) are gone:
  generation surfaces no longer copy the marks and are not marked while
  drawn (generated frames reuse the newer real frame's mask); the
  native-wide centre copy is colour only again and the mask takes the
  centre's marks from the hr surface; the mask itself is resolved in the
  presented surface's own pixels through an R8 target that shares the
  surface's depth-stencil renderbuffer, then mapped to the window.
- Marking needs one pass per batch, not two: 3D batches only set, 2D
  opaque ones only clear, semi-transparent ones only set; only batches of
  unknown make (queued replays, lines) still do both.
- No full-size copy of the image: `source_down` (a blit straight to the
  pass's size) feeds the bright pass, and the composite screen-blends onto
  the window (`blend screen`; unlit pixels are discarded, so they keep their
  exact value). The debug split/bloom-only views go with the copy.

M4, R4 race, render thread + reprojection, PSX_FRAME_GEN_FORCE, a host
loaded by other work (absolute rates low): bloom pass on real / generated
frames 1.2 / 0.7 ms at 1080p, 1.3 / 0.9 ms at 1440p, 2.6 / 1.6 ms at 4K
(glFinish-bracketed); generated frames with bloom 79-80% of bloom-off at
all three (was ~30%). A 1/8-resolution blur chain was tried and kept no
more frames, so the 1/4 chain (the look) stays.

Tests: parser (blend, source_down, bloom preset reads no full copy), GL
fixture (source_down + blend screen chain exact; HUD and mask checks
unchanged), FXAA unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 04:03:35 -07:00
Shokunin de8d286180 Dithering: native-grid pattern is the default, internal-pixel is elective
Review of #584: the default must not make guest-visible VRAM depend on the
internal scale. Mode 1 ("on", default; "scaled" kept as an alias) now
puts the PS1 pattern on the native VRAM grid; mode 2 ("fine") is the
elective per-internal-pixel pattern. gl_dithering_test checks the default
mode's native VRAM is identical at 4x and 1x (equal-colour Gouraud now
averages 15.50 in the default at every scale). Docs keep the
semi-transparent approximation explicit. OpenBIOS stamp regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 02:18:29 -07:00
Shokunin abbae48947 Dithering on by default with explicit per-primitive eligibility
Maintainer review of #584: PS1 dithering is hardware behaviour, so it is
now on by default whenever the guest sets GP0(E1h) bit 9 ([video]
dithering = "on"; "scaled" stays opt-in, "off" is the old true-colour
output).

Eligibility is decided per primitive from its command and carried in the
vertex instead of being inferred from the colour:
- Gouraud polygons and shaded lines: geometry vertex a_col.a + 2*131072
  (decoded in GEO_VS, v_dith);
- texture-modulated polygons: a_semi + 8 (v_dith in TEX_VS);
- flat polygons/lines, raw-texture polygons and every rectangle: never.
This fixes the two reproduced bugs (Gouraud with 5-bit-exact colours was
skipped; textured rectangles were dithered). Bit changes no longer flush:
eligibility is fixed when the primitive is queued; mode changes still drain.

gl_dithering_test covers each case (Gouraud incl. equal colours, shaded
line, modulated and neutral-modulated textured polys dithered; flat tri,
flat rect, flat line, raw poly, modulated and raw textured rects never;
bit clear and off unchanged), plus scaled 4x == 1x, render thread, PGXP
depth, native-wide and the accurate-blending basis. OpenBIOS stamp
regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 02:18:29 -07:00
Shokunin 023af6d9d4 GL: opt-in PS1 dithering ([video] dithering = off|on|scaled)
The OpenGL renderer has always drawn shaded and texture-modulated pixels
at 8 bits per channel with no dither pattern (true colour). That stays the
default. 'on' applies the PS1 4x4 offset matrix and 5-bit truncation per
internal-resolution pixel; 'scaled' puts the pattern on the native grid,
so it reads like the console at any scale and the native VRAM is the same
at every internal resolution.

GP0(E1h) bit 9 reaches the backend through a new optional facade hook
(gr_set_dither) recorded for the render thread and Smooth motion redraws.
With the mode off nothing flushes and no uniform changes. Flat, raw and
other 5-bit-exact pixels are never touched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 02:18:29 -07:00
Shokunin 8eccea1612 post effects: no per-frame GL queries; CRLF presets tested
- Uniform locations are looked up once per program (each lookup can be a
  driver round trip on a threaded GL; the executor runs per present,
  generated frames included).
- State save queries only capability flags and the viewport. The mask pass
  no longer clears (it draws 0 then 1), so the clear colour is never
  touched; the present's window target and texture unit 0 are left bound.
  The GL fixture checks exactly that contract.
- postfx_chain_test: a preset with CRLF line ends parses the same, and the
  import check writes its shader in binary mode (it failed on Windows).
- docs/POST_EFFECTS.md: `generated reuse`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 02:15:46 -07:00
Shokunin 74dadc6004 GL: one post-effect pipeline; bloom and FXAA as built-in chains, user chains via [video] post_shader
Post effects now run as chains of full-screen fragment passes on one
executor (gl_postfx.inc), as asked in review. A chain is a small .pfx preset
(postfx_chain.c, GL-free): passes with a shader (a file next to the preset or
builtin:<name>), inputs (source, the optional primitive-derived mask,
previous or a named earlier pass), a scale, format, filter and uniforms.
The executor owns target allocation and lifetime, program build/cache,
uniform binding (u_rcp, u_size, u_org) and GL state save/restore.

Stages, in order, each from a fresh copy of the image: the built-in "bloom"
chain ([video] bloom), a user chain ([video] post_shader / PSX_POST_SHADER,
elective, off by default), and the built-in "fxaa"/"fxaa_hq" chain
([video] antialiasing_mode). FXAA folds in as a one-pass chain and its
output is byte-identical to the former fixed pass; it still runs on real
frames only. Generated (Smooth motion) frames run bloom and the user chain.

The "may glow" mask is an optional pipeline input: draws keep stencil bit 1
only while an active chain reads `mask`, and the window-sized mask texture is
built once per present for the chains that use it.

Tests: postfx_chain_test (format, built-ins, errors, file import, no GL);
gl_bloom_test gains an imported two-pass chain (byte-exact invert), the mask
input (HUD unlit, 3D lit), a bad preset, a pass that does not compile, and GL
state restored with bloom + a mask chain + FXAA on, all on the caller thread
and the render thread. docs/POST_EFFECTS.md documents the format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 02:15:46 -07:00
Shokunin e730e03a8a GL: opt-in bloom ([video] bloom), sourced from 3D and additive primitives only
[video] bloom = 0.0 (off, default) .. 2.0 adds a glow around lights on the
OpenGL backend. PSX_BLOOM overrides it for one run; {"cmd":"bloom"} reads or
changes strength, threshold and a debug view live. It is a plain [video] key,
so [quality.*] presets can switch it off on low-end machines.

The HUD never glows: with bloom on every textured and untextured draw is
followed by two stencil-only passes of the same vertices that keep a
"may glow" mark in stencil bit 1 (bit 0 stays the mask-bit mirror). Opaque
primitives clear it under their coverage, then PGXP-proven 3D primitives and
additive semi-transparent texels/primitives (modes 1 and 3) set it, painter
ordered like the colour; 3D and non-3D primitives never share a batch while
bloom is on. Semi-transparent primitives leave the mark alone and the PGXP
depth-clear pass (colour writes off) marks nothing. Without PGXP geometry only
additive primitives glow.

The pass runs on the composed game image before AA and the OSD: the presented
surface's marks are blitted into a quarter-resolution stencil, a soft-knee
bright pass runs under it, three separable Gaussian iterations spread it and a
screen blend adds it back. The marks follow the picture: native-wide centre
copies and Smooth motion surfaces (redraw and reprojection) copy stencil with
colour, and generated frames get the same pass. Off: nothing runs, no state
changes, and the composed frame is byte-identical to master.

test_gl_bloom (gl_bloom_test): off is byte-identical before/after bloom and
with --dump against master; on, a bright 2D panel and a panel over a lit 3D
polygon are byte-identical to off, an additive and a 3D polygon glow; guest
VRAM is unchanged; on this thread and on the render thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 02:15:46 -07:00
Shokunin 1bc74b8190 host_output hooks observe a CPU copy; guest-mutating services refuse
Review (mstan): a host-output callback could change the shared CPU (GPR2 set
to 0x12345678 survived an online psx_mod_function_entry). Each host-output
callback now gets a private CPUState copy whose changes are discarded, and
while one runs (psx_mod_host_output_scope) every guest-mutating mod service
refuses: memory writes, host_write_ram, call_guest*, DMA / SPU / VRAM
uploads, guest and GPU-DMA allocations, texture packet memory, the
cycle-scale gate and finish_function. netplay_view_mods_test reproduces the
review case (GPR2 + PC changed in the callback) and checks the shared CPU is
byte-identical after the hook; it fails without the copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 22:40:27 -07:00
Shokunin 13d59b7a39 Mod plugins: netplay = "host_output" (read-only hooks stay on online)
A plugin that only reads guest state to drive this player's host output
(rumble, haptics) can now declare netplay = "host_output". Online it stays
on per player: its function-entry hooks run in the shared simulation while
the rest of the own-view plan is parked, a completion request is ignored and
every psx_mod_write_* it attempts is refused, so it can never diverge peers.
Offline it is an ordinary plugin. netplay_view_mods_test covers both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 22:38:35 -07:00
Matthew Stanley 7dfef44598 Reconcile current master with validated X4 co-op support for PR23 playtest 2026-10-10 20:49:35 -07:00
Matt Stanley 26b3878e78 fix: reduce CPU spin before high-refresh blended presents (#627) 2026-10-10 12:56:57 -07:00
Matt Stanley f9db2561d0 Fix persistent HD texture cache churn and missing live background dumps (#626)
* fix: reuse resident HD textures and publish live background dumps

* test: keep residency stubs local to the filtering fixture
2026-10-10 12:55:54 -07:00
Matthew Stanley 4b96c039f6 Integrate current ICE lobby transports and preserve settled LAN boot settings 2026-10-10 10:53:54 -07:00
Matt Stanley 8cb420660e Merge pull request #624 from RetroPortingToolKit/fix/pgxp-qualified-defaults-20261010
Use dataflow-only PGXP defaults automatically in hook builds
2026-10-10 09:52:57 -07:00
Matt Stanley f17a946e6a Merge pull request #623 from RetroPortingToolKit/fix/native-wide-default-clipping-20261010
Make camera-plane clipping automatic with native-wide projection correction
2026-10-10 09:52:51 -07:00
Alex Vanderveen 1a8994ac0b Merge feat/ice-hub-relay: host relay over ICE for online rooms
Resolved against master: resolve_transport keeps master's single-agent
transport=ice launch (2-player rooms) ahead of psx_transport_decide; match_caps
JSON keeps the mod-plan fields and adds relay_via=ice; recomp-net bumped to
a48d355 (host_ice).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-10 04:20:24 -04:00
Matthew Stanley 8f6867225c Support independent co-op audio voices and diagnostic OSD rows 2026-10-10 00:53:39 -07:00
Matthew Stanley e7a059643c fix: select dataflow-only PGXP defaults in hook builds 2026-10-10 00:48:22 -07:00
Matthew Stanley ddbb979f18 fix: enable camera-plane clipping with native-wide projection correction 2026-10-10 00:48:17 -07:00
Matthew Stanley 1dd2afec07 Merge master and enable PS1 blend correction by default 2026-10-09 23:55:29 -07:00
Matt Stanley eb4c76fc47 Merge pull request #586 from RetroPortingToolKit/feat/gl-xbr-filter
GL: opt-in xBR edge-directed texture filter (texture_filtering = "xbr")
2026-10-09 23:19:31 -07:00
Matt Stanley cf5bf1c88a Merge pull request #608 from RetroPortingToolKit/feat/mod-host-rumble
Mod API: title-supplied host rumble (psx_mod_set_host_rumble)
2026-10-09 22:36:08 -07:00
Matt Stanley 16758c1e24 Merge pull request #604 from RetroPortingToolKit/codex/mod-internal-resolution
Support session-only internal resolution requests from graphics mods
2026-10-09 22:35:59 -07:00
Shokunin 70c735944b GL accurate blending: unorm8-exact blend constants (NVIDIA), regen OpenBIOS stamp
NVIDIA quantises the constant blend colour to the 8-bit target (0.5 ->
127/255), putting B/2+F/2 and B+F/4 one step under a k*8 boundary, so
gl_blend_accuracy_test failed there (2016 mismatches). With accurate
blending on, use 128/255 and 64/255: exact in unorm8, and the small upward
bias stays inside the PS1 truncation bucket for every 5-bit operand, so
fixed-point and float blenders agree. Passes on Apple M-series GL and an
RTX 4080 SUPER (NVIDIA 610.88). Default path unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 19:18:36 -07:00
Shokunin 0e3c53720b GL: opt-in accurate blending + PS1 blend/mask accuracy test
Verifies the four PS1 semi-transparency modes, set-mask, mask check and
texel STP at 4x internal resolution with PGXP depth on and off, directly
and on the render thread, against the PS1 formulas and the software
rasterizer (new gl_blend_accuracy_test).

Finding: with the historical surface bases (fills and texels stored as
k*255/31, everything else as k*8) single-layer blends are off by one 5-bit
step in places (1312 of the test's checked pixels, e.g. B+F/4 over a fill).
[video] accurate_blending = true stores every VRAM write as k*8 so GL's
8-bit blend truncated by the readback is exactly the PS1 arithmetic; whites
of fills/texels then present as 248 like uploads already do. Default off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 19:18:16 -07:00
Shokunin b55d92124d GL: opt-in xBR edge-directed texture filter (texture_filtering = "xbr")
Filter mode 3 magnifies textures with an edge-directed rule after Hyllian's
xBR (written from the published description, no code reused): for the
texel corner nearest a sample, weighted YUV colour distances over a 5x5
neighbourhood decide whether an edge runs along the corner's diagonal; if
so the corner is cut with an anti-aliased boundary and takes the closer
side neighbour. Flat areas, straight edges, gradients, cutouts and 1:1 draws
stay nearest. Selectable from [video] texture_filtering, settings.toml,
PSX_TEXTURE_FILTER and the new texture_filter TCP command. Default unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 19:17:27 -07:00
Matthew Stanley 73f527f926 Merge remote-tracking branch 'origin/master' into feat/uncharged-call-counted-cycles
# Conflicts:
#	docs/TCP_COMMANDS.md
2026-10-09 15:44:41 -07:00
Matthew Stanley 9dab74fac3 Merge remote-tracking branch 'origin/master' into feat/pgxp-mod-region-depth
# Conflicts:
#	docs/TCP_COMMANDS.md
2026-10-09 15:43:57 -07:00
Matthew Stanley 37d3ab3e38 PGXP: track packets in mod guest regions and keep validated depth through the seam clamp
Enhancement arenas (GPU DMA aperture, Expansion-1 mod memory) were untracked, so Crash widescreen drew every vertex native with no depth. Adds depth stats/clear causes to pgxp, depth to pgxp_tri_ring, input_route_start at_frame, integer number keys in game.toml.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 13:20:27 -07:00
Matthew Stanley 1e33a8b8ec Add build-time HLE tier for OpenGL textured batching and batch_sites flush attribution
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 11:19:42 -07:00
Matthew Stanley e4300a46e0 Add an always-on guest-cycle profile ring (gcp_ring)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 04:45:27 -07:00
Matthew Stanley 8fff59f82c Agree trusted camera options and isolate local render transactions 2026-10-09 04:33:12 -07:00
Shokunin ee56f79087 Mod API: title-supplied host rumble (psx_mod_set_host_rumble)
Some titles compute vibration for every pad but only send it over SIO to a
DualShock (R4 with a presented NeGcon). A trusted mod can now hand the runtime
DualShock motor values per seat; the host pad gets the louder of that and the
guest's SIO motors. Values lapse 8 VBlanks after the last call and are cleared
at every session reset, so nothing can stick on. Opt-in: no title that does
not call it changes. PSX_RUMBLE_TRACE now also logs headless.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 23:25:25 -07:00
Matthew Stanley 15a8096ed7 Recompute OpenBIOS emitter stamp and TCP command index after merging #585/#588
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 23:04:29 -07:00
Matthew Stanley 50747ae16d Merge PR #585: GL opt-in texture LOD + anisotropic filtering
# Conflicts:
#	docs/TCP_COMMANDS.md
#	docs/config_schema.md
#	generated/OpenBIOS.emitter.sha
#	recompiler/src/config_loader.cpp
#	recompiler/src/config_loader.h
#	runtime/CMakeLists.txt
#	runtime/src/debug_server.c
#	runtime/src/main.cpp
2026-10-08 23:04:04 -07:00
Matthew Stanley c92278e415 Merge PR #588: GL opt-in FMV chroma smoothing 2026-10-08 23:03:43 -07:00
Matthew Stanley 320d94869c Allow trusted graphics mods to request a session-only internal resolution 2026-10-08 21:33:46 -07:00
Matthew Stanley 29e647cebb Share build-selected guest HLE bindings and implementation metadata 2026-10-08 16:58:05 -07:00
Matthew Stanley 6fbd5a3462 Merge remote-tracking branch 'origin/master' into fix/tomba-session-capture-20261008
# Conflicts:
#	runtime/src/boot_state.c
2026-10-08 16:52:33 -07:00
Matthew Stanley 5d7837e991 fix(runtime): restore capture guards after nonlocal guest escapes 2026-10-08 15:39:01 -07:00
Shokunin ab13278bdf GL: opt-in FMV chroma smoothing for 24-bit MDEC frames
[video] fmv_chroma_smoothing = true makes the OpenGL present of a 24-bit
(MDEC) frame keep each sample's luma and take its chroma from a [1 2 1]
tent over the 3x3 source pixels, hiding the 2x2 colour blocks of 4:2:0
video without softening luma. Pairs with the existing fmv_filter upscale.
Guest VRAM/MDEC output untouched; 15-bit presents and the default unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 14:37:27 -07:00
Matthew Stanley dfd29f76e2 Require retained-bank OpenGL policy for trusted co-op sessions 2026-10-08 14:30:44 -07:00
Shokunin cf756f0b2d GL: opt-in texture LOD + anisotropic filtering for world textures
[video] texture_lod = "mipmap" emulates mip levels for PS1 texture pages,
which are decoded per fetch from VRAM and so have no GL mip chain: the
screen-space UV footprint of a minified, proven-3D primitive is box-averaged
(opaque texels of the fragment's STP class only), and anisotropic_filtering
(1..16) spreads that many taps along the footprint's major axis. Every tap
clamps to the primitive's UV bounds or texture window, so packed atlases
never bleed. The mode rides in the textured batch's filter key; off (the
default), sprites/HUD and magnified textures are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 14:01:07 -07:00
Matthew Stanley aa1035f9be Add trusted co-op netplay profiles and host state digest policy 2026-10-08 13:46:08 -07:00
Matthew Stanley d6652474fe Merge commit 'fe88727025' into integrate/pr558plus-fixes-20261008 2026-10-08 11:00:53 -07:00
Matthew Stanley c87b8deab6 Merge commit '33a4ff56b0f769cf37f2804d00dce2e4cb106408' into integrate/pr558plus-fixes-20261008
# Conflicts:
#	runtime/include/frame_gen.h
#	runtime/src/gpu_gl_renderer.c
#	runtime/src/main.cpp
2026-10-08 11:00:53 -07:00