fix(agc): clear interior holes in recycled sparse buffers #4206
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4206"
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 jweidenh on 2026-10-12T01:20:13Z.
What
A sparse guest buffer whose final page is committed keeps its full allocation.
copyRegiononly cleared holes when it shortened the allocation, so an interior uncommitted page could retain bytes from a recycled GPU buffer. With the first and third 64 KiB committed in a 192 KiB descriptor, the GPU reads the previous buffer's data from the middle 64 KiB.Clear every gap in a sparse CPU copy. Allocation sizes, committed-page copies and packed write-back tracking remain unchanged. This extends the existing zero-filled-hole behavior to unshortened copies. The adjacent profiling work in #4187 retains the faulty condition and does not implement this correction.
Add CPU and native Vulkan regressions, each covering readable/writable uploads with an interior hole, a shortened allocation, and fully committed memory. Both require reuse of an exact buffer seeded with
0xA5. The native fixture reads all 49,152 DWORDs through a storage-buffer compute shader; the CPU fixture also checks write-back permissions. Neither reads inaccessible guest pages on the CPU.Tested
Windows 11, RTX 5090, NVIDIA 617.42, WinLibs GCC 15.2, Release with SPIRV-Tools enabled. Full
libstarget built. Native tests required Vulkan; pipeline LTO remained disabled.7a84b22267831edb5c624d047581412dd329cb11.8404d62be9c2d09d3b58d5fa2f0ad0446e705fcf. Both regressions reproduced exactly the two interior-hole failures and passed their other four cases. Each failing GPU readback contained all 16,384 seeded0xA5A5A5A5words in the hole, with committed words intact.38b05f4868bd0bc3e54502a752d3cfe9fbd10251. Test sources are identical to baseline; only the production clearing conditions differ. No compatibility overlay.agc_sparse_buffer_holesagc_driver_sparse_buffer_holesagc_buffer_poolagc_driver_buffer_unaligned_baseagc_driver_copied_writer_copyAll five candidate tests ran without skips and below 30 seconds. Exact source pins, test inventory, JUnit, device identity and raw logs were independently checked. Conventions and
git diff --checkpass.Linux was not rerun: the local runner still lacks the required SDL PipeWire/PulseAudio/ALSA development dependencies. This is synthetic buffer-path validation, not a retail-title reproduction, full-suite result, startup improvement or FPS claim.
Checklist
main; no other open PR implements this sparse-hole correctionImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T01:30:17Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/CMakeLists.txtL1171core/libs/prx/libSceAgcDriver/tests/Graphics.cppL5197core/libs/prx/libSceAgcDriver/tests/Graphics.cppL5197core/libs/prx/libSceAgcDriver/tests/Graphics.cppL5197core/libs/prx/libSceAgcDriver/tests/Graphics.cppL5197core/libs/prx/libSceAgcDriver/tests/Graphics.cppL5197core/libs/prx/libSceAgcDriver/tests/Graphics.cppL5197Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T01:37:42Z.
Windows RTX5070Ti cross-test: retained your fix commit38b05f48 and fixture commit8404d62 on our combined007 WIP, resulting head8c1ed096edf311c250b50d016b8098f645ff630a (Scramblrrrr/AnyPS5 codex/first-light-mixed-table-perf-cross-test). Required Vulkan, Release, toolsOFF: sparse CPU0.04s, native Vulkan0.53s; graphics/BDA/draw-cache reuse GPL on/off also passed,6/6 in6.80s. No skips reported by CTest. Test-registration conflicts adapted to our older stack; this is not a standalone current-main or full-suite validation. Bounded007 run underway; no FPS or title-specific stale-hole reproduction claim. Thanks for keeping the correctness fix separate from #4187 diagnostics. AI-assisted: yes (Codex).
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-12T01:37:43Z.
This is a real correctness bug and the fix closes it cleanly. The old gate for zero-filling a sparse buffer's uncommitted holes only fired when the copy shortened the allocation — so an interior hole (uncommitted pages sandwiched between two committed ones) fell straight through uncleared. Worked through the body's own numbers: a 192 KiB descriptor with pages 0 and 2 committed and page 1 not, the old code skips the hole's memset entirely because the allocation wasn't shortened, so that 64 KiB keeps whatever a previous, recycled GPU buffer left there — and that's genuinely GPU-visible, not just a harmless internal detail, since nothing downstream re-clears it before a shader can read it. Removing the "only if shortened" gate and clearing every interior and leading gap, not just a tail one, fixes it by construction — the fix only touches the clearing condition, leaving allocation sizing, committed-page copies, and write-back tracking untouched as claimed.
Worth checking explicitly since this is the fourth PR tonight to touch shared recompiler/driver surface area: this PR's own body says #4187 (which we reviewed earlier tonight as metrics-only) "retains the faulty condition" in the same function. That checks out — a real three-way trace confirms a proper three-way merge of the two is clean with no behavioral interaction (the clearing logic and #4187's read-byte counter sit on either side of the same
GuestMemory::Readcall and don't affect each other), though a naive two-way patch/rebase tool would report a conflict at that hunk since #4187 inserts a line in the middle of the context this PR carries. Worth flagging to whoever merges second: a plaingit applywill fail here even though the real merge doesn't — expect to resolve it by hand, not take the tool's failure as a real incompatibility.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T22:10:37Z.
Re-cross-test of your existing #4206 on the current007 recovery/fiber/key/sorting stack: fixture8404d62be + fix38b05f486, author preserved, integration a9454c295 (https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-key-sort-sparse-holes). Resolved only registration/CLI conflicts, preserving both existing modes; no production compatibility overlay.
Windows11/RTX5070Ti/GCC15.2 Release/toolsOFF: initial CPU sparse-hole PASS0.47s, native GPU PASS0.54s, full mocked graphics PASS4.75s. Production-only negative restores GuestBufferMemory.cpp from e8cc22c7b, fixture/CMake unchanged: CPU and GPU both FAIL exactly readable/writable interior cases; shortened and committed controls pass. GPU readback exposes16384 stale seeded words in each interior case. Restored/touched/rebuilt positive: CPU0.04s, nativeGPU0.33s, fullgraphics4.85s,3/3 PASS5.27s. No skips. Source clean/diff-check pass.
Only patched graphics226930059E23F2E8C5AE2DA3DB5B76EBC877EFF43FC6CFDB01CD43C2466539C9 now staged; libc99D37E34 unchanged. Normal warm-cache/cache16 game run started22:10UTC, no concurrent builds/native tests or sampler/profile. Not claiming sparse holes caused007's missing scene or an FPS benefit. AI-assisted: Codex.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T22:18:31Z.
Sparse-hole game cross-test a9454c295/graphics22693005/libc99D37E34/cache16 crashed: Resume22:16:50.160UTC, exit0xc0000005 at22:17:24.492 (~34s), Entity Streamer Thread#0, guestRVA e2861c/invalid read. Matching private dump confirms thread37344/guestRVA e2861c. Last private16.267GB/free6.027GB, below guards. This is before the slow cinematic and differs from the earlier EntityStreamer e3092a on418ecdc86 without #4206; not attributing this occurrence to sparse-hole correction on one run. Native red/green evidence remains separate. Dump/guest data remain local.
Next control reruns preceding e8cc22c7b graphicsFFD11FE1 (without #4206), same warm-cache/settings/inputs, to audit intermittent crash vs regression before adding anything else. Prepared later image-ordering integration85b2bf7e9 remains unbuilt/unstaged. AI-assisted: Codex.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T23:30:34Z.
Re-cross-test of #4206
8404d62befixture +38b05f4868fix, author preserved, on our newer shared-write tracking stack: integration38318147bddb8f71e57dc5dccff15c068d00b0af, https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-deferred-sparse-holes . Parentd26e52a82 includes revised #4661 and #4535 Windows tracking port plus main's reserved-view mapping dependency; none of those are attributed to this PR.Windows11/RTX5070Ti/GCC15.2/Release/toolsOFF: full mocked graphics4.77s, native GPU sparse holes0.53s, CPU holes0.03s, plus Windows backend/AGC tracking/guest-memory controls,6/6 PASS7.02s. Production-only negative restores GuestBufferMemory.cpp fromd26e52a82, fixtures/CMake unchanged: both CPU/GPU FAIL only readable/writable interior cases; shortened/committed controls PASS. Native readback finds16384 stale seeded words in each interior case. Restore/touch/rebuild: graphics4.92s/GPU0.33s/CPU0.03s plus3 tracking controls,6/6 PASS6.74s; no skips, source clean/diff-check pass.
Only patched graphics91E5B2B79A925D9F39527751956727D2705832CF97779CF293F8C3CAF826ACEE staged; libc08AB01A9 unchanged. Normal007 warm-cache/cache16 rerun launched23:30:00.897UTC, no sampler/profile or concurrent builds/native tests. Earliera9454c295 single EntityStreamer e2861c crash remains unassigned; this run audits the fix on newer tracking, not a claimed crash cure. Preceding cache64 comparison ended intentionally, same partial black scene/~0.15FPS; cache64 did not establish a gain, so this code comparison returns to16.
AI-assisted: Codex.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T23:40:59Z.
007 sparse-hole rerun38318147b/graphics91E5B2B7/libc08AB01A9/cache16 crashed: Resume23:38:13.331UTC, exit0xc0000005 at23:39:40.815 (~87s). Matching local dump identifies thread4712 RenderThread, guestRVA17bd927, the previously observed RenderThread stop on older stacks without #4206; not the earliera945 EntityStreamer e2861c stop. Last private18.829GB/free7.682GB, below guard limits; three trims total, not a guard termination. Native sparse-hole/tracking red/green proof remains separate. Guest code/dump/screenshots remain local; pointer scans are not an unwound stack.
Restored only the preceding graphics8745FDBD (d26e52a82), libc08AB01A9 unchanged, cache16/other settings unchanged. Control launched23:40:24.311UTC, prefix sparse383control. Source383 remains saved/public but its graphics are not active. No sampler/profile/concurrent builds/native tests. This second sparse-integration crash is important to audit, but its known prior occurrence without #4206 does not establish causality. Will report the matching control before adding another change. AI-assisted: Codex.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T23:51:36Z.
Normal control completed intentionally: d26e52a8294bbc2e61b18a7f2f59e355da5a3c98, graphics8745FDBD/libc08AB01A9/cache16, no #4206. Resume23:47:52.989UTC/frame1030; stopped23:51:12.684 (~3m20), exit-1 at23:51:15.688. Final frame1808/~0.17FPS, bright shape over black; last private22.787GB/free5.640GB, five bounded trims. No fatal in this one control, past sparse383's ~87s RenderThread fault. Prior occurrences without #4206 and differing crash classes still prevent assigning causality from these runs.
A separate diagnostic started23:51:18UTC with the exact same graphics8745FDBD1E62CD423E9E5F0DFB79E4EE7D73149A36B02D98AFADAEEE406A0986/libc08AB01A94E6A9D0D82DF51F1676B5D7392437CD8382DD7C36CC0801A5288C10A, cache16/warm cache/settings unchanged, adding only APS5_PROFILE_DRAW=1. Prefix d26drawprofile; no sampler/build/native tests concurrently. This is draw/resource/cache/copy phase diagnosis, not a clean FPS comparison. The larger-cache comparison did not establish a gain, and runtime table stores remain unsupported/pending SleglJan's work. AI-assisted: Codex.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-13T00:02:13Z.
PROFILE_DRAW diagnostic on unchanged d26e52a8294bbc2e61b18a7f2f59e355da5a3c98 / graphics8745FDBD1E62CD423E9E5F0DFB79E4EE7D73149A36B02D98AFADAEEE406A0986 / libc08AB01A9 / cache16 (no #4206) crashed: Resume23:59:35.902UTC, exit0xc0000005 at00:01:13.748UTC (~98s). Matching local dump/log identify RenderThread39884, guestRVA17bd927, the same RenderThread stop as sparse383. Last private20.980GB/free4.471GB; three bounded trims, below guard limits. No sampler or concurrent builds/native tests. This reproduces that fault without #4206, although profiling changes timing; preceding unprofiled d26 control survived3m20 and was stopped intentionally. Does not explain the distinct earlier EntityStreamer crash.
New performance evidence after Resume: one emitted indirect interval reports894 dispatches/7355ms device call, resources7224ms, nested image handling4999ms. Its longest dispatch4459.3ms spent4280.13ms in sampled made-snapshot lookups (nested, not additive); that interval includes3053 made-snapshot lookups/4280ms and180367 snapshot hits/262ms. The GPU-side indirect path was used; CPU argument fallback/read time0. This points to snapshot creation/resource building, not CPU-reading indirect arguments, for this measured stall. Initial loading and scene transition share the interval; not a steady cinematic benchmark. Draw cache still has substantial hits; larger capacity did not establish a gain. Will inspect the snapshot path/compare its safe reuse controls before proposing a change, and keep runtime table-store/referenced-texture work coordinated with SleglJan.
No title code/dumps/screenshots uploaded. AI-assisted: Codex.