fix(agc): refuse buffer aliases of native MSAA targets #6498

Merged
Amoenus merged 18 commits from upstream-pr/6498 into main 2026-10-29 23:19:54 +00:00
Amoenus commented 2026-10-15 17:35:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-15T17:35:12Z.


What

Fixes #6480. A buffer descriptor overlapping resident native MSAA storage bypasses the existing unsupported guest-access refusal. In the test-only main control, a typed buffer load reads zero guest DWORDs while MIMG reads the resident image's half-float ones.

Check logical guest-buffer ranges before preparation, final upload and binding, including warmed/deferred/recipe reuse and the actual moved ranges during draw-binding preparation. Adjacent logical ranges remain usable even when their allocation also contains a native target. Unresolved accesses throw through the existing guard; no readback approximation, retry, environment switch or silent success.

Four files: 15 added production .cpp lines, a private declaration, an extension of the existing execution fixture and a debt update. This does not implement native MSAA buffer publication or change instruction semantics. Dynamically addressed BDA heaps remain outside this check; main's separate vertex/index coverage is retained.

Published history is preserved: this refresh merges main into the existing PR head rather than replacing its reviewed implementation. The experimental integration's native-publication work remains separate.

Tested

28October current-main refresh: b2aad7239cb4ce282d1df7ebf154db01d66fa5d3 on tested maind4cb89300fe54cce0ad74edf67803086e302b819,including merged #11369. Normal merge/fast-forward preserves published494b and original authorship,with identical own topic lines and no force-push.

Why retest: #11369 changes the GPU buffer-write/depth boundary in GuestBufferMemory::UploadFinish. The refreshed main/control/fix matrix verifies that its depth retirement coexists with this separate color-buffer guard. Main-production plus the identical alias fixture still misses all six guard refusals3/3 per vendor;candidate catches all six and retains adjacent/native-sample controls.

Exact pins,portable control patch,full native builds,real-fixture proofs,verbose logs and artifact manifests: 60positive processes(56physicalGPU/4CPU),six intended color-guard control failures. Main and candidate each30/30. Both execute merged native-depth buffer-write cases3/vendor,all D16/D32 x2/4/8 cases verified,plus depth retirement/clear controls. Ordinary/pipelined relocation,deferred/recipe reuse,native vertex and linear-target binding/dispatch checks retained. Longest CTest6.450s;zero validation warnings/errors/VUIDs,skips,timeouts. Full native libraries/relinker/real selected fixtures,conventions and whitespace pass;stable per-phase manifests.

Actual RTX5080/621.01 and Radeon Graphics1002:13c0/26.10.1,Windows11 Enterprise26200,WinLibsGCC15.2r7/UCRT Release;required Vulkan,app cache/journal off,loaded Khronos1.4.363,serial verbose CTest/30s. Driver caches/implicit layers left as found. Cppcheck/clang-tidy:47.021analyzer-seconds,4unchanged-context notices,no parser/configuration errors/timeouts;no static-clean claim.

Overlap order: #6498→#8963 is agreed,merge order only;#6498→#9508 remains proposed. Preserve this guard before fault-slot/descriptor work and early returns,using moved logical ranges. No combined heap/fault-arena runtime claim.

#11369 is merged. Fresh matched main/change checks below execute its native-depth buffer-write regression alongside this color-buffer guard;no dependency remains on an open11369. This guard covers known logical buffer bindings;GPU-discovered BDA addresses remain outside its scope.

