fix(agc): advance stored layers when a write-back keeps CPU-written blocks #4663

Merged
fdfawef324 merged 3 commits from upstream-pr/4663 into main 2026-10-14 17:46:53 +00:00
fdfawef324 commented 2026-10-12 18:17:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-12T18:17:28Z.


What

On a host-imported surface a storage write-back keeps the 64 KiB blocks that the CPU wrote since their tracked layer's generation, stores the rest, and stamps the stored ranges with MarkWritten. Settling advanced the stored layers' generations past those stamps only when no layer kept a block (or when an adjacent pending surface needed the collect).

So when one tracked layer kept a block, every other stored layer kept its old generation, and the write-back's own stamps then read as CPU writes: the next write-back kept those layers as well and did not store the GPU's newer results over them.

A tracked layer is one 64 KiB unit when the surface has block units: tiled (not linear), 64 KiB-aligned base, not thick, with layer and block tracking on. Otherwise it is an array layer (64 KiB-aligned layer slices, layer tracking on) or the whole surface. With a single tracked layer, a layer that kept a block is the only stored layer, so nothing advances and settling behaves as on main.

Settling now collects and advances each stored layer that kept no block. A layer that kept a block keeps its old generation and re-uploads at its next use, as before. When no stored layer advances (nothing stored, or every selected layer kept a block), no adjacent pending surface needs the collect and no unit was retiled into the unit shadow, settling still skips the collect, as on main.

MarkShadowed now takes the settle collect's generation also when a block was kept; main passed TrackerGeneration() there without collecting. The two differ only for a CPU write to a stored unit made after the keep decision: on main a later walk stamped it newer, so the retiled unit went stale and the CPU's bytes won; now this walk stamps it at the marked generation and the stored results win, as they already did when no block was kept.

agc_storage_kept_unit_settle uses a 1024x512 RGBA8 surface in 64 KiB tiling (32 block units). It writes one byte of unit 0 from the CPU, stores a red clear (unit 0 is kept, as intended), then stores a blue clear, and requires units 1-31 to be blue and unit 0 to keep the CPU's byte after both stores. It runs on GPU-mapped direct memory (the host-import path, where that import keeps the memory write-watched) and on watched memory with host imports off (the write-back that stores through the CPU). On main the direct-memory case fails:

AGC graphics: (k) GPU-mapped direct memory: unit 1 kept the results of the earlier write-back; that write-back's own store was taken for a CPU write because a neighbouring unit was kept for the CPU

The watched-memory case passes on main. It guards the kept layer's old generation on the path that stores through the CPU, which this change also makes collect and advance when a unit is kept: if settling advanced the layer that kept a block too, the watched case fails (the second write-back stored over unit 0, which the CPU wrote after that unit's generation).

The watched-memory case is required and passes independently when the optional direct-memory subcase is unavailable. Unsupported direct imports still print the specific subcase reason and continue. A missing host write watch or any readback failure fails the test. The suite no longer reports all of its coverage skipped merely because the direct-memory subcase could not run.

Found while tracing the storage corruption in Demon's Souls (PPSA01342 v1.005). On its own this change shows no visible difference there: the green band in that title's movies comes from shared write tracking, fixed in #4661. This PR fixes the write-back bookkeeping that the test above exercises.

Tested

