fix(agc): preserve resident multisample baselines before unwatch #16483

Merged
cookie42073-cmd merged 7 commits from upstream-pr/16483 into main 2026-11-17 20:58:12 +00:00
cookie42073-cmd commented 2026-11-06 20:29:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by cookie42073-cmd on 2026-11-06T20:29:24Z.


What

Preserve an already resident multisampled DCC target when a host import removes write watching from its guest memory. Previously, later reuse could refuse unchanged data because the original watch proof was gone.

The shared unwatch callback now saves a complete baseline for each affected tracked range only when its write generation, mapping, metadata and pending-write checks still prove it current. Owner tracking, an import preflight and a publication hold coordinate target registration with concurrent imports while preserving GPU/import lock order. Failed proof and changed data retain their refusal paths. Two focused fixtures cover preservation/refusal cases and publication/import ordering.

This addresses the resident-MSAA DCC portion of #12522; it does not close that multi-failure issue. Same-value CPU stores after watch removal remain unobservable by byte comparison alone. The original contribution 0635d91d793758ee6705fe33a996acfe92191b96 and Blazing Cook's authorship are retained in history.

Tested

Native AGC execution fixtures on the same Windows 11 Pro machine, OS 10.0.26300, GCC 15.2 Release. Tests ran serially on each GPU listed below.

  • Main: 6fd097073810784f8e3455d36320542cd59252bf.
  • Candidate, before and after negative controls: d0aced879ffb5a0ba1922b819de013cb4d46c2de.
GPU Main: 17 common cases Initial candidate: 19 cases Restored candidate: 19 cases
NVIDIA GeForce RTX 4070 SUPER 17 passed 19 passed 19 passed
Intel UHD Graphics 770 14 passed, 2 failed, 1 skipped 17 passed, 1 failed, 1 skipped 17 passed, 1 failed, 1 skipped

Both new tests, agc_driver_msaa_dcc_unwatch and agc_driver_msaa_dcc_publish_gate, pass on both GPUs in both candidate runs. Intel agc_driver_msaa_dcc_clear_2 changes from the watched-memory reuse refusal to PASS. Every other common passing case remains passing.

Intel agc_driver_native_depth_publication still fails with native D32S8 publication lost live samples, HTILE, padding or guest writes, identically on main and both candidate runs. Intel agc_import_settle_initial_dcc still skips because no second settle queue is available; the skip is not counted as a pass. These separate outcomes are unchanged by this patch.

Runs used ctest -V, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. Verbose logs confirm the selected GPU and actual Khronos layer insertion for every invocation; the new cases and controls also enable APS5_ASSERT_GPU_LOCK=1. There are no VUID/SYNC diagnostics or new validation errors/warnings. Three pre-existing loader errors for missing third-party implicit-layer manifests remain identical; validation still loads. The logs are not error-free.

Three single-mechanism mutations were separately built and exercised on both GPUs:

Disabled mechanism NVIDIA failure Intel failure
MSAA snapshot callback Unchanged-data preservation assertion Same assertion
Publication hold Import did not wait for publication Initial DCC watched-memory refusal
MSAA import-preflight result Import did not defer after publication Exact GPU/import lock-order assertion and deliberate abort

All six controls fail for their intended mechanism, without skip, timeout, device loss or validation diagnostic. Both source files were restored byte-for-byte, all four targets rebuilt, and the complete 19-case selection repeated on both GPUs. Independent review audited all 116 test invocations and all 47 original evidence files.

Tracked AnyPS5 source is clean for the unmutated runs. The checkout retains an identical QuickJS submodule dirty marker from 153 missing JavaScript fixtures in nested test262, with its commit pin unchanged. QuickJS/NKWebKit/test262 are not inputs to these four AGC targets; this is not a globally clean recursive-checkout claim.

The candidate cleanly merges with newer main 9e432fbfa47ea68a70cfc10c507d9b252684a891 in a source-only preview. No AGC production file changed between tested main and that preview base. The combined newer tree was not runtime-tested. The pre-push conventions check passed without warnings. No title, native-console, Linux/macOS, AMD, performance or full-suite result is claimed.

Overlap review: the official scan against main 578dd09c42edb71eb17e9ad7b6fa7fea7978e7ff examined 1,901 open PRs and 164 relevant merge comparisons. It exited 2, reporting five confirmed conflicts and 62 unresolved shared-file comparisons. All 67 have explicit pinned manual dispositions in the evidence; no duplicate implementation or prerequisite for this standalone change was found. The official result remains exit 2.

