Commit Graph
48841 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5.5 f7db56628c ARM disassembler: Rewrite, cover everything the emitter can emit, add a test
The old disarm handled the integer instructions but only a fraction of VFP
and NEON, and got several of those wrong. The new one decodes ARMv7-A ARM
state with VFPv4 and NEON, printing UAL with upper case mnemonics.

The new ArmDisasm test runs every ARM emitter function through it, two
examples each. Tools/arm_disasm_check.py compares the test's output with
llvm-mc; they agree on all of it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 22:23:14 +02:00
Henrik RydgårdandClaude Opus 5.5 e9d2c5966f ARM emitter: Fix encodings found by disassembling every instruction
VACGE/VACGT encoded VMUL, and VACLT didn't swap its operands. The
two-register compares with zero, VCLS, VCLZ and VCNT had the wrong prefix,
VCEQ #0 came out as VEXT, VEXT put its index in the Vm field, VADDHN
encoded VMLAL, and VMLAL/VMLSL lacked bit 23.

VHADD, VHSUB, VMAX and VMIN put the unsigned flag in bit 23, and VQADD,
VMULL and VSHLL dropped it. VQDMULH, VQRDMULH and float VABD ignored Q
registers. VSUB/VABD (IntegerSize) put M in the Q bit. VMOV_neon encoded
0xXX00 in 16-bit lanes as zero. VCVT between F32 and F64 had sz inverted,
and int to F64 took its sign from ROUND_TO_ZERO; double to double now
asserts, since it was never a valid encoding. Lane loads and stores in the
top half of a Q register only worked for 32-bit lanes.

Also fixes asserts that rejected valid D registers (VSUB, VSUBHN, VSWP,
VMLAL/VMLSL) and 64-bit alignment for one and three register VLD1/VST1.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 22:23:14 +02:00
Henrik Rydgård 3bec722d62 Merge pull request #22548 from hrydgard/arm64-disasm-test
Arm64 disassembler (for JIT debugging): Complete it and fix bugs
2026-10-13 21:50:33 +02:00
Henrik RydgårdandClaude Opus 5.5 4163737bbc ARM64 disassembler: Cover everything the emitter can emit, add a test
Rewrites most of DisArm64.cpp. Previously missing: test-and-branch,
exceptions other than brk, hints and barriers, adc/sbc, conditional
compare, extr, literal loads, exclusives, unscaled and FP register
offset loads, ldpsw, SIMD structure loads/stores, scalar pairwise,
fixed-point conversions, fccmp, most two-reg misc ops, modified
immediates, smov/umov/dup from GPR, and the scalar shift forms.

Fixed: sp printed as x31, unsigned load offsets sign-extended, ldrsb and
friends shown as stores, adrp ignoring the page, double precision
1-source ops shown as single, fcmpe shown as fcmp, smulh/umulh, the
bitmask decode for 64-bit elements, and fpcr shown as fpsr. Common
aliases are used now (cset, mul, tst, cmn, lsl/asr/ubfx, sxtw...).

TestArm64Disasm runs two examples of every emitter function through it.
The expected strings were verified with Tools/arm64_disasm_check.py,
which compares all 833 instruction words against llvm-mc.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 20:59:51 +02:00
Henrik RydgårdandClaude Opus 5.5 421fbcd2ea ARM64 emitter: Fix encodings found by disassembling every instruction
None of these are reachable from current JIT code with the registers it
uses, but they emit wrong or unallocated instructions:

- EXTR put Rm in the Rn field.
- CRC32X/CRC32CX took sf from the W destination (unallocated encoding).
- LDRSB/LDRSH/LDRSW (immediate) with an X destination set the size bits
  again, turning them into other loads or prfm.
- LDPSW encoded opc 11 (unallocated) and scaled the offset by 8.
- CMxx and LD1R/LD2R with 64-bit elements used size >> 4, which spills
  out of the size field. The CMxx asserts were inverted too.
- SCVTF/UCVTF between FP registers always encoded the single version.
- FCVTZS/FCVTZU to a GPR with a scale wrote fbits into the scale field,
  which holds 64 - fbits.
- LDURSW asserted a 32-bit destination.
- CLREX now uses the canonical CRm of 15.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 20:59:51 +02:00
Henrik Rydgård 18ed9ffd65 Merge pull request #22547 from hrydgard/jackass-postprocess
Vulkan: Batch Jackass' tiled in-place postprocess
2026-10-13 18:26:28 +02:00
Henrik RydgårdandClaude Opus 5.5 60100c4254 - Fixes #13676
Vulkan: Batch Jackass' tiled in-place color grade

