fix(agc): store GPU results over CPU-stamped bytes the CPU left unchanged #1599
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1599"
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 andrey231 on 2026-10-08T14:06:20Z.
What
Fixes the boxed glyphs in PPSA12544's menus (finding 2 of #865).
StorageTexture::writeBackLayerskeeps the CPU's bytes for a block the write watch stamped after the layer's generation, and drops the GPU results there. The write watch reports page writes, not changes. In #865 the stamped pages of the font atlas still hold the allocator fill (0xCD) the image was uploaded from, so the CPU changed nothing there, yet the glyphs the GPU drew into those pages are lost.The keep decision now also asks whether the CPU changed the bytes:
upload, including the clear and import paths), images up to 1 MiB keep a copy of their guest bytes (generationBaseline). An image uploaded through the CPU snapshot already has it inoriginal.A stale baseline (generation moved on without a new copy) can only make the comparison fail, which keeps the previous behaviour. Real CPU stores change bytes and still win. The direct (import) write-back path is unchanged: the decision only removes ranges from the CPU-kept set.
This is the range-level variant of the baseline comparison suggested in #865. @merwie's experiment there merges per byte and forces the CPU write-back path; this one keeps the existing paths and decides per stored range.
Tested
unchangedCpuStampTestsinagc_driver_recorder_tests: a 256x256 RGBA8 linear image at +0x2000 in watched memory (so its first unit is an edge block), cleared on the GPU and marked dirty, then the CPU rewrites the first page.dropped 14336 of 65536 texels the GPU wrote(the 0xe000-byte head edge).ctest: 456 of 456 passed.agc_driver_recorder_tests(run directly, as it needs the GPU): passed.APS5_TRACE_FLUSH=1reports no CPU-kept blocks. No eager write-back.tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T04:22:29Z.
Linux results, since this was tested on Windows only. Everything passes here.
Nobara 44 (Linux 7.2), GCC 16.2.1, Release,
BUILD_TESTING=ON. This PR merged ontomain29e533ac.main29e533acmain+ this PRctest -R agc_driver -j1-E agc_driver)The CPU failure is
guest_dynamic_loader, which fails the same way onmain.Imported from boykopovar/AnyPS5. Originally posted by awake-devel on 2026-10-09T06:46:55Z.
Tested on Linux with PPSA12544 (Arch, GCC 16, GTX 1050 Ti Max-Q, NVIDIA 580.178.04). This PR was cherry-picked onto our Silksong test stack (
maincba8d86dplus the open Linux PRs the title needs), withAPS5_TRACE_FLUSH=1.The font atlas keeps no stale block with this PR.
Two of the runs with the PR went through the menus and the intro cinematic into gameplay (Moss Grotto). The menu and HUD text rendered with no boxes.
unchangedCpuStampTestspasses on Linux. In the sameagc_driver_recorder_testsbinary, the check "(w) a cache over the pages the import reported sees no change" fails, but it fails the same way on our stack without this PR, so it isn't caused by this change.0x264510000 ... keeps 135 CPU-written 64 KiB blocksand0x263b10000 ... keeps 95. Their "first stored byte" is at +0x870000 or +0x900000, past the end of the image data. If those are the stamps behind the fps drop reported in #865, they would need the same comparison, or a different rule, for large images.Imported from boykopovar/AnyPS5. Originally posted by andrey231 on 2026-10-09T11:32:20Z.
Thanks @fisherjoey and @awake-devel for the Linux runs.
Rebased onto
maind70b8998to resolve the conflict with #2096. That change keeps a guest-byte snapshot (original) for the clear path and for unwatched imports, and compares it when the memory is untracked. The keep decision now takes both:compared || !edge || StoredOver(...)from #2096, then!unchangedSinceBaseline(from, to)from this PR. Watched imports (the PPSA12544 font atlas) still haveoriginalValid == falseonmain, so they still need the baseline here. Where #2096 now leavesoriginalvalid, the comparison uses it instead ofgenerationBaseline.After the rebase (Windows 11, RTX 5090):
ctest507 of 507,tools/check_conventions.pypasses, andunchangedCpuStampTestspasses. Inagc_driver_recorder_tests,storageRefreshTestsfails with "the refresh's store of the results did not reach guest memory" before reaching this test. It fails the same way onmaind70b8998without this PR, so I ran the rest of the binary with that call skipped locally.On the large images @awake-devel saw keeping blocks: the 1 MiB cap is deliberate, since a baseline copy of every 8 MiB render target on each upload costs time and memory. Those 1920x1080 images keep everything before
+0x870000/+0x900000for the CPU, so the same unchanged-stamp question may apply to them, but it needs a different way to compare than a full copy per upload. If they turn out to be behind the fps drop in #865, I would rather look at them in a separate PR.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by orbz22 on 2026-10-09T14:34:17Z.
Confirmed on Windows with NVIDIA, PPSA12544 (Hollow Knight: Silksong 01.000.010).
Build:
maind70b8998+ #1836 + #1968 + #1969 + #846, relinked with--windows --module-dir Media/Plugins.APS5_DUMP_FRAMES) of the title menu and the profile screen. Every glyph is intact: START GAME, OPTIONS, EXTRAS, SELECT PROFILE, the four NEW GAME labels, 1. to 4. and BACK.guest memory changed while GPU results were pending; keeping the CPU's blocks8 times in a 150 s run, for storage images at 0x260371000, 0x2603e0000, 0x262090000, 0x2629d0000 and 0x263310000. I saw no visible damage from them in these scenes.Windows 11, RTX 3060 Laptop (NVIDIA 616.92), WinLibs GCC 15.2.
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T00:14:47Z.
Review: CHANGES_REQUESTED
Thanks for the fix, and for the Linux/Windows confirmations in the thread. One thing before this can land:
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp:2182(unchangedCpuStampTests) does not fail without the change on Linux. I merged this onto currentmain(with #2096), removed&& !unchangedSinceBaseline(from, to)atTexture.cpp:3529, rebuilt, and ran only this test (RADV): it still printsunchanged CPU stamps: ok. The "dropped 14336 of 65536 texels" failure you describe is Windows-only, so Linux CI/reviewers can't tell whether the fix is exercised. Please make the case reproduce on Linux as well (e.g. make sure the image reaches the watched-import path withoriginalValid == false, as the font atlas does, and assert that case), so the test fails onmainand passes with the change on both hosts.agc_driver_recorder_testsis not registered in ctest and exits early onmain(drawInputReuseTests), so nothing in CI runs this test. If you can't register the whole binary, a small separate registered target for just this case would do.Everything else I checked is fine: build + ctest (270/270, libSceAgcDriver scope) green, and the test passes with the fix applied.
Imported from boykopovar/AnyPS5. Originally posted by andrey231 on 2026-10-10T05:31:28Z.
Thanks @adriadam10, you were right. And it was not Linux-only: since the rebase onto #2096, the case passed without the fix on Windows too. The test memory got a host import there as well, the import was compared rather than watched, and
originalwas valid, so the write-back took the compared path and kept the unchanged block anyway.Rebased onto
mainb667d1e3and pushed 4e453180:hostImportAlignment = 0in the test's context), on every host.originalis valid here.SetImportWatch(Watch), restored afterwards, as inimportWindowTests). As with the font atlas,originalValidis false after the GPU-direct write-back, so the decision uses the generation baseline.agc_unchanged_cpu_stamps(agc_driver_recorder_tests --unchanged-cpu-stamps-only), next toagc_pipeline_cache. It skips with 77 when there is no Vulkan device.check_test_registration.py: 503 executables, none unregistered.Each run below was made with and without
&& !unchangedSinceBaseline(from, to):dropped 14336 of 65536 texelsdropped 14336 of 65536 texelsdropped 14336 of 65536 texelsImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:18:58Z.
Review: APPROVED
Thanks for the rework:
agc_unchanged_cpu_stampsnow fails without the change on Linux and passes with it, and it is registered in ctest.Checked on current
main(rebased, no conflicts): scoped build + ctest of libSceAgcDriver green, the new test fails withunchangedSinceBaselineremoved, conventions check passes. Linux/Windows runs on PPSA12544 from @fisherjoey, @awake-devel and @orbz22 cover what I can't run here.Added on top as our own commit:
docs/dev/TechnicalDebt.md(Functional): the 1 MiB baseline limit, and that a CPU store rewriting the baseline value after the GPU changed it is not distinguished from no store.Merging once the full Build (linux + windows) is green, since the test opens a Vulkan device.