Windows Server 2025, RTX 3060, GCC 15.2 (Release). The branch is rebased onto main at 14db08435; the tests below ran on the same commit rebased onto 84659e16d (git range-diff shows it unchanged). Main between the two adds the 3rdparty/libusb-cmake submodule, which this worktree's build directory could not configure without initialising, and changes no libSceAgcDriver file.

  • agc_storage_kept_unit_settle: passes with this change. With only the Texture.cpp change reverted, the direct-memory case fails with the message above. With settling also advancing layers that kept a block, the watched-memory case fails (checked on the earlier base 014221568).
  • ctest -R agc -j 4 (446 tests): 436 pass and agc_driver_stencil_ref_export skips. 9 fail, and each also failed with only the Texture.cpp change reverted (checked on the earlier base 621ce1da1): agc_driver_flat_loads, agc_driver_flat_loads_x2_x3, agc_driver_flat_loads_x4, agc_driver_global_loads, agc_driver_global_loads_x2_x3, agc_driver_global_loads_x4, agc_driver_flat_apertures_2, agc_driver_flat_apertures_5 (abort with "guest allocation ... is still pinned by GPU work or an import") and agc_driver_pixel_interlock (vkDeviceWaitIdle returns -4).
  • tools/check_test_registration.py: passes.
  • Not run in this round: the full ctest outside agc, and any title or homebrew.

Follow-up for Linux CI coverage: ca73d0f changes only the fixture's completion policy; the production code and GPU readback body are unchanged. The entire matching-header Recorder.cpp and unchanged Texture.cpp pass GCC -O3 syntax checks. A CPU replay of the literal completion selector/catch/Require, with explicit observation callbacks replacing GPU work, reports old exit 77 versus corrected exit 0 after watched success/direct unavailability; the unchanged Linux check_skips.py reports lost coverage before and passes afterward. Injected watched/direct failures still fail. This is a completion-policy check, not a fresh Linux or native GPU rerun; the published CI run must verify lavapipe rendering coverage.

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
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100
  • AI-assisted: yes

🤖 Generated with Claude Code

