Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
carminelau:fix/agc-msaa-initial-color-upload
Nov 17, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
carminelau:fix/agc-msaa-initial-color-upload

Conversation

@carminelau

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line build docs agc libSceAgc* labels Nov 15, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot added review queue Next in the maintainer review queue: checks pass, no open change request, no conflict and removed review queue Next in the maintainer review queue: checks pass, no open change request, no conflict labels Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

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 1368 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 1395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5371 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5925 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6186 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6188 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6192 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6209 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6280 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6412 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6481 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6808 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp
PR 7275 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7508 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7642 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleUpload.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp
PR 7689 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8246 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp
PR 8592 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 10193 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleUpload.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp
PR 10359 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 10442 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 11825 core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp
PR 12324 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 12746 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 12828 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 13148 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 13863 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 13920 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 13928 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleUpload.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp
PR 13929 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleUpload.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp
PR 13963 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 17652 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 17915 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 17956 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp
PR 18173 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 18515 core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp
PR 20030 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 20187 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 20315 core/libs/prx/libSceAgcDriver/Graphics/include/TextureDetiler.hpp

@NathanFahey23

Copy link
Copy Markdown
Contributor

Windows NVIDIA check of head 7b770f9cad, merged onto main b885c40a67 (8bf640cb5a, clean merge), on a GPU that has shaderStorageImageMultisample, so the regular path rather than the new fallback.

Setup: Windows 11 Home 10.0.26300, i9-13900K, WinLibs GCC 15.2.0, Release, RTX 4080 (10de:2704, driver 32.0.16.2101), ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, Khronos validation layer loaded. GPU set: ctest -R '^(agc_\|shader\|video_out\|guest_video)' --parallel 4, one run per side.

main b885c40a67 merge 8bf640cb5a
GPU set 1843 pass, 20 skipped, 0 failed 1843 pass, 20 skipped, 0 failed
VUID- lines 0 0
the seven agc_driver_native_color_initial_* tests and agc_driver_sample_multisample_target 8 of 8 pass 8 of 8 pass
homebrew, 30 s each (tools/title_run.py, cold shader cache) Jelly5 rendering 118.2, VLC rendering 119.5, DriftCheck rendering 59.9, PS5SX2 rendering 59.8, DOOM rendering 36.4 Jelly5 rendering 118.0, VLC rendering 119.6, DriftCheck rendering 59.9, PS5SX2 rendering 59.9, DOOM rendering 36.4

The one test not run on both sides is agc_driver_upload_cache_read_only_flush: its executable does not build on Windows on this main (setenv, fixed by #19899). The homebrew titles are Jelly5, VLC, DriftCheck, PS5SX2 and DOOM; fps is one run each, for whether they still render, not a performance comparison.

All seven native_color_initial tests already pass on main here (none skipped, unlike the Arc 140V), so apart from what _nonuniform_capabilities forces, this run shows the fallback leaves the storage-image path unchanged rather than exercising the fallback itself.

Not checked: AMD, Linux, macOS, any commercial title.

AI-assisted: yes

@GiannisG1

Copy link
Copy Markdown
Contributor

Results from a device this targets: an Intel HD Graphics 630 (Mesa 25.2.8 ANV, shaderStorageImageMultisample false), plus a GTX 1050 Ti (NVIDIA 580.178.04) and llvmpipe (Mesa 25.2.8) with shaderStorageImageMultisample turned off through the Khronos profiles layer. Linux, head 7b770f9cad cherry-picked onto main b7aeb6f406, compared with that main; under Xvfb, ANYPS5_GPU to pick the device. With this PR every case ran three times.

agc_driver_native_color_… main (HD 630, and both masked devices) this PR (HD 630, and both masked devices)
initial_uniform, …_refusals, …_hook pass pass 3/3
initial_nonuniform, …_lifetime, …_capabilities, …_hook skip ("the device does not enable multisampled formatless storage writes") pass 3/3
snapshot, snapshot_refusals fail: "initial multisample color samples require enabled formatless multisampled storage image writes" pass 3/3
readback fail, same message fail 3/3: ShaderRecompiler::Recompile: SPIR-V module emission failed: storage image multisampling is unavailable on the target device

On the GTX and llvmpipe without the mask all ten pass 3/3 with this PR, and check_skips.py accepts every run.

So the fallback works on the HD 630. readback (from #6987) gets further and then stops in a guest shader that uses a multisampled storage image. From the test's code I think that is the per-sample stores of the fragments == Samples branch (StoreSamples, "after storage migration and per-sample writes") or the MIMG sample reads it compares against; I have not narrowed it down. On main it is one of the three native_color cases that fail on this device today rather than skip.

@github-actions github-actions Bot added the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 16, 2026

@kurexw kurexw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 3b17977 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.

@oneandonlydean
oneandonlydean merged commit 3e1ba97 into boykopovar:main Nov 17, 2026
3 checks passed
@github-actions github-actions Bot removed the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build docs unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants