fix(agc): rasterize a single-sample scan into a multisampled target at the pixel center #4414

Merged
reyani-dev merged 1 commit from upstream-pr/4414 into main 2026-10-12 18:23:57 +00:00
reyani-dev commented 2026-10-12 10:06:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-12T10:06:54Z.


What

A draw whose rasterizer is single-sample (PA_SC_AA_CONFIG.MSAA_NUM_SAMPLES = 0) with MSAA_ENABLE off, into a multisampled color target, throws a color target's sample count differs from the rasterizer's.

The hardware supports this combination. radeonsi programs exactly this when GL multisampling is disabled on a multisampled framebuffer: in si_emit_msaa_config (si_state.c, mesa-25.2.0), sc_aa_config stays 0 unless rs->multisample_enable, and MSAA_ENABLE follows state->multisample, while CB_COLORi_ATTRIB keeps the framebuffer's samples. GL defines the result: with MULTISAMPLE disabled, rasterization is single-sample at the fragment center "except that the fragment coverage value is set to full coverage", so every sample gets the pixel's color.

Such a draw now rasterizes the color target's sample count with every sample location at the pixel center (the custom sample locations from #2169), so all samples are covered exactly when the center is. It applies only with no depth target, no alpha-to-coverage and MSAA_ENABLE off, and only when the first written color target is multisampled. Any other mix still throws, and MSAA_ENABLE on keeps #4309's checks.

Title: ProsperoPuzzles (PPSA99006) stops here on main 9bc362351 at its first draw into its 4x target:

  what():  AGC graphics: a color target's sample count differs from the rasterizer's

Register values at that draw (posted on #419): CB_COLOR0_ATTRIB 0x00012000 (4 samples, 4 fragments), PA_SC_AA_CONFIG 0x00000000, PA_SC_MODE_CNTL_0 0x00000022 (MSAA_ENABLE off), no depth. The title renders through blackbearreloaded/ps5-opengl (Mesa gallium on AGC), the same driver family as radeonsi. With this change it gets past that draw and stops at the next one, which samples that 4x image: DescriptorBindingBuilder::Populate multisampled image resources have no descriptor image shape (#3036).

Tested

Windows 11 (26200), RTX 4070, WinLibs GCC 15.2.0 r7, Release, main 9bc362351:

  • agc_driver_graphics (multisampleTests): AA config 0, MSAA_ENABLE off and a 4x/4f target decode as 4 samples with customSampleLocations and all four locations at (0.5, 0.5). With MSAA_ENABLE on, the same draw is still refused (by #4309's check). This fails with main's State.cpp and passes with this change.
  • ctest -E "^agc_|video_out|^shader|recompiler": 497/497. GPU suite (VK_LOADER_DRIVERS_DISABLE=*dzn*, #3255): 441/441.
  • ProsperoPuzzles, before and after (above).
  • tools/check_conventions.py and tools/pr_overlap.py: clean.

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 in TechnicalDebt
  • 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: PPSA99006 #4427
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4827889366 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4414). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-12T10:06:54Z. --- ### What A draw whose rasterizer is single-sample (`PA_SC_AA_CONFIG.MSAA_NUM_SAMPLES` = 0) with `MSAA_ENABLE` off, into a multisampled color target, throws `a color target's sample count differs from the rasterizer's`. The hardware supports this combination. radeonsi programs exactly this when GL multisampling is disabled on a multisampled framebuffer: in `si_emit_msaa_config` ([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#L3518-L3530)), `sc_aa_config` stays 0 unless `rs->multisample_enable`, and `MSAA_ENABLE` follows `state->multisample`, while `CB_COLORi_ATTRIB` keeps the framebuffer's samples. GL defines the result: with `MULTISAMPLE` disabled, rasterization is single-sample at the fragment center "except that the fragment coverage value is set to full coverage", so every sample gets the pixel's color. Such a draw now rasterizes the color target's sample count with every sample location at the pixel center (the custom sample locations from #2169), so all samples are covered exactly when the center is. It applies only with no depth target, no alpha-to-coverage and `MSAA_ENABLE` off, and only when the first written color target is multisampled. Any other mix still throws, and `MSAA_ENABLE` on keeps #4309's checks. **Title:** ProsperoPuzzles (PPSA99006) stops here on `main` 9bc362351 at its first draw into its 4x target: ``` what(): AGC graphics: a color target's sample count differs from the rasterizer's ``` Register values at that draw (posted on #419): `CB_COLOR0_ATTRIB` `0x00012000` (4 samples, 4 fragments), `PA_SC_AA_CONFIG` `0x00000000`, `PA_SC_MODE_CNTL_0` `0x00000022` (`MSAA_ENABLE` off), no depth. The title renders through blackbearreloaded/ps5-opengl (Mesa gallium on AGC), the same driver family as radeonsi. With this change it gets past that draw and stops at the next one, which samples that 4x image: `DescriptorBindingBuilder::Populate multisampled image resources have no descriptor image shape` (#3036). ### Tested Windows 11 (26200), RTX 4070, WinLibs GCC 15.2.0 r7, Release, `main` 9bc362351: - `agc_driver_graphics` (`multisampleTests`): AA config 0, `MSAA_ENABLE` off and a 4x/4f target decode as 4 samples with `customSampleLocations` and all four locations at (0.5, 0.5). With `MSAA_ENABLE` on, the same draw is still refused (by #4309's check). This fails with main's `State.cpp` and passes with this change. - `ctest -E "^agc_|video_out|^shader|recompiler"`: 497/497. GPU suite (`VK_LOADER_DRIVERS_DISABLE=*dzn*`, #3255): 441/441. - ProsperoPuzzles, before and after (above). - `tools/check_conventions.py` and `tools/pr_overlap.py`: clean. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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: PPSA99006 #4427 - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
xXPBSXx commented 2026-10-12 12:40:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T12:40:26Z.


Windows test (MinGW, local build): PR head merged onto main c5675762a without conflicts; agc_driver_graphics (ctest) passes, including the new test from this PR. Not tested: no game run, no other test suites.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6124448029 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4414#issuecomment-6124448029). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-12T12:40:26Z. --- Windows test (MinGW, local build): PR head merged onto main c5675762a without conflicts; `agc_driver_graphics` (ctest) passes, including the new test from this PR. Not tested: no game run, no other test suites. AI-assisted (Claude Code).
xXPBSXx commented 2026-10-12 12:40:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T12:40:41Z.


Correction to my test comment: the base I actually built and tested was main 0ef9dc928, not c5675762a (my local upstream/main ref had moved). Result unchanged: clean merge, agc_driver_graphics passes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6124451868 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4414#issuecomment-6124451868). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-12T12:40:41Z. --- Correction to my test comment: the base I actually built and tested was main 0ef9dc928, not c5675762a (my local upstream/main ref had moved). Result unchanged: clean merge, `agc_driver_graphics` passes. AI-assisted (Claude Code).
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!4414
No description provided.