fix(agc): store a storage image's DCC keys at write-back only when not stored yet #3458
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3458"
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 alfalfa-star on 2026-10-11T10:58:17Z.
What
A storage image's write-back stores uncompressed DCC keys over its metadata again, even when the image's first write already stored them (
b8d30603). The write-back is deferred until something flushes it. By then the title may have reused the metadata memory, and the store overwrites the title's data with0xff.Title: RIDE 4 (PPSA01599, Unreal Engine 4) on Linux, main
8ec0e131. With #3435 and #3440 for its earlier stops, it shows the logo and legal screen. Then, about 150 s in, it crashes in game code (app.elf+0x260884e, SIGSEGV): UE4's small-block allocator pops a per-thread free list whose head is0xffffffffffffffff.What happens, from a gdb run (breakpoint on
MarkDccUncompressed, hardware watchpoint on the corrupted word):0x2020800000has keys at0x2021800000.StorageTexture::MarkDirtystores0xc000uncompressed keys there (uploadedKeysbecomesUncompressed).app+0x25f9ea8,app+0x26086dc, ...) writes heap pointers (0x1020e5....) to0x2021800020.AcquireRegistered→FlushForAccess→writeBack→writeBackLayersruns the targets' pending write-backs. Each callsMarkDccUncompressedagain. ItsAlreadyUncompressedcheck sees the allocator's bytes, not0xff, so it stores0xc000bytes of0xffover them.0xff...ff.The address changes from run to run (
0x2021800020,0x2021a00020,0x2021e00020), but it is always a key block that a write-back stores after the reuse.Fix
The three write-back paths in
writeBackLayers(GPU-direct, retile and CPU round trip) store the keys only when the image's uploaded keys are notUncompressedalready. In that case the first write, or an earlier write-back, already stored them, and nothing the driver saw has changed them since.filledKeys) still skips the store, as before.Clear*) still gets them stored at the next write-back.Tested
Linux (Arch), GCC, Release, RADV, on main
99c1c263.agc_driver_dcc_keys_first_writegetsRunReusedKeys:0xffkeys;0x5a, standing in for the title reusing the memory;FlushPending, the keys must still be0x5aand the texels must hold the image's results.0 of 256 key bytes are 0x5a (key 0 is 0xff); with the fix it passes. The existing first-write, fill and refresh cases pass unchanged.ctest: 825/825 (4 video-out flip tests skipped as usual).sceAjmBatchJobSetResampleParametersEx: a ratio change per sample is unsupported.tools/check_conventions.pypasses.@Celegans12, this changes when the keys from your first-write store are written again at write-back. Does it miss a case you had in mind?
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T11:49:12Z.
Checked build and ctest (libSceAgcDriver scope, 382/382) on the PR merged onto main.
agc_driver_dcc_keys_first_writepasses with the change andRunReusedKeysfails without it. The three write-back paths now skip the key store only when the first write or an earlier write-back already storedUncompressed; the fill andClear*refresh cases are unchanged. Merging.