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>
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>
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>
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>
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>
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>
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>
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>
--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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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.