Skip to content

fix(agc): handle FMASK decompress on MSAA targets - #4767

Merged
adriadam10 merged 4 commits into
boykopovar:mainfrom
Swastik-51:fix/agc-fmask-decompress-msaa
Oct 14, 2026
Merged

adriadam10 merged 4 commits into
boykopovar:mainfrom
Swastik-51:fix/agc-fmask-decompress-msaa

Conversation

@Swastik-51

@Swastik-51 Swastik-51 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What

Fixes #4685. Recognize AGC CB_COLOR_CONTROL Mode 5 (FMASK decompress) for multisampled color targets.

  • Materialize pending CMASK fast clears onto the host multisampled Vulkan image before subsequent use.
  • Keep the FMASK decompress path separate from the existing single-sample DCC decompression path.
  • Restrict support to multisampled targets with a valid CMASK address and preserve validation for unsupported configurations.
  • Add decoder validation tests and a GPU-backed regression test covering fast-clear materialization, resolve, and repeated use.

Tested

  • git diff --check — passed.
  • python tools/check_conventions.py --base upstream/main — passed locally.
  • Latest GitHub Actions CI workflows for commit 3548a7e34:
    • conventions: passed (success).
    • eligibility: passed (success).
    • report: passed (success).
    • Build jobs (linux, windows, write-watch, relinker, register-context) were skipped (full PR runs require manual collaborator dispatch).
  • Native C++ build and runtime tests have not been run locally (required build toolchain is unavailable in the local environment).
  • The earlier Linux regression-test report was for commit dabcf4056, before the rebase and DCC follow-up commit. Those prior results are not presented as tests of the current head (3548a7e34).

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
  • New third-party code is a submodule built from source (not applicable; no third-party code added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA68091, issue AGC: FMASK decompress over a 4x MSAA target with CMASK, FMASK and DCC stops Ruffle's player (PPSA68091) #4685
  • AI-assisted: yes

@Swastik-51
Swastik-51 marked this pull request as ready for review October 12, 2026 21:35
@github-actions github-actions Bot added the agc libSceAgc* label Oct 12, 2026
@Swastik-51

Swastik-51 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Hello maintainers,

Could you please trigger the Linux/Windows CI build and run the regression tests (fmaskDecompressMsaaTests in Recorder.cpp and multisampleTests in Graphics.cpp) for these AGC graphics changes when convenient? Local testing was limited to conventions and whitespace checks due to the absence of the required build toolchain in my local environment.

Thank you!

@kr4y4

kr4y4 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

First build and hardware run, since the description says the change wasn't compiled or run.

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 00d5ed1 merged into main 584cc4c, which passes 1018 of 1018 on both GPUs.

It builds. Two tests fail on both GPUs in every run (with --repeat until-fail:3 and in the full suite), and the other 1016 pass:

  • agc_driver_graphics: unexpected failure: AGC graphics: missing register in context bank at DWORD 0x31f (799).
    • This is the new "without a CMASK address" case in multisampleTests. Its CB_COLOR0_INFO (0x1002e028) has the fast-clear bit (13) set, so DecodeColorBuffer reads CB_COLOR0_CMASK (0x31f), which that queue doesn't set.
    • Decoding stops there, before the new FMASK decompress of a target without a CMASK address check, and expectFailure sees a different message.
    • Reading the code, with 0x31f set to 0 the existing CMASK fast clears without a CMASK address are unsupported check would fire first, also before the new one.
  • agc_multisample_guest_access, the new case in Recorder.cpp: FMASK decompress did not materialize the seeded clear to the host multisampled image.

Separately, the change removes the DCC over a multisampled color target is unsupported check from DecodeColorBuffer. So DCC on a multisampled target is now accepted on every path, not only by the FMASK decompress pass.

Written with AI assistance.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Has this been built and run? kr4y4's run of 00d5ed1 had agc_driver_graphics and agc_multisample_guest_access failing on both GPUs, and dabcf40 came after it with no result. Two things before this can go in:

  • a build and a run of both tests on the current head, with the OS and GPU (CONTRIBUTING: run the tests before opening the pull request);
  • DecodeColorBuffer in State.cpp loses the DCC over a multisampled color target is unsupported check on every path, not only for the FMASK decompress pass. Keep it for the other paths, or record in docs/dev/debt/libSceAgcDriver.md what DCC on a multisampled target does now.

A run of PPSA68091 past the stop in #4685 would settle the rest.

@simonbbby

Copy link
Copy Markdown
Contributor

Built and ran the current head dabcf4056e3d214cad630a5b348de769382b677f on Linux. Both requested tests pass on all three devices:

Device agc_driver_graphics agc_multisample_guest_access
RTX 3090, NVIDIA 595.99.02 pass pass
gfx1036 RDNA2 iGPU, RADV Mesa 25.2.8 pass pass
llvmpipe, Mesa 25.2.8 pass pass

agc_multisample_guest_access invokes agc_driver_recorder_tests --multisample-only; every device log includes FMASK decompress MSAA clear and resolve tests passed. The Vulkan ICD was restricted to the intended device for each run, with ANYPS5_REQUIRE_VULKAN=1 and shader cache disabled. No ctest skipped. Both tests finished below 3 seconds per device. agc_driver_graphics does report its existing guest-arena/write-watch-dependent heap-mirror subchecks as not tested.

Ubuntu 24.04, Linux 7.0, GCC 13.3, Release, Ninja, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON, bundled dependencies. XRandR development files were unpacked into an isolated prefix for this build; no system package was installed. Production source and tests were unchanged, and the worktree is clean. This tests the exact PR head rather than a merge onto newer main.

This resolves the missing current-head build/test evidence on these Linux devices. It does not resolve the maintainer's separate concern about accepting MSAA DCC outside the decompress path. PPSA68091 was not launched, no hardware metadata semantics were measured, and the full suite was not run.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@Swastik-51
Swastik-51 force-pushed the fix/agc-fmask-decompress-msaa branch from dabcf40 to fe14efe Compare October 13, 2026 06:30
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@LeandroLP23

Copy link
Copy Markdown
Contributor

AMD coverage, since the GPU tests in CI run only on lavapipe: Windows 11 (26300), Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release. Head 3548a7e34 merged onto main 9ba9ac1c8.

AI-assisted: yes (Claude Code)

@Swastik-51

Copy link
Copy Markdown
Contributor Author

Thanks for the review feedback. I've updated the implementation to preserve the DCC-over-MSAA rejection outside the explicit FMASK-decompress path, added coverage for missing CMASK handling and clear materialization, and verified that the conventions checks pass on the current head (02b40581a00f1eb5aa63c74d738d4e8417ab77b5).

The full Linux and Windows CI jobs are currently skipped for PRs unless a collaborator dispatches the Build workflow. Could someone with the required permissions please trigger the full Build workflow for PR #4767 so the current head can be validated?

I haven't been able to run the native C++/Vulkan tests locally due to the missing build toolchain and Vulkan runtime. Thanks!

@LeandroLP23

Copy link
Copy Markdown
Contributor

Validation of the current head 02b40581a on AMD, following up on my earlier run of 3548a7e34. Setup: Windows 11 (26300), Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release, full build. The PR is merged onto main 665ad7da7 without conflicts.

  • ctest -R '^agc_' -j 1, test shader cache emptied: 481 pass, 2 skip, 1 fails. The failure is agc_driver_layered_volume_vertex_no_gpl, which fails on main on this driver too (GPL-off pipelines, AMD Windows: GPL-mode cache failures (alpha/wave32 pass after local driver update) #4768). agc_driver_graphics and agc_multisample_guest_access pass.
  • The new fmaskDecompressMsaaTests run only through agc_driver_recorder_tests --multisample-only, which is what agc_multisample_guest_access executes. Run directly 5 times, it exits 0 every time and ends with FMASK decompress MSAA clear and resolve tests passed.
  • The no-argument run of agc_driver_recorder_tests stops early on this machine at a signaled batch's read still refuses. Plain main stops at the same check, so this PR does not cause it. That run is not registered in CTest; test(agc): register the full recorder run with CTest #5211 proposes registering it.

Not checked: Ruffle's Flash player path. An unattended run doesn't open it, so it never reaches the FMASK decompress from #4685.

AI-assisted: yes (Claude Code)

@Amoenus

Amoenus commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

@Swastik-51 Update after #4767 merged first: #5939 head347d11b93 is rebased onto main8f51 and tested with merged #4767/#4820. The earlier merge-order suggestion below is superseded.

Full Windows app/libs/checkers pass. Sixteen groups pass once+5 under NVIDIA/AMD selectors; eight runtime groups, including DCC2/4/8 and native MSAA sampling, verify both actual devices. The two legacy recorder groups select NVIDIA in both Windows runs, so those results are NVIDIA-only. Linux lavapipe builds four executables and five supported groups pass once+5; unsupported2/8 explicitly skip. Main's FMASK clear/reuse fixture executes and passes.

The DCC fixture now materializes supported CMASK cases through Mode5 before drawing and checks that a later Mode5 pass preserves drawn samples despite changed clear registers. FMASK decode retains DCC control so unsupported flags are refused by the importer. #5336 holds unchanged-main state/pixel failure controls, geometry225×5 and original-title evidence with its older pins. This is synthetic merged-path validation, not a fresh title replay.

Earlier coordination request, superseded

@Swastik-51 I opened #5939 for uniform initial DCC fast clears in normal rendering. It builds independently on main e34, with NVIDIA/AMD and lavapipe supported-case regressions; #5336 has the title stop and scoped replay. The shared overlap is DecodeColorBuffer's multisample-DCC validation, while Mode5 FMASK decompression remains your topic. I suggest merging the normal-render support first, then rebasing #4767 onto it. Please let me know if you prefer the other order; I can retest the resulting composition. No claim that the two current heads have been composed/tested together.

@adriadam10 adriadam10 self-assigned this Oct 14, 2026
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked on the PR merged onto main: the scoped build and the libSceAgcDriver ctest (550/551; the one failure is agc_driver_tessellation, a RADV segfault that also shows on unrelated PRs), including agc_driver_graphics and agc_multisample_guest_access. The new tests don't compile without the change, and the Recorder case tells a materialized clear from a re-clear. The DCC-over-MSAA rejection is back on every path except the FMASK decompress pass, as @oneandonlydean asked, and kr4y4's two failures are gone (also covered by simonbbby on NVIDIA/RADV/llvmpipe and LeandroLP23 on AMD).

Added as our own commit on your branch: the Multisampled targets in CB passes line in docs/dev/debt/libSceAgcDriver.md said a DCC pass over a multisampled target throws and only a resolve is modeled; it now describes the FMASK decompress (CMASK fast clear materialized only, DCC/FMASK contents not interpreted).

Not verified: Ruffle's Flash player path from #4685; merging once the full Build is green.

@adriadam10
adriadam10 force-pushed the fix/agc-fmask-decompress-msaa branch from 02b4058 to 3deff40 Compare October 14, 2026 17:11
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@adriadam10

Copy link
Copy Markdown
Collaborator

Rebased onto current main: the only conflict was adjacency in MultisampleTarget.hpp/.cpp (MultisampleTargetTexture landed next to MaterializeMultisampleTargetClear); both kept, no logic change. Scoped build and libSceAgcDriver ctest on the rebased tree: everything passes except agc_driver_tessellation, a RADV segfault that also fails on main. Merging once the full Build is green.

@adriadam10
adriadam10 force-pushed the fix/agc-fmask-decompress-msaa branch from 3deff40 to a15f163 Compare October 14, 2026 17:58
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

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
#5200 core/libs/prx/libSceAgcDriver/Graphics/include/State.hpp L144

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@Swastik-51

Copy link
Copy Markdown
Contributor Author

Thanks again for rebasing the PR and adding the debt documentation commit!

I checked the latest Build workflow run for head a15f16324. The conventions check passed, but the Linux and Windows jobs were skipped because the workflow requires a collaborator-triggered workflow_dispatch for full builds.

Could you please trigger the Build workflow for PR 4767 from main, with the input pr=4767?

Once the full build completes, we can review the results and proceed accordingly. Thanks!

@adriadam10
adriadam10 merged commit c5f6269 into boykopovar:main Oct 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AGC: FMASK decompress over a 4x MSAA target with CMASK, FMASK and DCC stops Ruffle's player (PPSA68091)

7 participants