Co-Authored-By: Codex [email protected]

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4833332421 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4663). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-12T18:17:28Z. --- ### What On a host-imported surface a storage write-back keeps the 64 KiB blocks that the CPU wrote since their tracked layer's generation, stores the rest, and stamps the stored ranges with `MarkWritten`. Settling advanced the stored layers' generations past those stamps only when no layer kept a block (or when an adjacent pending surface needed the collect). So when one tracked layer kept a block, every other stored layer kept its old generation, and the write-back's own stamps then read as CPU writes: the next write-back kept those layers as well and did not store the GPU's newer results over them. A tracked layer is one 64 KiB unit when the surface has block units: tiled (not linear), 64 KiB-aligned base, not thick, with layer and block tracking on. Otherwise it is an array layer (64 KiB-aligned layer slices, layer tracking on) or the whole surface. With a single tracked layer, a layer that kept a block is the only stored layer, so nothing advances and settling behaves as on `main`. Settling now collects and advances each stored layer that kept no block. A layer that kept a block keeps its old generation and re-uploads at its next use, as before. When no stored layer advances (nothing stored, or every selected layer kept a block), no adjacent pending surface needs the collect and no unit was retiled into the unit shadow, settling still skips the collect, as on `main`. `MarkShadowed` now takes the settle collect's generation also when a block was kept; `main` passed `TrackerGeneration()` there without collecting. The two differ only for a CPU write to a stored unit made after the keep decision: on `main` a later walk stamped it newer, so the retiled unit went stale and the CPU's bytes won; now this walk stamps it at the marked generation and the stored results win, as they already did when no block was kept. `agc_storage_kept_unit_settle` uses a 1024x512 RGBA8 surface in 64 KiB tiling (32 block units). It writes one byte of unit 0 from the CPU, stores a red clear (unit 0 is kept, as intended), then stores a blue clear, and requires units 1-31 to be blue and unit 0 to keep the CPU's byte after both stores. It runs on GPU-mapped direct memory (the host-import path, where that import keeps the memory write-watched) and on watched memory with host imports off (the write-back that stores through the CPU). On `main` the direct-memory case fails: ``` AGC graphics: (k) GPU-mapped direct memory: unit 1 kept the results of the earlier write-back; that write-back's own store was taken for a CPU write because a neighbouring unit was kept for the CPU ``` The watched-memory case passes on `main`. It guards the kept layer's old generation on the path that stores through the CPU, which this change also makes collect and advance when a unit is kept: if settling advanced the layer that kept a block too, the watched case fails (`the second write-back stored over unit 0, which the CPU wrote after that unit's generation`). The watched-memory case is required and passes independently when the optional direct-memory subcase is unavailable. Unsupported direct imports still print the specific subcase reason and continue. A missing host write watch or any readback failure fails the test. The suite no longer reports all of its coverage skipped merely because the direct-memory subcase could not run. Found while tracing the storage corruption in Demon's Souls (PPSA01342 v1.005). On its own this change shows no visible difference there: the green band in that title's movies comes from shared write tracking, fixed in #4661. This PR fixes the write-back bookkeeping that the test above exercises. ### Tested Windows Server 2025, RTX 3060, GCC 15.2 (Release). The branch is rebased onto `main` at 14db08435; the tests below ran on the same commit rebased onto 84659e16d (`git range-diff` shows it unchanged). Main between the two adds the `3rdparty/libusb-cmake` submodule, which this worktree's build directory could not configure without initialising, and changes no `libSceAgcDriver` file. - `agc_storage_kept_unit_settle`: passes with this change. With only the `Texture.cpp` change reverted, the direct-memory case fails with the message above. With settling also advancing layers that kept a block, the watched-memory case fails (checked on the earlier base 014221568). - `ctest -R agc -j 4` (446 tests): 436 pass and `agc_driver_stencil_ref_export` skips. 9 fail, and each also failed with only the `Texture.cpp` change reverted (checked on the earlier base 621ce1da1): `agc_driver_flat_loads`, `agc_driver_flat_loads_x2_x3`, `agc_driver_flat_loads_x4`, `agc_driver_global_loads`, `agc_driver_global_loads_x2_x3`, `agc_driver_global_loads_x4`, `agc_driver_flat_apertures_2`, `agc_driver_flat_apertures_5` (abort with "guest allocation ... is still pinned by GPU work or an import") and `agc_driver_pixel_interlock` (`vkDeviceWaitIdle` returns -4). - `tools/check_test_registration.py`: passes. - Not run in this round: the full ctest outside `agc`, and any title or homebrew. Follow-up for Linux CI coverage: `ca73d0f` changes only the fixture's completion policy; the production code and GPU readback body are unchanged. The entire matching-header `Recorder.cpp` and unchanged `Texture.cpp` pass GCC `-O3` syntax checks. A CPU replay of the literal completion selector/catch/Require, with explicit observation callbacks replacing GPU work, reports old exit 77 versus corrected exit 0 after watched success/direct unavailability; the unchanged Linux `check_skips.py` reports lost coverage before and passes afterward. Injected watched/direct failures still fail. This is a completion-policy check, not a fresh Linux or native GPU rerun; the published CI run must verify lavapipe rendering coverage. ### Checklist - [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] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Codex <[email protected]>
fdfawef324 commented 2026-10-12 21:50:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-12T21:50:08Z.


