fix(libc): preserve writes during partial shared-memory collection #3783
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3783"
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-11T16:40:29Z.
What
Preserve pending CPU writes when Windows collects only part of a shared direct-memory view. Shared views are 16 KiB, while
GuestMemorycollects and records CPU-write versions in 4 KiB pages. Collecting a prefix previously marked the entire view clean and advanced itsseengeneration, even though neighboring pages had not been reported. A laterUnchangedSinceCollectedcould therefore incorrectly report a changed neighboring page as unchanged; GPU label synchronization uses that result.Only mark the collected interval clean, advance
seenwhen a whole view is collected, and stop at already-clean interior intervals instead of reporting them again. The existing early return for a full output buffer and non-reset collection semantics are preserved.The regression maps direct memory twice on Windows to exercise the shared path, writes the last subpage, collects the first, and verifies that the last subpage is still observed as changed. It also checks independent alias observations, writes through either alias, repeated non-reset probes, previously cleared interior pages, limited output capacity and continuation. Both the normal and two-pass collectors are covered. The portable part runs on Linux; unavailable write watching follows the existing test skip convention.
PRs #637 and #2054 retain the defective shared-view path. This change is independent of their private direct-memory paths; the Windows fixture deliberately creates an alias so it stays relevant with either implementation.
Tested
Current head:
3b32e54ed90777c6dcdf6b7b5aa21f6cfb442bba, rebased onto0a8b1d32b12a6d6a3acd462787750b482bf78884. The only conflict was adjacent CMake registration; upstream sRGB and both partial-collection cases were preserved. Production and regression-test source are unchanged.Rebase validation on this exact head rebuilt the focused executables and patched runtime libraries. Windows 11 / RTX 5090 / NVIDIA 617.42 passed all seven cases again without skips (8.06 s total; slowest 2.75 s). Linux GCC 13.3 passed all four portable cases without skips (slowest 0.017 s), on the private self-hosted validation run.
Original regression validation: base
a11c8f7f70a0ed4e71504a89de69e8cdae687817, test-only baseline44bd7086aeba5e3c6b9f68b23c8f1a44083ac4db, fixed head6b433a19a89a845539646dc740adf054447b90f7. The unchanged negative controls were not rerun after rebase.partial collect lost a neighboring guest writein both normal and two-pass modes. Final head passes all 7/7 cases without skips or fatal output:agc_shared_write_partial_collect,agc_shared_write_partial_collect_two_pass,agc_shared_write,agc_write_tracking,agc_write_watch_coverage,agc_driver_unimported_label_order, andagc_driver_copied_writer_copy. Both Vulkan tests log selection of the RTX 5090 and reach their success markers. Total 1.16 s; every case below 0.48 s. The initial production-fix run also passed all seven tests (5.12 s total).libs: final head passes 4/4 portable cases (agc_shared_write_partial_collect,agc_shared_write,agc_write_tracking,agc_write_watch_coverage), without skips or fatal output, each below 0.012 s. Private run38156295437, workflow commit65edae1e06eb69cdb4a9925c6a54b3c09dffe838, pinned to the final source head above.This demonstrates the lost-write regression and related GPU memory-order/copy behavior. No retail-title reproduction or gameplay/FPS improvement is claimed.
Checklist
main; no other open PR implements the same fixImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T20:33:02Z.
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/libc/include/WindowsMappings.hppL238-239, L258-259Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T22:01:05Z.
Checked the
Collectchange against the surrounding walk (clean-range lookup, capacity-full early return,seenonly on a whole view) and ran build + ctest for libSceAgcDriver and libc on Linux (447 tests green,agc_shared_write_partial_collectpasses). The fix itself is Windows-only; relying on the Windows 11 runs in the description for that part. Merging.Note for #3864: it rewrites the same loop in
WindowsMappings::Collectand will need a rebase on this one.