Existing author coordination supports a separate main-based fix. For future combinations, preserve DCC owner/refusal tracking alongside the plain-color publication stack (#6987/#6989/#6995/#7002). #13963 ordering is storage-result flush, then DccPublication, then TargetsLock. #10233's two-sample native FMASK expansion must extend both the publication span and owner-bearing guard; #6808's older blanket retirement must not replace current DCC lifetime/refusal rules. These are future integration requirements, not dependencies or tested combinations.

Logs, receipts, manifests and independent reviews. The public manifest maps normalized/redacted evidence to original hashes; receipt log hashes refer to the originals.

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 4070 SUPER, driver 621.01 (Windows 32.0.16.2101); Intel UHD Graphics 770, driver 32.0.101.7088; both Windows 11 Pro 10.0.26300.
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5194185922 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16483). Originally posted by [cookie42073-cmd](https://github.com/cookie42073-cmd) on 2026-11-06T20:29:24Z. --- ### What Preserve an already resident multisampled DCC target when a host import removes write watching from its guest memory. Previously, later reuse could refuse unchanged data because the original watch proof was gone. The shared unwatch callback now saves a complete baseline for each affected tracked range only when its write generation, mapping, metadata and pending-write checks still prove it current. Owner tracking, an import preflight and a publication hold coordinate target registration with concurrent imports while preserving GPU/import lock order. Failed proof and changed data retain their refusal paths. Two focused fixtures cover preservation/refusal cases and publication/import ordering. This addresses the resident-MSAA DCC portion of #12522; it does not close that multi-failure issue. Same-value CPU stores after watch removal remain unobservable by byte comparison alone. The original contribution `0635d91d793758ee6705fe33a996acfe92191b96` and Blazing Cook's authorship are retained in history. ### 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. --> Native AGC execution fixtures on the same Windows 11 Pro machine, OS 10.0.26300, GCC 15.2 Release. Tests ran serially on each GPU listed below. - Main: `6fd097073810784f8e3455d36320542cd59252bf`. - Candidate, before and after negative controls: `d0aced879ffb5a0ba1922b819de013cb4d46c2de`. | GPU | Main: 17 common cases | Initial candidate: 19 cases | Restored candidate: 19 cases | |---|---|---|---| | NVIDIA GeForce RTX 4070 SUPER | 17 passed | 19 passed | 19 passed | | Intel UHD Graphics 770 | 14 passed, 2 failed, 1 skipped | 17 passed, 1 failed, 1 skipped | 17 passed, 1 failed, 1 skipped | Both new tests, `agc_driver_msaa_dcc_unwatch` and `agc_driver_msaa_dcc_publish_gate`, pass on both GPUs in both candidate runs. Intel `agc_driver_msaa_dcc_clear_2` changes from the watched-memory reuse refusal to PASS. Every other common passing case remains passing. Intel `agc_driver_native_depth_publication` still fails with `native D32S8 publication lost live samples, HTILE, padding or guest writes`, identically on main and both candidate runs. Intel `agc_import_settle_initial_dcc` still skips because no second settle queue is available; the skip is not counted as a pass. These separate outcomes are unchanged by this patch. Runs used `ctest -V`, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`. Verbose logs confirm the selected GPU and actual Khronos layer insertion for every invocation; the new cases and controls also enable `APS5_ASSERT_GPU_LOCK=1`. There are no VUID/SYNC diagnostics or new validation errors/warnings. Three pre-existing loader errors for missing third-party implicit-layer manifests remain identical; validation still loads. The logs are not error-free. Three single-mechanism mutations were separately built and exercised on both GPUs: | Disabled mechanism | NVIDIA failure | Intel failure | |---|---|---| | MSAA snapshot callback | Unchanged-data preservation assertion | Same assertion | | Publication hold | Import did not wait for publication | Initial DCC watched-memory refusal | | MSAA import-preflight result | Import did not defer after publication | Exact GPU/import lock-order assertion and deliberate abort | All six controls fail for their intended mechanism, without skip, timeout, device loss or validation diagnostic. Both source files were restored byte-for-byte, all four targets rebuilt, and the complete 19-case selection repeated on both GPUs. Independent review audited all 116 test invocations and all 47 original evidence files. Tracked AnyPS5 source is clean for the unmutated runs. The checkout retains an identical QuickJS submodule dirty marker from 153 missing JavaScript fixtures in nested test262, with its commit pin unchanged. QuickJS/NKWebKit/test262 are not inputs to these four AGC targets; this is not a globally clean recursive-checkout claim. The candidate cleanly merges with newer main `9e432fbfa47ea68a70cfc10c507d9b252684a891` in a **source-only preview**. No AGC production file changed between tested main and that preview base. The combined newer tree was **not runtime-tested**. The pre-push conventions check passed without warnings. No title, native-console, Linux/macOS, AMD, performance or full-suite result is claimed. **Overlap review:** the official scan against main `578dd09c42edb71eb17e9ad7b6fa7fea7978e7ff` examined 1,901 open PRs and 164 relevant merge comparisons. It exited **2**, reporting five confirmed conflicts and 62 unresolved shared-file comparisons. All 67 have explicit pinned manual dispositions in the evidence; no duplicate implementation or prerequisite for this standalone change was found. The official result remains exit 2. Existing [author coordination](https://github.com/boykopovar/AnyPS5/issues/12522#issuecomment-6595488781) supports a separate main-based fix. For future combinations, preserve DCC owner/refusal tracking alongside the plain-color publication stack (#6987/#6989/#6995/#7002). [#13963 ordering](https://github.com/boykopovar/AnyPS5/issues/12522#issuecomment-6603191850) is storage-result flush, then `DccPublication`, then `TargetsLock`. #10233's two-sample native FMASK expansion must extend both the publication span and owner-bearing guard; #6808's older blanket retirement must not replace current DCC lifetime/refusal rules. These are future integration requirements, not dependencies or tested combinations. [Logs, receipts, manifests and independent reviews](https://gist.github.com/cookie42073-cmd/d5ee23ebab3f19fe3d64dcb9a14595fb). The public manifest maps normalized/redacted evidence to original hashes; receipt log hashes refer to the originals. ### 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: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01 (Windows 32.0.16.2101); Intel UHD Graphics 770, driver 32.0.101.7088; both Windows 11 Pro 10.0.26300. <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
gabichuuuuu commented 2026-11-08 17:09:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T17:09:50Z.

Review: COMMENTED


Ran d0aced879f merged on main 302864d48c on Windows 11 x64 (WinLibs GCC 15.2), on an NVIDIA laptop GPU (Turing, driver 621) and an Intel iGPU (driver 101.70xx), with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Khronos validation layer 1.4.368), ctest -R 'alpha_to_coverage|agc_driver_msaa_dcc' -V.

