agc: the idle flush does not wait for its unit-shadow publish, so a CPU store made before the copy runs is lost (Demon's Souls New Game stall) #7983
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 fisherjoey on 2026-10-19T16:53:43Z.
What happens
Demon's Souls (PPSA01341 v1.07, Linux, RTX 5070 Ti, NVIDIA 595.91.07): after New Game the level load never starts. Frames keep rendering at about 60 fps on the menu scene for the full 900 s run, and nothing fails or crashes. On our test set it happened in 3 of 4 runs.
Where
The idle flush publishes unit shadows into the host import and does not wait for the copies:
VulkanDevice::StoreIdleResults(VulkanDevice.cpp:2171) callsStorageTexture::FlushAllPending("idle")and thenSubmitRecorded, which submits without waiting.FlushPendingends withPublishShadow(Texture.cpp:3736). When no image is pending it callsPublishShadowsOnlyinstead (Texture.cpp:3686, 3899).publishUnits(UnitShadow.cpp:296) collects the tracker, drops every unit the CPU wrote since the retile, and picks the rest.recordCopies(UnitShadow.cpp:227) records the slab to importvkCmdCopyBufferinto the open batch and notes the ranges as pending writes.The choice of units is made on the CPU, but the bytes reach guest memory only when the GPU runs the copy. A guest store made after the decision and before the copy runs is overwritten with the older shadow bytes. Nothing reads the range through the flush hook at that point, so nothing waits for the pending write. The memory-access hook is different:
FlushForAccesswaits throughSyncThroughright after its flush (Recorder.cpp:1065), before the accessing thread continues.This is not the window #6364 closed. #6364 waits for unfinished GPU writers before the decision; this window is CPU stores after it. #6960 (@romainveurrier, open) handles the same decision-then-copy window for
StorageTexture::writeBackLayersand does not touchUnitShadow.cppor the publish. #5934 (SONIC SUPERSTARS, guest heap overwritten with texel data) looks like the same family.Evidence
All runs: Demon's Souls PPSA01341 v1.07, Linux (Nobara, kernel 7.2), RTX 5070 Ti, driver 595.91.07, 900 s from boot through New Game.
The test base is not current main. It is main
93e54ceddplus these local patches: a stencil-export workaround (APS5_IGNORE_STENCIL_EXPORT=1, never upstream), #6280, a cherry-pick of #6567 (merged since), a sampled-texture snapshot sharing patch, anImportWatchedpage-digest fix, a port of KytyPS5's job-worker idle sleep (enabled withAPS5_JOB_IDLE_SLEEP=1in all runs below), and a diagnostic that logs CPU stores into blocks a GPU-timeline store had just covered (APS5_TRACE_WB_REUSE=1).Two crashes on related sets fit the same mechanism, but we have not proven that this path caused them. On main
ccb0c0926with #6567 and the stencil workaround, a SIGSEGV in guest code read pointers from a 64 KiB block filled with RGBA8 texels (0x320e60000, inside a 2048x2048 storage image whose memory the title had reused for heap). On the test base above without the digest fix, the title's allocator asked for 60.88 GiB, a size read from corrupted memory. Neither happened in the 4 runs with the wait, which is too few to rule them out.AI-assisted: yes