Commit Graph

1073 Commits

Author SHA1 Message Date
Matthew Stanley a3f36c8c02 Scale widescreen cull margin to the display width; keep ratio sites on the 320 basis
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 00:16:38 -07:00
Matthew Stanley c3ff07814c Account existing pinned textures across preload retries
Bound reservations against total retained residency, skip decoding pinned images, and report complete repeated loads truthfully. Cover cap reductions and publication retry in both formats. Tracking: beads-eio.3.386.
2026-10-24 12:36:09 -07:00
Matthew Stanley 338bf846cb Account retained preload bytes after publication failure 2026-10-24 12:36:08 -07:00
Shokunin 954e28b051 HD preload: bounded contract, safe threads, explicit partial result
Both preload functions now take an aggregate decoded-byte cap and a thread
cap (runtime: 512 MiB, 4 threads). Each image is probed and its RGBA
reserved against the cap before decoding; per-image limits follow the
pack's decode budget, which is no longer grown to usage (pinned images sit
outside it, and outside the Duck 512-entry cap). The pool (texture_pack_
preload.hpp) joins every started thread on unwinding, survives thread
creation failure, and catches worker exceptions. Images not preloaded are
left to the asynchronous budgeted path instead of being marked failed, and
HdTexturePreloadResult reports loaded / over-cap / failed / worker errors
with a complete-or-partial status. The Beetle async worker no longer lets
allocation failures escape its thread entry.

Tests cover both formats: complete preload, over-cap skip with on-demand
fallback, malformed images, injected worker and thread-creation failures,
and budget reservation bounds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 12:36:08 -07:00
Shokunin 0a9fb8600a HD textures: decode the whole pack into RAM before the game runs
Replacement images were decoded on demand by a single low-priority
worker, so a texture first seen mid-race appeared late and could be
evicted again. When replacements are on, configuring a pack now decodes
every unambiguous image (DuckStation and Beetle formats) across all
cores and pins it in RAM before the game draws; pinned images are never
evicted by the decode budget. Logs the count, size and time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 12:35:57 -07:00
yacineolivier-maker f7fed074f1 HD textures: filtered sampling, a cache sized for a whole pack, indexed keys
- Filtered replacement sampling: with any texture filter but nearest, the
  replacement is sampled through its mip chain (textureGrad), the footprint
  clamped to the primitive's own UV bounds so atlas neighbours cannot bleed
  in. Texture windows (repeat) and UVs outside the page keep hd_texel.
- Edge clamp: an out-of-bounds sample clamped to the primitive's UV bounds
  takes the edge's sub-texel position too (keeping the outside fraction read
  a 1 px sliver of the next glyph at sprite borders).
- GL cache: 4096 slots and a PSX_HD_GL_CACHE_MIB budget (default 2048 MiB)
  with a direct-mapped hint table; a 4x pack of one race scene is several
  hundred textures, and the old 256 slot / 128 MiB cache re-uploaded and
  re-mipped them every frame.
- Invalidation: duck_texture_pack_invalidate returns early when a native
  write touches no residency or cache entry (almost every draw under HD
  authority lands on the frame buffer), and retire_unused walks the
  residency lists once instead of once per source.
- Indexed replacements: a TTTTTTTT-index.png key resolves through the palette
  in use at draw time, for packs whose textures are shared by several CLUTs.
- Debug: TCP {"cmd":"hd_uploads","x":..,"y":..} lists the texture uploads
  covering a VRAM point (pack authoring).

