Repository navigation
fix(agc): store a storage image's DCC keys at write-back only when not stored yet - #3458
Merged
adriadam10 merged 2 commits intoOct 11, 2026
Merged
Conversation
…t stored yet MarkDirty stores uncompressed keys at an image's first write and marks its uploaded keys uncompressed. The write-back stored them again, whenever the key bytes did not read uncompressed. By then the title may have reused the metadata memory: RIDE 4 (PPSA01599) frees its 1920x1088 render targets after the legal screen and Unreal Engine's small-block allocator takes the 64 KiB key block that followed one of them. The deferred write-back then filled the allocator's free lists with 0xff and the title crashed popping one. The write-back now stores keys only when the image's uploaded keys are not uncompressed already, that is when no store at the first write or an earlier write-back made them so since the keys were last read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e-back Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
Checked build and ctest (libSceAgcDriver scope, 382/382) on the PR merged onto main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 (b8d3060). 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 with
0xff.Title: RIDE 4 (PPSA01599, Unreal Engine 4) on Linux, main 8ec0e13. 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 99c1c26.
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