AGC: a storage surface refresh waits for the whole GPU when pending GPU writes overlap its DCC keys #3505
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 ThatsLeo on 2026-10-11T12:00:50Z.
StorageTexture::ProvedKeysasksWaitForKeyWritersfor the keys of a DCC surface whose uploaded keys areUncompressed. When the recorder has a pending GPU write over the keys that is neither a known store nor a fill, it callsRecorder::SyncThrough, which finishes the recorder and waits for its fences (DccMetadata.cpp,WaitForKeyWriters). That happens on the draw path, once per refresh of such a surface.In Stray (PPSA02101 v01.002, UE4), this wait is now the frame time. It runs at the calibration screen on
mainf1ae427bwith the set in #2749, which removes the byte comparisons that came first:APS5_PROFILE_DRAW:Graphics::Drawtakes 8.5 to 9.0 ms per draw packet, about 9.1 s of every 10 s on the graphics worker (about 500 draw packets per 10 s, 2 FPS).I have no fix. The keys only have to be known before the CPU reads the surface's contents. The ways I can see:
Uncompressedfrom the shader that writes them, asPendingStoreKeysandPendingFillsLeaveUncompressedalready do for stores and fills.Both are design questions for the DCC code. I can measure any branch on this title.
Setup: Fedora 44, GCC 16.2.1, Release, Intel Arc (Meteor Lake, Mesa 26.2.3 ANV).
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by santhoshkumar-dev on 2026-10-11T19:46:03Z.
@ThatsLeo I have a branch for part of this and no title that reaches the path. Could you measure it on Stray the way you measured
main?Branch: https://github.com/santhoshkumar-dev/AnyPS5/tree/codex/dcc-pending-key-state (commit d1302782f, one commit on top of
maina11c8f7f7). I can't open a PR for it yet because of the open-PR limit, so I'm asking here.What it changes:
StorageTexture::ProvedKeysasksWaitForKeyWritersfor every DCC surface, not only those whose uploaded keys areUncompressed.WaitForKeyWriterstakes the keys from those fills in record order (a later fill replaces only the bytes it covers) instead of callingSyncThrough. The answer is dropped on submission or on any guest mapping change.PendingFillsLeaveUncompressedno longer counts a range covered by a writer of unknown value as uncompressed.What it does not change: a pending writer whose result is unknown (a shader or a copy, not a fill) still syncs. Your report says the writer in Stray is neither a known store nor a fill, so this branch may not help there. A measurement would tell either way.
Useful numbers with
APS5_PROFILE_DRAW=1, at the calibration screen, onmainand on the branch:Graphics::Drawtime per draw packet ([draw]line)recorded storesync count and wait in the[recorder]linekeys proven: N sampled, N storagein the[rescache]lineSyncThroughfromWaitForKeyWritersI tried Dreaming Sarah (PPSA02929). It has no DCC surfaces (0 key proofs, no
[dcc]lines), so it says nothing about this change.Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-11T20:26:39Z.
@santhoshkumar-dev measured on Stray (PPSA02101 v01.002) at the brightness calibration screen. Intel Arc (Meteor Lake, Mesa 26.2.3 ANV), Fedora 44, Release,
APS5_PROFILE_DRAW=1.Main alone doesn't reach that screen, so both arms use the set from #2749 on
main8ec0e131. The only difference between the arms is yourd1302782f, which cherry-picks cleanly. Each run is 180 s; the averages cover 100 to 180 s, by which point the screen is steady.recorded storesyncs per 10 sFrame time is unchanged: about 2.1 FPS either way. With the branch there are twice as many syncs, each about half as long, and the total wait is the same.
A stack sample of the graphics worker at 150 s still shows the same path:
StorageTexture::Refresh→ProvedKeys→WaitForKeyWriters→Recorder::SyncThrough. That fits what you expected: in Stray the pending writer is not a fill, so the new fill path can't answer, and askingWaitForKeyWritersfor every DCC surface adds syncs rather than removing them.Two more baseline runs (without the branch) froze early: the log went silent at 62 and 93 s, with every thread waiting and the driver idle. One more baseline ran with a stall and is left out of the table. None of the runs with the branch froze, so I take this as an intermittent Stray startup hang that the branch doesn't cause, but it's worth knowing if you try it.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by santhoshkumar-dev on 2026-10-11T20:33:34Z.
@ThatsLeo thank you, that settles it. The branch does not help Stray, and asking
WaitForKeyWritersfor every DCC surface doubles the syncs, so I won't open a PR for it in this form. Thanks also for the note on the baseline freezes.Fixing this needs to know what the pending writer over the keys is. Could you find out?
APS5_TRACE_DCC_KEYS=1, is there any[dcc-keys] title fills keys 0x...line whose range covers thedccAddressof the surface being refreshed? The[dcc-keys] refresh 0x...lines name the surface. If no fill covers it, the writer is not a fill.If it's easier, I can push a diagnostic commit to the branch that prints the pending writes over the key range (range, fill value or unknown, record order) at the
SyncThroughinWaitForKeyWriters.Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-11T21:33:54Z.
@santhoshkumar-dev found it. I added a local diagnostic (not for upstream): every call that notes a pending write records who made it, and the sync in
WaitForKeyWritersprints the noted writers that cover the key range. This is Stray at the calibration screen, on the same set as before, withAPS5_TRACE_DCC_KEYS=1, over 150 s.Surface. Every sync is for one surface:
0x204fa60000, 3840×2160, guest format 71 (R16G16B16A16_SFLOATon the host);0x2029780000+0x3fc00.Writers. No
title fills keysline appears at all, so the writer is not a fill packet. Each frame, in this order:uncompressed store by first write (?) for surface 0x204fa60000, which fills the keys with 0xff.0x200bc20000, noted over0x2029780000+0x48000. That is the whole key range plus 0x8400 bytes past it.refresh 0x204fa60000+0x3fc0000 keys uncompressed -> 0001.This happens once per frame: 83 stores against 85 presents over 40 s.
The shader is a fill done in compute:
It writes the same 32-bit value, loaded through the pointer in
s[4:5], to every dword of the buffer. That's why the recorder sees an unknown write. The value sits in guest memory when the dispatch is recorded, and the range is the dispatch size × 64 × 4 bytes (here, presumably clamped by the buffer descriptor). So the dispatch could be recognized as a uniform fill: read the dword at dispatch time, when no pending write covers it, then noteNotePendingFillor the key value instead of an unknown write. I haven't checked what the dword holds. The-> 0001after the refresh suggests a fast-clear key value.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by santhoshkumar-dev on 2026-10-11T22:08:48Z.
@ThatsLeo great find, thank you. That gives a concrete fix:
BufferFill.cppalready does for three other fill kernels: read the dword behinds[4:5]when the dispatch is recorded (only when no pending GPU write covers it, otherwise it keeps running as a shader) and go throughfillBuffer. The recorder then notes a fill of0x40over the keys instead of an unknown write.mainthat alone would still sync, becausePendingFillsLeaveUncompressedonly answers when the fill leaves the keys uncompressed and0001doesn't. The branch'sOpenFillValueanswers it from the fill.I'll also restore theEdit: I'm keeping the branch'suploadedKeys == Uncompressedcondition inProvedKeysProvedKeysas it is. Without it, a surface whose keys were uploaded as a clear code reads its key bytes while an unknown writer is still pending on the GPU, so the doubled syncs you measured were mostly that read waiting for the writer. Once this kernel is a known fill,OpenFillValueshould answer both cases without a sync.To match the kernel exactly I need the raw values rather than the disassembly (the existing fill kernels use
buffer_store_format_x, so the opcode matters):0x200bc20000, throughs_endpgms[0:7], or however many there are: the V# and the pointer)DISPATCH_DIRECTdimensions and initiator), and the compute stage's thread counts and TGID enables[4:5](I expect0x40404040), and whether any GPU work writes that address before the dispatchI'll push the kernel recognizer to the same branch and ping you when it's ready to measure.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:45:26Z.
Status: step 1 of the fix above is on main with #4603 (the dword-fill kernel is taken as a buffer fill). #5380 (a dword fill of any inline constant) and #5497 (DCC keys behind the pattern-fill fast clear) cover the rest and are still open.