main (17 tests) change without the two Texture.cpp hook calls (19) change, 2 runs each (19)
NVIDIA 17/17 14/19 19/19
Intel 16/17 14/19 19/19
  • For the middle column I kept the PR whole and removed only MultisampleDccUnwatchLocksGpu from UnwatchHookLocksGpu and SaveMultisampleDccBeforeUnwatch from SaveBeforeUnwatch. On both GPUs, the new msaa_dcc_unwatch and msaa_dcc_publish_gate fail, and so do msaa_dcc_clear_2/4/8 with "multisampled DCC target reuse requires watched guest memory". With the calls back in, all of them pass every time.
  • On main, agc_driver_msaa_dcc_clear_2 failed once on the Intel iGPU with the same "requires watched guest memory" message (color range, 2 samples). The change passed it in both Intel runs. I ran main only once, so I can't say how often it fails there.
  • msaa_dcc_compared_import_2/4/8 skip on both GPUs in every build, so this run doesn't cover them.
  • The layer was inserted in every device test. No log has was not found but was requested by env var VK_INSTANCE_LAYERS, and no log on either side has a VUID-. To be sure validation messages reach these logs, the same layer with best practices on printed 28 BestPractices- warnings into an agc_driver_recorder log on each GPU.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5818797576 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16483#pullrequestreview-5818797576). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-08T17:09:50Z. **Review:** COMMENTED --- Ran `d0aced879f` merged on `main` 302864d48c on Windows 11 x64 (WinLibs GCC 15.2), on an NVIDIA laptop GPU (Turing, driver 621) and an Intel iGPU (driver 101.70xx), with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (Khronos validation layer 1.4.368), `ctest -R 'alpha_to_coverage|agc_driver_msaa_dcc' -V`. | | `main` (17 tests) | change without the two `Texture.cpp` hook calls (19) | change, 2 runs each (19) | |---|---|---|---| | NVIDIA | 17/17 | 14/19 | 19/19 | | Intel | 16/17 | 14/19 | 19/19 | - For the middle column I kept the PR whole and removed only `MultisampleDccUnwatchLocksGpu` from `UnwatchHookLocksGpu` and `SaveMultisampleDccBeforeUnwatch` from `SaveBeforeUnwatch`. On both GPUs, the new `msaa_dcc_unwatch` and `msaa_dcc_publish_gate` fail, and so do `msaa_dcc_clear_2/4/8` with "multisampled DCC target reuse requires watched guest memory". With the calls back in, all of them pass every time. - On `main`, `agc_driver_msaa_dcc_clear_2` failed once on the Intel iGPU with the same "requires watched guest memory" message (color range, 2 samples). The change passed it in both Intel runs. I ran `main` only once, so I can't say how often it fails there. - `msaa_dcc_compared_import_2/4/8` skip on both GPUs in every build, so this run doesn't cover them. - The layer was inserted in every device test. No log has `was not found but was requested by env var VK_INSTANCE_LAYERS`, and no log on either side has a `VUID-`. To be sure validation messages reach these logs, the same layer with best practices on printed 28 `BestPractices-` warnings into an `agc_driver_recorder` log on each GPU. AI-assisted: 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!16483
No description provided.