fix(agc): capture direct-write order under the tracker lock #15551

Merged
rickyalvarez185 merged 2 commits from upstream-pr/15551 into main 2026-11-07 12:38:56 +00:00
rickyalvarez185 commented 2026-11-03 18:39:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rickyalvarez185 on 2026-11-03T18:39:19Z.


What

Capture the direct-write record order while holding the write-tracker lock, independently of whether the destination has valid write-watch proof. MarkDirectWrites previously reused the zero proof value for untracked destinations as its record order; completion could then discard image results recorded after the buffer write once the destination became tracked again.

The existing two-argument MarkPossiblyWritten still returns zero when proof is unavailable. The ordered overload also reserves a distinct order after a failed fresh collect temporarily releases the lock for an unwatch hook.

Adds agc_write_tracking_mark_order, covering empty, tracked and untracked ranges, concurrent generation advances, and a deterministic failed-collect interleaving. No GDS allocation/layout workaround is included.

Tested

Windows 11, WinLibs GCC 15.2.0 UCRT, Release/Ninja; NVIDIA GeForce RTX 4080 SUPER, driver 621.01; Vulkan validation layer 1.4.363.1. GPU tests run at medium integrity with ANYPS5_GPU=4080, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, and verbose loader/layer logging. The layer's actual insertion and absence of missing-layer warnings were checked, not just its installation.

  • Baseline: clean main at 1e658521a0a599872612bb91949311e2956b5283; agc_driver_direct_write_completion fails. The regression was also bisected to merge 8009be68d7602c728b7d8f7c70880035b4ec343f (#13159), while its parent passed on the same GPU.
  • Negative control: removing only the post-suspension generation increment makes the new ordering test fail with a failed fresh collect reused the intervening writer's mark order; restoring it passes. The pre-update candidate passed the direct-write and write-tracking focused set three consecutive times without VUIDs.
  • Current-main focused comparison: identical CTest selection on baseline and change, including the direct-write regression, all write-tracking cases, agc_storage_rewritten_blocks, agc_storage_rewritten_stale_units, agc_driver_prepared_exports and agc_driver_srgb8_color_target. Baseline: 9 pass / 1 fail; change: 11 pass / 0 fail (the additional case is the new ordering test). Both logs have exactly 18 occurrences of VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 from the existing validation controls, with identical VUID-ID multisets, six validation-layer insertions each and no missing-layer warning. The direct-write regression adds no VUID; the focused comparison introduces no new validation error.
  • Complete Release build and libs target succeeded. Full verbose CTest run after the final overlap-avoidance changes: 3925 cases, 3912 passed, 12 skipped, 1 failed. The only failure is agc_driver_store_over_untracked (the first result was not stored), reproduced on clean main at the base above and intentionally left to a separate fix. The full run reports only the same 18 occurrences of the validation ID already present in the focused baseline. The previously intermittent no-timeline test and Windows relinker fixture pass in this completed run; interrupted earlier runs are not counted as completed validation. Relocating the new test's Windows PATH property preserves all 3925 generated test command/property configurations exactly.
  • Conventions, whitespace, and test registration checks passed. The final official pr_overlap.py --branch fix/agc-direct-write-record-order --repo boykopovar/AnyPS5 --base main --jobs 4 reports no direct overlap but exits 2, not clean: 33 other PRs already conflict with main, so its comparisons fail closed. Every one was checked with paired base+PR and change+PR merge trees: identical conflict paths and identical modes/source after reversing only this contribution, ignoring only left-side commit labels on conflict-marker lines. #14137 is also checked and merges without the former registration collision. All 34 audited heads and the base remained unchanged in the final official rerun. These are source/merge checks, not claims that the other branches build or pass tests.

Validation logs, full-suite summary and per-head overlap evidence: https://gist.github.com/rickyalvarez185/bb546d1d2140addcb2a91bd52ccba2a4

Final head: 30a0b806bf71da658f0e5231bfa79b1c4fdc1b39. Independent static review approved both the runtime patch and final overlap-avoidance changes; final-head focused rerun: 11/11 pass.

  • No real title was tested; no title-unblock or performance claim.

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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4080 SUPER, driver 621.01, Windows 11
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5142623511 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15551). Originally posted by [rickyalvarez185](https://github.com/rickyalvarez185) on 2026-11-03T18:39:19Z. --- ### What Capture the direct-write record order while holding the write-tracker lock, independently of whether the destination has valid write-watch proof. `MarkDirectWrites` previously reused the zero proof value for untracked destinations as its record order; completion could then discard image results recorded after the buffer write once the destination became tracked again. The existing two-argument `MarkPossiblyWritten` still returns zero when proof is unavailable. The ordered overload also reserves a distinct order after a failed fresh collect temporarily releases the lock for an unwatch hook. Adds `agc_write_tracking_mark_order`, covering empty, tracked and untracked ranges, concurrent generation advances, and a deterministic failed-collect interleaving. No GDS allocation/layout workaround is included. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, WinLibs GCC 15.2.0 UCRT, Release/Ninja; NVIDIA GeForce RTX 4080 SUPER, driver 621.01; Vulkan validation layer 1.4.363.1. GPU tests run at medium integrity with `ANYPS5_GPU=4080`, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, and verbose loader/layer logging. The layer's actual insertion and absence of missing-layer warnings were checked, not just its installation. - Baseline: clean `main` at `1e658521a0a599872612bb91949311e2956b5283`; `agc_driver_direct_write_completion` fails. The regression was also bisected to merge `8009be68d7602c728b7d8f7c70880035b4ec343f` (#13159), while its parent passed on the same GPU. - Negative control: removing only the post-suspension generation increment makes the new ordering test fail with `a failed fresh collect reused the intervening writer's mark order`; restoring it passes. The pre-update candidate passed the direct-write and write-tracking focused set three consecutive times without VUIDs. - Current-main focused comparison: identical CTest selection on baseline and change, including the direct-write regression, all write-tracking cases, `agc_storage_rewritten_blocks`, `agc_storage_rewritten_stale_units`, `agc_driver_prepared_exports` and `agc_driver_srgb8_color_target`. Baseline: 9 pass / 1 fail; change: 11 pass / 0 fail (the additional case is the new ordering test). Both logs have exactly 18 occurrences of `VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605` from the existing validation controls, with identical VUID-ID multisets, six validation-layer insertions each and no missing-layer warning. The direct-write regression adds no VUID; the focused comparison introduces no new validation error. - Complete Release build and `libs` target succeeded. Full verbose CTest run after the final overlap-avoidance changes: **3925 cases, 3912 passed, 12 skipped, 1 failed**. The only failure is `agc_driver_store_over_untracked` (`the first result was not stored`), reproduced on clean `main` at the base above and intentionally left to a separate fix. The full run reports only the same 18 occurrences of the validation ID already present in the focused baseline. The previously intermittent no-timeline test and Windows relinker fixture pass in this completed run; interrupted earlier runs are not counted as completed validation. Relocating the new test's Windows PATH property preserves all 3925 generated test command/property configurations exactly. - Conventions, whitespace, and test registration checks passed. The final official `pr_overlap.py --branch fix/agc-direct-write-record-order --repo boykopovar/AnyPS5 --base main --jobs 4` reports no direct overlap but **exits 2**, not clean: 33 other PRs already conflict with `main`, so its comparisons fail closed. Every one was checked with paired base+PR and change+PR merge trees: identical conflict paths and identical modes/source after reversing only this contribution, ignoring only left-side commit labels on conflict-marker lines. #14137 is also checked and merges without the former registration collision. All 34 audited heads and the base remained unchanged in the final official rerun. These are source/merge checks, not claims that the other branches build or pass tests. Validation logs, full-suite summary and per-head overlap evidence: https://gist.github.com/rickyalvarez185/bb546d1d2140addcb2a91bd52ccba2a4 Final head: `30a0b806bf71da658f0e5231bfa79b1c4fdc1b39`. Independent static review approved both the runtime patch and final overlap-avoidance changes; final-head focused rerun: 11/11 pass. - No real title was tested; no title-unblock or performance claim. ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> NVIDIA GeForce RTX 4080 SUPER, driver 621.01, Windows 11 - [x] AI-assisted: <!-- yes / no --> yes
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!15551
No description provided.