perf(agc): prove an untracked snapshot once per collect epoch instead of walking its template #15529
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15529"
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 Nesyth on 2026-11-03T17:46:50Z.
What
With #14262 a fast proof takes a surface outside the write watch by its stamp until the next ordering point. In Grand Theft Auto V (PPSA04264) the sampled textures left outside the watch sit in shared section views: pages the game maps twice, and resident pages that a joined host import aliased (#15454 fixes the second kind). Windows cannot write-watch such views, and they carry no hint. Their stamp moves at every collect epoch, so after each ordering point the proof refuses (
FastFail::Collect) and the whole template takes the full walk, whose lookups compare every such snapshot again. This PR proves each snapshot once per collect epoch instead. The texture cache entry keeps the stamp its snapshot was last read or compared equal behind. A lookup or a proof under that stamp takes the snapshot without comparing, and a proof whose stamp moved compares the one snapshot instead of walking the template. The bound is the oneStorageTexture::compareUntrackedalready gives storage images: a CPU store into unwatched memory is seen at the next ordering point. In Grand Theft Auto V the frame p50 drops from 61.3 to 49.1 ms.ForgetStamp), no depth surface at the base, and no recorded GPU write or pending storage image over the surface. Its flush hook can store into other surfaces, so the proof then runs once more without compares.APS5_NO_UNTRACKED_REPROOF=1restores the old behaviour. UnderAPS5_VERIFY_UNTRACKED_PROOFS=1the lookups compare every such snapshot, so the verifying walk checks each proof against the bytes.maininto it; the two conflicts were the member list inShaderResources.hppand the WIN32 test list.cachedTexture(the snapshot hit and the snapshot read); the conflicts are textual. #11444 refuses a sampled surface whose memory became a depth target in every proof; the depth check here covers only the reproof.Tested
Windows 11 Pro 26300, Radeon RX 7900 XTX (AMD Software 26.10.1), Ryzen 7 7800X3D, Release, MinGW-w64 GCC 15.2.
agc_untracked_reproof,agc_untracked_reproof_disabledandagc_untracked_reproof_verifiedpass, and fail without theForgetStampguard or the verify bypass.^agc_suite, 1314 tests, fails the same three tests on this branch and on its base:agc_driver_direct_write_completion,agc_driver_sample_order_grid_referenceandagc_driver_store_over_untracked.agc_driver_sample_multisample_targetfailed once under-j6and passes alone on both.APS5_VERIFY_UNTRACKED_PROOFS=1in Grand Theft Auto V checked 500,000 fast proofs over untracked memory against the full walk: 0 disagreed.Grand Theft Auto V, Performance graphics mode, gameplay of the opening level, same machine, warm caches, no profiling:
main+ #14262d4dbfc54e7Trace digests
The two traces behind the summary lines above: aps5-trace-d4dbfc54e701-10824.json.gz (main) and aps5-trace-55169d3363e0-43064.json.gz (with the change).
tools/trace_digest.py, main (d4dbfc54e7)seconds 150:30 from present 4074: 489 presents, frame p50 61.3 / p90 62.7 / p99 66.1 / max 74.0 ms, GPU busy 29.6 ms per present
AMD Radeon RX 7900 XTX, AMD proprietary driver 26.10.1 (LLPC), Windows 10.0.26300, 3840x2160, commit
d4dbfc54e7, dropped: yesIncomplete trace: recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately.
Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): batch 29.6, Graphics.Draw 19.8, Graphics.Draw.draw_and_resource_release 18.0, Driver.Packet 10.7, VideoOut.Flip 10.2, Driver.Present 10.1, VideoOut.Flip.present 10.0, Driver.Packet.draw 8.4, Driver.Draw 8.3, Driver.Present.acquire_image 7.2
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
tools/trace_digest.py, with the change (55169d3363)seconds 150:30 from present 4349: 610 presents, frame p50 49.1 / p90 50.8 / p99 53.0 / max 56.8 ms, GPU busy 22.3 ms per present
AMD Radeon RX 7900 XTX, AMD proprietary driver 26.10.1 (LLPC), Windows 10.0.26300, 3840x2160, commit
55169d3363, dropped: yesIncomplete trace: recorded data was lost. Slice-based timings, waits and batch inventories cover retained events only; missing slices are not idle time. Summary statistics are reported separately.
Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): batch 22.3, Graphics.Draw 11.9, Graphics.Draw.draw_and_resource_release 10.3, VideoOut.Flip 6.7, Driver.Present 6.6, VideoOut.Flip.present 6.6, Driver.Packet 6.6, Driver.Packet.draw 4.9, Driver.Draw 4.9, Driver.Present.acquire_image 4.3
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T18:14:15Z.
Review: APPROVED
Reviewed — approved
The per-epoch reproof of untracked sampled snapshots builds and passes its five focused tests in all three modes. It adds no new
VUID-lines, and its tests fail when the new guards are mutated away. I found nothing blocking.What I ran
Head
55169d3363e016f5d01c560849673bd9205d0c8a,main1e658521a0a599872612bb91949311e2956b5283, merged with--no-ffin a clean worktree. Machine: Debian 13 VM, 2× Xeon Gold 6136 (32 vCPU), GCC 14.2.0, Release, Vulkan on lavapipe (Mesa 26.1.6, LLVM 19).The prepared run also covers the selected suite (2225 tests) and the Khronos-validation comparison with
main.Results
git diff --checkcheck_conventions.pylibsagc_driver_division, the denormal-mode tests,vector_constant_factor_tininess, one unwrap test) also fail onmain. 114 skips, all expectedagc_untracked_forget,agc_untracked_revalidate,agc_untracked_reproof,agc_untracked_reproof_disabled,agc_untracked_reproof_verifiedoklineVUID-lines compared withmainExcerpt of
ctest -VNegative control
main(GuestMemory.hpp/.cpp,ShaderResources.hpp/.cpp,Texture.cpp): the test executable no longer compiles ('UntrackedReproofCounts' is not a member of 'AgcDriver::Graphics::ShaderResources'). The new tests depend on the new API, so I ran three targeted mutations instead.ForgetStampguard removed (&& surface.untracked[2] == stamp[2]dropped from the reproof condition):agc_untracked_reproofandagc_untracked_reproof_verifiedfail with an uncaughtruntime_errorfromRequire. The other three pass. This confirms the description's claim about the guard.fastRevalidate(reprovableforced tofalse):agc_untracked_reproofandagc_untracked_reproof_verifiedfail._disabledstill passes, as it should.Texture.cpprestored frommain(the stamp goes back to the globalForgetSerial):agc_untracked_forgetfails with "forgetting memory the surface does not cover made its refresh compare again".After the controls I restored the merged files and rebuilt.
git status --porcelainwas empty and all 5 tests passed again.Findings
Blocking
None.
Non-blocking
46afd87d…b4cd566a), which are not inmain. Merging this PR therefore merges #14262 too. The PR declares this on itsDepends online. Only55169d33is this PR's own change (+231/−11 over 6 files). Reviewers of #14262 should know that its code (ForgetStamp,untrackedRangeStamp, theAPS5_VERIFY_UNTRACKED_PROOFSblock) is reviewed here as well. I suggest landing #14262 first, then rebasing this PR so its diff is only the reproof.fastRevalidatetwice, so its profiling counters count twice. After the compares,fastRevalidatecalls itself withcompares = false(core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp:3630-3642in the merged tree, L3596-L3608 at head). Both passes bump the profiling counters:countKeysProven(lines 3539 and 3546) andserialSkips(line 3626). With a reproof, the[revalidate]counts therefore overstate keys proven and serial skips. Correctness is not affected. A fix is to skip the counting on the second pass, for example whencomparesis false.main+ #14262, notmain. The baseline summary line is fromd4dbfc54e7(the merge ofmaininto #14262), not frommain. Given the declared dependency, this isolates the commit's own effect, which is fair. It also means the 61.3 → 49.1 ms frame p50 says nothing about #14262's own share. The JSON lines reporttrace_dropped: truewithevents_lostin the hundreds of thousands on both runs, so the per-phase numbers are partial. The frame-time and present counts are not affected.Not verified
CollectEpoch()is a per-thread slot. A cache entry'sprovedstamp written by one thread can match the stamp of a thread whose epoch is older. Epoch values are globally unique, so equal stamps mean the same epoch, and the storage-image memo (compareUntracked) already relies on the same per-thread epoch. Still, I did not check whether a thread that handles work after an ordering point always adopts the latest epoch before it looks up textures.docs/dev/ARCHITECTURE.md), matching the storage-image bound. I did not test it against a title.^agc_suite. I relied on the prepared selected run.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T18:58:51Z.
Review: APPROVED
Re-checked — approved
Since my last review, commit
e953f6607fkeeps the second, compare-free pass offastRevalidatefrom counting its profiling counters again, and adds a debt entry for the bound that reuses unwatched sampled snapshots for one collect epoch. The checks and the five focused tests pass, and nothing blocking is left.What changed since my last review
e953f6607f. The nine earlier commits are the same (delta.patch).ShaderResources.cpp, every success-path profiling counter infastRevalidateis now guarded bycompares. That coverscountKeysProven(all three calls),ownSourceViews,refreshedOverlapsandserialSkips.docs/dev/debt/libSceAgcDriver.mdgets a new entry. Sampled snapshots over unwatched memory with no hint are reused for one collect epoch, by the texture lookups and by the fast proofs.APS5_NO_UNTRACKED_REPROOF=1restores the compare on every lookup.mainonce #14262 lands.What I ran
Head
e953f6607f4a2b5f14bb478780fc18b1a1235029,main1e658521a0a599872612bb91949311e2956b5283, merged with--no-ff(merged tree39117bbd290a9bc08d12dffb0fde3db8b82af5df) in a clean worktree. Machine: Debian 13 VM, 2× Xeon Gold 6136, GCC 14.2.0, Release, lavapipe (Mesa 26.1.6, LLVM 19).git diff --checkcheck_conventions.pylibs(prepared run)main. 114 skips, all expected^agc_untracked(5 tests)VUID-linesNegative control: the test files did not change in this push. The new commit only changes profiling counters and docs, so the mutations from my last review still apply and I did not run them again.
Previous findings
compares(ShaderResources.cpp:3539,:3546,:3581,:3604,:3615,:3625). The recursive call at:3641passescompares = false.:3630-3642), so a reproved proof counts each success counter once.fail→countFastFail,countCollectRefusal,depthGuardRefusals) still count in the second pass. A failure there is the proof's only failure, so this is correct, as the author says.main+ #14262: No longer applies. The declared dependency makes this baseline the right one to isolate this change. Nothing needs to change.DrawPipeline::FollowEpochis called from the draw and dispatch paths (Draw.cpp:747,:1205,:1274,Dispatch.cpp:521).AdoptLatestCollectEpochis called fromVulkanDevice.cpp:3601.New findings
Blocking
None.
Non-blocking
None. The new debt entry states the gap first, names the code and the opt-out, and covers what oneandonlydean asked for.
Not verified
^agc_suite; I relied on the prepared run of the selected tests.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T22:09:25Z.
Review: APPROVED
Re-checked — approved
The only new commit is
f57412c6e1, which mergesmaininto the branch. The PR's own changes are the same as ate953f6607f, apart from the merge of one test-property line, which keepsmain's new test. The checks and the five focused tests pass, and nothing blocking is left.What changed since my last review
f57412c6e1(Merge main into perf/agc-untracked-snapshot-reproof). The ten earlier commits are the same (delta.patch).core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake. There,mainhad addedagc_recorder_stored_bytesto the sharedset_tests_properties(... ENVIRONMENT_MODIFICATION ...)list, and the merge keeps it beside the fiveagc_untracked_*tests. That is the correct resolution.What I ran
Head
f57412c6e102361fc70ab69316b51fb9e7a79cac,main04a9eb4fa2877eb6e40bf2c83adf972e40d89b24, merged with--no-ff(merged treea1a697b9824eda52c4fa0fe0ed51752c1a3ad1b2) in a clean worktree. Machine: Debian 13 VM, 2× Xeon Gold 6136, GCC 14.2.0, Release, lavapipe (Mesa 26.1.6, LLVM 19).git diff --checkcheck_conventions.pylibs(prepared run)main. 115 skips, all expected^agc_untracked(5 tests)VUID-VkSamplerCreateInfo-addressMode*lines inagc_driver_image_gather_volumecome frommain(see below)git status --porcelainis emptyagc_driver_image_gather_volume: this test (ImageGatherVolume.cpp, added byf75385c1a2) is not in the baseline commit1e658521a0, so the prepared comparison marked it "test not run on main". I restored the PR's five production files frommainand ran it with the validation layer. It reports the same fourVUID-VkSamplerCreateInfo-addressModeU-01079/addressMode{U,V,W}-parameterIDs, so they are not this PR's. They come frommain.Negative control: the tests did not change in this push. With the production files restored from
main,agc_driver_recorder_testsno longer compiles, becauseRecorder.cpp:6407usesShaderResources::UntrackedReproofCounts. So the new tests cannot pass without the change. The behavioural mutations from my earlier reviews still apply.Previous findings
e953f6607f. The merge leavesShaderResources.cppthe same as in the PR's earlier net diff.New findings
Blocking
None.
Non-blocking
None.
Not verified
^agc_suite. I relied on the prepared run of the selected tests.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T04:17:58Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing in the inspected code shows a verified blocking defect; this review is incomplete because I did not read all of the changed test file or run checks.
What I ran
Reviewed head
0a021791668ab1e452609c6a547a281550fcaac5. I used the prepared diff andrepo_read.pyto inspect changed code and relevant context. No commands or tests were run.Results
Findings
Blocking
None verified in the inspected code.
Non-blocking
None.
Not verified
I read
ShaderResources.hpp, selected relevant portions ofShaderResources.cpp, selected test-registration lines inagc_driver_recorder_tests.cmake, and the changed sections ofARCHITECTURE.md,ENVIRONMENT.md, anddebt/libSceAgcDriver.md. I did not read all oftests/Recorder.cpp, or run the reported tests or performance checks. The full text ofShaderResources.cppandtests/Recorder.cppwas excluded from the prepared review folder; I read selected ranges throughrepo_read.py.To get this to a good state
Nothing is required. The optional follow-up is to inspect the remaining changed test code and run the reported checks.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T14:05:53Z.
Review: COMMENTED
Reviewed — comments
The core change is partially reviewed; the remaining changed files and full test changes were not inspected, so a formal decision is not justified.
What I ran
No commands or tests were run. I read the supplied review description, commit list, manifest, and diff, then inspected the changed
fastRevalidateimplementation at the pinned head.Results
Findings
Blocking
None identified in the inspected code.
Non-blocking
None.
Not verified
I did not read all changed files. The full
ShaderResources.cppandRecorder.cpptexts were excluded from the review folder; I read only the relevantfastRevalidaterange and part of the test diff. I did not inspect the changed header, the remaining test changes, the CMake test list, or the three documentation changes. The description reports tests and performance measurements, but I did not run or independently verify them.To get this to a good state
Nothing is required. Optional: complete review of the changed files not inspected above before making a formal decision.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T20:18:19Z.
Review: COMMENTED
Actionable comments
b8165fd8-b737-401a-935c-8305fa67b9a7Reviewing files that changed from the base of the PR and between
d2e04ef9b3and244fb62f95.core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmakedocs/dev/ARCHITECTURE.mddocs/dev/ENVIRONMENT.mddocs/dev/debt/libSceAgcDriver.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:41:02Z.
Review: COMMENTED
The trial merge onto
c1601e56d5was clean. I checked the stamp hit, single-snapshot reproof, and full walk after the compared bytes change. Keep the verification-mode and write-index cases alongside the full-walk control, because they reach the untracked texture through different paths. The documentation acknowledges that an intra-epoch CPU store may first show at the next epoch. Please put the direct AGC debt edit in a fragment. Paired recorder validation is pending.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T22:57:57Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes at head
244fb62f951212aaa2ed99f2960bd7ada7353684show no verified blocking defects.What I ran
Reviewed the prepared diff and all seven changed files’ added lines, using targeted source context from
repo_read.py. No tests, builds, or merged-preview checks were run; no compiler or toolchain was invoked.Results
Negative control
Not run by the reviewer. The description reports that targeted tests fail without the
ForgetStampguard or verification bypass.Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
Tests and performance measurements were author-reported, not independently run. Physical-console behavior and the supplied performance traces were not independently verified. All seven files in
files.jsonunderreviewedwere read; none were excluded.To get this to a good state
Nothing is required.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.