Changes in this revision (rebased onto current main at 14db08435, still one commit; the conflict in tests/Recorder.cpp with --integer-clear-only keeps both options):

  • Block units are now defined as in Texture.cpp: tiled (not linear), 64 KiB-aligned base, not thick, with layer and block tracking on; otherwise a tracked layer is an array layer (64 KiB-aligned layer slices, layer tracking on) or the whole surface. Fixed in the commit message and the body.
  • settle returns before the collect when no stored layer advances (nothing stored, or every selected layer kept a block, e.g. a single tracked layer that kept one), no adjacent pending surface needs it and nothing was retiled into the unit shadow. This replaces the keep.empty() check and drops the walk that advanced nothing; a cost change, not a correctness one.
  • The body and message now say that MarkShadowed takes the settle collect's generation instead of TrackerGeneration() when a block was kept, and when the two differ (a CPU write to a stored unit after the keep decision: the stored results now win, as when no block was kept).
  • Test helper: Backing's destructor releases the direct memory whenever it was allocated, also when mapping it failed.
  • Red/green: with the Texture.cpp change reverted the direct-memory case fails at unit 1; with it both cases pass. The suite ran on base 84659e16d (same commit per git range-diff); the newest base adds the libusb-cmake submodule, which my build directory could not configure.
    No finding was refuted in this round.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6133253629 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4663#issuecomment-6133253629). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-12T21:50:08Z. --- Changes in this revision (rebased onto current `main` at 14db08435, still one commit; the conflict in `tests/Recorder.cpp` with `--integer-clear-only` keeps both options): - Block units are now defined as in `Texture.cpp`: tiled (not linear), 64 KiB-aligned base, not thick, with layer and block tracking on; otherwise a tracked layer is an array layer (64 KiB-aligned layer slices, layer tracking on) or the whole surface. Fixed in the commit message and the body. - `settle` returns before the collect when no stored layer advances (nothing stored, or every selected layer kept a block, e.g. a single tracked layer that kept one), no adjacent pending surface needs it and nothing was retiled into the unit shadow. This replaces the `keep.empty()` check and drops the walk that advanced nothing; a cost change, not a correctness one. - The body and message now say that `MarkShadowed` takes the settle collect's generation instead of `TrackerGeneration()` when a block was kept, and when the two differ (a CPU write to a stored unit after the keep decision: the stored results now win, as when no block was kept). - Test helper: `Backing`'s destructor releases the direct memory whenever it was allocated, also when mapping it failed. - Red/green: with the `Texture.cpp` change reverted the direct-memory case fails at unit 1; with it both cases pass. The suite ran on base 84659e16d (same commit per `git range-diff`); the newest base adds the `libusb-cmake` submodule, which my build directory could not configure. No finding was refuted in this round.
kr4y4 commented 2026-10-13 05:00:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kr4y4 on 2026-10-13T05:00:37Z.


An Intel run, and the full suite, which the description lists as not 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 c6b403d71 merged into main 495bf91a0, which passes 1023 of 1023 on both GPUs.

  • agc_storage_kept_unit_settle and the other 16 recorder entries pass on both GPUs with --repeat until-fail:3.
  • Full suite (ctest --timeout 120 --parallel 4): 1024 of 1024 on both GPUs. That includes the nine that fail on your machine with and without this change (agc_driver_flat_loads and _x2_x3, _x4; agc_driver_global_loads and _x2_x3, _x4; agc_driver_flat_apertures_2, _5; agc_driver_pixel_interlock). They pass on both GPUs here.
  • With Texture.cpp as on main, agc_storage_kept_unit_settle fails on both GPUs with the direct-memory message from the description ((k) GPU-mapped direct memory: unit 1 kept the results of the earlier write-back; ...). The other 16 pass.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6138603790 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4663#issuecomment-6138603790). Originally posted by [kr4y4](https://github.com/kr4y4) on 2026-10-13T05:00:37Z. --- An Intel run, and the full suite, which the description lists as not 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 c6b403d71 merged into `main` 495bf91a0, which passes 1023 of 1023 on both GPUs. - `agc_storage_kept_unit_settle` and the other 16 recorder entries pass on both GPUs with `--repeat until-fail:3`. - Full suite (`ctest --timeout 120 --parallel 4`): 1024 of 1024 on both GPUs. That includes the nine that fail on your machine with and without this change (`agc_driver_flat_loads` and `_x2_x3`, `_x4`; `agc_driver_global_loads` and `_x2_x3`, `_x4`; `agc_driver_flat_apertures_2`, `_5`; `agc_driver_pixel_interlock`). They pass on both GPUs here. - With `Texture.cpp` as on `main`, `agc_storage_kept_unit_settle` fails on both GPUs with the direct-memory message from the description (`(k) GPU-mapped direct memory: unit 1 kept the results of the earlier write-back; ...`). The other 16 pass. Written with AI assistance.
