Repository navigation
perf(agc): clear a register fast clear without waiting for a known key store - #6247
Conversation
…y store materializeRegisterClear clears the resident image to CB_COLOR_CLEAR_WORD when the target's DCC keys read as the register clear code. Most of the time those keys come from a key store the driver recorded itself (NoteKeysFillOnGpu) and the GPU has not run it yet, so FillClear refused with "keys pending" and the fallback waited for that store (SyncThrough). The wait buys nothing when the newest recorded writer of the whole key range is the noted store: ProvedCurrentDccKeys already answered from the same memo (PendingStoreKeys), so the keys the GPU will hold are known and are the code this clear stands for. The image clear and the "uncompressed" key store after it are recorded into the same queue behind that store and land after it, the order the wait gave. KnownPendingDccKeys exposes that proof, and the register clear passes it as FillClear's allowRegisterClear, which skips only the "keys pending" refusal; the key scan still runs. Any other pending writer (a title kernel, a later partial or wider write, a shadowed range) keeps the wait. Tests: the proof answers only for a pending noted store covering the range, and a clear recorded behind a pending register clear key store leaves the clear word in memory and uncompressed keys.
|
Building each first-parent merge since 042eb7c: it passes at 2848b55 and fails from 2c4574a (this merge). With a temporary print before that line (not committed), Inferred, not checked: on a machine where the host import of the test block is refused, the test prints "pending key stores not tested" and returns before this check, which may be why it passed where it was run. AI-assisted: yes |
What
materializeRegisterClear(Graphics/src/Draw.cpp) clears the resident image toCB_COLOR_CLEAR_WORDwhen the target's DCC keys read as the register clear code. Usually those keys come from a key store the driver recorded itself (NoteKeysFillOnGpu) that the GPU has not run yet.FillClearthen refuses withkeys pending, and the fallback callsRecorder::SyncThroughand waits for that store.The wait does nothing when the newest recorded writer of the whole key range is that noted store.
ProvedCurrentDccKeyshas already answered from the same memo (PendingStoreKeys), so the keys the GPU will hold are known, and they are the code this clear stands for. The image clear and the "uncompressed" key store after it go into the same queue behind that store and land after it, which is the order the wait gave.KnownPendingDccKeysexposes that proof, and the register clear passes it asFillClear'sallowRegisterClear(added by #5560 for the metadata pass). The flag skips only thekeys pendingrefusal, and the key scan still runs. Any other pending writer keeps the wait: a title kernel, a later partial or wider write, or a shadowed range.Related: #5497 notes the keys of a fill kernel's fast clear (the writer side). This PR is the reader side of the register clear and does not overlap it.
Tested
Linux (CachyOS), RTX 4090, driver 610.57.04, Release, SPIRV-Tools on.
tests/Recorder.cpp.agc_pending_key_stores: the proof answers only for a pending noted store that covers the range, not for a wider range, a later writer or an unwritten range.agc_metadata_pass: a clear recorded behind a pending register clear key store is refused without the proof, is taken with it without waiting, and leaves the clear word in memory and uncompressed keys. Both fail to build onmain(noKnownPendingDccKeys).ctest -R 'agc_|pm4|recorder': 572 of 573 pass.agc_driver_preparation_scope_settlefailed once under-j4and passes 3 of 3 alone, onmainand with this change.tools/check_conventions.pypasses.A 3D title, title screen, menu and first level, 4 gate runs in ABBA order (warm caches,
APS5_PROFILE_DRAW=1). Waits from this site (recorded storesource,refreshResidentTarget):Frame rate does not move outside the noise here. For level frames 100..600 the times are 31.8 / 52.0 / 38.8 / 39.2 ms per present (main, this, this, main). Thirteen other
mainruns of the same commit range from 31.8 to 49.2 ms. Video check passes on all four runs, with 0 torn or stale frames.A 2D title passes its reference run: menu 24.0 fps, gameplay 25.7 fps, 0 skipped draws, 0 flashes.
DotDebian measured it on Windows 11 (Core Ultra 9 285K, RTX 5080) in the same 3D title: the CPU wait of this path dropped from about 145 to 4 ms per frame, with the same image.
Carried from DotDebian's oneandonlydean#3. Rebased onto current
main, which already has theFillClearflag from #5560. The environment switch is dropped.Checklist
main; no other open PR implements the same functionsNotImplemented_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)