AGC: multisampled targets whose memory a title reuses throw on the next access (SONIC SUPERSTARS PPSA06888) #5933
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by billythemenace2 on 2026-10-14T16:18:49Z.
SONIC SUPERSTARS (PPSA06888) reuses the memory of 4x multisampled color targets it no longer draws to: for textures, a storage image and CPU-read data. Every such access throws, because a multisampled target's guard stays until its memory is unmapped. The title plays, but it stops a few minutes in: on entering or leaving a bonus stage, and in the main stage.
Observed (one per run):
The second one is an ordinary texture: T#
025378f0 cad00000 007fc07f 90590fac 00000000 00700090 00000000 00000000, 512x512, format 173, 10 mips, tile mode 2, 0x56000 bytes, starting 0x51000 below the target. Every target in these errors is a 64 KiB 4x surface.What did not work, so a fix needs another signal for "the target is dead":
UnchangedSinceCollectedfails). It never fires here: a log at guard time showsGuestMemory::Watchedfalse for every multisampled target in these runs (both the 4x and the 2x ones), so CPU stores into that memory are not seen.Write,WriteChanged,StoreOwnBytes,MarkWritten). This is wrong. A log of those writes shows the sameMarkWrittenranges over targets every frame, for example0x26dcbfe30+0x14c70over the target at0x26dcc0000and0x286d0fd30+0x13fb0over0x286d10000. With the hook most of the scene disappeared, which points to targets still in use being retired.Open question for the multisample code (#4474, #4820, #5445): what tells AnyPS5 that the guest has moved on from a target whose memory is not write-watched? Candidates I have not tried: a draw or dispatch binding the range as something other than this target (as in the storage image case above), or the guest allocator's free, if one is visible.
Setup: Windows 11, MinGW-w64 GCC 15, Release, AMD Radeon RX 5700 XT.
main5a6ad0ed3plus #5865, #5375, #5456, #5882, #4820 and #5445 (the title's earlier stops), and a local footprint for the Z64KBX layout (#5445 comment).AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by KingDarkHN on 2026-10-16T13:40:45Z.
Addressed by #6808.
The signal you are looking for is the read site that reuses the range. Instead of keying retirement off a CPU store or a driver write to the target (your two attempts that did not work), this keys it off the guest-memory access that reuses the target's memory:
RequireNoMultisampleTargetdrops the reused color guard instead of throwing, so thea texture read,a storage image accessanda CPU readaccesses in the log above retire the target they overlap.RequireNoResidentDepthReadtakesallowStaleOwnerRetirement; a read taggedRegisters,TextureReadorVertexBufferretires a stale depth owner whose range is no longer attached, while a read that still overlaps an attached target keeps refusing. The native depth lookup is moved ahead of the guard, so sampling a live depth target still goes through the depth path.A guest read of a target's memory as something else (a texture, a vertex buffer, registers) is therefore the proof that the guest has moved on. A write to that memory is not needed, which is why it does not matter that
GuestMemory::Watchedis false for these targets.Measured with #6808: SONIC SUPERSTARS got past the bonus stages and the main stage in a ~6 minute run (Linux, Omarchy/Arch, kernel 7.2.3, RTX 5060 Ti, driver 610.57.04) without this throw, and the full
agc_driversuite stays at its pre-existing pass rate.One caveat on the depth half: retiring a written depth owner drops its host image without publishing it back to guest memory, so it is a compatibility workaround rather than a full fix. That is recorded as a debt entry in the PR (
docs/dev/debt/libSceAgcDriver.md) and discussed with #6727. The color-target half, which is this issue, has no such caveat.The change is documented in detail on the pull request.