fix(agc): upload initial MSAA color through an attachment fallback #20579

Merged
carminelau merged 1 commit from upstream-pr/20579 into main 2026-11-17 03:19:00 +00:00
carminelau commented 2026-11-15 10:18:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by carminelau on 2026-11-15T10:18:48Z.


What

Import nonuniform initial MSAA color on hosts that lack shaderStorageImageMultisample or shaderStorageImageWriteWithoutFormat and support the required multisampled color attachment and sample-rate shading. A fragment pass writes each guest sample through a format-compatible unsigned attachment view. The existing compute upload is still used when its features are available.

Reuse the staging buffer and respect storage-buffer alignment and range limits. Keep the upload resources alive through submission and use the recorder's uncounted pass for the internal draw.

Tested

Ran ctest --test-dir build -R '^agc_driver_native_color_initial_' -V on the same Intel Arc 140V, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, and VK_LOADER_DEBUG=layer. The loader inserted validation layer 1.4.363 in all seven test processes in both runs.

Build Passed Skipped Vulkan VUIDs
main at 055010d80b 3 4 0
This PR 7 0 0

The four nonuniform cases ran on the attachment fallback. The sample checks covered 2×, 4×, and 8× MSAA with pipe-bank XOR values of 0 and 0x8100. The capability fixture also forced a 256-byte storage buffer range.