nicolasfalesy commented 2026-10-13 08:30:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T08:30:23Z.


Linux test (Arch, GCC 16.2.1, Release, Intel Arc B390 on Mesa 26.2.2 ANV), head c6b403d71 merged alone onto main 7e181fcc3 (clean merge): agc_storage_kept_unit_settle fails on the direct-memory case, with the same message your description gives for the unfixed code:

units stored next to a unit kept for the CPU in watched memory: ok
AGC graphics: (k) GPU-mapped direct memory: the second write-back stored over unit 0, which the CPU wrote after that unit's generation

The watched-memory case passes. On this machine the write-watch probe reports dma-buf imports keep write protection: yes and host imports resolve write protection: yes, so GPU-mapped direct memory goes through the dma-buf import path here rather than Windows' host import, which may be why the Texture.cpp change doesn't reach it. Happy to rerun with any trace switch.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6141543641 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4663#issuecomment-6141543641). Originally posted by [nicolasfalesy](https://github.com/nicolasfalesy) on 2026-10-13T08:30:23Z. --- Linux test (Arch, GCC 16.2.1, Release, Intel Arc B390 on Mesa 26.2.2 ANV), head `c6b403d71` merged alone onto `main` 7e181fcc3 (clean merge): **`agc_storage_kept_unit_settle` fails** on the direct-memory case, with the same message your description gives for the unfixed code: ``` units stored next to a unit kept for the CPU in watched memory: ok AGC graphics: (k) GPU-mapped direct memory: the second write-back stored over unit 0, which the CPU wrote after that unit's generation ``` The watched-memory case passes. On this machine the write-watch probe reports `dma-buf imports keep write protection: yes` and `host imports resolve write protection: yes`, so GPU-mapped direct memory goes through the dma-buf import path here rather than Windows' host import, which may be why the `Texture.cpp` change doesn't reach it. Happy to rerun with any trace switch.
adriadam10 commented 2026-10-13 14:57:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:57:03Z.

Review: CHANGES_REQUESTED


Checked on Linux (RADV, Radeon 660M): the PR merged onto main builds, agc_storage_kept_unit_settle passes, and it fails with only the Texture.cpp change reverted, so the test does exercise the change there. libSceAgcDriver ctest otherwise matches main (agc_driver_tessellation segfaults on main too).

  • However, @nicolasfalesy reports that on Linux with Intel Arc (ANV, Mesa 26.2.2) the direct-memory case fails with this PR: the second write-back stored over unit 0, which the CPU wrote after that unit's generation. That is the failure that the watched-memory case guards against (a layer that kept a block must keep its old generation). There the probe reports dma-buf imports keep write protection: yes, so direct memory takes the dma-buf import path, not the host-import path the description targets. We can't reproduce it on RADV, so please find out why that path advances (or stamps) unit 0's generation, and either fix it or restrict what the test claims. A test that fails on a Linux driver can't be merged.
  • Windows runs by @kr4y4 (RTX 4070 and Intel iGPU, full suite) pass, so this looks specific to the Linux dma-buf path.

Happy to re-review once the Linux/ANV case passes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5505554726 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4663#pullrequestreview-5505554726). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T14:57:03Z. **Review:** CHANGES_REQUESTED --- Checked on Linux (RADV, Radeon 660M): the PR merged onto main builds, `agc_storage_kept_unit_settle` passes, and it fails with only the `Texture.cpp` change reverted, so the test does exercise the change there. `libSceAgcDriver` ctest otherwise matches main (`agc_driver_tessellation` segfaults on main too). - However, @nicolasfalesy reports that on Linux with Intel Arc (ANV, Mesa 26.2.2) the direct-memory case fails with this PR: `the second write-back stored over unit 0, which the CPU wrote after that unit's generation`. That is the failure that the watched-memory case guards against (a layer that kept a block must keep its old generation). There the probe reports `dma-buf imports keep write protection: yes`, so direct memory takes the dma-buf import path, not the host-import path the description targets. We can't reproduce it on RADV, so please find out why that path advances (or stamps) unit 0's generation, and either fix it or restrict what the test claims. A test that fails on a Linux driver can't be merged. - Windows runs by @kr4y4 (RTX 4070 and Intel iGPU, full suite) pass, so this looks specific to the Linux dma-buf path. Happy to re-review once the Linux/ANV case passes.
fdfawef324 commented 2026-10-13 15:11:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-13T15:11:01Z.


