perf(agc): accept a refreshed view in the T1 re-run when the lookup would not view the pending alias #11740
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11740"
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 thuanquang on 2026-10-27T06:29:28Z.
What
When
ShaderResources::Revalidate's fast proof finds an image pending over a sampled surface, T1 (refreshOwnObjects) brings the view's own storage image up to date the way the full walk's lookup would, and the fast proof runs again. That re-run accepts the refreshed view only whileScanPending's rawfoundis the view's source or nothing. A pending alias of the surface (same base, size and shape, another format:StorageTexture::pendingAlias) breaks that rule.foundis the alias, butcachedTexturewould not view it (its copy filters drop it), and the refreshed own image has just borrowed the alias's units. So the re-run always fails, and the full walk then returns the same view.In Persona 5 Royal's first gameplay area this happens on every draw over such surfaces: about 24,000-25,000 full walks per 10 s with "T1 fallback: re-run failed" (
APS5_PROFILE_DRAW), on the draw committer, one of the three stages (with the queue worker and the GPU) that bound the frame there.This change makes T1 and its re-run ask the lookup's own question:
cachedTexture's pending-source decision (FindPending, the block, repack, depth-copy and sRGB-expand filters,MetadataMoved) moves into one helper,pendingLookupSource.cachedTexturecalls it with no change in behaviour.refreshViewuses the helper instead ofFindPendingplusCanCopyFromalone, with the element's depth-compare flag taken the way the full walk takes it (sampled bindings and image tables). It records that flag and whether it refreshed the source inPendingOverlap.APS5_VERIFY_PROOFS=1already runs the full walk beside every accepted T1 proof and aborts on another object or an upload. The new test runs under it.Tested
Windows 11 26200, Ryzen 5 5600X, AMD Radeon RX 6700 XT (gfx1031), AMD Windows driver 32.0.21045.16010, WinLibs GCC 15.2.0 r7, Release. Head
9978af5ec7onmainefc24518bc.agc_driver_own_refresh_repack_alias(runs withAPS5_VERIFY_PROOFS=1; skips when the device does not import guest memory). It builds a reusable set over a surface whose view is its own storage image, then stores an 8888 UNorm alias over it twice:mainT1 takes the alias as a foreign view, so this covers T1's filter).GuestMemory::Watched), eachRevalidatemust takeProofPath::OwnRefreshed. Where it doesn't (host imports compared instead of watched, as on the Linux lavapipe runner), the fast proof stops at the write collection onmainas with this change, so the set must only be proved current and keep its view.main'sShaderResources.cpp/.hppthe test fails 3 of 3 at its first case (a set whose view refreshed its own image over a pending 8888 unorm alias took the full walk, not the own-object refresh), and its R32F case run alone fails 3 of 3 the same way. With this change it passes 3 of 3.agc|shadersuite on this head (1,165 tests,--parallel 4): 1,155 pass, 9 skip, 1 fails:agc_driver_sample_order_grid_reference(vkQueueSubmit recorder: Vulkan result -4), which fails the same way onmainefc24518bchere.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1,ctest -V) on the new test andlookup_log_fits_build,cached_image_multisample_guard,sampled_cache_budget(3 entries),storage_one_slice_alias,bc_block_copyanddepth_compare_copy: 9 of 9 pass on this head and the 8 existing ones pass onmainefc24518bc. The loader inserted the layer in every test on both sides, no log haswas not found but was requested, and there is noVUID-line on either side.PPSA05110 (own dump), first gameplay area, measured on the earlier head
c005abb24f(the same production change, onmain88795ed448), standing still after the fixed input route (New Game, opening movie skipped); warm shader and pipeline caches. P5R needs two other changes to reach this scene with a usable frame rate: #10913 (merged since) and #7844 (open; host import budget). So the pair is:6b5543b03d12=main88795ed448+ #10913 + #7844 (fork branchevidence/t1-rerun-p5r-base);1835554de245= base + exactly the earlier head's diff (git diff 6b5543b03d 1835554de2is identical togit diff 88795ed448 c005abb24f; this head has the same production lines, only the test changed;evidence/t1-rerun-p5r-candidate).Counters (separate shared runs with
APS5_PROFILE_DRAW, 10 s intervals in gameplay):T1 fallback: re-run failedRevalidatetime per 10 sAn earlier version of this change (same logic, before the review cleanups and the second test case) ran the scene for 660 s with
APS5_VERIFY_PROOFS=1, which runs the full walk beside every accepted proof: no abort.Timing, rerun on 2026-10-28 as the Performance report form asks: among the trace and profile switches only
APS5_TRACE_SECONDS=560:4, with the default event buffer (the queue worker records about 51,000 slices per second in this scene, so 4 s fit the default 262,144; neither trace dropped events).APS5_TRACE_DIRnames the output folder. The other variables belong to our input driver:APS5_NO_PAD_INPUTandAPS5_PAD_INPUT_FILEfeed the fixed pad route, andAPS5_DUMP_FRAMES=1060withAPS5_DUMP_FRAMES_EVERY=20let it see the screen. In both runs a few dumps (one per 20 frames) still fell inside the window, so both carry the same small read-back cost. The log went to a file through our launcher, as in all our runs. Exclusive GPU and build locks, warm caches, same machine and session, candidate then base back to back (03:26-03:48 local); the HUD was reached at 219 s and 324 s after New Game, and the route never entered the Load screen. A CPU monitor ran beside each run: no game was running; other processes used 12-27 % of the CPU around the windows (background services, VMware host, Steam, the WSL VM of our tools), similar in both.1835554de2456b5543b03d12aps5-summary.jsonl, trace window of each run
Traces and
tools/trace_digest.pyoutput:evidence/t1-rerun-p5r-traces-2on our fork. I listed every key and string value in both traces: 95 distinct strings, all emulator scope, thread or trace-format names; no paths, title text or memory contents.Earlier pair, supplemental only (it also set APS5_TRACE_EVENTS and APS5_TRACE_SUMMARY_EVERY, which the form excludes)
Earlier pair, kept as supplemental data only: it also set
APS5_TRACE_EVENTS=1048576andAPS5_TRACE_SUMMARY_EVERY=10, which the form excludes. Timing of that pair: exclusive GPU and build locks, no other GPU user (sampled during each run), onlyAPS5_TRACE_SUMMARY_EVERY=10andAPS5_TRACE_SECONDS=480:10(plus a frame dump every 20th frame in every run, used to find the gameplay windows by the HUD). Base, then candidate, back to back (02:09-02:30 local), 600 s each.Graphics.Draw, ms per frame6b5543b03d121835554de245"Gameplay windows" are the 10 s summary intervals whose frame dumps show the gameplay HUD. The last four columns come from
tools/trace_digest.pyon each trace.Summary lines of the trace windows:
aps5-summary.jsonl, trace window of each run
Traces:
evidence/t1-rerun-p5r-traceson our fork (aps5-trace-6b5543b03d12-23260.json.gz,aps5-trace-1835554de245-6752.json.gz). They hold only the emulator's scope and thread names, timestamps, durations, host process and thread IDs and thebatch/present/mscounters; I listed every key and string value in both (98 distinct strings, all emulator scope, thread or trace-format names; no paths, title text or memory contents). No trace dropped events.What this shows: the change removes about 88 % of the full walks on the draw committer (24,000-25,000 per 10 s that the re-run refused), and
Revalidatetime drops from 2.02-2.15 to 1.47-1.86 s per 10 s (counter runs above). At the frame level I cannot resolve a difference in this scene: in the pair that follows the form, frame time and committer busy time are the same within the noise of 4 s windows (58 vs 60 presents; committer 44.6 vs 43.6 ms per frame), and the supplemental pair showed a 1.2 ms per frame lower committer busy time with presents 159.7 vs 162.7 per 10 s. In this scene the queue worker (47-51 ms per frame) and the GPU (about 45 ms per present) bound the frame as much as the committer, so a committer saving of this size does not show in frame time.Second vendor, from @Oscar45397 (comment): NVIDIA GeForce RTX 3080, driver 610.88, Windows 11 26200, the same nine validation-layer tests on the earlier head
c005abb24fand the eight onmain88795ed448, two runs per side: all pass, the layer inserted in every test, noVUID-orSYNC-HAZARD-IDs, andagc_driver_own_refresh_repack_aliasran (not skipped).Not tested: native Linux, including the
linuxjob's setup (write-watched guest memory with compared imports; WSL2 has no write watch, so the Build is its first run), macOS, GPUs other than these; titles other than PPSA05110; no speed comparison on the RTX 3080.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)c005abb24f, by @Oscar45397)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T06:32:34Z.
Review: CHANGES_REQUESTED
The implementation, proof-checking test, validation runs, and matched Persona 5 Royal captures are carefully documented. I found one performance-report requirement that still needs addressing: both summary lines include
APS5_TRACE_EVENTS=1048576andAPS5_TRACE_SUMMARY_EVERY=10in addition toAPS5_TRACE_SECONDS. The repository's Performance report form says not to set any otherAPS5_TRACE_*orAPS5_PROFILE_*switches because they cost time. Please rerun and attach the comparison using only the required window switch (and the normal trace defaults), then refresh the digest and summary lines. The current pair is useful supplemental evidence, but does not meet the prescribed capture protocol as written.The PR reports the nine relevant validation tests on both base and change, plus a title capture pair; hosted policy checks pass, while product CI is skipped by path policy. I did not rerun the GPU tests locally.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-28T17:39:49Z.
Review: CHANGES_REQUESTED
The full Build of this head (run 40724347830,
linuxjob, lavapipe) fails the new test:agc_driver_own_refresh_repack_aliasfails in 0.30 s withAGC graphics: 10_11_11 float view: a set whose view refreshed its own image over a pending 8888 unorm alias took the full walk, not the own-object refresh(OwnRefreshRepackAlias.cpp:223). The test is new, so main does not have this failure, and the other tests of the run behave as on main.open /dev/udmabuf: Permission denied; shared direct memory is copied instead of imported. The only skip isHostImportCovers(OwnRefreshRepackAlias.cpp:203), and it does not skip here, so the test either needs a skip that matches this environment, or the own-object refresh does not take this path on Linux and the change needs a fix there. Please check which one it is (the test was only run on Windows) and push a head where thelinuxjob passes.The rest of the review stands:
pendingLookupSourcekeepscachedTexture's conditions, and the timing pair meets @MarcZX10's request.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T10:16:02Z.
Review: CHANGES_REQUESTED
Re-reviewed exact head
c005abb24f6a076d3db0ae0d6caef6d69a87f43dagainst currentmainf99d7fece316e31878f0195f8bbc2ad2fbe635e4.The corrected performance report now follows the capture-form switch rule, includes paired summaries/traces/digests, and reports the frame-level result as within noise rather than claiming a frame-time gain. That resolves my earlier report-format finding.
Two merge-readiness issues remain:
agc_driver_own_refresh_repack_aliasfails on Linux when/dev/udmabufis denied:HostImportCoversdoes not skip that environment and the firstRevalidatefails the new proof-path assertion. Please establish whether this is an implementation failure or unsupported test setup, then make the Linux run pass (with an explicit, justified skip only if the required import capability is unavailable) and retain a run that exercises the regression on a host that supports it.88795ed448, while currentmainhas since changedShaderResources.cpp, including thecachedTexturepending-source lookup that this PR refactors andfastRevalidaterelies on. The merge preview is clean, but the old paired timing/validation evidence does not cover that current integration. Please refresh the branch and rerun the focused regression/validation tests and matched performance comparison on the resulting current-main base.I checked the exact source and current-main delta; I did not run a local GPU build. Hosted policy checks pass, while product Linux/Windows jobs are skipped. The independent Linux failure report is not resolved by the added RTX 3080 Windows validation run.