A separate title smoke test with the same fallback applied to AnyPS5 v0.1.5 reached the title screen of Plants vs. Zombies: Replanted (PPSA29802, 01.510.000) on the same GPU.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: PPSA29802, Game bring-up #6404 (verified through the title screen)
  • GPUs tested: Intel Arc 140V, Intel graphics driver 101.8991, Windows 11 build 26300
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5321734844 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20579). Originally posted by [carminelau](https://github.com/carminelau) on 2026-11-15T10:18:48Z. --- ### What Import nonuniform initial MSAA color on hosts that lack `shaderStorageImageMultisample` or `shaderStorageImageWriteWithoutFormat` and support the required multisampled color attachment and sample-rate shading. A fragment pass writes each guest sample through a format-compatible unsigned attachment view. The existing compute upload is still used when its features are available. Reuse the staging buffer and respect storage-buffer alignment and range limits. Keep the upload resources alive through submission and use the recorder's uncounted pass for the internal draw. ### 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. --> Ran `ctest --test-dir build -R '^agc_driver_native_color_initial_' -V` on the same Intel Arc 140V, with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, and `VK_LOADER_DEBUG=layer`. The loader inserted validation layer 1.4.363 in all seven test processes in both runs. | Build | Passed | Skipped | Vulkan VUIDs | | --- | ---: | ---: | ---: | | `main` at `055010d80b` | 3 | 4 | 0 | | This PR | 7 | 0 | 0 | The four nonuniform cases ran on the attachment fallback. The sample checks covered 2×, 4×, and 8× MSAA with pipe-bank XOR values of 0 and 0x8100. The capability fixture also forced a 256-byte storage buffer range. A separate title smoke test with the same fallback applied to AnyPS5 v0.1.5 reached the title screen of Plants vs. Zombies: Replanted (PPSA29802, 01.510.000) on the same GPU. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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: PPSA29802, [Game bring-up #6404](https://github.com/boykopovar/AnyPS5/discussions/6404) (verified through the title screen) <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: Intel Arc 140V, Intel graphics driver 101.8991, Windows 11 build 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 -->
MarcZX10 commented 2026-11-15 10:41:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T10:41:50Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the points below are optional.

What I ran

Reviewed head 7b770f9cad9520e4d3b37f0c4eecf8334e0a458a. I used repo_read.py to inspect the prepared diff and targeted source ranges; I ran no build or tests. The PR description reports Vulkan validation tests and a title smoke test; those were not run by me.

Results

Check Result Note
Diff and targeted source review passed All changed files were read
Build and tests not run Author-reported results only

Findings

Blocking

None.

Non-blocking

  • The attachment fallback creates a separate descriptor set for every storage-buffer chunk and a draw for each set. Very large initial targets could require many descriptor sets and draws; consider batching or imposing a practical chunk-count limit if this is seen in real workloads. (core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleUpload.cpp:93)

Not verified

No build, test, physical-console run, or independent confirmation of the author-reported results was performed. I read every changed file listed in the manifest: core/libs/prx/libSceAgcDriver/CMakeLists.txt, core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp, core/libs/prx/libSceAgcDriver/Graphics/shaders/MultisampleUpload.comp, core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp, core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleUpload.cpp, core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp, and docs/dev/debt/changes/fix-agc-msaa-initial-color-upload.md. No changed files were excluded by the manifest.

To get this to a good state

Nothing is required. The chunk-count performance point above is optional.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5910289189 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20579#pullrequestreview-5910289189). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-15T10:41:50Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the points below are optional. ## What I ran Reviewed head `7b770f9cad9520e4d3b37f0c4eecf8334e0a458a`. I used `repo_read.py` to inspect the prepared diff and targeted source ranges; I ran no build or tests. The PR description reports Vulkan validation tests and a title smoke test; those were not run by me. ## Results | Check | Result | Note | | --- | --- | --- | | Diff and targeted source review | passed | All changed files were read | | Build and tests | not run | Author-reported results only | ## Findings ### Blocking None. ### Non-blocking - The attachment fallback creates a separate descriptor set for every storage-buffer chunk and a draw for each set. Very large initial targets could require many descriptor sets and draws; consider batching or imposing a practical chunk-count limit if this is seen in real workloads. (`core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleUpload.cpp:93`) ## Not verified No build, test, physical-console run, or independent confirmation of the author-reported results was performed. I read every changed file listed in the manifest: `core/libs/prx/libSceAgcDriver/CMakeLists.txt`, `core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp`, `core/libs/prx/libSceAgcDriver/Graphics/shaders/MultisampleUpload.comp`, `core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp`, `core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleUpload.cpp`, `core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp`, and `docs/dev/debt/changes/fix-agc-msaa-initial-color-upload.md`. No changed files were excluded by the manifest. ## To get this to a good state Nothing is required. The chunk-count performance point above is optional.
kurexw commented 2026-11-16 21:12:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kurexw on 2026-11-16T21:12:50Z.

Review: COMMENTED


Tested on an Apple M4 (macOS 27.2, MoltenVK 1.4.2 from the LunarG SDK 1.4.363.1, x86-64 build under Rosetta). This device has sampleRateShading and shaderStorageImageWriteWithoutFormat but no shaderStorageImageMultisample, so it is the case this fallback targets.

Method: main at 3b17977ba6 against this PR merged onto that commit (clean merge), three runs per side, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and VK_LOADER_DEBUG=layer:

ctest --test-dir build -R '^agc_driver_(native_color_(readback|snapshot|initial)|sample_multisample|multisample_srgb)' -V

Every test process logged Insert instance layer "VK_LAYER_KHRONOS_validation" (layer 1.4.363). None logged the missing-layer message. There were 0 VUID- lines on either side. All three runs were identical.

Test main This PR
agc_driver_native_color_snapshot Failed Passed
agc_driver_native_color_snapshot_refusals Failed Passed
agc_driver_native_color_initial_nonuniform Skipped Passed
agc_driver_native_color_initial_nonuniform_lifetime Skipped Passed
agc_driver_native_color_initial_nonuniform_capabilities Skipped Passed
agc_driver_native_color_initial_nonuniform_hook Skipped Passed
agc_driver_native_color_readback Failed Failed (a later step, see below)
agc_driver_sample_multisample_target Skipped Skipped
the other four (initial_uniform*, multisample_srgb_twin) Passed Passed

On main the failures were "initial multisample color samples require enabled formatless multisampled storage image writes". With this PR, the attachment fallback handles those imports on the M4.

agc_driver_native_color_readback now passes its 2× coverage, fill, refusal, chunk and exceptional-value checks. It then fails at SampleMultisampleTarget.cpp:1363, where the 4× pass calls StoreSamples. That step dispatches a guest shader that stores to a multisampled storage image, and the recompiler refuses it: SPIR-V module emission failed: storage image multisampling is unavailable on the target device. This is not a regression; on main the test never reached that line. A device without shaderStorageImageMultisample can't run that step at all.

Suggestion: gate that block on context.storageImageMultisample, as the same file already does at line 855 ("a dispatch's store after a claim not tested: storage image multisampling unavailable"). Then the remaining checks also run on MoltenVK. The PR's code needs no changes.

I didn't test this on Linux, Windows or another GPU vendor.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5927782537 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20579#pullrequestreview-5927782537). Originally posted by [kurexw](https://github.com/kurexw) on 2026-11-16T21:12:50Z. **Review:** COMMENTED --- Tested on an Apple M4 (macOS 27.2, MoltenVK 1.4.2 from the LunarG SDK 1.4.363.1, x86-64 build under Rosetta). This device has `sampleRateShading` and `shaderStorageImageWriteWithoutFormat` but no `shaderStorageImageMultisample`, so it is the case this fallback targets. Method: `main` at 3b17977ba6 against this PR merged onto that commit (clean merge), three runs per side, with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` and `VK_LOADER_DEBUG=layer`: ``` ctest --test-dir build -R '^agc_driver_(native_color_(readback|snapshot|initial)|sample_multisample|multisample_srgb)' -V ``` Every test process logged `Insert instance layer "VK_LAYER_KHRONOS_validation"` (layer 1.4.363). None logged the missing-layer message. There were 0 `VUID-` lines on either side. All three runs were identical. | Test | main | This PR | | --- | --- | --- | | `agc_driver_native_color_snapshot` | Failed | Passed | | `agc_driver_native_color_snapshot_refusals` | Failed | Passed | | `agc_driver_native_color_initial_nonuniform` | Skipped | Passed | | `agc_driver_native_color_initial_nonuniform_lifetime` | Skipped | Passed | | `agc_driver_native_color_initial_nonuniform_capabilities` | Skipped | Passed | | `agc_driver_native_color_initial_nonuniform_hook` | Skipped | Passed | | `agc_driver_native_color_readback` | Failed | Failed (a later step, see below) | | `agc_driver_sample_multisample_target` | Skipped | Skipped | | the other four (`initial_uniform*`, `multisample_srgb_twin`) | Passed | Passed | On main the failures were "initial multisample color samples require enabled formatless multisampled storage image writes". With this PR, the attachment fallback handles those imports on the M4. `agc_driver_native_color_readback` now passes its 2× coverage, fill, refusal, chunk and exceptional-value checks. It then fails at `SampleMultisampleTarget.cpp:1363`, where the 4× pass calls `StoreSamples`. That step dispatches a guest shader that stores to a multisampled storage image, and the recompiler refuses it: `SPIR-V module emission failed: storage image multisampling is unavailable on the target device`. This is not a regression; on main the test never reached that line. A device without `shaderStorageImageMultisample` can't run that step at all. Suggestion: gate that block on `context.storageImageMultisample`, as the same file already does at line 855 ("a dispatch's store after a claim not tested: storage image multisampling unavailable"). Then the remaining checks also run on MoltenVK. The PR's code needs no changes. I didn't test this on Linux, Windows or another GPU vendor.
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!20579
No description provided.