fix(agc): read the compressed FMASK of a resident two-sample color target #10233

Merged
YossiYad merged 6 commits from upstream-pr/10233 into main 2026-11-12 19:19:16 +00:00
YossiYad commented 2026-10-23 15:07:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-23T15:07:40Z.


What

Rush 2 Recompiled (PPSA69423) stops on main before its first frame:

shader 0x201dce900 stage 5: FMASK format is not implemented

Its pixel shader reads the FMASK of a two-sample color target that has DCC and CMASK (Fmask8_S2_F2, CMASK metadata in the T#). #7948 added this read for a tracked resident target, but only for eight samples and eight fragments. This PR takes the same path for two:

  • The T# decoder and the shader compiler accept CMASK on Fmask8_S2_F2, as they do on Fmask32_S8_F8. Without CMASK, #8429 already reads it from guest memory.
  • The FMASK range of a two-sample target is watched at its stored size of one byte per pixel.
  • The host view holds what a fully expanded surface stores: 0x02 for two samples (Gfx9Fmask::GetPackedExpandedValue), as 0x76543210 is for eight. #8429's shader expansion turns it into 0x10, four bits per sample, as Mesa reads it for every sample count (nir_lower_ms_txf_to_fragment_fetch). The view accepts the identity selectors that expansion reads with. Neither value is measured on a PS5; the debt entry says so.

With this, Rush 2 reaches its launcher ("Locate ROM") and holds 60 FPS for 60 s with the shader cache off. Going further needs the player's own ROM.

Tested

Current validation (2026-10-25): rebased onto main 16ff208dc3. On AMD Radeon RX 7700 XT, RADV Mesa 26.2.4, Bazzite 44, the focused shader-memory, graphics and native-FMASK pattern passes on both main (3 tests) and this branch (4 tests, including two/eight samples). Both runs use ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and ctest -V; no VUID- errors or missing-layer warnings in either log. No title rerun for this update.

Linux (Fedora 44, GCC 16, Ninja, -DBUILD_TESTING=ON), RX 7700 XT (RADV), based on main 3c44638fc6:

  • The native FMASK test now runs for two and eight samples (agc_driver_native_fmask_2, agc_driver_native_fmask_8). The two-sample run draws a different color into each sample, then checks that each sample's FMASK index picks its own fragment, both XOR settings, both registration modes, cached and prepared dispatches, and invalid metadata/owner/extent checks. It also refuses an eight-sample FMASK format on a two-sample target.
  • agc_shader_memory and agc_driver_graphics check that a two-fragment FMASK is accepted with CMASK without pinning valid-but-unimplemented layouts to rejection.
  • Each of these changes makes a test fail: the view returning 0x10 instead of the stored 0x02, the view refusing identity selectors, eight samples only, and refusing CMASK on two fragments in the compiler or the T# decoder.
  • All 711 agc_driver and shader tests pass except agc_driver_tessellation, agc_driver_bda_reads_shadowed_results and its _per_build variant, which fail the same way on main on this machine.
  • tools/check_conventions.py --base upstream/main passes. tools/pr_overlap.py finds no PR with the same change. The others share test, CMake or debt lines.

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
  • Fixes: none
  • Unblocks: none (Rush 2 Recompiled, PPSA69423, launcher tested previously; no linked bring-up discussion)
  • GPUs tested: AMD Radeon RX 7700 XT (RADV NAVI32), Mesa 26.2.4, Bazzite 44
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4984878502 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10233). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-23T15:07:40Z. --- ### What Rush 2 Recompiled (PPSA69423) stops on `main` before its first frame: ```text shader 0x201dce900 stage 5: FMASK format is not implemented ``` Its pixel shader reads the FMASK of a two-sample color target that has DCC and CMASK (`Fmask8_S2_F2`, CMASK metadata in the T#). #7948 added this read for a tracked resident target, but only for eight samples and eight fragments. This PR takes the same path for two: - The T# decoder and the shader compiler accept CMASK on `Fmask8_S2_F2`, as they do on `Fmask32_S8_F8`. Without CMASK, #8429 already reads it from guest memory. - The FMASK range of a two-sample target is watched at its stored size of one byte per pixel. - The host view holds what a fully expanded surface stores: `0x02` for two samples ([`Gfx9Fmask::GetPackedExpandedValue`](https://github.com/GPUOpen-Drivers/pal/blob/c5e800072a32f68b6ccc4422936d96167c6e0728/src/core/hw/gfxip/gfx9/gfx9MaskRam.cpp#L5005-L5019)), as `0x76543210` is for eight. #8429's shader expansion turns it into `0x10`, four bits per sample, as Mesa reads it for every sample count ([`nir_lower_ms_txf_to_fragment_fetch`](https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-25.0.0/src/compiler/nir/nir_lower_tex.c#L1391)). The view accepts the identity selectors that expansion reads with. Neither value is measured on a PS5; the debt entry says so. With this, Rush 2 reaches its launcher ("Locate ROM") and holds 60 FPS for 60 s with the shader cache off. Going further needs the player's own ROM. ### 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. --> Current validation (2026-10-25): rebased onto main `16ff208dc3`. On AMD Radeon RX 7700 XT, RADV Mesa 26.2.4, Bazzite 44, the focused shader-memory, graphics and native-FMASK pattern passes on both main (3 tests) and this branch (4 tests, including two/eight samples). Both runs use `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` and `ctest -V`; no `VUID-` errors or missing-layer warnings in either log. No title rerun for this update. Linux (Fedora 44, GCC 16, Ninja, `-DBUILD_TESTING=ON`), RX 7700 XT (RADV), based on `main` `3c44638fc6`: - The native FMASK test now runs for two and eight samples (`agc_driver_native_fmask_2`, `agc_driver_native_fmask_8`). The two-sample run draws a different color into each sample, then checks that each sample's FMASK index picks its own fragment, both XOR settings, both registration modes, cached and prepared dispatches, and invalid metadata/owner/extent checks. It also refuses an eight-sample FMASK format on a two-sample target. - `agc_shader_memory` and `agc_driver_graphics` check that a two-fragment FMASK is accepted with CMASK without pinning valid-but-unimplemented layouts to rejection. - Each of these changes makes a test fail: the view returning `0x10` instead of the stored `0x02`, the view refusing identity selectors, eight samples only, and refusing CMASK on two fragments in the compiler or the T# decoder. - All 711 `agc_driver` and `shader` tests pass except `agc_driver_tessellation`, `agc_driver_bda_reads_shadowed_results` and its `_per_build` variant, which fail the same way on `main` on this machine. - `tools/check_conventions.py --base upstream/main` passes. `tools/pr_overlap.py` finds no PR with the same change. The others share test, CMake or debt lines. ### 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) - [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] Fixes: none - [x] Unblocks: none (Rush 2 Recompiled, PPSA69423, launcher tested previously; no linked bring-up discussion) - [x] GPUs tested: AMD Radeon RX 7700 XT (RADV NAVI32), Mesa 26.2.4, Bazzite 44 - [x] AI-assisted: yes
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!10233
No description provided.