Jackass: The Game color grades the framebuffer in 32x64 tiles, one channel
per pass, texturing from the framebuffer it renders to. Each of the 225
draws became a depal pass plus a pass drawing it back, 450 render passes
per frame. A new queue hack, enabled by the TiledDepalHack compat flag,
sorts these pairs into waves of non-overlapping tiles and runs each wave
as one depal pass and one draw pass, leaving 6.

Output is byte-identical to before on both dumps from the issue, at 1x
and 3x on desktop, and at 1x on both phones below.

Time saved per post-processed frame, from replaying the dumps from the
issue with headless --bench (each replay renders that frame once):

  Redmi 9A (PowerVR GE8320):  ~145ms at 1x, ~180ms at 2x
  Unisoc UMS9632 (Mali-G57):  ~55ms at 1x and 2x

Either is more than a whole 33ms frame, so on those GPUs this pass alone
ruled out 30fps.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 17:08:58 +02:00
Henrik Rydgård 4585f70500 Merge pull request #22545 from hrydgard/gpu-fallback-fixes
Fixes to GPU feature fallbacks
2026-10-13 16:46:34 +02:00
Henrik RydgårdandClaude Opus 5.5 2b724699ce Android CMake build fix: Add includes libc++ no longer brings in
The Gradle build goes through CMake and so gets _LIBCPP_REMOVE_TRANSITIVE_INCLUDES,
which CI's ndk-build Android jobs don't.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 15:48:58 +02:00
Henrik RydgårdandClaude Opus 5.5 85d751ebe1 Keep near plane clipping in the fragment depth clamp fallback
The fallback set the rasterizer's Z to a constant so nothing would clip, which
lost the clipping at the PSP's near plane too. Hardware depth clamp loses it
the same way, which the vertex shader can only make up for with a clip plane.

Give the rasterizer (z + w) / 65536 instead: 0 at the near plane, so it clips
there, and past w only beyond 65535 * w. And without clip distances, use the
fragment fallback instead of hardware depth clamp.

With --disable-gpu-features for all three on the Mac, the framedumps set now
differs from the full render by 15570 px instead of 184229 (WALL-E, Hokuto no
Ken, Frontier Gate, FF Zero). The full render doesn't change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 15:06:49 +02:00
Henrik Rydgård 709e2ac277 Merge pull request #22544 from hrydgard/libretro-core-fixes
Libretro core fixes
2026-10-13 15:06:08 +02:00
Henrik Rydgård b4b4390c49 Merge pull request #22543 from hrydgard/android-headless-gpu
Android: Add setup for headless GPU rendering test
2026-10-13 15:02:11 +02:00
Henrik RydgårdandClaude Opus 5.5 2d61d58bbe Make the fragment depth clamp fallback match hardware depth clamp
For GPUs without depth clamp (old Mali), found by comparing with
--disable-gpu-features=depth-clamp on the Mac:

