fix(agc): size multisample guest guards by fragment blocks #4199

Merged
sanxchep merged 1 commit from upstream-pr/4199 into main 2026-10-13 02:36:15 +00:00
sanxchep commented 2026-10-12 01:08:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by sanxchep on 2026-10-12T01:08:50Z.


What

Size the guest-memory guard for a multisampled RenderTarget using 64 KiB blocks whose pixel dimensions account for fragment count. The old max(single-sample CB bytes × samples, raw pixel bytes × samples) bound can cover a neighboring allocation. For example, a 1920×1080 RGBA8 4× target occupies 0x1fe0000 bytes with fragment-aware blocks, while the previous guard spans 0x21c0000 bytes.

Keep the conservative bound for other tile modes. Add guard regressions for tiled 2× and 8× targets, a layout check for the 1920×1080 case, and document that console layout equivalence has not been measured.

This is independent of custom sample-location support in #2169. PR #2132 computes the same block dimensions for color-memory fills; if it merges first, this guard can reuse its footprint helper during integration.

Tested

Linux, Release, GCC 13.3:

  • agc_driver_graphics — passed (3.40 s)
  • agc_multisample_guest_access — passed (1.20 s)
  • python3 tools/check_conventions.py --base origin/main — passed
  • git diff --check — passed

A title was run with the patch and reported working by the PR author. Console layout equivalence was not separately measured.

Checklist

  • Based on current main; no other open PR changes the guest-read guard
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source; none added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4823745959 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4199). Originally posted by [sanxchep](https://github.com/sanxchep) on 2026-10-12T01:08:50Z. --- ### What Size the guest-memory guard for a multisampled `RenderTarget` using 64 KiB blocks whose pixel dimensions account for fragment count. The old `max(single-sample CB bytes × samples, raw pixel bytes × samples)` bound can cover a neighboring allocation. For example, a 1920×1080 RGBA8 4× target occupies `0x1fe0000` bytes with fragment-aware blocks, while the previous guard spans `0x21c0000` bytes. Keep the conservative bound for other tile modes. Add guard regressions for tiled 2× and 8× targets, a layout check for the 1920×1080 case, and document that console layout equivalence has not been measured. This is independent of custom sample-location support in #2169. PR #2132 computes the same block dimensions for color-memory fills; if it merges first, this guard can reuse its footprint helper during integration. ### Tested Linux, Release, GCC 13.3: - `agc_driver_graphics` — passed (3.40 s) - `agc_multisample_guest_access` — passed (1.20 s) - `python3 tools/check_conventions.py --base origin/main` — passed - `git diff --check` — passed A title was run with the patch and reported working by the PR author. Console layout equivalence was not separately measured. ### Checklist - [x] Based on current `main`; no other open PR changes the guest-read guard - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source; none added - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
MarcZX10 commented 2026-10-12 01:13:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T01:13:44Z.


The conventions run (check 114622799227) fails because the PR template’s AI-assisted field is unanswered. Please mark AI-assisted: yes or no in the checklist/body so the required template check can pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6116006165 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4199#issuecomment-6116006165). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T01:13:44Z. --- The conventions run (check 114622799227) fails because the PR template’s AI-assisted field is unanswered. Please mark `AI-assisted: yes` or `no` in the checklist/body so the required template check can pass.
sanxchep commented 2026-10-12 01:16:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by sanxchep on 2026-10-12T01:16:17Z.


The conventions run (check 114622799227) fails because the PR template’s AI-assisted field is unanswered. Please mark AI-assisted: yes or no in the checklist/body so the required template check can pass.

done

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6116027821 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4199#issuecomment-6116027821). Originally posted by [sanxchep](https://github.com/sanxchep) on 2026-10-12T01:16:17Z. --- > The conventions run (check 114622799227) fails because the PR template’s AI-assisted field is unanswered. Please mark `AI-assisted: yes` or `no` in the checklist/body so the required template check can pass. done
blawesom commented 2026-10-12 12:28:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-12T12:28:13Z.


Rebase handoff — this branch was ~347 commits behind main (only a trivial TechnicalDebt.md union conflict). Rebased onto current main, authorship unchanged; both doc entries kept.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

  • builds; tools/check_conventions.py --base origin/main passes
  • full suite: 949/949 passed

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/4199
git checkout <your branch>
git merge --ff-only FETCH_HEAD   # or reset to it

Head is 5ab79cd51. (This PR also passed an earlier independent pre-review at its previous base — full suite was green there too.)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6124262512 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4199#issuecomment-6124262512). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-12T12:28:13Z. --- **Rebase handoff** — this branch was ~347 commits behind `main` (only a trivial `TechnicalDebt.md` union conflict). Rebased onto current `main`, authorship unchanged; both doc entries kept. Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): - builds; `tools/check_conventions.py --base origin/main` passes - **full suite: 949/949 passed** **To pick it up:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/4199 git checkout <your branch> git merge --ff-only FETCH_HEAD # or reset to it ``` Head is `5ab79cd51`. (This PR also passed an earlier independent pre-review at its previous base — full suite was green there too.)
sanxchep commented 2026-10-12 15:35:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by sanxchep on 2026-10-12T15:35:59Z.


Rebase handoff — this branch was ~347 commits behind main (only a trivial TechnicalDebt.md union conflict). Rebased onto current main, authorship unchanged; both doc entries kept.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

  • builds; tools/check_conventions.py --base origin/main passes
  • full suite: 949/949 passed

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/4199
git checkout <your branch>
git merge --ff-only FETCH_HEAD   # or reset to it

Head is 5ab79cd51. (This PR also passed an earlier independent pre-review at its previous base — full suite was green there too.)

done

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6127478517 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4199#issuecomment-6127478517). Originally posted by [sanxchep](https://github.com/sanxchep) on 2026-10-12T15:35:59Z. --- > **Rebase handoff** — this branch was ~347 commits behind `main` (only a trivial `TechnicalDebt.md` union conflict). Rebased onto current `main`, authorship unchanged; both doc entries kept. > > Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): > > * builds; `tools/check_conventions.py --base origin/main` passes > * **full suite: 949/949 passed** > > **To pick it up:** > > ``` > git fetch https://github.com/blawesom/AnyPS5 rebase/4199 > git checkout <your branch> > git merge --ff-only FETCH_HEAD # or reset to it > ``` > > Head is `5ab79cd51`. (This PR also passed an earlier independent pre-review at its previous base — full suite was green there too.) done
blawesom commented 2026-10-12 17:15:32 +00:00 (Migrated from github.com)

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


Independent verification of your rebase — the new head builds and passes the full local suite on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV): 957/957, conventions green. From my side this is merge-ready.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6129061296 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4199#issuecomment-6129061296). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-12T17:15:32Z. --- **Independent verification of your rebase** — the new head builds and passes the full local suite on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): **957/957**, conventions green. From my side this is merge-ready.
sanxchep commented 2026-10-12 18:16:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by sanxchep on 2026-10-12T18:16:56Z.


