feat(agc): reuse unchanged untracked draw input copies #13793

Merged
Celegans12 merged 3 commits from upstream-pr/13793 into main 2026-11-09 04:57:22 +00:00
Celegans12 commented 2026-10-31 06:54:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-31T06:54:20Z.


What

Stacked on #13784; please review the last commit only.

Untracked vertex/index copy fallbacks always reread guest bytes. Reuse an exact address/size/use snapshot when libc write-watch tokens and AGC write evidence still hold. Flush pending writes before lookup, capture the proof before reading, and validate that original proof when keeping the copy. Entries share the existing input-cache limits. Refused ranges copy normally. On non-Windows platforms the draw path bypasses owned-token lookup and arming, because the current libc token implementation is Windows-only.

The branch is restacked on #13784, including its pending-page merge fix. In-place inputs and zero-padded reads keep their existing paths. Trace summaries count arm outcomes, proof checks, arena calls, requested blocks, reuse, invalidation and input-pool evictions; an unbound event marks the trace incomplete. Requested blocks are not exact syscall counts. No title or performance claim.

#9875 also changes draw-copy range metadata; #9712 changes copy allocation policy; #12921 handles untracked shader-resource proofs. #13809 extends these owned proofs to storage. The current overlap scan could not complete 98 shared-file comparisons; 29 include implementation files and need composition review if those branches land.

Tested

After restacking on the bounded parent, the current-main storage-stack merge passed 10 selected Windows tests and seven Linux tests three times each. Linux cannot exercise Windows write-watch.

Based on main 66e1f7f993 plus #13784 4b26f5d61b. Exact merge with main 93dbd0f82a: Windows 11 / MinGW-w64 GCC 15.2.0, NVIDIA RTX 3080 Laptop, validation 1.4.363: six focused tests passed three times; Ubuntu llvmpipe, validation 1.3.275: five passed three times. No reported VUIDs or skips. Linux lacked asynchronous UFFD write protection and uses the non-owned fallback.

The two-block fixture checks requested-block counts; trace-window, unbound-thread and input-pool eviction fixtures check summary output and incomplete captures. On the earlier head db033149f7, late-arm and late-stamp mutants failed both owned-input tests; restored candidate passed. Three neighboring cases passed once per platform on that earlier head.

Not tested: macOS runtime, title scenes, console behavior, title performance or tracing overhead. No real-scene block count is claimed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #13784
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA RTX 3080 Laptop, 610.62, Windows 11; lavapipe LLVM 22.1.8, Windows 11; lavapipe Mesa 25.2.8 / LLVM 20.1.2, Ubuntu 24.04
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5095362779 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13793). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-31T06:54:20Z. --- ### What Stacked on #13784; please review the last commit only. Untracked vertex/index copy fallbacks always reread guest bytes. Reuse an exact address/size/use snapshot when libc write-watch tokens and AGC write evidence still hold. Flush pending writes before lookup, capture the proof before reading, and validate that original proof when keeping the copy. Entries share the existing input-cache limits. Refused ranges copy normally. On non-Windows platforms the draw path bypasses owned-token lookup and arming, because the current libc token implementation is Windows-only. The branch is restacked on #13784, including its pending-page merge fix. In-place inputs and zero-padded reads keep their existing paths. Trace summaries count arm outcomes, proof checks, arena calls, requested blocks, reuse, invalidation and input-pool evictions; an unbound event marks the trace incomplete. Requested blocks are not exact syscall counts. No title or performance claim. #9875 also changes draw-copy range metadata; #9712 changes copy allocation policy; #12921 handles untracked shader-resource proofs. #13809 extends these owned proofs to storage. The current overlap scan could not complete 98 shared-file comparisons; 29 include implementation files and need composition review if those branches land. ### Tested After restacking on the bounded parent, the current-main storage-stack merge passed 10 selected Windows tests and seven Linux tests three times each. Linux cannot exercise Windows write-watch. Based on `main` 66e1f7f993 plus #13784 `4b26f5d61b`. Exact merge with main `93dbd0f82a`: Windows 11 / MinGW-w64 GCC 15.2.0, NVIDIA RTX 3080 Laptop, validation 1.4.363: six focused tests passed three times; Ubuntu llvmpipe, validation 1.3.275: five passed three times. No reported VUIDs or skips. Linux lacked asynchronous UFFD write protection and uses the non-owned fallback. The two-block fixture checks requested-block counts; trace-window, unbound-thread and input-pool eviction fixtures check summary output and incomplete captures. On the earlier head `db033149f7`, late-arm and late-stamp mutants failed both owned-input tests; restored candidate passed. Three neighboring cases passed once per platform on that earlier head. Not tested: macOS runtime, title scenes, console behavior, title performance or tracing overhead. No real-scene block count is claimed. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #13784 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA RTX 3080 Laptop, 610.62, Windows 11; lavapipe LLVM 22.1.8, Windows 11; lavapipe Mesa 25.2.8 / LLVM 20.1.2, Ubuntu 24.04 - [x] AI-assisted: yes
CnRJay commented 2026-11-01 19:48:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:48:16Z.