Thanks for the Linux run. I traced it, and the failure doesn't come from a dma-buf write-back path. Your direct memory never reached the dma-buf import.

  • With host imports resolve write protection: yes and dma-buf imports keep write protection: yes, importAllocation (GuestBufferMemory.cpp:759-774) tries the host-pointer import first. That attempt runs in a window that doesn't stay watched. dma-buf is tried only if the host-pointer import fails. On ANV the host-pointer import of shared direct memory succeeds, so ImportWatched (GuestMemory.cpp:1216-1219) takes the surface out of the write watch.
  • The test checked the write watch before it made that import, so the direct case ran on the compared path:
    • The upload saves the guest bytes.
    • The first write-back keeps unit 0 by comparison and drops the saved bytes of every selected unit (Texture.cpp:4166).
    • The second write-back has nothing to compare.
  • On your base (7e181fcc3, before e5449936f) that store wrote every unit whole, over unit 0. That's your message. On current main the same store throws storing storage image results pending over memory outside the write watch ... not implemented, which no technical-debt entry covers yet. The existing entry only covers results over a range that left the watch after they became pending. Here the range was compared from before the upload, and the saved bytes are gone after the first GPU-direct store. That needs its own PR.
  • None of this depends on this PR's Texture.cpp change, because the compared path has no generations to settle. I reproduced both outcomes on Windows by importing private watched memory (Windows compares that import):
    • On 7e181fcc3, with and without this PR's change, the run fails with your message.
    • On main the run throws.

What changed: the branch is rebased onto f2c314e90 with one extra commit. The direct case now checks the write watch again after the import. If the import took the memory out of the watch, it prints the host import of the direct memory took it out of the write watch (its imports are compared): ... not tested and the test returns 77. Where the import keeps the memory watched (the Windows alias import, or a Linux dma-buf import when the host-pointer import fails, as with shared memory on RADV), the case runs as before. That path uses the same write-back and settle code as Windows.

