Skip to content

fix(libc): preserve writes during partial shared-memory collection - #3783

Merged
adriadam10 merged 3 commits into
boykopovar:mainfrom
jweidenh:codex/windows-partial-write-tracking
Oct 11, 2026
Merged

adriadam10 merged 3 commits into
boykopovar:mainfrom
jweidenh:codex/windows-partial-write-tracking

Conversation

@jweidenh

@jweidenh jweidenh commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What

Preserve pending CPU writes when Windows collects only part of a shared direct-memory view. Shared views are 16 KiB, while GuestMemory collects and records CPU-write versions in 4 KiB pages. Collecting a prefix previously marked the entire view clean and advanced its seen generation, even though neighboring pages had not been reported. A later UnchangedSinceCollected could therefore incorrectly report a changed neighboring page as unchanged; GPU label synchronization uses that result.

Only mark the collected interval clean, advance seen when 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 onto 0a8b1d32b12a6d6a3acd462787750b482bf78884. 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 baseline 44bd7086aeba5e3c6b9f68b23c8f1a44083ac4db, fixed head 6b433a19a89a845539646dc740adf054447b90f7. The unchanged negative controls were not rerun after rebase.

  • Native Windows 11 Pro 10.0.26300, Ryzen 7 5800X, RTX 5090 / NVIDIA 617.42, portable WinLibs GCC 15.2.0 UCRT/POSIX/SEH, Release. The test-only baseline fails with partial collect lost a neighboring guest write in 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, and agc_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).
  • Linux x86-64 local self-hosted runner, Ubuntu GCC 13.3.0, Release, targeted executables plus all runtime 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 run 38156295437, workflow commit 65edae1e06eb69cdb4a9925c6a54b3c09dffe838, pinned to the final source head above.
  • Conventions, whitespace checks and independent review pass.

This demonstrates the lost-write regression and related GPU memory-order/copy behavior. No retail-title reproduction or gameplay/FPS improvement is claimed.

Checklist

  • Based on current main; no other open PR implements the same fix
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no new stubs
  • No notes, investigation files or images added to the repository
  • No new third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

@jweidenh
jweidenh force-pushed the codex/windows-partial-write-tracking branch from 6b433a1 to 3b32e54 Compare October 11, 2026 20:18
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 11, 2026
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
#3864 core/libs/prx/libc/include/WindowsMappings.hpp L238-239, L258-259

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the Collect change against the surrounding walk (clean-range lookup, capacity-full early return, seen only on a whole view) and ran build + ctest for libSceAgcDriver and libc on Linux (447 tests green, agc_shared_write_partial_collect passes). 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::Collect and will need a rebase on this one.

@adriadam10
adriadam10 merged commit 974116d into boykopovar:main Oct 11, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants