fix(agc): rasterize a multisampled target without MSAA_ENABLE at the pixel center #5882

Merged
billythemenace2 merged 2 commits from upstream-pr/5882 into main 2026-10-15 21:58:25 +00:00
billythemenace2 commented 2026-10-14 14:40:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by billythemenace2 on 2026-10-14T14:40:20Z.


Requested by billy

What

Before: a draw whose PA_SC_AA_CONFIG.MSAA_NUM_SAMPLES is above 0 while PA_SC_MODE_CNTL_0.MSAA_ENABLE is clear threw "multisampled targets rasterized without MSAA_ENABLE are unsupported". SONIC SUPERSTARS (PPSA06888) stops on such a draw: a 2x color target, no depth target, no alpha-to-coverage, PA_SC_AA_CONFIG 0x00108001, PA_SC_MODE_CNTL_0 0, nonstandard sample locations (0xc44c).

After: such a draw keeps the target's sample count and puts every sample at the pixel center, the representation #4414 already uses for a single-sample scan into a multisampled target. Points, lines, a depth target and alpha-to-coverage still throw.

Where the semantics come from (not measured on hardware; the hardware oracle runs compute kernels only):

  • On GFX10 and later, MSAA_ENABLE is what makes the rasterizer use the programmed sample locations: RADV 061bc615 sets it for 1x user sample locations because they have no effect without it. The MSAA_ENABLE on a single-sample target debt entry relies on the same commit.
  • radeonsi sets MSAA_ENABLE from the GL multisample state (si_state.c, mesa-25.2.0). With multisampling disabled, GL rasterizes at the pixel center and gives the fragment full coverage, so every sample gets the pixel's value.
  • AMD's Evergreen register reference describes the bit as "Enable MultiSample AA in DX10 and below. Used for lines in DX10.1 and above". That predates the RADV finding for GFX10, which shows the bit still changes triangle sampling there. Lines are left throwing, because an aliased line on the hardware is not a Vulkan rectangular line.

The debt entry in docs/dev/debt/libSceAgcDriver.md records that the result with MSAA_NUM_SAMPLES above 0 is inferred.

How

DecodeState used to refuse the combination after decoding the depth target and alpha-to-coverage state. It now accepts it for filled primitives without either, and sets customSampleLocations with every location at the center. That is the same path SampleLocations already serves for #4414. The Graphics.cpp case that expected the refusal now checks the sample count and the centered locations, and that alpha-to-coverage still throws.

Tested