Measured with a full HD HUD and course pack for R4: steady 60 fps in races
where the old cache dropped to the high 20s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rkyma8rbyPiccs9n2bkyG6
2026-10-24 12:30:30 -07:00
Matt Stanley ddf1dfdbd4 Merge pull request #716: post effects depth, history and live uniforms
Coherent projection publication and bounded diagnostics; repaired final-pass history advancement and reload clock. Real GL182 checks and combined title regression/visual gate passed. Owner explicitly authorized this merge.
2026-10-24 12:29:29 -07:00
Matt Stanley 38f11cd804 Merge pull request #715: race-free host API present cadence
Atomic/versioned telemetry and presenter-owned reset; explicitly measures host API completion. Focused and combined runtime/title checks passed; owner explicitly authorized this merge.
2026-10-24 12:29:22 -07:00
Aliet Exposito Garcia 1c4731bb14 feat: add configurable widescreen sxy culling support
Some PlayStation 1 titles implement trivial rejection by folding the sign bits of projected vertex screen coordinates across triangle or quad primitives with a chain of AND instructions. Without adjusting these checks during widescreen presentation, geometry in the newly revealed horizontal area is still rejected by the original 4:3 bounds. Rather than embedding title specific instruction patterns directly into the recompiler, this introduces a generalized `[[widescreen.cull.sxy]]` configuration schema within `game.toml`.

Game configurations can now declare multi vertex trivial rejection sequences by their exact AND instruction words, vertex registers and the branch that consumes the result. The loader derives the expected chain from those words and rejects any other shape. Each AND keeps its original value except for the horizontal sign bit, which survives only while that vertex lies beyond the revealed left edge, so vertical and right side rejection are preserved and 4:3 output is bit identical. Shifted coordinate lower edge comparisons reuse the existing `screen_x_sites` handling through a new `slti rt, x, 0` form instead of adding a separate site family.

Full parity is maintained between recompiled code and the dirty RAM interpreter by sharing the same runtime helper and validating every fold and consumer instruction word on both paths, leaving mismatching overlay variants untouched. This eliminates hardcoded game logic from the recompiler while giving titles clean geometry retention in expanded aspect ratios.
2026-10-24 12:28:38 -07:00
Matthew Stanley d486a78acf Scope package overrides and defer snapshots across their native stacks 2026-10-24 11:16:39 -07:00
Matthew Stanley 56b6839602 Reject partial function override activation before session callbacks 2026-10-24 09:31:11 -07:00
Matthew Stanley e706b9d84f Publish coherent postfx projection and escape bounded diagnostic JSON 2026-10-24 09:26:47 -07:00
Henrique Guedes 4cbedf5579 Add function overrides with guarded registration and cycle credit on current runtime 2026-10-24 09:18:57 -07:00
yacineolivier-maker 3ad83c910b Post effects: depth and history inputs, u_time / u_proj, live uniforms
For title-specific lighting presets ([video] post_shader):
- `input <sampler> depth`: view depth sz (GTE screen z) of the presented frame,
  R32F at window size, rebuilt from the surfaces' PGXP depth; 0 where nothing
  3D drew. Only built while a loaded chain reads it.
- `input <sampler> history`: the pass's own target from the last real frame
  (trails, temporal filters); generated frames do not update it.
- `u_time` (seconds since the chain loaded) and `u_proj` (latest GTE
  projection: 240/H, screen centre in uv, aspect) in every pass.
- Live uniforms: psx_host_set_post_uniform(name, x, y, z, w) sets a preset
  `uniform` from game state (e.g. a light source projected to the screen);
  the preset value applies until the first call.
- Debug: TCP {"cmd":"post_shader"} reports the loaded preset, its parse status
  and the live values; {"cmd":"post_shader","path":"..."} reloads a preset
  (or loads another) without restarting, for shader work.
docs/POST_EFFECTS.md documents the inputs and the uniforms.

