perf(agc): keep an untracked fast proof across collect epochs on Windows while its write-watch hint has not moved #12921
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12921"
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 EagleBearerYS on 2026-10-29T14:23:15Z.
What
Windows only in effect. Write-watch hints exist only on Windows (
GuestMemory::UntrackedHintreturns 0 on other platforms), so on Linux this changes nothing: every untracked proof keeps #6192's epoch stamp.#6192 lets a fast revalidation over untracked memory accept a surface by its stamp until the next ordering point: the stamp is
{collect epoch, NewestStamp, ForgetStamp, write note}. In Resident Evil Village (PPSA01556)'s static menu, collect epochs advance about 80 times a second, so most of those proofs expire before they're reused, and the next one walks the full table again.On Windows, an unwatched range has a write-watch hint (
GuestMemory::UntrackedHint), and a store into it moves the hint at the next walk of that page's marks. The check runs that walk itself:UntrackedHintreads and resets the range's marks (walkHints) unless this thread already walked the range in the current collect epoch. This change keeps a proof across epochs while the hint hasn't moved.{hint, NewestStamp, ForgetStamp, write note, 1}. Every field is taken just before the bytes the proof stands on are read or compared, not when the proof is captured:untrackedKey, carried in the lookup record (LookupRecord::untracked);StorageTexture::compareUntracked, throughStorageTexture::HintedComparison.NewestStamp, a forget movesForgetStamp, and a new recorded GPU write moves the note. So at the next ordering point the check walks again.APS5_VERIFY_UNTRACKED_PROOFS=1still cross-checks every fast proof that used an untracked stamp, hinted or epoch, with the full walk.The branch. It holds #6192's four commits unchanged (with #6187 under them), then four of ours:
main. #6192 conflicts with current main inTexture.cpp(main's per-rangecomparedRangesmemo kept, with #6187'sForgetStampin place ofForgetSerial),ShaderResources.cpp(main'sLastRecordIndices,GenerationForand depth guard kept, with the untracked stamps added) andCMakeLists.txt(the Windows test list).ENVIRONMENT.mdrow forAPS5_VERIFY_UNTRACKED_PROOFS, which main's conventions check requires.agc_untracked_forget's teardown fix, offered on #6187: the test freed its detiler while a recorded dispatch still used its pipeline, which crashed lavapipe's queue thread. It's test-only.Overlap: checked with
git merge-treeagainst each pull request the overlap comment lists, at headfdc70046f8.main: the same four commits of TheAggie's, rebased and kept under TheAggie's name, with oneandonlydean's test fixes. This PR carries the original commits. Once #14262 lands, this PR's next merge ofmaintakes their changes frommain, and this PR's diff is then only its hinted stamp.GuestSnapshots()where this PR addsHintedComparison(), inTexture.hppandTexture.cpp. The clash is textual only: whichever lands second keeps both.cachedTexture's sampled-cache hit branch as a per-entry check. This PR adds one argument in that branch: the untracked proof's key, passed tologLookup. QRMOE agreed in #12575's thread that this PR goes first, and carries itslogLookupargument into the per-entry form when #12575 is rebased (comment).CMakeLists.txt), and #10894 (ShaderResources.cpp), conflict with #6192's commits, which this PR carries. The conflicting hunks are the same with #6192's head merged withmain, and this PR's own lines don't touch them, so their order follows #6192's. #11550 has merged, and31dff937b5merges it (Tested).DepthSurface's HTILE clear check of untracked memory on the sameUntrackedHint. It's a different consumer of the same hint.Resident Evil Village (PPSA01556)
Static menu, one block of four unprofiled runs, B A A B.
main319621ba2eplus #11580 and #10304, with a localscePadOpenanswer for port types 3 and 4 (103015a9ca). B is the same tree plus #6192's four commits and this PR's commit (24b56bc1b4: the same added and removed lines as this head, apart from theagc_untracked_forgetteardown fix, which only changes a test). So the pair measures #6192 and this PR together; #6192 alone wasn't run.APS5_LAZY_SHADER_PREPARE=1 APS5_NO_GPL=1 APS5_HOST_IMPORT_MIB=6400 APS5_TRACE_SUMMARY_EVERY=10, with scripted pad input. The change has no switch, so nothing else differs.Driver.Packet3,926 / 3,368 against 4,944 / 4,253, about 21 % lower.Driver.Packet.memory_wait2,277 / 1,943 against 2,898 / 2,482.Graphics.Draw782 / 689 against 1,056 / 907.APS5_PROFILE_DRAW=1; menu +10..15, 31 ten-second[rescache]blocks):APS5_VERIFY_UNTRACKED_PROOFS=1, so its revalidation time includes the self-check's extra full walks.diag/village-combined-on-103015a9cac9cff8c839, the A tree above plus #12478, #12745 and #12921, run withAPS5_TABLE_INDEX=1.Driver.Packetper frame: 3,822 and 3,568 ms against 5,187 and 5,301 ms.memory_wait: 2,199 and 2,032 ms against 3,090 and 3,167 ms.APS5_TABLE_INDEX=1:agc_untracked_revalidateandagc_untracked_hint_proof, expect a full walk after a collect epoch. The index proves those draws by looking the elements up again, which re-reads the memory, so the content still follows every store.test/untracked-proof-index-on-12745, for #12745 if #12921 lands first;test/untracked-proof-index-on-12921, for #12921 if #12745 lands first.ctest -R '^agc'gives 1,048 passed, 73 skipped and 0 failed in both modes.Summary lines at menu +10 of the first B and A runs (B 07f624d854, A 103015a9ca). Each row is one 10 s interval, so its frame times aren't the window's figures above.
APS5_TRACE_SECONDS=960:30and no other trace or profile switch:16eab88b27f0843a5aa46433a83dbb69cc1fd960ff2a521acade7d20b52fb809;bb08a9ac103f778937429c3ead8343ed6b3e87b6abf7bc7ff8c471b125913f0b.trace_digest.py of A (103015a9ca)
seconds 960:30 from present 2901: 21 presents, frame p50 1497.6 / p90 1783.2 / p99 1903.7 / max 1903.7 ms, GPU busy 230.6 ms per present
NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 3840x2160, commit 103015a9ca66, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 4250.6, Driver.Packet.memory_wait 2505.1, Driver.WorkerWait 1594.9, Driver.WorkerWait.dequeue_order 1338.7, Driver.Packet.draw 1155.6, Driver.Draw 1154.5, Graphics.Draw 927.6, Graphics.Draw.draw_and_resource_release 906.3, Driver.Packet.dispatch 559.1, Driver.Dispatch 508.7
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
trace_digest.py of B (07f624d854)
seconds 960:30 from present 1815: 19 presents, frame p50 1438.8 / p90 2203.1 / p99 2511.8 / max 2511.8 ms, GPU busy 255.7 ms per present
NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 3840x2160, commit 07f624d854fb, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 4184.1, Driver.Packet.memory_wait 2410.1, Driver.WorkerWait 1639.1, Driver.WorkerWait.dequeue_order 1381.6, Driver.Packet.draw 1090.9, Driver.Draw 1089.8, Graphics.Draw 809.3, Graphics.Draw.draw_and_resource_release 787.9, Driver.Packet.dispatch 648.6, Driver.Dispatch 594.5
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Grand Theft Auto V (PPSA04263), by @chitters2004
On Windows 11, a Ryzen 7 5800X and an RTX 3080 (driver 621.01), with the same machine, scene and save in both arms.
e8efeed58a+ #11580, sincemainstops at Story load. The change merges23ef222060into it, so it adds #6192's four commits and this PR's together.APS5_PROFILE_DRAW=1,Revalidatefull walks refused bycollectfell from 3,380 to 1,530 ms per 10 s.untrackedRangeStamp's hinted branch is removed, so every proof takes #6192's epoch stamp. Two runs each, alternating, with no crashes.collectrefusals per 10 s are on plain sampled snapshots recorded with the epoch stamp.GuestArenaCollectWritesrefuses their ranges: in one 10 s sample, all 19,091 refusals came fromcollectable, on direct-memory pages markedcomparedWhenShared. SowalkHintsfails andUntrackedHintreturns 0. This is the shared-pages case under What's "Unhinted ranges".main52c09d567d+ #11580 + #6192 against the same plus this PR, three runs each.APS5_VERIFY_UNTRACKED_PROOFS=1 APS5_VERIFY_PROOFS=1) compared 300,000 fast proofs with the full walk, with 0 disagreements.Grand Theft Auto V (PPSA04264), by @Nesyth
Windows 11 Pro 26300, a Radeon RX 7900 XTX (AMD Software 26.10.1), a Ryzen 7 7800X3D, 3840x2160 output. Version 01.011.001 in the Performance graphics mode, gameplay of the opening level with warm caches (comment). The arms are
main9090972b7eand the same commit with this PR's head793fc7f8eamerged, so the second carries #6192's four commits as well as this PR's. Each run is a separate boot, and FPS is the window title's counter over 57 s of scripted gameplay.main, against 17.32 and 18.70 with the change (+20 to +29 %). WithAPS5_PROFILE_DRAW=1: 12.78 and 13.56, against 15.60 and 16.36.main). Draw commit: 39.9 and 37.6 µs, against 31.3 and 30.3 µs. Collect full walks: 3.83 and 3.58 s per 10 s, against 2.42 and 2.22 s. Collect refusals per 10 s: 50,181 over 163 surfaces and 41,172 over 125, against 30,269 over 120 and 30,118 over 119. Every remaining refusal is counted as unwatched.mainwith #6192 and this PR together, so it doesn't separate their shares. On the Story save above, the split put the gain on #6192.Tested
agc_untracked_hint_proof(new), with two sampled 64 KiB surfaces over write-watched, host-imported, then unwatched memory:MarkWrittendriver store; a recorded GPU write note, before and after the write is reaped; and a CPU store made after the hint is sampled but before the stamp is recorded, through a flush hook.settlere-proves the stamps after each one. No case asserts a throw.agc_untracked_hint_proof,agc_untracked_revalidateandagc_untracked_forgetpassed 10 of 10 each.agc_untracked_hint_proof,agc_untracked_revalidateandagc_untracked_forgetpassed 20 of 20 each. Linux has no hints, so the new test runs there under the epoch rule and checks that nothing changes.ctest -R '^agc' --parallel 4: 1,119 tests: 1,046 passed, 73 skipped, 0 failed.agc_untracked_forgetcrashes on lavapipe 20 of 20 times.check_conventions.pyandcheck_test_registration.pypass. MinGW-w64-fsyntax-onlyadds no errors or warnings tomain's. Nothing undercore/shader/**changes, so the shader cache key is unchanged.mainplus the teardown fix (e440b742c3), so it differs from this head only by the hint key.agc_untracked_hint_proof,agc_untracked_revalidateandagc_untracked_forgetpassed 10 of 10 under validation.^agcunder validation: 1,119 run, 73 skipped, 1 failed. The failure isagc_driver_image_table, whose only validation message isVUID-VkDeviceCreateInfo-pNext-pNextfromvkCreateDevice("unknown VkStructureType (1000574000) ... version 275 of the Vulkan header"). That's the runner's validation layer being older than the headers. The comparison arm fails that test the same way, and the change adds no VUID.APS5_SKIP_TIMING_TESTS=1, pass: 191 and 291 on Linux, 220 and 314 on Windows.agc_driver_image_tablewithout the validation layer (run 40890382693) passes on both sides. On Linux, it ran with the branch's 78 tests: 71 passed, 7 skipped, 0 failed. On Windows, 94 ran, 4 passed and 90 skipped, since the runner has no device. The suites match the run above.31dff937b5, a merge ofmain673fa865f4, which brings johandavidcm's #11550 (run).fastRevalidate, in lines #6192 changes. #11550 counts each collect refusal withcountCollectRefusal, and #6192 lets an untracked surface whose stamp still matches pass instead of refusing.countCollectRefusalnow sits inside #6192's stamp check, just beforereturn fail(FastFail::Collect). So only collects that are still refused are counted, and an untracked surface its stamp proves isn't.agc_driver_resource_cache_collect_refusals; the untracked-proof testsagc_untracked_revalidate,agc_untracked_forgetandagc_untracked_hint_proof;agc_write_tracking; and the^agc_driver_image_tabletests, with the tests for the files the merge changes.APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.2b74a6c5d5, cross-thread cases (test-only).agc_untracked_hint_proofgains three cases:agc_write_trackinggains a device-free case on Windows:agc_untracked_hint_proof,agc_untracked_revalidate,agc_untracked_forgetandagc_write_trackingpass 10 of 10 each.agc_write_trackingalone passes 20 of 20.agc_write_tracking's device-free cases run there.APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.UntrackedHintmemo made to ignore the collect epoch (a measurement branch, not part of this PR):agc_write_trackingfails with "the last store of a racing thread did not move the hint past every value read before it", andagc_untracked_hint_prooffails at its existing step, "a CPU store after a collect epoch kept the fast proof".agc_write_trackingwith the same message, andagc_untracked_hint_proofskips there. Linux passes: it has no write-watch hints, so its ranges keep the epoch stamp.23ef222060, a merge ofmain8304ccaedb(run).CMakeLists.txt, the WindowsENVIRONMENT_MODIFICATIONtest list, where #9565 addsagc_recorder_command_buffer_release. The resolution is the union of both sides' names, each once.^agc_untracked_tests,agc_write_tracking,agc_driver_recorderand main'sagc_recorder_command_buffer_release.APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.8bee4cadbf, a merge ofmain0836dfdf4f(run). #12862 movedlibSceAgcDriver's test registrations intotests/cmake/; the conflict inCMakeLists.txtis resolved withtools/agc_test_split.py resolve, which moves this PR's registrations intotests/cmake/agc_driver_recorder_tests.cmake(+7 −1). Nothing else conflicted. Apart from the move, this PR's diff is unchanged. With-DBUILD_TESTING=ON,ctest -Ngives 3078 tests:main's 3075 plus its 3 tests, each listed once.agc_driver_recorder,agc_recorder_command_buffer_release,agc_untracked_forget,agc_untracked_hint_proof,agc_untracked_revalidate,agc_write_trackingpass 10 runs in a row. Linux: 6 run, 6 pass, 0 skip, 0 fail. Windows: 6 run, 1 pass, 5 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (199 and 308) and on Windows (226 and 330). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.793fc7f8ea, the untracked proof tests report a skip when they can't run, for oneandonlydean's review (test-only,tests/Recorder.cpp).untrackedForgetTests,untrackedRevalidateTestsanduntrackedHintProofTestsreturnfalseat each of their 10 early outs andtrueat the end, and their--untracked-*-onlybranches return? 0 : 77, asSKIP_RETURN_CODE 77expects.APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.793fc7f8ea, from TechLevelZero's AMD bot (report): this head merged ontomain291e02d, Ubuntu 26.04.1, 2,540 of 3,155 tests selected.main.VK_LAYER_KHRONOS_validation, no new validation IDs over 934 GPU tests.agc_untracked_forget,agc_untracked_revalidateandagc_untracked_hint_proofpassed on the GPU, so they ran in full there, since this head reports 77 when they can't. They aren't inmain's baseline, so their validation wasn't compared.793fc7f8ea, from TechLevelZero's NVIDIA bot (report): this head merged ontomaine6f5730, driver 595.99.02, Ubuntu 26.04.1, 2,535 of 3,148 tests selected.main, and 3 are unstable onmain.VK_LAYER_KHRONOS_validation, no new validation IDs over 934 GPU tests. The threeagc_untracked_*tests passed on the GPU, so they ran in full there too. They aren't inmain's baseline, so their validation wasn't compared.38dc520c3f, oneandonlydean's merge ofmainf6232fcfda. It resolves the conflicts inShaderResources.hppandtests/cmake/agc_driver_recorder_tests.cmake. This PR's own lines are unchanged. The only difference in its diff is the WindowsENVIRONMENT_MODIFICATIONlist line, which now carries main'sagc_window_import_unmap.38dc520c3f, from TechLevelZero's NVIDIA bot (report): this head merged ontomainf6232fc, driver 595.99.02, Ubuntu 26.04.1, 2,795 of 3,743 tests selected. 2,740 passed, 6 failed and 49 skipped. None of the failures is new: 3 also fail onmain, and 3 are unstable onmain. WithVK_LAYER_KHRONOS_validation, no new validation IDs over 937 GPU tests.8468301cdd, a merge ofmain4f41f4c375(run).Texture.hpp,main's newOccasionalLabelStoresdeclaration and this PR'sHintedComparisondeclaration are adjacent, and both stay. Intests/cmake/agc_driver_recorder_tests.cmake, the WindowsENVIRONMENT_MODIFICATIONlist, wheremainaddsagc_changed_copy, the resolution is the union of both sides' names, each once. This PR's own lines are unchanged, and that list line is the only difference in its diff.agc_changed_copy,agc_recorder_read_listand every test matching^agc_untrackedor^guest_memory. Linux: 9 run, 9 pass, 0 skip, 0 fail. Windows: 8 run, 3 pass, 5 skip (no Vulkan device), 0 fail. The libc and libkernel suites run 300 and 322 tests on Linux and 327 and 342 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.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)Graphics/src/ShaderResources.cppand conflict there, and this PR takes the second merge with the test-only update ontest/untracked-proof-index-on-12921Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-29T18:51:38Z.
Review: COMMENTED
The measurement does not isolate this change, and the fast path it extends gets more expensive per proof. Neither point is addressed in the description.
1. The +29.9 % is #6192 plus this PR. The description says so: "#6192 alone wasn't run". The branch carries #6192's four commits, #6187 under them, and a merge of
main, so an unrelated diff of about 450 lines is reviewed as one PR. The arms are 4 runs of 0.51–0.83 fps with a 19–25 % spread inside each arm. B ahead of A by 30 % on two runs per arm is not distinguishable from the spread. The only independent run so far is chitters2004's GTA V one above (12.60 vs 12.31 fps, inside the noise), and it says the fast-fails there are on ranges with no hint, where this change does not apply. Please runmain+ #6192 againstmain+ #6192 + this PR on the Village menu, same machine and scene, withtools/trace_digest.pysummaries of both. That is the only comparison that measures this PR.2. The proof now does more work per surface. For an untracked surface,
currentUntrackedStampcallshintedProof:UntrackedHint,NewestStamp,ForgetStampandNewestWriteNote.ForgetStamp, which this branch carries from #6192, loops over every 64 KiB block of the range with an acquire load per block. A 3840x2160 RGBA16F target is about 66 MB, which is about 1,000 loads per call, per surface, per proof. GTA shows about 135k fast proofs per 10 s, and each proof can hold several untracked surfaces. The fast path exists because it is cheaper than the full walk; with #6192's loop it costs O(range size) per surface instead of O(1). Keep a single global counter that the forget path bumps, and use the per-block slots only when that counter has moved. Or show the proof cost in the trace.3. Correctness depends on the hint being up to date. The description says "a store into it moves the hint at the next walk of that page's marks". Between two ordering points no walk happens, so a CPU store after the compare is only visible if something walks those marks before the next check. Please say what guarantees a walk between the compare and the next check on a surface nobody reads through
CollectWrites.APS5_VERIFY_UNTRACKED_PROOFScovers the runs listed, but a title that rewrites an untracked surface once per frame from the CPU would show a stale texture instead of a slow frame. The new test would need a case that stores into the range from another thread right after the compare.4. Smaller points.
APS5_PROFILE_DRAW=1. The Performance report form does not accept those for a speed claim. They are fine as explanation, but the claim needs theaps5-summary.jsonlfigures from item 1.What.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T12:14:31Z.
Review: COMMENTED
Reviewed — comments
On Linux/lavapipe the merge is clean, it builds, the checks pass, and the three new
agc_untracked_*tests pass here and fail onmain's production code. Two limits: the PR's own hinted stamp only runs on Windows, so this machine can't exercise it, and theAPS5_VERIFY_UNTRACKED_PROOFSself-check cannot detect a stale view or storage image.What I ran
Head
8468301cddcc8d5ba3992077b94084c449293b1f,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree5ae2065315ccc0445f9f5092dfbd6ec1d619d5ce. Debian 13 VM (Xeon Gold 6136), GCC 14.2.0, Release, lavapipe (Mesa 26.1.6, LLVM 19).Results
git diff --checkcheck_conventions.pymainagc_untracked_forget,agc_untracked_revalidate,agc_untracked_hint_proof,agc_write_trackingagc_driver_native_depth_uniform_planesd1ae628bc2), so the script had nomainresult to compare with. Withmain's production files I get the same 4 ×VUID-vkCmdDispatch-groupCountX-00386. The test passes in both.layer_missing_inis emptyuniform_planes with main's production files
Negative control
I restored only the six production files from
mainand rebuilt. All three new tests fail:output
These failures come from #6192's in-epoch part, which this branch carries. On Linux,
UntrackedHintreturns 0, soagc_untracked_hint_prooftakes its "no hint" branch. The hinted stamp this PR adds (untrackedRangeStamp'shinted[0] != 0branch,HintedComparison, the hintedproofKey) never runs on this machine, and this control does not cover it. The red/green for that path is the author's RTX 3070 run on Windows. I restored the merged files afterwards;git status --porcelainis empty.Findings
Blocking
None.
Non-blocking
APS5_VERIFY_UNTRACKED_PROOFScan't detect a stale view or storage image. The check is atcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp:3880. It counts a disagreement only whenfullWalk()returns false.fullWalkcompares only pointer identity:cachedTexture(...) != textures[textureIndex]atShaderResources.cpp:3806andexpected != storageTextures[storageIndex]atShaderResources.cpp:3817.HintedComparison). The "0 disagreed" figures (38,000 in Village, 300,000 in GTA V) are therefore evidence only for snapshots.validatedTextures[i].sourceandstorageTextures[i]Version()before the full walk, and also count a disagreement when any of them moves.main+ #6192 againstmain+ #6192 + this PR on the Village menu would show whether this PR's own lines pay off.HintedComparison. It reads the mutable, non-atomiccomparedRangesof aStorageTexturefromcaptureValidation;compareUntrackedwrites that array. Please confirm that both run under the same lock (the GPU mutex) or on the same thread.Not verified
agc_untracked_hint_proof, andCheckUntrackedHintAcrossThreadsinagc_write_tracking(compiled only under_WIN32) from the author's RTX 3070 report.To get this to a good state
HintedComparisonreadscomparedRanges.Pull request closed