feat(agc): trace draw-key cache misses #5364
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5364"
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 MarcZX10 on 2026-10-13T18:03:19Z.
What
Adds per-group attribution for draw register-key cache misses: stable registers, user-data registers, auxiliary registers, device, and shader set, plus misses where none of those components changed.
This extends the existing
APS5_TRACE_DRAW_CACHEreport, which already distinguishes new-register misses, user-word/pointer-only misses, evictions, and keys seen but never inserted. It reusestraceDrawCache()and its 10-second report; there is no separate environment variable or stderr logging path. Shader-set identity is included so distinct snapshots are tracked separately.Tested
agc_driver_register_key_testsandlibSceAgcDriver.prxsuccessfully with Ninja Release.APS5_VERIFY_REGISTER_KEYS=1 ctest --test-dir /tmp/anyps5-open-diagnostics-main-build -R '^agc_driver_register_key$' --output-on-failure— the test executable cannot enter its test body on this host: Xeon E5-1620 v2 lacks LZCNT, BMI1, BMI2, MOVBE, AVX2, and FMA.python3 tools/check_conventions.py --base upstream/main— passed.git diff --check upstream/main...HEAD— passed.Checklist
main; no other open PR implements the same functionsImported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-13T21:17:02Z.
I ran this head merged into
main0aa4cb1c2on Astro's Playroom (Linux, RTX 5080) withAPS5_TRACE_DRAW_KEY_MISSES=1. About 145,000 draw-key lookups miss per 10 s there, and the whole run printed four lines:cbf29ce484222325is the FNV offset basis. IndrawRegisterKey,(*components)[4]is set to it and the shader identities are mixed into(*components)[3]only, so every draw has the same shader-set id and the four-lines-per-set cap stops the trace after four misses. It also meansdevicereports a change whenever the shaders differ.agc_driver_register_keypasses here.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T03:05:39Z.
mixShaderIdentitymixes into(*components)[3], the device slot, so(*components)[4]stays at the FNV basis for every draw (DrawRegisterKey.cpp:86-95). Every draw then has the same shader-set id,devicechanges whenever the shaders do, and the four-line cap ends the trace after four misses, as fma-rc's run shows. Please mix the shader identity into[4]and add a check intests/RegisterKey.cppthat two shader sets get different ids.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T06:44:32Z.
Fixed the component mix-up: shader snapshot identities and offsets now feed the shader-set key in
components[4], whilecomponents[3]remains the device serial. Added a regression comparing two registries with different shader snapshots. Linux Release build ofagc_driver_register_key_testssucceeded; focused CTest passed 1/1, and conventions passed.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T11:40:03Z.
Checked the new head:
components[4]now carries the shader-set key andcomponents[3]the device serial.agc_driver_register_key_testsbuilds and passes withAPS5_VERIFY_REGISTER_KEYS=1, and the new shader-set check fails when the snapshot mix inDrawShaderSetKeyis removed. Default behaviour is unchanged with the variable unset. Merging once the full Build is green.Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-14T17:16:07Z.
Ran this in a title: PPSA25344 (Sword of the Sea), title screen,
mainf0854887d+ this PR at2dd5ecdf4(after thecomponents[4]fix),APS5_TRACE_DRAW_KEY_MISSES=1, RTX 3060, Windows 10, 300 s. It builds and runs, and frame rate matchedmain(3.70 FPS both).It printed 217
[draw-key-miss]lines from 57 shader sets (the per-set cap of 4 is hit by 52 of them):changed=stable-registers,user-data-registersuser-data-registersfirst-seenno-component-changechanged=st, a line cut by interleaved output)Among the sampled repeat misses, user-data registers changed in all but one, and stable registers changed along with them in about half. One note from using it: there's no per-10 s total, so the lines show which components change but not how many draws miss in all. A count line like #5408's
[keymiss]summary would make it comparable across runs.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T21:37:52Z.
Review: CHANGES_REQUESTED
This now conflicts with
maininDrawRegisterKey.hpp/.cpp,Driver.hppandDraw.cpp, and it is not a mechanical rebase: #58b6ddf72addedAPS5_TRACE_DRAW_CACHE(traceDrawCache(),absentUserWords/absentNewRegisters/absentEvictedcounters) and changedRegisterStateKey/drawRegisterKeyto return ashapeKeythrough the same parameter slot this PR uses forRegisterStateKeyParts/components.Could you rebase onto current
mainand:traceDrawCache()gate and shape key instead of adding a second env var and a second miss path inDriver::draw, or say why a separate trace is needed;maindoes not already report (the per-group breakdown: stable / user-data / auxiliary / device / shader-set), and say in the PR body what it adds over theabsentUserWords/absentNewRegisterssplit;agc_driver_register_key_testswithAPS5_VERIFY_REGISTER_KEYS=1on the rebased head.The
components[4]fix and the new shader-set test looked right on the previous head; they only need to survive the rebase.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T23:58:36Z.
Rebased onto current
mainand integrated the requested breakdown withtraceDrawCache()and its existing 10-second report. The existingabsentNewRegisters/absentUserWords/ eviction accounting remains intact; the report now adds miss counts for stable registers, user-data registers, auxiliary registers, device, first-seen shader sets, and misses where no component changed. Shader-set identity remains in component slot 4, with a regression test for distinct snapshots.Validation on the rebased head: the focused
agc_driver_register_key_teststarget builds successfully and conventions pass. CTest starts the binary but cannot enter the test body on this Xeon E5-1620 v2 because the host lacks LZCNT, BMI1, BMI2, MOVBE, AVX2, and FMA. I recorded that limitation in the PR description.Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-15T00:07:37Z.
@MarcZX100 the force-push at 23:58 UTC left this branch with a single commit, fdba06400
fix(libkernel): log resolved paths for failed opens, which only touchescore/libs/prx/libkernel/File/src/Open.cppandcore/libs/tests/GuestFilesystem.cpp. The draw-key work and thetraceDrawCache()breakdown you describe aren't in the diff any more (notraceDrawCacheorregister_keylines), so it looks like another branch went tomarc/trace-draw-key-misses. Once the right commit is back I'll build it and run it on Astro's Playroom, where most draw-cache misses carry the same key as the set's last one.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T00:09:06Z.
You were right: I accidentally pushed the unrelated diagnostics commit to this branch. I restored the intended rebased trace work; the current head is
d1afc595e, and GitHub now shows the expected seven AGC draw-cache files. Sorry for the confusion.I also corrected the PR description: this version uses the existing
APS5_TRACE_DRAW_CACHEreport and does not add a second trace switch or stderr path. The focused target builds and conventions pass. The CTest executable is blocked before its test body on this Xeon E5-1620 v2 due to missing LZCNT, BMI1, BMI2, MOVBE, AVX2, and FMA; I have updated the validation text to say that accurately.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T00:47:14Z.
Rebased onto current
mainand pushed as4f142b189. The update reusestraceDrawCache()/APS5_TRACE_DRAW_CACHEand the existing 10-second[draw-cache]report. It adds the stable-register, user-data, auxiliary-register, device, and shader-set attribution (plus an unchanged-component counter) beyond the existing new-register vs. user-word/pointer-only classification. ThetestShaderSetKeyregression remains. Local conventions andgit diff --check upstream/main...HEADpass. I could not execute the focused test body on my Xeon E5-1620 v2 due to unsupported required CPU features; the previously reported supported-host run of the component test remains relevant.Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-15T00:59:36Z.
I built 4f142b189 on main
8cd937e29and ranagc_driver_register_key,agc_driver_draw_cache_reuse,agc_driver_draw_cache_reuse_offandagc_driver_draw_cache_reuse_verify: all 4 pass on an RTX 5080, on RADV (Radeon 610M) and on lavapipe.I also ran Astro's Playroom (PPSA01325) into its heavy gameplay scene with
APS5_TRACE_DRAW_CACHE=1for 264 s with no throw. Three consecutive 10 s reports:So every register-key miss there has changed user data, and only about 2% also changed stable registers. That is what the data-only path work in PR 5656 and PR 5609 goes after, and this report makes it easy to see.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T01:24:03Z.
I believe the requested updates are now present in head
4f142b189: it builds on currentmain, reusestraceDrawCache()/APS5_TRACE_DRAW_CACHEand the existing report, and adds the per-component stable-register, user-data, auxiliary-register, device and shader-set attribution beyond the existing register/user-data split. The component-slot collision is fixed and the distinct shader-set regression remains.For validation, fma-rc reports
agc_driver_register_key,agc_driver_draw_cache_reuse,agc_driver_draw_cache_reuse_offandagc_driver_draw_cache_reuse_verifypassing on RTX 5080, RADV Radeon 610M and lavapipe, plus a 264-second Astro's Playroom trace without throws. The hosted eligibility, conventions and report checks pass; hardware/path-filtered jobs skip. I still cannot enter the local test body on this Xeon because of the host CPU guard. Could you re-review the current head against your requested changes?Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T11:08:39Z.
Review: APPROVED
Re-checked the rebased head: it now reuses
traceDrawCache()and the existing 10 s[draw-cache]report,components[4]carries the shader-set key andcomponents[3]the device serial.agc_driver_register_keyand the fouragc_driver_draw_cache_reuse*tests pass withAPS5_VERIFY_REGISTER_KEYS=1, and the new test does not build without the change. Default behaviour is unchanged with the variable unset. Confirmed by @fma-rc on RTX 5080, RADV and lavapipe.Added on top as a small commit: dropped the unused
identitytemporary indrawRegisterKey(DrawRegisterKey.cpp) and a stray blank line. Merging once the full Build is green.