fix(agc): count adjacent registered allocations as covering a storage-image write-back #5321
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5321"
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 lubaxe on 2026-10-13T17:12:33Z.
What
StorageTexture::writeBackLayersdrops a surface's pending results when its memory is no longer registered (RegisteredReadableCoversis false), so that stale texels are not stored over memory that was freed or reused.RegisteredReadableCoverslooked for one readable registered range containing the whole span (containingRange). A surface placed across two adjacent allocations was therefore reported as unregistered, and every write-back of it was dropped. Only the first four drops are logged, and a title usually uses them all at startup, so the later drops are silent.PPSA06694 (Remnant 2, UE5) hits this with its HZB occlusion test. A pixel shader tests object bounds against the HZB into a 256x256 RGBA8 target. A compute pass copies that target into a 256x256 linear staging image, and the CPU reads the result (
Remnant2.exe+0x2f8e75d). The staging image (0x40000 bytes) lies across two registered allocations (0x30000 + 0x10000), so its results never reached guest memory. The CPU read zeros and treated every object as occluded: the logo mesh was drawn on the first frame only and the screen then stayed black, and later the Create Character screen shows no character.RegisteredReadableCoversnow walks the registered ranges from the start of the span. The span is covered when consecutive readable ranges reach its end without a gap. The other caller, theDMA_DATAcopy inPacketMemory.cpp(outcome.path == 2), uses it to decide whether a destination is registered memory; a destination across adjacent allocations now counts as registered there too.Tested
registeredReadableCoverTestsinagc_driver_graphics: a range inside one allocation, across two adjacent ones, and over both; not covered past the last allocation, over a gap, over an unreadable allocation, an empty range, and after removal. Onmainit fails witha range across two adjacent registered allocations must be covered.ctestonmain8c772ad3with this change: 1076 of 1077 passed. The failure isagc_driver_pixel_lds, which also fails on unmodifiedmainon this GPU. Rebased ontomain61b8742b; thereagc_driver_graphics,guest_np_authandagc_driver_vertex_clip_cull_distancespass.maine152ba8fwith the other changes listed in the bring-up discussion (#5322, #5323, #5324 withAPS5_STORE_AT_LABEL=1): 8 of 8 runs show the character on the Create Character screen. Without this change, 4 of 4 runs do not: in two it is missing, in two it is drawn black with metallic highlights.tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functions (#1191 and #1324 also changeRegisteredReadableCovers, for speed, and will conflict with this one there)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-13T19:18:40Z.
Tested on Linux x86-64 (Release build, lavapipe / llvmpipe LLVM 20.1.2), with
db1ddb96cmerged into main18c438b10:agc_driver_graphics,agc_sparse_buffer_holes,agc_descriptor_pool_reset_failure,agc_compute_descriptor_layout_flags,agc_driver_covered_centroid_state).agc_driver_graphicsfails withAGC graphics: a range across two adjacent registered allocations must be coveredAI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by Nesyth on 2026-10-13T20:02:39Z.
Ready or Not (PPSA18605, #4184) loses storage-image write-backs the same way, and this PR fixes the visible effect there. Measured on
main18c438b10(Windows 11, RX 7900 XTX), with every module built from that commit:main, every session drops write-backs from boot on: the log shows the 4memory no longer registered; 1 pending ranges droppedlines it allows (images of 1 MiB to 64 MiB) in each of 4 sessions. With this PR there are none in any of 3 sessions.1280x85 mips=1 layers=5 dim=4 tile=7 format=36) instead of from its storage image. On my bring-up build without a fix, all 11 sessions with that layout had the tint and none of the 18 without it.mainsessions had the layout, so the tinted example (second screenshot) is from my bring-up build.mainthe write-back is dropped and none of the 32 stored texels reach memory; with this PR all 32 do.One difference from the rule I had tested locally, which accepted only adjacent ranges of the same allocation: memory that is freed and registered again as two adjacent allocations now gets the write-back too (32 texels stored into the new allocations in the same unit check, where
maindrops it).mainalready writes back into memory registered again as a single allocation, so this may be intended.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T18:32:42Z.
Checked on Linux (build + ctest scoped to libSceAgcDriver: only the pre-existing
agc_driver_tessellationSEGFAULT fails, same as main). WithRegisteredReadableCoversreverted,agc_driver_graphicsfails on the new test, so it pins the change. The walk over contiguous readable ranges stops at gaps and unreadable ranges, and the test covers those cases. Also confirmed by @coltken95 (Linux) and @Nesyth (Ready or Not, RX 7900 XTX); merging.