- Write Z / 65536 like the vertex shader, not / 65535.
- Pass the fragment shader Z after the vertex depth rounding, which hardware
  clamp sees too (Puyo Puyo Fever 2's ground at Z = 0).
- Also clamp draws whose Z only touches 0 or 65535.
- Draws that skip the bounds check (skinned, morphed) get the fragment clamp
  and min/max discard wherever the hardware versions would be on, since those
  don't depend on the check either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 14:44:34 +02:00
Henrik RydgårdandClaude Opus 5.5 7c118f2ee3 Headless: Add --hardware-transform and --disable-gpu-features
--disable-gpu-features=clip-distance,cull-distance,depth-clamp acts as if the
GPU lacked those, to test the fallbacks for old Mali on any machine. It
replaces the simulateOldMali constant. --hardware-transform=false runs every
draw through software transform.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 14:44:34 +02:00
Henrik RydgårdandClaude Opus 5.5 3193031e7b Bounds-check PRIM draws of any size, not only up to 2500 vertices
Bigger draws skipped the check and kept whatever clip flags the previous draw
left. Checked, the ones that cross the clip volume in Z get software clipping
where the GPU needs it: on the Mac (no cull distances), Valkyria Chronicles II
and Street Riders get closer to the PSP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 14:44:34 +02:00
Henrik RydgårdandClaude Opus 5.5 eab9a69521 frametests.py --adb: Apply compat settings on both sides by default
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 14:44:34 +02:00
Henrik RydgårdandClaude Opus 5.5 9073aad504 Cull and clip check Bezier and spline patches like PRIM
Curves skipped the per-draw bounding box check and relied on the vertex
shader's near clip plane. On old Mali (no clip distances), that left the
geometry behind the PSP's near plane to the GPU: Test Drive's hills reached
over the sky.

A patch lies within the convex hull of its control points, so run the PRIM
check on those: a patch entirely outside is skipped, and only one with points
outside the clip volume in Z goes through software transform. Missing clip
distances are now also a reason to software-clip, for PRIM too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 14:44:34 +02:00
Henrik RydgårdandClaude Opus 5.5 c7d60a5cfb Headless: Vulkan and OpenGL ES on Android, and frametests.py --adb
The Android headless build only did software rendering. Vulkan takes the
offscreen path desktop headless already uses, and OpenGL ES renders into an
EGL pbuffer, so both run from adb shell with no window. Assets are found next
to the executable, like on desktop, instead of in an APK path that no longer
exists.

frametests.py --adb pushes the binary, assets and dumps to a device, runs each
dump there with Vulkan and GLES, and compares the screenshots with the host's
Vulkan render using Tools/image_compare.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 14:44:34 +02:00
Henrik RydgårdandClaude Opus 5.5 6a15aff789 Android.mk: Don't link the adrenotools hook libraries into ppsspp_common
They are meant to be separate shared libraries that driver.cpp loads into the
driver's namespace by name (ext/libadrenotools builds them that way, and so
does the gradle build). Linked into an executable, file_redirect_hook.c's
global fopen() takes over every fopen in the process, including the one in
libc's own startup, and hook_fopen() calls fopen() again forever. That hung
ppsspp_headless (and the unit test executable) before main().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 14:44:34 +02:00
715c13dcba libretro: let a pending boot finish before unload and reset
retro_unload_game() and retro_reset() could call PSP_Shutdown() while the
loader thread was still booting, tearing down memory and file systems
under it, or after it had failed and already shut down, which asserts.
They now drain PSP_InitUpdate() first, and drop a state queued for the
boot.

Based on 2ac075c3dd from libretro-fork/psp, kept to the libretro side.

Co-Authored-By: Codex <codex@openai.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 13:52:43 +02:00
CodexandClaude Opus 5.5 112fad2e07 libretro: update the buttons in one call
retro_input() set or cleared each button with its own
__CtrlUpdateButtons() call, so with the GL emu thread running the game
could sample a mix of the old and new button state.

(The input part of 1bb8e3797e from libretro-fork/psp.)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 13:51:10 +02:00
Henrik RydgårdandClaude Opus 5.5 299cbcfe68 libretro: check the state size inside MeasureAndSavePtr
The size check in retro_serialize measured the state separately before
MeasureAndSavePtr measured it again, a third DoState pass on every save,
which rewind and run-ahead do every frame. MeasureAndSavePtr now takes
the capacity of a caller-provided buffer and fails after its own measure
pass if the state doesn't fit.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 13:50:54 +02:00
libretroadminandClaude Opus 5.5 fb61ec51cb libretro: create the GL presets once
LibretroHWRenderContext::ContextReset() already creates them right after
CreateDrawContext(), so the GL contexts' own call leaked the first set.

(The libretro part of 329f30a0c9 from libretro-fork/psp.)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 13:50:33 +02:00
libretroadmin b71fbaeb5c libretro: fix OOB, UAF, data races and control flow in core glue
System_AudioPushSamples converts straight into the output buffer: the
block loop never advanced the source pointer and copied numSamples*2
int16s out of a 2048-sample stack buffer, a stack OOB read for any push
over 1024 frames. Realloc failure drops samples instead of crashing and
log_cb is NULL-checked. retro_serialize refuses to write a state larger
than the frontend's buffer, retro_get_memory_data/size return nothing
until PSP memory is mapped, deferred unserialize no longer leaks the
previous buffer, and the cheat entry points stop leaking a CWCheatEngine
per call.