Used by a lighting preset for R4 (sun and tunnel light shafts, lamp halos,
speed streaks, paint reflections on the player's car from live car pose),
about 0.7 ms of GPU at 1080p on an RTX 3060.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rkyma8rbyPiccs9n2bkyG6
2026-10-24 09:04:33 -07:00
Matthew Stanley 84ba185176 Publish cadence through shared video telemetry without reader races
Use a bounded atomic snapshot and presenter-owned reset across all backends. Readers sort their own snapshots; report host API completion cadence. Add deterministic and concurrent reader/reset coverage.
2026-10-24 08:32:29 -07:00
Matthew Stanley 910c47602c Merge branch 'master' of https://github.com/RetroPortingToolKit/psxrecomp into fix/held-746-20261022
# Conflicts:
#	runtime/src/main.cpp
2026-10-22 18:01:49 -07:00
Matt Stanley afc82849be Apply Internal resolution and Supersampling live from the in-game menu 2026-10-22 17:59:52 -07:00
Matt Stanley 7c4bf09259 Windows GL: wall-clock pacing instead of driver vsync (windowed/borderless) 2026-10-22 17:59:45 -07:00
Matthew Stanley 3a2057c6f5 Merge remote-tracking branch 'origin/master' into fix/held-723-20261022 2026-10-22 17:25:07 -07:00
Matthew Stanley 570c4c8398 Merge remote-tracking branch 'origin/master' into fix/held-710-20261022 2026-10-22 17:25:02 -07:00
Matthew Stanley a2359ca095 Merge remote-tracking branch 'origin/master' into fix/held-737-20261022
# Conflicts:
#	docs/TCP_COMMANDS.md
#	generated/OpenBIOS.emitter.sha
2026-10-22 17:21:40 -07:00
Matthew Stanley 0980667752 Confirm live resolution allocation before reporting success 2026-10-22 17:03:12 -07:00
Matthew Stanley d383ef210b Drain and reset session HUD callbacks 2026-10-22 17:03:06 -07:00
Yves ebca6c5aaf Report XR readiness without the debug server 2026-10-23 06:53:57 +08:00
Matthew Stanley 182073bca9 Integrate current master and complete GPU fixture APIs 2026-10-22 15:35:38 -07:00
Matt Stanley e4301fb8fa VR: diagnose ambiguous XR origin poses without recentering 2026-10-22 15:34:35 -07:00
Matt Stanley eb659c1be7 VR: capture both HUD mattes with one checkpoint and readback 2026-10-22 15:27:16 -07:00
Matt Stanley 4be0669dfa VR: reuse one guest checkpoint per stereo pair 2026-10-22 15:27:11 -07:00
Matt Stanley ba5a609168 VR: bound stereo shedding and recover at the display deadline 2026-10-22 15:27:05 -07:00
Matt Stanley fcf5dbe96c VR: add opt-in stereo and XR frame attribution 2026-10-22 15:26:59 -07:00
Shokunin 67200909e4 PGXP: keep full depth and unclamped XY for far geometry 2026-10-22 15:26:53 -07:00
Shokunin 74c7cbf94a [video] supersample_disable_at_lines: drop SSAA on 4K/8K displays (opt-in) 2026-10-22 15:26:47 -07:00
Yves 510560e599 Preserve precise eye poses and clip near-camera geometry
Co-authored-by: Yves <calibratedbeats@gmail.com>
2026-10-23 05:45:20 +08:00
Yves 689f3b348e Report ambiguous XR origin diagnostics without recentering
Co-authored-by: Yves <calibratedbeats@gmail.com>
2026-10-23 05:37:28 +08:00
Alexandros Mandravillis e3705227b5 Document runtime provenance and hardware references (#731) 2026-10-22 14:23:14 -07:00
Shokunin b1ce3be00a Live resolution: truthful restart contract per backend
Keep the requested internal resolution / supersample (shown and saved)
apart from what the backend last applied. When the live change is
unavailable (no GL, windowed high-resolution mode, CPU-authoritative dual
rendering, no context) or refused, the session scale is left as applied and
PSX_VIDEO_RESTART_RESOLUTION stays set, in both psx_video_apply_live and
the menu's restart bits (psx_host_video_restart_bits_backend, unit-tested
for the capable and refused cases). video_set rejects invalid presets and
factors without applying or saving, and reports applied values, capability
and pending restart. TCP command index regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 14:20:55 -07:00
Shokunin cb17f2f2d4 Windows GL vsync workaround: scope to the measured case
Narrow host_driver_vsync_unreliable() on Windows to the configuration the
stall was measured on: GL active, render thread running, GL_VENDOR NVIDIA,
not exclusive fullscreen. Other driver families and the unthreaded path
keep driver vsync; PSX_TRUST_DRIVER_VSYNC=1 still forces it everywhere.
Evaluated per call, so runtime renderer/fullscreen changes apply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 14:17:33 -07:00
Matthew Stanley ea3b1e3204 Document the paired capture pixel and context contract 2026-10-22 14:11:20 -07:00
Yves e4f1f98542 Capture both HUD mattes with one checkpoint and readback
Co-authored-by: Yves <calibratedbeats@gmail.com>
2026-10-23 03:25:18 +08:00
Yves 4419d234ab Reuse one guest checkpoint per stereo pair
Co-authored-by: Yves <calibratedbeats@gmail.com>
2026-10-23 03:24:41 +08:00
Yves 0cdf95957c Bound stereo shedding and recover at the display deadline
Co-authored-by: Yves <calibratedbeats@gmail.com>
2026-10-23 03:24:01 +08:00
Yves 8400b55dc0 Add opt-in stereo and XR frame attribution
Co-authored-by: Yves <calibratedbeats@gmail.com>
2026-10-23 03:22:42 +08:00
Shokunin 37c1e5254c Apply Internal resolution and Supersampling live
Changing the internal resolution in the in-game menu did nothing until a
relaunch: ovl_video_from() never copied it, and the restart bits forced
a relaunch for it anyway. Supersampling (the [video] supersample
multiplier) had no player setting at all.

- PsxHostVideoSettings gains supersample_milli; internal resolution and
  supersample are live changes (PSX_VIDEO_LIVE_RESOLUTION). Only the
  legacy integer supersampling factor still needs a relaunch.
- psx_video_apply_live resolves the new scale and calls
  gl_renderer_set_internal_scale_live(): it moves the step ceiling
  (clamped like the boot scale) and queues the step through the dynamic
  resolution machinery, recorded in stream order with the render thread.
  The dynamic-resolution controller is retargeted to the new ceiling.
- settings.toml [video] supersample is the player's pick (1.0..4.0).
- The in-game menu round-trips internal_resolution and, with a launcher
  that has RECOMP_LAUNCHER_HAS_SUPERSAMPLE, supersample_milli.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 10:43:34 -07:00
PeriBluGaming b285f08f16 Widescreen: honor screen_x_sites in the dirty-RAM interpreter (#728) 2026-10-21 14:45:40 -07:00
Shokunin f521768fd0 Reprojection: correct depth, two-frame warp, no un-warped fills (#724) 2026-10-21 14:45:33 -07:00
yacineolivier-maker 030a50415e Mods: named debug commands (psx_mod_register_command, TCP mod_cmd) (#711) 2026-10-21 14:45:08 -07:00
yacineolivier-maker 0127fcfc73 Host HUD layer: psx_host_set_hud_draw_cb, drawn under the in-game menu
A title can draw its own heads-up display on the host side (ImGui, like the
in-game overlay provider), once per presented frame -- real and generated
frames -- under the in-game menu and with the same thread and GL rules as
psx_host_overlay_set_draw_cb. Registered once at title activation; NULL
unregisters. No callback registered: no change in behaviour.

Used by a modern race HUD for R4 (lap, timing, tachometer, track map) drawn
at window resolution instead of the 320x240 native one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rkyma8rbyPiccs9n2bkyG6
2026-10-20 21:58:39 +02:00
Matt Stanley 916da6f80d Integrate shared disc tray with the maintained menu provider (#652) 2026-10-19 18:13:38 -07:00
Matthew Stanley ee9e464fd0 Preserve stock-frame VSync on faster displays 2026-10-19 18:02:47 -07:00
Matt Stanley 13b7f81d29 Add guarded instruction variants fixed during offline mod activation
Keep selector zero stock and seal all choices until the next session restart. Refuse nonzero online activation, scope non-stock save states by frozen choices, and preserve original instruction guards when combined with effective-address adapters. Use overlay ABI34 on current master without the old menu dependency stack.
2026-10-19 16:37:32 -07:00