Could you rerun ctest -R '^agc_storage_kept_unit_settle$' -V on the new head? ctest prints nothing for a skipped test without -V. I expect units stored next to a unit kept for the CPU in watched memory: ok, the new skip line, and the test reported as skipped. A different result would mean my reading is wrong somewhere. If you also have an AMD or other non-ANV Linux machine with /dev/udmabuf access, a run there would cover the dma-buf case.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6148727084 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4663#issuecomment-6148727084). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-13T15:11:01Z. --- Thanks for the Linux run. I traced it, and the failure doesn't come from a dma-buf write-back path. Your direct memory never reached the dma-buf import. - With `host imports resolve write protection: yes` and `dma-buf imports keep write protection: yes`, `importAllocation` (GuestBufferMemory.cpp:759-774) tries the host-pointer import first. That attempt runs in a window that doesn't stay watched. dma-buf is tried only if the host-pointer import fails. On ANV the host-pointer import of shared direct memory succeeds, so `ImportWatched` (GuestMemory.cpp:1216-1219) takes the surface out of the write watch. - The test checked the write watch before it made that import, so the direct case ran on the compared path: - The upload saves the guest bytes. - The first write-back keeps unit 0 by comparison and drops the saved bytes of every selected unit (Texture.cpp:4166). - The second write-back has nothing to compare. - On your base (7e181fcc3, before e5449936f) that store wrote every unit whole, over unit 0. That's your message. On current `main` the same store throws `storing storage image results pending over memory outside the write watch ... not implemented`, which no technical-debt entry covers yet. The existing entry only covers results over a range that left the watch after they became pending. Here the range was compared from before the upload, and the saved bytes are gone after the first GPU-direct store. That needs its own PR. - None of this depends on this PR's `Texture.cpp` change, because the compared path has no generations to settle. I reproduced both outcomes on Windows by importing private watched memory (Windows compares that import): - On 7e181fcc3, with and without this PR's change, the run fails with your message. - On `main` the run throws. What changed: the branch is rebased onto f2c314e90 with one extra commit. The direct case now checks the write watch again after the import. If the import took the memory out of the watch, it prints `the host import of the direct memory took it out of the write watch (its imports are compared): ... not tested` and the test returns 77. Where the import keeps the memory watched (the Windows alias import, or a Linux dma-buf import when the host-pointer import fails, as with shared memory on RADV), the case runs as before. That path uses the same write-back and settle code as Windows. Could you rerun `ctest -R '^agc_storage_kept_unit_settle$' -V` on the new head? ctest prints nothing for a skipped test without `-V`. I expect `units stored next to a unit kept for the CPU in watched memory: ok`, the new skip line, and the test reported as skipped. A different result would mean my reading is wrong somewhere. If you also have an AMD or other non-ANV Linux machine with `/dev/udmabuf` access, a run there would cover the dma-buf case. Written with AI assistance.
adriadam10 commented 2026-10-13 15:52:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T15:52:59Z.

Review: APPROVED


Checked on Linux (RADV): the PR merged onto main builds, agc_storage_kept_unit_settle passes, and it fails with only the Texture.cpp change reverted. The remaining libSceAgcDriver ctest difference vs main is agc_driver_tessellation (segfaults on main too). The ANV case from @nicolasfalesy is now skipped (77) when the host import takes the memory out of the write watch, which matches the trace in your reply; the compared-path store throwing on main is a separate follow-up. Windows full-suite runs by @kr4y4 pass. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5506336980 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4663#pullrequestreview-5506336980). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T15:52:59Z. **Review:** APPROVED --- Checked on Linux (RADV): the PR merged onto main builds, `agc_storage_kept_unit_settle` passes, and it fails with only the `Texture.cpp` change reverted. The remaining `libSceAgcDriver` ctest difference vs main is `agc_driver_tessellation` (segfaults on main too). The ANV case from @nicolasfalesy is now skipped (77) when the host import takes the memory out of the write watch, which matches the trace in your reply; the compared-path store throwing on main is a separate follow-up. Windows full-suite runs by @kr4y4 pass. Merging once the full Build is green.
github-actions[bot] commented 2026-10-13 22:26:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T22:26:09Z.


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
#5522 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp L4474-4485
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6156535061 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4663#issuecomment-6156535061). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T22:26:09Z. --- <!-- pr-overlap --> 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 | |---|---|---|---| | #5522 | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` [L4474-4485](https://github.com/boykopovar/AnyPS5/blob/8b8bfe0b6e69c0ccdf4fdb932a8c807df5b24783/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp#L4474-L4485) | | |
oneandonlydean commented 2026-10-14 06:19:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T06:19:04Z.


The full Build is red on this head, on Linux only: tools/check_skips.py fails with agc_storage_kept_unit_settle skipped (run 38513427247). On CI's lavapipe the test now returns 77, and the reason it prints isn't one of the device limitations the check accepts, so the job counts it as lost coverage.