No fresh title,FPS,full default suite,Linux,dynamic-BDA or console-equivalence result. Historical controls and other-platform results retain their original pins in the same Gist. Maintainer full Build/title gates remain separate.

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: Fixes #6480
  • Unblocks: none established; synthetic investigation associated with PPSA99902 / #4443
  • GPUs tested: NVIDIA GeForce RTX5080 (10de:2c02), driver621.01/32.0.16.2101; AMD Radeon(TM) Graphics (1002:13c0), driver32.0.21045.16010; both Windows11 Enterprise26200.
  • AI-assisted: yes, Codex; author responsible for every line
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4877369026 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6498). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-15T17:35:12Z. --- ### What Fixes #6480. A buffer descriptor overlapping resident native MSAA storage bypasses the existing unsupported guest-access refusal. In the test-only main control, a typed buffer load reads zero guest DWORDs while MIMG reads the resident image's half-float ones. Check logical guest-buffer ranges before preparation, final upload and binding, including warmed/deferred/recipe reuse and the actual moved ranges during draw-binding preparation. Adjacent logical ranges remain usable even when their allocation also contains a native target. Unresolved accesses throw through the existing guard; no readback approximation, retry, environment switch or silent success. Four files: 15 added production `.cpp` lines, a private declaration, an extension of the existing execution fixture and a debt update. This does not implement native MSAA buffer publication or change instruction semantics. Dynamically addressed BDA heaps remain outside this check; main's separate vertex/index coverage is retained. Published history is preserved: this refresh merges main into the existing PR head rather than replacing its reviewed implementation. The experimental integration's native-publication work remains separate. ### Tested **28October current-main refresh:** [`b2aad7239cb4ce282d1df7ebf154db01d66fa5d3`](https://github.com/Amoenus/AnyPS5/commit/b2aad7239cb4ce282d1df7ebf154db01d66fa5d3) on tested main`d4cb89300fe54cce0ad74edf67803086e302b819`,including merged #11369. Normal merge/fast-forward preserves published494b and original authorship,with identical own topic lines and no force-push. **Why retest:** #11369 changes the GPU buffer-write/depth boundary in GuestBufferMemory::UploadFinish. The refreshed main/control/fix matrix verifies that its depth retirement coexists with this separate color-buffer guard. Main-production plus the identical alias fixture still misses all six guard refusals3/3 per vendor;candidate catches all six and retains adjacent/native-sample controls. [Exact pins,portable control patch,full native builds,real-fixture proofs,verbose logs and artifact manifests](https://gist.github.com/Amoenus/8e50ec43bf7c5959ea481beb386fcdab#file-pr6498-maind4cb-report-v1-md): **60positive processes(56physicalGPU/4CPU),six intended color-guard control failures.** Main and candidate each30/30. Both execute merged native-depth buffer-write cases3/vendor,all D16/D32 x2/4/8 cases verified,plus depth retirement/clear controls. Ordinary/pipelined relocation,deferred/recipe reuse,native vertex and linear-target binding/dispatch checks retained. Longest CTest6.450s;zero validation warnings/errors/VUIDs,skips,timeouts. Full native libraries/relinker/real selected fixtures,conventions and whitespace pass;stable per-phase manifests. Actual RTX5080/621.01 and Radeon Graphics1002:13c0/26.10.1,Windows11 Enterprise26200,WinLibsGCC15.2r7/UCRT Release;required Vulkan,app cache/journal off,loaded Khronos1.4.363,serial verbose CTest/30s. Driver caches/implicit layers left as found. Cppcheck/clang-tidy:47.021analyzer-seconds,4unchanged-context notices,no parser/configuration errors/timeouts;no static-clean claim. **Overlap order:** #6498→#8963 is [agreed,merge order only](https://github.com/boykopovar/AnyPS5/pull/8963#issuecomment-6460569498);#6498→#9508 remains [proposed](https://github.com/boykopovar/AnyPS5/pull/9508#issuecomment-6440862835). Preserve this guard before fault-slot/descriptor work and early returns,using moved logical ranges. No combined heap/fault-arena runtime claim. <!-- codex-overlap-11369-20261026 --> **#11369 is merged.** Fresh matched main/change checks below execute its native-depth buffer-write regression alongside this color-buffer guard;no dependency remains on an open11369. This guard covers known logical buffer bindings;GPU-discovered BDA addresses remain outside its scope. <!-- /codex-overlap-11369-20261026 --> No fresh title,FPS,full default suite,Linux,dynamic-BDA or console-equivalence result. Historical controls and other-platform results retain their original pins in the same Gist. Maintainer full Build/title gates remain separate. ### 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 --> Fixes #6480 - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none established; synthetic investigation associated with PPSA99902 / #4443 - [x] GPUs tested: NVIDIA GeForce RTX5080 (10de:2c02), driver621.01/32.0.16.2101; AMD Radeon(TM) Graphics (1002:13c0), driver32.0.21045.16010; both Windows11 Enterprise26200. - [x] AI-assisted: <!-- yes / no --> yes, Codex; author responsible for every line
jotitadev commented 2026-10-15 21:27:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T21:27:29Z.