Windows 11, MinGW-w64 GCC 15, Release. agc_driver_graphics and agc_driver_msaa_enable_single_sample pass, and tools/check_conventions.py --base origin/main passes. SONIC SUPERSTARS (PPSA06888), on main with #5865, #5375 and #5456 merged locally, gets past this stop and reaches the next one: a shader reading a multisampled image. I did not compare the picture with a console. Not tested: Linux, other GPU vendors.

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
  • Unblocks: PPSA06888 (SONIC SUPERSTARS) #5382; it also needs #5865, #5375 and #5456
  • GPUs tested: AMD Radeon RX 5700 XT, AMD Software (amdvlk64), Windows 11
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4859604598 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5882). Originally posted by [billythemenace2](https://github.com/billythemenace2) on 2026-10-14T14:40:20Z. --- <!-- claude-projects-attribution --> _Requested by **billy**_ ### What Before: a draw whose `PA_SC_AA_CONFIG.MSAA_NUM_SAMPLES` is above 0 while `PA_SC_MODE_CNTL_0.MSAA_ENABLE` is clear threw "multisampled targets rasterized without MSAA_ENABLE are unsupported". SONIC SUPERSTARS (PPSA06888) stops on such a draw: a 2x color target, no depth target, no alpha-to-coverage, `PA_SC_AA_CONFIG` 0x00108001, `PA_SC_MODE_CNTL_0` 0, nonstandard sample locations (0xc44c). After: such a draw keeps the target's sample count and puts every sample at the pixel center, the representation #4414 already uses for a single-sample scan into a multisampled target. Points, lines, a depth target and alpha-to-coverage still throw. Where the semantics come from (not measured on hardware; the hardware oracle runs compute kernels only): - On GFX10 and later, `MSAA_ENABLE` is what makes the rasterizer use the programmed sample locations: [RADV 061bc615](https://gitlab.freedesktop.org/mesa/mesa/-/commit/061bc6151a11597f720535f00e79a5752e24aff6) sets it for 1x user sample locations because they have no effect without it. The `MSAA_ENABLE on a single-sample target` debt entry relies on the same commit. - radeonsi sets `MSAA_ENABLE` from the GL multisample state ([si_state.c, mesa-25.2.0](https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-25.2.0/src/gallium/drivers/radeonsi/si_state.c#L1078)). With multisampling disabled, GL rasterizes at the pixel center and gives the fragment full coverage, so every sample gets the pixel's value. - AMD's Evergreen register reference describes the bit as "Enable MultiSample AA in DX10 and below. Used for lines in DX10.1 and above". That predates the RADV finding for GFX10, which shows the bit still changes triangle sampling there. Lines are left throwing, because an aliased line on the hardware is not a Vulkan rectangular line. The debt entry in `docs/dev/debt/libSceAgcDriver.md` records that the result with `MSAA_NUM_SAMPLES` above 0 is inferred. ### How `DecodeState` used to refuse the combination after decoding the depth target and alpha-to-coverage state. It now accepts it for filled primitives without either, and sets `customSampleLocations` with every location at the center. That is the same path `SampleLocations` already serves for #4414. The `Graphics.cpp` case that expected the refusal now checks the sample count and the centered locations, and that alpha-to-coverage still throws. ### Tested Windows 11, MinGW-w64 GCC 15, Release. `agc_driver_graphics` and `agc_driver_msaa_enable_single_sample` pass, and `tools/check_conventions.py --base origin/main` passes. SONIC SUPERSTARS (PPSA06888), on main with #5865, #5375 and #5456 merged locally, gets past this stop and reaches the next one: a shader reading a multisampled image. I did not compare the picture with a console. Not tested: Linux, other GPU vendors. ### Checklist - [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 - [x] Unblocks: PPSA06888 (SONIC SUPERSTARS) #5382; it also needs #5865, #5375 and #5456 - [x] GPUs tested: AMD Radeon RX 5700 XT, AMD Software (amdvlk64), Windows 11 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
mrfelek commented 2026-10-14 16:21:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mrfelek on 2026-10-14T16:21:19Z.


Real-title check. METAL GEAR SOLID: Peace Walker (PPSA18216), Linux, RTX 3080 Ti (NVIDIA 615.71.09), main e34c47921 plus #5439, #5915 and this PR, with the launcher hand-over from boykopovar/AnyPS5#5268. After #5915 clears the single-sample draw over a 4-sample depth target, the frame stops at this PR's multisampled targets rasterized without MSAA_ENABLE are unsupported for points, lines, a depth target or alpha-to-coverage (the !result.depth check in State.cpp). The draw is a depth plus colour pair with MSAA_ENABLE clear: PA_SC_AA_CONFIG 0x0020c002, DB_EQAA 0x00010002, DB_Z_INFO 0xa290098b (4 samples), DB_DEPTH_CONTROL 0x00000710 and 0x00000711, CB_COLOR0_INFO 0x00008028, CB_COLOR0_ATTRIB 0x00012000 (4 samples, 4 fragments), no PA_SC_MODE_CNTL_0 bit 0 (value 0x2). So this is the case discussed on #5268 as draw B. I can rerun with more registers if useful.

AI-assisted; the runs are from my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6172999090 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5882#issuecomment-6172999090). Originally posted by [mrfelek](https://github.com/mrfelek) on 2026-10-14T16:21:19Z. --- Real-title check. METAL GEAR SOLID: Peace Walker (PPSA18216), Linux, RTX 3080 Ti (NVIDIA 615.71.09), `main` e34c47921 plus #5439, #5915 and this PR, with the launcher hand-over from boykopovar/AnyPS5#5268. After #5915 clears the single-sample draw over a 4-sample depth target, the frame stops at this PR's `multisampled targets rasterized without MSAA_ENABLE are unsupported for points, lines, a depth target or alpha-to-coverage` (the `!result.depth` check in `State.cpp`). The draw is a depth plus colour pair with `MSAA_ENABLE` clear: `PA_SC_AA_CONFIG` 0x0020c002, `DB_EQAA` 0x00010002, `DB_Z_INFO` 0xa290098b (4 samples), `DB_DEPTH_CONTROL` 0x00000710 and 0x00000711, `CB_COLOR0_INFO` 0x00008028, `CB_COLOR0_ATTRIB` 0x00012000 (4 samples, 4 fragments), no `PA_SC_MODE_CNTL_0` bit 0 (value 0x2). So this is the case discussed on #5268 as draw B. I can rerun with more registers if useful. AI-assisted; the runs are from my machine.
SandstromPL commented 2026-10-14 16:46:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SandstromPL on 2026-10-14T16:46:14Z.


MGS Peace Walker (PPSA18216, #5268) reaches this refusal with a depth target bound. On main + #5439 + #5915 + this PR, mrfelek's run stops at draw B: PA_SC_AA_CONFIG 0x0020c002 (4x), MSAA_ENABLE clear, DB_Z_INFO 0xa290098b (4x), CB_COLOR0_ATTRIB 0x00012000 (4x/4f), from https://github.com/boykopovar/AnyPS5/discussions/5268#discussioncomment-18926400. #5915 handles the single-sample-rasterizer version with a depth target by centring the depth samples too. Would you extend this PR to a depth target the same way, or would you prefer a follow-up after it merges? Happy to send that follow-up.
AI-assisted

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6173483717 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5882#issuecomment-6173483717). Originally posted by [SandstromPL](https://github.com/SandstromPL) on 2026-10-14T16:46:14Z. --- MGS Peace Walker (PPSA18216, #5268) reaches this refusal with a depth target bound. On `main` + #5439 + #5915 + this PR, mrfelek's run stops at draw B: `PA_SC_AA_CONFIG` 0x0020c002 (4x), `MSAA_ENABLE` clear, `DB_Z_INFO` 0xa290098b (4x), `CB_COLOR0_ATTRIB` 0x00012000 (4x/4f), from https://github.com/boykopovar/AnyPS5/discussions/5268#discussioncomment-18926400. #5915 handles the single-sample-rasterizer version with a depth target by centring the depth samples too. Would you extend this PR to a depth target the same way, or would you prefer a follow-up after it merges? Happy to send that follow-up. AI-assisted
billythemenace2 commented 2026-10-14 18:34:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by billythemenace2 on 2026-10-14T18:34:22Z.


@mrfelek @SandstromPL Thanks for the Peace Walker data. I'd keep this PR to the case it was checked on, filled primitives with no depth target and no alpha-to-coverage, and take the depth target in a follow-up after it merges. #5915 already centres the depth samples for the single-sample-rasterizer case, so the depth handling belongs with that work. @SandstromPL, please go ahead with the follow-up.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175536337 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5882#issuecomment-6175536337). Originally posted by [billythemenace2](https://github.com/billythemenace2) on 2026-10-14T18:34:22Z. --- @mrfelek @SandstromPL Thanks for the Peace Walker data. I'd keep this PR to the case it was checked on, filled primitives with no depth target and no alpha-to-coverage, and take the depth target in a follow-up after it merges. #5915 already centres the depth samples for the single-sample-rasterizer case, so the depth handling belongs with that work. @SandstromPL, please go ahead with the follow-up. AI-assisted (Claude Code).
SandstromPL commented 2026-10-14 19:21:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SandstromPL on 2026-10-14T19:21:48Z.


One thing for this PR on current main: since #5861, decodeSampleLocations sets sampleLocationGrid for a pattern that varies between pixels (State.cpp:438), and this block fills the locations with zeros but leaves the flag set. The locations are then all centred, but Pipeline.cpp:120 still requires a 2x2 sample-location grid and the pipeline keys differ for the same state. Adding result.sampleLocationGrid = false; next to result.sampleLocations.fill(0); covers it. The draw B follow-up is up as #6014 , stacked on this PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6176447983 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5882#issuecomment-6176447983). Originally posted by [SandstromPL](https://github.com/SandstromPL) on 2026-10-14T19:21:48Z. --- One thing for this PR on current `main`: since #5861, `decodeSampleLocations` sets `sampleLocationGrid` for a pattern that varies between pixels (State.cpp:438), and this block fills the locations with zeros but leaves the flag set. The locations are then all centred, but Pipeline.cpp:120 still requires a 2x2 sample-location grid and the pipeline keys differ for the same state. Adding `result.sampleLocationGrid = false;` next to `result.sampleLocations.fill(0);` covers it. The draw B follow-up is up as #6014 , stacked on this PR.
billythemenace2 commented 2026-10-14 21:06:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by billythemenace2 on 2026-10-14T21:06:17Z.


@SandstromPL Thanks, good catch. Done in e10ec3904 on top of a rebase onto current main: the block now also clears sampleLocationGrid. The test adds a 2x target without MSAA_ENABLE whose pixel 1 holds different locations, and checks that it ends up centred with no grid. The test fails without the line and passes with it, and tools/check_conventions.py passes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6178507383 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5882#issuecomment-6178507383). Originally posted by [billythemenace2](https://github.com/billythemenace2) on 2026-10-14T21:06:17Z. --- @SandstromPL Thanks, good catch. Done in `e10ec3904` on top of a rebase onto current `main`: the block now also clears `sampleLocationGrid`. The test adds a 2x target without `MSAA_ENABLE` whose pixel 1 holds different locations, and checks that it ends up centred with no grid. The test fails without the line and passes with it, and `tools/check_conventions.py` passes. AI-assisted (Claude Code).
github-actions[bot] commented 2026-10-15 12:11:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:11:04Z.


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
PR 6563 docs/dev/debt/libSceAgcDriver.md L21

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4448 docs/dev/debt/libSceAgcDriver.md
PR 4650 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 5058 docs/dev/debt/libSceAgcDriver.md
PR 5499 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 5500 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5761 docs/dev/debt/libSceAgcDriver.md
PR 5867 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
PR 5925 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6222 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6235 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191729708 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5882#issuecomment-6191729708). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:11:04Z. --- <!-- 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 | |---|---|---|---| | [PR 6563](https://www.github.com/boykopovar/AnyPS5/pull/6563) | `docs/dev/debt/libSceAgcDriver.md` [L21](https://github.com/boykopovar/AnyPS5/blob/e16b2bcce15f5cf441f8e7ad99b545e08fd24ef6/docs/dev/debt/libSceAgcDriver.md#L21) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 1395](https://www.github.com/boykopovar/AnyPS5/pull/1395) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 4040](https://www.github.com/boykopovar/AnyPS5/pull/4040) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 4448](https://www.github.com/boykopovar/AnyPS5/pull/4448) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 4650](https://www.github.com/boykopovar/AnyPS5/pull/4650) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 5058](https://www.github.com/boykopovar/AnyPS5/pull/5058) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 5499](https://www.github.com/boykopovar/AnyPS5/pull/5499) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 5500](https://www.github.com/boykopovar/AnyPS5/pull/5500) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 5761](https://www.github.com/boykopovar/AnyPS5/pull/5761) | `docs/dev/debt/libSceAgcDriver.md` | | [PR 5867](https://www.github.com/boykopovar/AnyPS5/pull/5867) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6188](https://www.github.com/boykopovar/AnyPS5/pull/6188) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`docs/dev/debt/libSceAgcDriver.md` | | [PR 6235](https://www.github.com/boykopovar/AnyPS5/pull/6235) | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` |
adriadam10 commented 2026-10-15 14:12:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T14:12:20Z.


Checked on the merged tree: agc_driver_graphics passes and fails without the State.cpp change (the 2x case, the alpha-to-coverage throw and the cleared sampleLocationGrid are all pinned). The libSceAgcDriver ctest scope is green apart from agc_driver_tessellation, which segfaults on main too. The debt entry is in place and marks the pixel-center result as inferred. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6194153336 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5882#issuecomment-6194153336). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-15T14:12:20Z. --- Checked on the merged tree: `agc_driver_graphics` passes and fails without the `State.cpp` change (the 2x case, the alpha-to-coverage throw and the cleared `sampleLocationGrid` are all pinned). The libSceAgcDriver ctest scope is green apart from `agc_driver_tessellation`, which segfaults on main too. The debt entry is in place and marks the pixel-center result as inferred. Merging once the full Build is green.
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!5882
No description provided.