The emu thread acknowledges a pause with a CAS so it cannot clobber a
concurrent quit request. EmuThreadStop stops and joins from any live
state, so unloading while paused no longer leaves a thread running over
freed state. EmuThreadPause pumps queued frames until the thread parks,
via a new non-blocking GLRenderManager::HasQueuedThreadWork() check,
instead of draining one frame, which deadlocked when the thread was
blocked on a readback sync in the next frame. retro_run resumes a paused
thread and pauses it before check_variables() rewrites g_Config,
retro_reset stops it before PSP_Shutdown(), and the sleep_ms(4) after
resume is gone.
2026-10-13 13:50:05 +02:00
libretroadmin 8abc5920c6 libretro: include <array> for the cheat file buffer
MSVC doesn't get std::array through the other headers, so libretro.cpp failed to build there.
2026-10-13 13:49:41 +02:00
Henrik Rydgård 0af0d86470 Merge pull request #22542 from hrydgard/faster-build
Faster CMake builds: libc++ transitive includes, less glslang/SPIRV-Cross, include cleanup
2026-10-13 12:57:43 +02:00
Henrik RydgårdandClaude Opus 5.5 e602aa1548 Add includes that were only arriving transitively
VertexDecoderRiscV.cpp got <cfloat> through SmallDataConvert.h, and three
headers used malloc/free without <cstdlib>, which libc++ no longer brings in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 12:36:06 +02:00
Henrik Rydgård 3c25f21bae Merge pull request #22541 from hrydgard/libretro-fork-fixes
Various bugfixes from libretro's experimental fork
2026-10-13 12:26:27 +02:00
Henrik RydgårdandClaude Opus 5.5 2aff37162b CMake: Keep glslang's HLSL frontend on Windows
MinGW/Cygwin CMake builds should match the MSVC and UWP glslang projects,
which build with ENABLE_HLSL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 12:17:28 +02:00
Henrik RydgårdandClaude Opus 5.5 a361dfc490 Drop unused Config.h and SmallDataConvert.h includes
Config.h is edited about 100 times a year and each edit recompiled 198
files; now 172. SmallDataConvert.h pulls in arm_neon.h and was included by
headers that don't use it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 12:13:42 +02:00
Henrik RydgårdandClaude Opus 5.5 ef8dcbf3c8 CMake: Build less, and parse less of libc++
- Define _LIBCPP_REMOVE_TRANSITIVE_INCLUDES for clang. Before C++23, libc++
  headers pull in many others for old code's sake (<vector> brings in
  <locale>). libstdc++ and MSVC ignore it.
- Turn off glslang's HLSL frontend everywhere, not just on Android. We only
  feed it GLSL.
- Don't build spirv-cross-cpp/msl/hlsl unless something links them (only
  hlsl, on Windows).