Review: COMMENTED


Review of the consumer commit on top of #13784.

  1. The stated purpose is to skip rereading guest bytes for untracked vertex/index copies, but the PR carries no number for it: "No title or performance claim", "Not tested: titles ... or performance", "Unblocks: none". The change is on by default (APS5_NO_OWNED_DRAW_INPUTS is an opt-out, Draw.cpp calls ArmOwnedDrawInput for every untracked copy). A default-on change to the draw path needs the title/scene where untracked copies dominate and tools/trace_digest.py summaries of main and the change from the same machine. As written the cost is certain (arm + proof capture on every untracked copy, GetWriteWatch per 64 KiB block under the mapping mutex) and the benefit is unmeasured.

  2. On Linux GuestArenaArmOwned returns false, so every copy still goes through the old path and pays the extra ArmOwnedDrawInput attempt (including PendingWriteOverlaps and AssertGpuLockHeld). Linux gets overhead and no reuse. Please show that the refused path is free, or gate the attempt on a capability query once.

  3. The reuse hit rate is not observable. Please add a counter (armed / reused / refused / invalidated) so a trace can show whether the cache is doing anything on a real title; otherwise the entries sit in the existing input-cache budget and may evict copies that were being reused by the current path.

  4. The negative control cited is the historical 6a691f build with a transplanted fixture, not main plus this commit, and the late-arm/stamp controls were "not rerun". For a correctness-by-proof feature (stale vertex data reaching the GPU if a proof is wrong) I would want the mutants re-run on this head.

Also, since this is stacked, please make sure #13784 is settled first; its mapping-mutex cost and unbounded token maps carry straight into this one.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729918447 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13793#pullrequestreview-5729918447). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:48:16Z. **Review:** COMMENTED --- Review of the consumer commit on top of #13784. 1. The stated purpose is to skip rereading guest bytes for untracked vertex/index copies, but the PR carries no number for it: "No title or performance claim", "Not tested: titles ... or performance", "Unblocks: none". The change is on by default (`APS5_NO_OWNED_DRAW_INPUTS` is an opt-out, `Draw.cpp` calls `ArmOwnedDrawInput` for every untracked copy). A default-on change to the draw path needs the title/scene where untracked copies dominate and `tools/trace_digest.py` summaries of main and the change from the same machine. As written the cost is certain (arm + proof capture on every untracked copy, `GetWriteWatch` per 64 KiB block under the mapping mutex) and the benefit is unmeasured. 2. On Linux `GuestArenaArmOwned` returns false, so every copy still goes through the old path and pays the extra `ArmOwnedDrawInput` attempt (including `PendingWriteOverlaps` and `AssertGpuLockHeld`). Linux gets overhead and no reuse. Please show that the refused path is free, or gate the attempt on a capability query once. 3. The reuse hit rate is not observable. Please add a counter (armed / reused / refused / invalidated) so a trace can show whether the cache is doing anything on a real title; otherwise the entries sit in the existing input-cache budget and may evict copies that were being reused by the current path. 4. The negative control cited is the historical 6a691f build with a transplanted fixture, not main plus this commit, and the late-arm/stamp controls were "not rerun". For a correctness-by-proof feature (stale vertex data reaching the GPU if a proof is wrong) I would want the mutants re-run on this head. Also, since this is stacked, please make sure #13784 is settled first; its mapping-mutex cost and unbounded token maps carry straight into this one.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!13793
No description provided.