@MarcZX100 should be ready to merge

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6130013173 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4199#issuecomment-6130013173). Originally posted by [sanxchep](https://github.com/sanxchep) on 2026-10-12T18:16:56Z. --- @MarcZX100 should be ready to merge
kr4y4 commented 2026-10-12 18:57:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kr4y4 on 2026-10-12T18:57:47Z.


Windows run, to go with the Linux runs above.

Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head cff1f68d5 merged into main 2a5eca11c, with no conflicts.

  • agc_multisample_guest_access and agc_driver_graphics (with the new ColorTargetLayout check) pass on both GPUs with --repeat until-fail:3.
  • With main's MultisampleTarget.cpp and the new tests, agc_multisample_guest_access fails on both GPUs: a CPU read of 0x…90000+0x40 overlaps multisampled color target 0x…80000+0x40000 (4 samples), whose samples are only on the host: guest access to it is not implemented.
  • Full suite (ctest --timeout 120 --parallel 4): 973 of 973 on the RTX 4070. On the iGPU 972 of 973; the one failure, agc_driver_f32_dot2_rounding, fails the same way on main (no shaderFloat64, #4528).

This touches guard() in MultisampleTarget.cpp like #4474, so whichever lands second will need a rebase there.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6130664482 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4199#issuecomment-6130664482). Originally posted by [kr4y4](https://github.com/kr4y4) on 2026-10-12T18:57:47Z. --- Windows run, to go with the Linux runs above. Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head cff1f68d5 merged into `main` 2a5eca11c, with no conflicts. - `agc_multisample_guest_access` and `agc_driver_graphics` (with the new `ColorTargetLayout` check) pass on both GPUs with `--repeat until-fail:3`. - With `main`'s `MultisampleTarget.cpp` and the new tests, `agc_multisample_guest_access` fails on both GPUs: `a CPU read of 0x…90000+0x40 overlaps multisampled color target 0x…80000+0x40000 (4 samples), whose samples are only on the host: guest access to it is not implemented`. - Full suite (`ctest --timeout 120 --parallel 4`): 973 of 973 on the RTX 4070. On the iGPU 972 of 973; the one failure, `agc_driver_f32_dot2_rounding`, fails the same way on `main` (no `shaderFloat64`, #4528). This touches `guard()` in `MultisampleTarget.cpp` like #4474, so whichever lands second will need a rebase there. Written with AI assistance.
github-actions[bot] commented 2026-10-13 00:59:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T00:59:13Z.


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
#4474 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L195-196
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp L4661-4662
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6135741959 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4199#issuecomment-6135741959). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T00:59:13Z. --- <!-- pr-overlap --> 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 | |---|---|---|---| | #4474 | `core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp` [L195-196](https://github.com/boykopovar/AnyPS5/blob/495bf91a04b2564772c4f0fdc19012bed9b8af01/core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp#L195-L196)<br>`core/libs/prx/libSceAgcDriver/tests/Recorder.cpp` [L4661-4662](https://github.com/boykopovar/AnyPS5/blob/495bf91a04b2564772c4f0fdc19012bed9b8af01/core/libs/prx/libSceAgcDriver/tests/Recorder.cpp#L4661-L4662) | | |
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!4199
No description provided.