Review: COMMENTED


Linux + NVIDIA run, since the PR and #6480 have Windows results only (RTX 5080 and Radeon).

Machine: NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, Ubuntu 26.04 (kernel 7.0.0-38), i7-8700. GCC 15.2, Release, BUILD_TESTING=ON. Head f9feba0b2 merged onto main 44df21632, no conflicts. ANYPS5_GPU="NVIDIA GeForce RTX 3070".

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), Linux

  • Test only (this PR's SampleMultisampleTarget.cpp, ShaderResources.{hpp,cpp} from main): agc_driver_sample_multisample_target fails. All six paths bypass the guard (fresh read, edge read, write, warmed dispatch, deferred dispatch, recipe dispatch), and the controls print adjacent=passed deferred=1 recipe=1. So #6480 reproduces on Linux + NVIDIA too.
  • With the fix: 3/3 pass.
  • ctest -R "^agc|shader|recompiler|image" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64|display|flip" -j1 --timeout 60: 600/602 pass.
    • agc_driver_store_over_untracked fails at the result did not reach a block the CPU left alone, as on unchanged main here (64/70 idle runs, #6347).
    • agc_frame_dump_io failed once with closed pipe pixel write was accepted. It ran once in this suite; on unchanged main it then passed 30/30. It does not touch ShaderResources, and I did not rerun it with the PR.

Written with AI assistance (Claude Code). I ran the tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5540155818 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6498#pullrequestreview-5540155818). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-15T21:27:29Z. **Review:** COMMENTED --- Linux + NVIDIA run, since the PR and #6480 have Windows results only (RTX 5080 and Radeon). **Machine:** NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, Ubuntu 26.04 (kernel 7.0.0-38), i7-8700. GCC 15.2, Release, `BUILD_TESTING=ON`. Head `f9feba0b2` merged onto `main` `44df21632`, no conflicts. `ANYPS5_GPU="NVIDIA GeForce RTX 3070"`. GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), Linux - **Test only** (this PR's `SampleMultisampleTarget.cpp`, `ShaderResources.{hpp,cpp}` from `main`): `agc_driver_sample_multisample_target` fails. All six paths bypass the guard (`fresh read`, `edge read`, `write`, `warmed dispatch`, `deferred dispatch`, `recipe dispatch`), and the controls print `adjacent=passed deferred=1 recipe=1`. So #6480 reproduces on Linux + NVIDIA too. - **With the fix:** 3/3 pass. - `ctest -R "^agc|shader|recompiler|image" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64|display|flip" -j1 --timeout 60`: 600/602 pass. - `agc_driver_store_over_untracked` fails at `the result did not reach a block the CPU left alone`, as on unchanged `main` here (64/70 idle runs, #6347). - `agc_frame_dump_io` failed once with `closed pipe pixel write was accepted`. It ran once in this suite; on unchanged `main` it then passed 30/30. It does not touch `ShaderResources`, and I did not rerun it with the PR. Written with AI assistance (Claude Code). I ran the tests above on my machine.
akkadbakkad89 commented 2026-10-17 07:44:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-17T07:44:52Z.


Runtime datapoint on NVIDIA hardware (RTX 3070, Ampere, driver 617.42, Windows 11 26200, WinLibs GCC 15.2.0, Release, ANYPS5_NO_SHADER_CACHE=1).

Head beee99c33 on base 7dcfff559. ctest -R over the multisample/MSAA-adjacent set, fresh serial processes:

Test Result
agc_driver_sample_multisample_target pass
agc_driver_sample_mask_multisample pass
agc_driver_native_multisample_depth pass
agc_driver_native_depth_retirement pass
agc_driver_native_depth_clears pass
agc_driver_native_depth_clear_refusals pass
agc_multisample_guest_access pass

7/7 pass including the new buffer-alias refusal cases.

One adjacent flake to flag: agc_driver_multisample_fill_host_only is intermittent on this machine independently of this PR — 4/10 pass on the PR head vs 3/10 on base 7dcfff559 (same build dir, rebuilt each way). Failure signature is "the sentinel fill did not land" with no crash, so it reads like a timing/ordering flake on this driver, not something the guard introduced.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6231350968 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6498#issuecomment-6231350968). Originally posted by [akkadbakkad89](https://github.com/akkadbakkad89) on 2026-10-17T07:44:52Z. --- Runtime datapoint on NVIDIA hardware (RTX 3070, Ampere, driver 617.42, Windows 11 26200, WinLibs GCC 15.2.0, Release, ANYPS5_NO_SHADER_CACHE=1). Head beee99c33 on base 7dcfff559. ctest -R over the multisample/MSAA-adjacent set, fresh serial processes: | Test | Result | |---|---| | agc_driver_sample_multisample_target | pass | | agc_driver_sample_mask_multisample | pass | | agc_driver_native_multisample_depth | pass | | agc_driver_native_depth_retirement | pass | | agc_driver_native_depth_clears | pass | | agc_driver_native_depth_clear_refusals | pass | | agc_multisample_guest_access | pass | 7/7 pass including the new buffer-alias refusal cases. One adjacent flake to flag: agc_driver_multisample_fill_host_only is intermittent on this machine **independently of this PR** — 4/10 pass on the PR head vs 3/10 on base 7dcfff559 (same build dir, rebuilt each way). Failure signature is "the sentinel fill did not land" with no crash, so it reads like a timing/ordering flake on this driver, not something the guard introduced.
oneandonlydean commented 2026-10-17 12:10:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T12:10:55Z.


@Amoenus this now conflicts with main after today's AGC merges (GitHub reports it as DIRTY at beee99c33). Could you rebase it? It's queued for our game tests together with #6445, so once there's a clean head we'll run CI and the gates on that.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233726429 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6498#issuecomment-6233726429). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T12:10:55Z. --- @Amoenus this now conflicts with main after today's AGC merges (GitHub reports it as DIRTY at beee99c33). Could you rebase it? It's queued for our game tests together with #6445, so once there's a clean head we'll run CI and the gates on that.
Amoenus commented 2026-10-17 13:16:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-17T13:16:03Z.


@oneandonlydean rebased and pushed: dd44829aa3a3239570c6a414b191dbea0baaa9dd, based on main c9e6c45de9 and clean against the newer 3a26ce271d.

Kept the new upstream vertex/index coverage and corrected the fixture's cleanup order so prepared buffer plans/recipes release before the Vulkan device. The production buffer guard is unchanged.

Validation on this exact head: Windows/Linux relinker and library builds; sample-target and native-vertex tests each pass 3 fresh processes on RTX 5080, AMD Radeon Graphics and llvmpipe (18 GPU test passes total); CPU graphics 3/3 on each OS. Windows Khronos 1.4.363 reports no validation errors/warnings. Conventions and registration pass. Full details, including the four existing analyzer advisories, are updated in the description.

Ready for your CI and game gates with #6445. No new title-unblock claim from these focused tests.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6234326826 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6498#issuecomment-6234326826). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-17T13:16:03Z. --- @oneandonlydean rebased and pushed: `dd44829aa3a3239570c6a414b191dbea0baaa9dd`, based on main `c9e6c45de9` and clean against the newer `3a26ce271d`. Kept the new upstream vertex/index coverage and corrected the fixture's cleanup order so prepared buffer plans/recipes release before the Vulkan device. The production buffer guard is unchanged. Validation on this exact head: Windows/Linux relinker and library builds; sample-target and native-vertex tests each pass 3 fresh processes on RTX 5080, AMD Radeon Graphics and llvmpipe (18 GPU test passes total); CPU graphics 3/3 on each OS. Windows Khronos 1.4.363 reports no validation errors/warnings. Conventions and registration pass. Full details, including the four existing analyzer advisories, are updated in the description. Ready for your CI and game gates with #6445. No new title-unblock claim from these focused tests.
oneandonlydean commented 2026-10-17 23:09:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T23:09:31Z.


This PR no longer merges cleanly into current main. Could you rebase onto current main? It is stacked with #6445 for our game gate, so we will run full CI and the gate on the new head from there.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6242867779 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6498#issuecomment-6242867779). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T23:09:31Z. --- This PR no longer merges cleanly into current main. Could you rebase onto current main? It is stacked with #6445 for our game gate, so we will run full CI and the gate on the new head from there.
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!6498
No description provided.