Clean Debug build on an M-series Mac: about 11% faster.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 12:13:40 +02:00
Henrik RydgårdandClaude Opus 5.5 1d92e28ce0 Update SPIRV-Cross to vulkan-sdk-1.4.363.0
The old version used std::terminate without including <exception>, which
breaks once libc++'s transitive includes are off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 12:13:40 +02:00
Henrik Rydgård df4ea65ee6 Merge pull request #22540 from hrydgard/ci-tests-in-build
CI: Run tests in the build jobs, fix ccache eviction, fewer macOS jobs
2026-10-13 11:16:43 +02:00
Henrik RydgårdandClaude Opus 5.5 fd79fb0007 Revert "CI: Cancel a PR's running builds when it gets a new push"
Cancelled runs show as failures on their commits, and PRs rarely get
pushed to often enough for it to pay off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 10:51:24 +02:00
Henrik RydgårdandClaude Opus 5.5 39f4d64abc CI: Suppress the MINGW64/MINGW32 deprecation warnings
Only make and bash come from MSYS2 in the libretro Windows builds, the compiler
is MSVC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 10:48:50 +02:00
Henrik RydgårdandClaude Opus 5.5 4bdfb8604c CI: Only check out the FFmpeg libraries each build uses
FFmpeg has prebuilt libraries for every platform, 1.5 GB, and every job checked
all of it out, taking 2-3 minutes. checkout-submodules.sh fetches the other
submodules as before, and FFmpeg as a partial clone with a sparse checkout of
the given folders, plus the source headers since some builds have the ffmpeg
folder on the include path. A Linux x86-64 build gets 67 MB. Alpine, which
builds FFmpeg itself, gets the sources and none of the libraries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 10:47:22 +02:00
Henrik Rydgård d726e736d5 Merge pull request #22539 from hrydgard/validate-ge-dump-commands
GE dump playback: Validate commands, clamp writes, bound allocations
2026-10-13 10:37:55 +02:00
Henrik RydgårdandClaude Opus 5.5 11d16ece2d CI: Build the iOS and tvOS libretro cores in one job
Only five macOS jobs run at once, and with six, one waited about ten minutes
for a runner. The two builds take under five minutes each, a separate job
mostly added another checkout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 10:35:21 +02:00
Henrik RydgårdandClaude Opus 5.5 5866231f66 CI: Cache the FFmpeg that the Alpine job builds
Keyed on the FFmpeg submodule, its build script and the Alpine release. Saves
the 3.3 minutes it took to compile it every run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 10:32:40 +02:00
Henrik RydgårdandClaude Opus 5.5 39321af847 CI: Cancel a PR's running builds when it gets a new push
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 10:10:12 +02:00
Henrik RydgårdandClaude Opus 5.5 3ad5657ff4 CI: Only save ccache on master, cap the AppImage one
The Actions cache was full (10 GB), mostly with caches saved by PR runs that only
that PR could restore, and the AppImage ccache had no size limit. Master's got
evicted, so even master builds found no cache and hit 0.3% of the time. PRs
still restore master's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 10:10:11 +02:00
Henrik RydgårdandClaude Opus 5.5 6cc7d848a1 CI: Run the tests in the build jobs that build them
The test job needed the whole build matrix, so it only started once the slowest
build was done, though it only used three of its artifacts. Running the tests
right after those three builds also saves the artifact download and a second
round of package installs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 10:07:16 +02:00
Henrik RydgårdandClaude Opus 5.5 ec76a4d56e GE dump playback: Refuse sections over 1 GB
A zstd frame doesn't always declare its size, and a small one can expand to
gigabytes, so this is the limit that keeps a crafted dump from exhausting
memory. The largest section in the 1042-dump test set is 82 MB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 10:05:35 +02:00
Henrik Rydgård f8c1e39315 Merge pull request #22535 from hrydgard/tvos-support
Apple tvOS support prototype (and CI)
2026-10-13 10:03:15 +02:00
Henrik RydgårdandClaude Opus 5.5 9c2cf98b84 GE dump playback: Clamp the remaining writes, bound the loader's allocations
Follows up the command range validation:
- Don't require anything of the data commands' sizes or alignment. Version 2
  dumps have empty VERTICES and CLUT commands, and old recorders didn't align
  anything. Registers() drops a trailing partial word instead.
- Split register blocks bigger than the list buffer, which they overran.
- Clamp MEMCPYDATA and MEMSET to valid memory. Only their start was checked.
- Check the compressed sizes against the file, and the decompressed sizes
  against what the frame declares, before allocating. Some version 5 dumps
  leave the size out of the zstd frame; those are checked after decompressing.
- Don't let a large FRAMEBUF size wrap around in MarkNeededTargets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 10:01:29 +02:00
Henrik Rydgård db8a749536 Merge pull request #22538 from hrydgard/ui-focus-beam
UI: Switch to a much nicer "beam algorithm" for kb/controller UI navigation
2026-10-13 09:41:24 +02:00
Henrik RydgårdandClaude Opus 5.5 625db43746 tvOS: Back on the main screen goes to the home screen, like on Android
tvOS only does that with a Back press it gets to see, so the view controller
lets controller events through to UIKit while the top screen is top level
(the new TOP_LEVEL_CHANGED notification), and passes presses that aren't
keyboard keys on to super. Elsewhere Back stays ours.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 09:29:26 +02:00
Acts1631 80b813f507 Validate GE replay commands before execution
Crafted ppdmp command ranges can extend past the decompressed push
buffer. Frame buffer playback can then copy adjacent host heap data
into emulated VRAM, exposing process memory through rendered output.

Validate each command's type, range, and minimum payload size before
constructing the replay executor.
2026-10-13 09:21:14 +02:00
Henrik Rydgård 76d86d8b9d Merge pull request #22537 from acts-1631/validate-stripped-zip-paths
Validate ZIP paths after stripping their common prefix
2026-10-13 09:18:59 +02:00
Acts1631 8220a0f855 Validate ZIP paths after stripping their common prefix
ExtractZipContents checked each archive path for parent components
before removing stripChars. A name could become ../ only after
stripping and escape the install directory, allowing a crafted archive
to overwrite files in sibling PSP directories.

Validate both archive and output paths, and apply stripping consistently
when checking for overwrites.
2026-10-12 22:17:53 -04:00