fix(agc): keep CMASK clears resident without host imports #1337

Merged
TibixDev merged 2 commits from upstream-pr/1337 into main 2026-10-11 00:13:34 +00:00
TibixDev commented 2026-10-07 23:50:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-07T23:50:43Z.


What

Keep a uniform CMASK clear in the GPU image when guest memory cannot be imported. Copy the result back when the CPU needs it. Let storage-image creation errors propagate instead of continuing with a CPU fallback.

Narrowed after #1072 and #1447 merged. Their CMASK decoding, extent calculation, and expanded-CMASK handling on DCC targets are retained. Metadata reuse is separate.

Tested

Fedora 44 Release: graphics tests and contribution checks pass. RX 6600/RADV and lavapipe pass the focused clear, repeated-clear, copied write-back, and creation-failure tests with core and synchronization validation. Windows CI is pending.

Checklist

  • Based on current main; related CMASK PRs checked.
  • One topic; no new code comments or repository reports.
  • Errors propagate; unsupported paths still throw.
  • No new third-party code or title-specific behavior.
  • Depends on: none.
  • AI-assisted: yes.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4779870197 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1337). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-07T23:50:43Z. --- ### What Keep a uniform CMASK clear in the GPU image when guest memory cannot be imported. Copy the result back when the CPU needs it. Let storage-image creation errors propagate instead of continuing with a CPU fallback. Narrowed after #1072 and #1447 merged. Their CMASK decoding, extent calculation, and expanded-CMASK handling on DCC targets are retained. Metadata reuse is separate. ### Tested Fedora 44 Release: graphics tests and contribution checks pass. RX 6600/RADV and lavapipe pass the focused clear, repeated-clear, copied write-back, and creation-failure tests with core and synchronization validation. Windows CI is pending. ### Checklist - [x] Based on current `main`; related CMASK PRs checked. - [x] One topic; no new code comments or repository reports. - [x] Errors propagate; unsupported paths still throw. - [x] No new third-party code or title-specific behavior. - [x] Depends on: none. - [x] AI-assisted: yes.
oneandonlydean commented 2026-10-08 03:26:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T03:26:21Z.


#1072 and #1237 already decode CMASK and materialize uniform clears, and both are still under review. Once they land, could you rebase and keep only what they lack, the reuse of validated CMASK metadata and the clear without host imports, as separate PRs?

Also, the new CMASK block in DrawWithRecipe (Draw.cpp) catches the exception from CachedStorageSurface and carries on without a resident image; please let it throw.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6051545592 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1337#issuecomment-6051545592). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-08T03:26:21Z. --- #1072 and #1237 already decode CMASK and materialize uniform clears, and both are still under review. Once they land, could you rebase and keep only what they lack, the reuse of validated CMASK metadata and the clear without host imports, as separate PRs? Also, the new CMASK block in `DrawWithRecipe` (`Draw.cpp`) catches the exception from `CachedStorageSurface` and carries on without a resident image; please let it throw.
TibixDev commented 2026-10-08 07:43:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T07:43:47Z.


Rebased on 6b573862 and narrowed after #1072 and #1447 merged. This now keeps clears resident without host imports and propagates storage-image creation errors. The duplicated decoder and size calculation are removed. Metadata reuse is being checked separately.

Fedora 44 Release graphics tests pass. RADV and lavapipe pass the focused repeated-clear, copied write-back, and failure tests with core and synchronization validation. Contribution checks pass; Windows CI is pending.

The removed metadata cache is preserved in a separate local experiment. It is not submitted: isolated 4/24/64 KiB tests show no reliable gain on Linux (both versions about 38–40 us per lookup; permission checks dominate). This PR keeps the verified resident-clear and error-propagation fixes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6055182419 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1337#issuecomment-6055182419). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-08T07:43:47Z. --- Rebased on `6b573862` and narrowed after #1072 and #1447 merged. This now keeps clears resident without host imports and propagates storage-image creation errors. The duplicated decoder and size calculation are removed. Metadata reuse is being checked separately. Fedora 44 Release graphics tests pass. RADV and lavapipe pass the focused repeated-clear, copied write-back, and failure tests with core and synchronization validation. Contribution checks pass; Windows CI is pending. The removed metadata cache is preserved in a separate local experiment. It is not submitted: isolated 4/24/64 KiB tests show no reliable gain on Linux (both versions about 38–40 us per lookup; permission checks dominate). This PR keeps the verified resident-clear and error-propagation fixes.
oneandonlydean commented 2026-10-09 09:22:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:07Z.


