perf(agc): clear a register fast clear without waiting for a known key store #6247
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6247"
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 oneandonlydean on 2026-10-15T07:07:17Z.
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/AnyPS5#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)Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-15T10:26:26Z.
agc_pending_key_storesfails onmaine49ec591don Linux (Ubuntu 24.04, GCC 13.3, Release, RTX 4070 Ti, NVIDIA 595.99), 3 of 3 runs, at the check this PR added:Building each first-parent merge since
042eb7c80: it passes at2848b55b9and fails from2c4574adf(this merge).With a temporary print before that line (not committed),
KnownPendingDccKeys(address, 2 * surfaceBytes)returnsDccKeys::Mixed(keyCount 256), notstd::nullopt. ReadingPendingStoreKeys, no memo store covers the wider range, so it falls through toKeysAfterPendingWrites, which sees the pending 0001 fill in the first 256 bytes and different bytes after it, and returnsMixed. InmaterializeRegisterClearthat still compares unequal toClearRegister, so the draw path looks unaffected. Only the test's!has_value()expectation trips.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