Could the direct-memory case skip on its own and let the rest of the test run (and pass) there? If the remaining skip really is a device limitation, word it the way check_skips.py expects ("skipped, the device ..."); otherwise the case needs to run on lavapipe.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6162226654 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4663#issuecomment-6162226654). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T06:19:04Z. --- The full Build is red on this head, on Linux only: `tools/check_skips.py` fails with `agc_storage_kept_unit_settle skipped` (run 38513427247). On CI's lavapipe the test now returns 77, and the reason it prints isn't one of the device limitations the check accepts, so the job counts it as lost coverage. Could the direct-memory case skip on its own and let the rest of the test run (and pass) there? If the remaining skip really is a device limitation, word it the way `check_skips.py` expects ("skipped, the device ..."); otherwise the case needs to run on lavapipe.
fdfawef324 commented 2026-10-14 08:10:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-14T08:10:29Z.


Fixed in ca73d0f. The watched-memory case now runs and passes independently; an unavailable direct-memory subcase only prints its own reason. Missing host write watching and all readback failures remain failures, so this does not turn required coverage into a skip.

Verification: full matching-header Recorder.cpp and unchanged Texture.cpp pass GCC -O3 syntax checks. The literal completion-policy CPU replay reproduces old exit77/check_skips failure and corrected exit0/check_skips success; injected watched/direct failures still fail. The GPU readback body and production code are unchanged. This follow-up has not been rerun on Linux or on a native GPU; CI must confirm lavapipe coverage.

On ca73d0f, conventions run 38533264055, eligibility and report pass. GitHub retains cancelled duplicate conventions run 38533264336; rerunning it requires repository admin rights. The test-only Build gate skipped Linux/Windows, so a maintainer Build dispatch with pr=4663 is needed for a fresh lavapipe result.

GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100 (prior production-fix/readback evidence in the PR; this follow-up uses source and CPU checks only).

AI-assisted: yes

Co-Authored-By: Codex [email protected]

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6163900133 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4663#issuecomment-6163900133). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-14T08:10:29Z. --- Fixed in ca73d0f. The watched-memory case now runs and passes independently; an unavailable direct-memory subcase only prints its own reason. Missing host write watching and all readback failures remain failures, so this does not turn required coverage into a skip. Verification: full matching-header Recorder.cpp and unchanged Texture.cpp pass GCC -O3 syntax checks. The literal completion-policy CPU replay reproduces old exit77/check_skips failure and corrected exit0/check_skips success; injected watched/direct failures still fail. The GPU readback body and production code are unchanged. This follow-up has not been rerun on Linux or on a native GPU; CI must confirm lavapipe coverage. On ca73d0f, conventions run [38533264055](https://github.com/boykopovar/AnyPS5/actions/runs/38533264055), eligibility and report pass. GitHub retains cancelled duplicate conventions run [38533264336](https://github.com/boykopovar/AnyPS5/actions/runs/38533264336); rerunning it requires repository admin rights. The test-only Build gate skipped Linux/Windows, so a maintainer Build dispatch with `pr=4663` is needed for a fresh lavapipe result. GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100 (prior production-fix/readback evidence in the PR; this follow-up uses source and CPU checks only). AI-assisted: yes Co-Authored-By: Codex <[email protected]>
adriadam10 commented 2026-10-14 17:03:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T17:03:15Z.


Re-checked the new commit ca73d0f: the watched-memory case now runs and passes on its own when the direct-memory subcase is unavailable, so lavapipe no longer returns 77 for the whole test (the check_skips.py failure from the last Build). Production code is unchanged. On Linux (RADV) the PR merged onto main builds, agc_storage_kept_unit_settle passes, and it fails with only the Texture.cpp change reverted. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6173815684 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4663#issuecomment-6173815684). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T17:03:15Z. --- Re-checked the new commit `ca73d0f`: the watched-memory case now runs and passes on its own when the direct-memory subcase is unavailable, so lavapipe no longer returns 77 for the whole test (the `check_skips.py` failure from the last Build). Production code is unchanged. On Linux (RADV) the PR merged onto main builds, `agc_storage_kept_unit_settle` passes, and it fails with only the `Texture.cpp` change reverted. Merging once the full Build is green.
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!4663
No description provided.