Conflicts with main in Draw.cpp (#1177 changed the tile-mode check next to your change) and tests/Recorder.cpp; please rebase.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078118093 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1337#issuecomment-6078118093). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:22:07Z. --- Conflicts with main in `Draw.cpp` (#1177 changed the tile-mode check next to your change) and `tests/Recorder.cpp`; please rebase.
adriadam10 commented 2026-10-09 23:13:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T23:13:18Z.


Rebased onto current main (conflicts in metadataPassResident after #1177, kept main's tile-mode condition and dropped the try/catch as asked; and the --cube-only/--cmask-only entries in tests/Recorder.cpp).

Checked: build + ctest for libSceAgcDriver green (267/267). agc_driver_recorder_tests --cmask-only passes with the change and fails without it ("CMASK storage creation failure was silently ignored"). Note that target is not registered in ctest (same as on main), so CI doesn't run it; I ran it by hand. Merging once CI is green on the rebased head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090848191 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1337#issuecomment-6090848191). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T23:13:18Z. --- Rebased onto current `main` (conflicts in `metadataPassResident` after #1177, kept main's tile-mode condition and dropped the try/catch as asked; and the `--cube-only`/`--cmask-only` entries in `tests/Recorder.cpp`). Checked: build + ctest for libSceAgcDriver green (267/267). `agc_driver_recorder_tests --cmask-only` passes with the change and fails without it ("CMASK storage creation failure was silently ignored"). Note that target is not registered in ctest (same as on `main`), so CI doesn't run it; I ran it by hand. Merging once CI is green on the rebased head.
adriadam10 commented 2026-10-10 06:04:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:04:20Z.


Rebased again onto current main: the only conflict was in tests/Recorder.cpp (the new --completion-labels-only entry next to --cmask-only); both are kept, no logic change.

Checked: build + ctest for libSceAgcDriver green, and agc_driver_recorder_tests --cmask-only passes. Merging once CI is green on the rebased head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094475335 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1337#issuecomment-6094475335). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T06:04:20Z. --- Rebased again onto current `main`: the only conflict was in `tests/Recorder.cpp` (the new `--completion-labels-only` entry next to `--cmask-only`); both are kept, no logic change. Checked: build + ctest for libSceAgcDriver green, and `agc_driver_recorder_tests --cmask-only` passes. Merging once CI is green on the rebased head.
Mouhand-Kaddo commented 2026-10-10 10:05:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-10T10:05:40Z.


Additional platform validation on standalone PR head a259913d82e95c4954c77f06ac43f88c43f79fcf:

Windows: passed — Windows 11, supported WinLibs GCC 15.2.0 UCRT/POSIX/SEH r7; CMake 4.3.1 / Ninja.

Release / BUILD_TESTING=ON: built the selected test targets; 1 CTest cases, 0 failures, 0 CTest skips.

Tests: agc_driver_graphics.

Reproduce after building the test targets: ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_driver_(graphics|recorder)$".

Also ran agc_driver_recorder_tests --cmask-only: passed the focused CMASK recorder regressions.

Vulkan: native AMD RX 6900 XT, driver 32.0.21045.5002.

Integration limitation: a local merge against main 948a526c2 has source conflicts; these results validate the standalone PR head, not a resolved merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6096398521 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1337#issuecomment-6096398521). Originally posted by [Mouhand-Kaddo](https://github.com/Mouhand-Kaddo) on 2026-10-10T10:05:40Z. --- <!-- anyps5-platform-validation:a259913d82e95c4954c77f06ac43f88c43f79fcf --> Additional platform validation on standalone PR head `a259913d82e95c4954c77f06ac43f88c43f79fcf`: **Windows: passed** — Windows 11, supported WinLibs GCC 15.2.0 UCRT/POSIX/SEH r7; CMake 4.3.1 / Ninja. Release / `BUILD_TESTING=ON`: built the selected test targets; 1 CTest cases, 0 failures, 0 CTest skips. Tests: `agc_driver_graphics`. Reproduce after building the test targets: `ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_driver_(graphics|recorder)$"`. Also ran `agc_driver_recorder_tests --cmask-only`: passed the focused CMASK recorder regressions. Vulkan: native AMD RX 6900 XT, driver 32.0.21045.5002. Integration limitation: a local merge against main `948a526c2` has source conflicts; these results validate the standalone PR head, not a resolved merge.
adriadam10 commented 2026-10-11 00:08:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T00:08:58Z.


Rebased onto current main. Conflict only in tests/Recorder.cpp (the --host-import-unmap-only / --unit-shadow-only entries next to --cmask-only); all are kept. GuestAllocations::Mutation::Add now takes a gpu flag on main, so I added one commit passing it in cmaskPassTests (true, true, true, like the rest of the file). No logic change.

Checked: build + ctest for libSceAgcDriver green, and agc_driver_recorder_tests --cmask-only passes. Also thanks to @Mouhand-Kaddo for the Windows run. Merging once CI is green on the rebased head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6103609130 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1337#issuecomment-6103609130). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T00:08:58Z. --- Rebased onto current `main`. Conflict only in `tests/Recorder.cpp` (the `--host-import-unmap-only` / `--unit-shadow-only` entries next to `--cmask-only`); all are kept. `GuestAllocations::Mutation::Add` now takes a `gpu` flag on `main`, so I added one commit passing it in `cmaskPassTests` (`true, true, true`, like the rest of the file). No logic change. Checked: build + ctest for libSceAgcDriver green, and `agc_driver_recorder_tests --cmask-only` passes. Also thanks to @Mouhand-Kaddo for the Windows run. Merging once CI is green on the rebased head.
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!1337
No description provided.