fix(agc): order driver stores over a depth plane by record order #15621

Merged
Astronaut10 merged 2 commits from upstream-pr/15621 into main 2026-11-30 08:52:11 +00:00
Astronaut10 commented 2026-11-03 22:11:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Astronaut10 on 2026-11-03T22:11:33Z.


What

#12238 reloads a sampled single-sample D32 Z64KBX depth plane from guest memory when the tracker says the guest wrote it after its bind. The tracker also stamps the driver's own stores, by when they are stamped rather than when their results were recorded. In Astro Bot (PPSA21564) Aerial Garden a colour image aliasing a 1920x1080 depth plane is stored once per frame by the bind's own mirror refresh, after the bind took its generation, with results recorded before the bind; at the sample all 135 units look guest-written and the drawn depth is replaced by colour bytes, so the cloud sea and haze render as teal water.

This keeps #12238's reload and orders driver stores against depth draws:

  • Each pending storage image layer records when its results were recorded; each depth unit records when its last draw was recorded (NextRecordOrder).
  • KeepNewerDepthUnits lets a driver store (storage image layer stores, the direct and copied-back branches of GuestBufferMemory::WriteBack) invalidate only units whose last draw was recorded before it, as StorageTexture::StampKeepingNewerResults already does for storage images.
  • SyncFromMemory first stores pending images inside the plane (not its own mirror), so stores its refresh would trigger fall inside the bind's generation.
  • CPU and record-time stamps keep today's rule, so a guest write after the draw (PPSA05684, GuestWriteAfterDrawCase) is still reloaded.
  • BDA completion stamps (markWrittenPages) carry no record order and are excluded from this fix; listed in docs/dev/debt/libSceAgcDriver.md.

New test AliasedStoreAfterDrawCase (image results pending over the plane, bind + draw, image stored, sample = drawn depth, plane store writes drawn depth to memory, plus the record-order guard called directly with a GPU write recorded before / after the draw; an imported-buffer completion is not exercised end to end). New ctest entry agc_driver_depth_plane_sampling_unimported (APS5_NO_HOST_IMPORT=1): with host imports on, the write-watch cases of this suite (#12238's GuestWriteAfterDrawCase and the new case) print "no write watch" and return without checking, while the rest of the suite runs; this entry runs them.

Related: #15551 (open) changes the line after the one this adds in GuestBufferMemory::MarkDirectWrites (the storage image write order taken under the tracker lock); the two order different things and compose, but whichever merges second needs a one-line rebase.

Tested

Linux (CachyOS, kernel 7.3.0-4-cachyos), AMD Radeon RX 9070 XT (RADV GFX1201), Mesa 26.2.5-arch3.1, Astro Bot PPSA21564 01.007.

On main 086c0686c8 (this branch, eab4ee3ac6):

  • ctest -R 'agc|guest_memory' with ANYPS5_REQUIRE_VULKAN=1: the same statuses as main plus the new entry (passed), 1,288 against 1,287. agc_driver_scattered_runs and agc_driver_tessellation (segfault) fail on main as well. agc_driver_depth_plane_sampling and _evicting print "no write watch" for the two write-watch cases; agc_driver_depth_plane_sampling_unimported runs them and passes.
  • Validation on the focused AGC set (ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest -V), main and this branch: layer loaded in both (vulkaninfo reports it; no "was not found but was requested" line), 244 and 245 passed, the same six VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 lines (all from agc_driver_srgb8_color_target) and 20 WARNING-VkImageSubresourceRange-layerCount-compatibility lines in both; this branch adds no VUID-.
  • Aerial Garden frame dumps (APS5_DUMP_FRAMES=40, every 25th frame, one run per side): main has no cloud sea (bottom third 1-3 % white in all 11 in-level dumps; the first shows teal water where the clouds are), this branch has it (80, 71, 61, 50, 37, 21, 10, 6, 2 % in its 9 in-level dumps, falling as the camera leaves the clouds, the same course as on the earlier base). Frames available on request.

On the earlier base 3ab5a11d66 (the same change as 450bc82830, before the rebase; the cost numbers below were not repeated on current main):

  • The new test fails with the pre-sync store disabled ("D32 plane drawn after an aliasing image's results were recorded, sampled after those results were stored: texel 0 read 0x3f800000, expected 0x3e800000") or with the record-order keep disabled ("sampled after a GPU write recorded before its draw completed"), in variants of this branch with that part disabled (the test does not build on the base, it calls the new functions); GuestWriteAfterDrawCase (PPSA05684's regression case) passes; PPSA05684 itself was not run.
  • Frame dumps: Aerial Garden has its cloud sea back in every in-level frame (about 80 % of the bottom third white in the first in-level frame, against about 2 % on the base, the same as the base with #12238's line removed); Crash Site: no obvious visual difference in inspected dumps compared at corresponding animation phases.
  • Aerial Garden 90 s clean runs, 4 per side: -1.8 % FPS against the base (95 % -3.3 to -0.4), GPU busy unchanged. Steady-state FPS / frame p50: base 3.53 / 281.8, 3.59 / 279.6, 3.54 / 280.9, 3.53 / 281.8 ms; this change 3.52 / 284.6, 3.50 / 286.4, 3.44 / 287.9, 3.48 / 287.0 ms. Against the base with only #12238's line removed (same clouds, no new code), 2 per side: -0.1 % (95 % -3.8 to +3.6), consistent with the cost coming with the restored rendering. A draw profile (APS5_PROFILE_DRAW, 2 runs per side, against the base with the line removed) puts the new code's own cost at about 3 ms per frame of draw-thread time, mostly waiting for the store SyncFromMemory now makes at the depth bind; that thread was about 74 % busy and the frame did not get longer, so it did not show on the critical path there.
  • tools/trace_digest.py of the aps5-summary.jsonl of one adjacent pair (APS5_TRACE_SUMMARY_EVERY=10, the level starts at about 19 s, the measured window is 40 s after it); the summary files of all eight runs are available on request. No APS5_TRACE_FRAMES window trace was captured for these runs.
base 3ab5a11d66
**15 intervals**, 0.0 to 152.2 s, 799 presents
AMD Radeon RX 9070 XT (RADV GFX1201), radv Mesa 26.2.5-arch3.1, Linux 7.3.0-4-cachyos, 3840x2160, commit 3ab5a11d665e

| # | seconds | presents | p50 | p90 | p99 | max | GPU busy | busiest worker | largest phase |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 0-10 | 252 | 28.5 | 30.6 | 628.8 | 1440.7 | 19.2 | 100 % | Driver.Packet 116.0 |
| 2 | 10-21 | 81 | 27.9 | 289.8 | 4524.1 | 4524.1 | 51.3 | 96 % | Driver.Packet 360.3 |
| 3 | 21-31 | 36 | 282.9 | 290.1 | 297.9 | 297.9 | 188.5 | 111 % | Driver.Packet 873.6 |
| 4 | 31-41 | 36 | 279.7 | 285.5 | 309.6 | 309.6 | 168.4 | 100 % | Driver.Packet 832.7 |
| 5 | 41-51 | 36 | 279.6 | 283.8 | 286.7 | 286.7 | 157.7 | 100 % | Driver.Packet 830.3 |
| 6 | 51-61 | 36 | 281.7 | 286.6 | 288.9 | 288.9 | 162.7 | 100 % | Driver.Packet 837.2 |
| 7 | 61-71 | 36 | 282.4 | 288.6 | 293.7 | 293.7 | 163.0 | 100 % | Driver.Packet 841.3 |
| 8 | 71-81 | 36 | 283.7 | 288.2 | 292.7 | 292.7 | 168.1 | 100 % | Driver.Packet 841.3 |
| 9 | 81-91 | 36 | 281.3 | 286.6 | 294.2 | 294.2 | 160.8 | 100 % | Driver.Packet 835.5 |
| 10 | 91-101 | 33 | 281.8 | 286.1 | 808.3 | 808.3 | 169.8 | 100 % | Driver.Packet 911.5 |
| 11 | 101-112 | 37 | 278.0 | 281.7 | 284.0 | 284.0 | 160.9 | 100 % | Driver.Packet 826.8 |
| 12 | 112-122 | 36 | 279.2 | 283.7 | 289.3 | 289.3 | 165.7 | 100 % | Driver.Packet 832.8 |
| 13 | 122-132 | 36 | 282.9 | 289.4 | 299.1 | 299.1 | 167.5 | 100 % | Driver.Packet 845.9 |
| 14 | 132-142 | 36 | 285.1 | 289.1 | 313.9 | 313.9 | 168.3 | 100 % | Driver.Packet 848.7 |
| 15 | 142-152 | 36 | 281.6 | 286.7 | 289.0 | 289.0 | 172.2 | 100 % | Driver.Packet 835.8 |

```
p99 ms  _@_______:_____  0-4524.1
gpu ms  _:@%%%%%%%%%%%%  0-188.5
```
this change (450bc82830 on 3ab5a11d66)
**15 intervals**, 0.0 to 152.4 s, 796 presents
AMD Radeon RX 9070 XT (RADV GFX1201), radv Mesa 26.2.5-arch3.1, Linux 7.3.0-4-cachyos, 3840x2160, commit 450bc82830ba

| # | seconds | presents | p50 | p90 | p99 | max | GPU busy | busiest worker | largest phase |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 0-10 | 258 | 28.4 | 30.5 | 534.7 | 1400.4 | 19.0 | 100 % | Driver.Packet 113.0 |
| 2 | 10-20 | 72 | 28.1 | 278.5 | 4310.7 | 4310.7 | 72.5 | 96 % | Driver.Packet 396.1 |
| 3 | 20-30 | 36 | 279.8 | 289.1 | 294.9 | 294.9 | 162.3 | 100 % | Driver.Packet 834.8 |
| 4 | 30-40 | 36 | 282.6 | 306.5 | 327.9 | 327.9 | 165.3 | 100 % | Driver.Packet 849.4 |
| 5 | 40-51 | 36 | 284.5 | 288.3 | 292.7 | 292.7 | 162.5 | 100 % | Driver.Packet 844.3 |
| 6 | 51-61 | 36 | 284.9 | 295.2 | 311.0 | 311.0 | 163.6 | 100 % | Driver.Packet 849.9 |
| 7 | 61-71 | 36 | 285.8 | 292.6 | 318.3 | 318.3 | 164.1 | 100 % | Driver.Packet 851.1 |
| 8 | 71-81 | 36 | 285.0 | 291.8 | 293.0 | 293.0 | 168.3 | 100 % | Driver.Packet 845.3 |
| 9 | 81-92 | 36 | 286.1 | 290.2 | 295.1 | 295.1 | 161.2 | 100 % | Driver.Packet 850.7 |
| 10 | 92-102 | 33 | 287.3 | 294.3 | 746.0 | 746.0 | 164.8 | 100 % | Driver.Packet 920.0 |
| 11 | 102-112 | 36 | 284.3 | 289.2 | 295.6 | 295.6 | 170.3 | 100 % | Driver.Packet 843.7 |
| 12 | 112-122 | 37 | 277.1 | 285.8 | 288.4 | 288.4 | 161.2 | 100 % | Driver.Packet 829.5 |
| 13 | 122-132 | 36 | 282.1 | 288.9 | 294.4 | 294.4 | 167.1 | 100 % | Driver.Packet 838.8 |
| 14 | 132-142 | 36 | 284.6 | 290.8 | 303.6 | 303.6 | 172.9 | 100 % | Driver.Packet 847.6 |
| 15 | 142-152 | 36 | 279.4 | 288.3 | 289.9 | 289.9 | 162.9 | 100 % | Driver.Packet 833.9 |

```
p99 ms  _@_______:_____  0-4310.7
gpu ms  _=%@%@@@%@@%@@%  0-172.9
```

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: PPSA21564 #357
  • GPUs tested: AMD Radeon RX 9070 XT (RADV GFX1201), Mesa 26.2.5-arch3.1, Linux (CachyOS, kernel 7.3.0-4-cachyos)
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_015W3M6Kw7yNRginUW6VUeE2

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5145289229 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15621). Originally posted by [Astronaut10](https://github.com/Astronaut10) on 2026-11-03T22:11:33Z. --- ### What #12238 reloads a sampled single-sample D32 Z64KBX depth plane from guest memory when the tracker says the guest wrote it after its bind. The tracker also stamps the driver's own stores, by when they are stamped rather than when their results were recorded. In Astro Bot (PPSA21564) Aerial Garden a colour image aliasing a 1920x1080 depth plane is stored once per frame by the bind's own mirror refresh, after the bind took its generation, with results recorded before the bind; at the sample all 135 units look guest-written and the drawn depth is replaced by colour bytes, so the cloud sea and haze render as teal water. This keeps #12238's reload and orders driver stores against depth draws: - Each pending storage image layer records when its results were recorded; each depth unit records when its last draw was recorded (`NextRecordOrder`). - `KeepNewerDepthUnits` lets a driver store (storage image layer stores, the direct and copied-back branches of `GuestBufferMemory::WriteBack`) invalidate only units whose last draw was recorded before it, as `StorageTexture::StampKeepingNewerResults` already does for storage images. - `SyncFromMemory` first stores pending images inside the plane (not its own mirror), so stores its refresh would trigger fall inside the bind's generation. - CPU and record-time stamps keep today's rule, so a guest write after the draw (PPSA05684, `GuestWriteAfterDrawCase`) is still reloaded. - BDA completion stamps (`markWrittenPages`) carry no record order and are excluded from this fix; listed in `docs/dev/debt/libSceAgcDriver.md`. New test `AliasedStoreAfterDrawCase` (image results pending over the plane, bind + draw, image stored, sample = drawn depth, plane store writes drawn depth to memory, plus the record-order guard called directly with a GPU write recorded before / after the draw; an imported-buffer completion is not exercised end to end). New ctest entry `agc_driver_depth_plane_sampling_unimported` (`APS5_NO_HOST_IMPORT=1`): with host imports on, the write-watch cases of this suite (#12238's `GuestWriteAfterDrawCase` and the new case) print "no write watch" and return without checking, while the rest of the suite runs; this entry runs them. Related: #15551 (open) changes the line after the one this adds in `GuestBufferMemory::MarkDirectWrites` (the storage image write order taken under the tracker lock); the two order different things and compose, but whichever merges second needs a one-line rebase. ### 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. --> Linux (CachyOS, kernel 7.3.0-4-cachyos), AMD Radeon RX 9070 XT (RADV GFX1201), Mesa 26.2.5-arch3.1, Astro Bot PPSA21564 01.007. On `main` `086c0686c8` (this branch, `eab4ee3ac6`): - `ctest -R 'agc|guest_memory'` with `ANYPS5_REQUIRE_VULKAN=1`: the same statuses as `main` plus the new entry (passed), 1,288 against 1,287. `agc_driver_scattered_runs` and `agc_driver_tessellation` (segfault) fail on `main` as well. `agc_driver_depth_plane_sampling` and `_evicting` print "no write watch" for the two write-watch cases; `agc_driver_depth_plane_sampling_unimported` runs them and passes. - Validation on the focused AGC set (`ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ctest -V`), `main` and this branch: layer loaded in both (`vulkaninfo` reports it; no "was not found but was requested" line), 244 and 245 passed, the same six `VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605` lines (all from `agc_driver_srgb8_color_target`) and 20 `WARNING-VkImageSubresourceRange-layerCount-compatibility` lines in both; this branch adds no `VUID-`. - Aerial Garden frame dumps (`APS5_DUMP_FRAMES=40`, every 25th frame, one run per side): `main` has no cloud sea (bottom third 1-3 % white in all 11 in-level dumps; the first shows teal water where the clouds are), this branch has it (80, 71, 61, 50, 37, 21, 10, 6, 2 % in its 9 in-level dumps, falling as the camera leaves the clouds, the same course as on the earlier base). Frames available on request. On the earlier base `3ab5a11d66` (the same change as `450bc82830`, before the rebase; the cost numbers below were not repeated on current `main`): - The new test fails with the pre-sync store disabled ("D32 plane drawn after an aliasing image's results were recorded, sampled after those results were stored: texel 0 read 0x3f800000, expected 0x3e800000") or with the record-order keep disabled ("sampled after a GPU write recorded before its draw completed"), in variants of this branch with that part disabled (the test does not build on the base, it calls the new functions); `GuestWriteAfterDrawCase` (PPSA05684's regression case) passes; PPSA05684 itself was not run. - Frame dumps: Aerial Garden has its cloud sea back in every in-level frame (about 80 % of the bottom third white in the first in-level frame, against about 2 % on the base, the same as the base with #12238's line removed); Crash Site: no obvious visual difference in inspected dumps compared at corresponding animation phases. - Aerial Garden 90 s clean runs, 4 per side: -1.8 % FPS against the base (95 % -3.3 to -0.4), GPU busy unchanged. Steady-state FPS / frame p50: base 3.53 / 281.8, 3.59 / 279.6, 3.54 / 280.9, 3.53 / 281.8 ms; this change 3.52 / 284.6, 3.50 / 286.4, 3.44 / 287.9, 3.48 / 287.0 ms. Against the base with only #12238's line removed (same clouds, no new code), 2 per side: -0.1 % (95 % -3.8 to +3.6), consistent with the cost coming with the restored rendering. A draw profile (`APS5_PROFILE_DRAW`, 2 runs per side, against the base with the line removed) puts the new code's own cost at about 3 ms per frame of draw-thread time, mostly waiting for the store `SyncFromMemory` now makes at the depth bind; that thread was about 74 % busy and the frame did not get longer, so it did not show on the critical path there. - `tools/trace_digest.py` of the `aps5-summary.jsonl` of one adjacent pair (`APS5_TRACE_SUMMARY_EVERY=10`, the level starts at about 19 s, the measured window is 40 s after it); the summary files of all eight runs are available on request. No `APS5_TRACE_FRAMES` window trace was captured for these runs. <details><summary>base 3ab5a11d66</summary> ```` **15 intervals**, 0.0 to 152.2 s, 799 presents AMD Radeon RX 9070 XT (RADV GFX1201), radv Mesa 26.2.5-arch3.1, Linux 7.3.0-4-cachyos, 3840x2160, commit 3ab5a11d665e | # | seconds | presents | p50 | p90 | p99 | max | GPU busy | busiest worker | largest phase | |---|---|---|---|---|---|---|---|---|---| | 1 | 0-10 | 252 | 28.5 | 30.6 | 628.8 | 1440.7 | 19.2 | 100 % | Driver.Packet 116.0 | | 2 | 10-21 | 81 | 27.9 | 289.8 | 4524.1 | 4524.1 | 51.3 | 96 % | Driver.Packet 360.3 | | 3 | 21-31 | 36 | 282.9 | 290.1 | 297.9 | 297.9 | 188.5 | 111 % | Driver.Packet 873.6 | | 4 | 31-41 | 36 | 279.7 | 285.5 | 309.6 | 309.6 | 168.4 | 100 % | Driver.Packet 832.7 | | 5 | 41-51 | 36 | 279.6 | 283.8 | 286.7 | 286.7 | 157.7 | 100 % | Driver.Packet 830.3 | | 6 | 51-61 | 36 | 281.7 | 286.6 | 288.9 | 288.9 | 162.7 | 100 % | Driver.Packet 837.2 | | 7 | 61-71 | 36 | 282.4 | 288.6 | 293.7 | 293.7 | 163.0 | 100 % | Driver.Packet 841.3 | | 8 | 71-81 | 36 | 283.7 | 288.2 | 292.7 | 292.7 | 168.1 | 100 % | Driver.Packet 841.3 | | 9 | 81-91 | 36 | 281.3 | 286.6 | 294.2 | 294.2 | 160.8 | 100 % | Driver.Packet 835.5 | | 10 | 91-101 | 33 | 281.8 | 286.1 | 808.3 | 808.3 | 169.8 | 100 % | Driver.Packet 911.5 | | 11 | 101-112 | 37 | 278.0 | 281.7 | 284.0 | 284.0 | 160.9 | 100 % | Driver.Packet 826.8 | | 12 | 112-122 | 36 | 279.2 | 283.7 | 289.3 | 289.3 | 165.7 | 100 % | Driver.Packet 832.8 | | 13 | 122-132 | 36 | 282.9 | 289.4 | 299.1 | 299.1 | 167.5 | 100 % | Driver.Packet 845.9 | | 14 | 132-142 | 36 | 285.1 | 289.1 | 313.9 | 313.9 | 168.3 | 100 % | Driver.Packet 848.7 | | 15 | 142-152 | 36 | 281.6 | 286.7 | 289.0 | 289.0 | 172.2 | 100 % | Driver.Packet 835.8 | ``` p99 ms _@_______:_____ 0-4524.1 gpu ms _:@%%%%%%%%%%%% 0-188.5 ``` ```` </details> <details><summary>this change (450bc82830 on 3ab5a11d66)</summary> ```` **15 intervals**, 0.0 to 152.4 s, 796 presents AMD Radeon RX 9070 XT (RADV GFX1201), radv Mesa 26.2.5-arch3.1, Linux 7.3.0-4-cachyos, 3840x2160, commit 450bc82830ba | # | seconds | presents | p50 | p90 | p99 | max | GPU busy | busiest worker | largest phase | |---|---|---|---|---|---|---|---|---|---| | 1 | 0-10 | 258 | 28.4 | 30.5 | 534.7 | 1400.4 | 19.0 | 100 % | Driver.Packet 113.0 | | 2 | 10-20 | 72 | 28.1 | 278.5 | 4310.7 | 4310.7 | 72.5 | 96 % | Driver.Packet 396.1 | | 3 | 20-30 | 36 | 279.8 | 289.1 | 294.9 | 294.9 | 162.3 | 100 % | Driver.Packet 834.8 | | 4 | 30-40 | 36 | 282.6 | 306.5 | 327.9 | 327.9 | 165.3 | 100 % | Driver.Packet 849.4 | | 5 | 40-51 | 36 | 284.5 | 288.3 | 292.7 | 292.7 | 162.5 | 100 % | Driver.Packet 844.3 | | 6 | 51-61 | 36 | 284.9 | 295.2 | 311.0 | 311.0 | 163.6 | 100 % | Driver.Packet 849.9 | | 7 | 61-71 | 36 | 285.8 | 292.6 | 318.3 | 318.3 | 164.1 | 100 % | Driver.Packet 851.1 | | 8 | 71-81 | 36 | 285.0 | 291.8 | 293.0 | 293.0 | 168.3 | 100 % | Driver.Packet 845.3 | | 9 | 81-92 | 36 | 286.1 | 290.2 | 295.1 | 295.1 | 161.2 | 100 % | Driver.Packet 850.7 | | 10 | 92-102 | 33 | 287.3 | 294.3 | 746.0 | 746.0 | 164.8 | 100 % | Driver.Packet 920.0 | | 11 | 102-112 | 36 | 284.3 | 289.2 | 295.6 | 295.6 | 170.3 | 100 % | Driver.Packet 843.7 | | 12 | 112-122 | 37 | 277.1 | 285.8 | 288.4 | 288.4 | 161.2 | 100 % | Driver.Packet 829.5 | | 13 | 122-132 | 36 | 282.1 | 288.9 | 294.4 | 294.4 | 167.1 | 100 % | Driver.Packet 838.8 | | 14 | 132-142 | 36 | 284.6 | 290.8 | 303.6 | 303.6 | 172.9 | 100 % | Driver.Packet 847.6 | | 15 | 142-152 | 36 | 279.4 | 288.3 | 289.9 | 289.9 | 162.9 | 100 % | Driver.Packet 833.9 | ``` p99 ms _@_______:_____ 0-4310.7 gpu ms _=%@%@@@%@@%@@% 0-172.9 ``` ```` </details> ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> PPSA21564 #357 - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> AMD Radeon RX 9070 XT (RADV GFX1201), Mesa 26.2.5-arch3.1, Linux (CachyOS, kernel 7.3.0-4-cachyos) - [x] AI-assisted: <!-- yes / no --> yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015W3M6Kw7yNRginUW6VUeE2
XairRrR commented 2026-11-03 22:55:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T22:55:35Z.

Review: APPROVED


Reviewed — approved

The fix is now ordered by record order: storing a depth plane's pending aliasing images before SyncFromMemory takes its generation, and keeping units drawn after a driver store, restores the drawn depth. Each half is covered by a check in AliasedStoreAfterDrawCase that fails when that half is disabled.

What I ran

Head eab4ee3ac6013f9d82b969ddd775ab1ee8fb929d, main 1c8c0efc8c41314402e6966da5bef6ea3d639d10, merged tree 9dd4f135b3e899321d23e326c68162fadb65808f (Debian 13 VM, GCC 14.2.0, lavapipe Mesa 26.1.6 / LLVM 19, no GPU).

git diff --check 1c8c0efc8c41314402e6966da5bef6ea3d639d10...eab4ee3ac6013f9d82b969ddd775ab1ee8fb929d
python3 tools/check_conventions.py --base 1c8c0efc8c41314402e6966da5bef6ea3d639d10
env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \
    ctest --test-dir build -V -R "depth_plane_sampling|image_gather_volume"
# main's six production files restored:
ninja -C build -j32 -l32 agc_driver_image_gather_volume_tests
env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \
    ctest --test-dir build -V -R "^agc_driver_image_gather_volume$"
# variants A and B (see Negative control), each:
ninja -C build -j32 -l32 agc_driver_depth_plane_sampling_tests
env ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build --output-on-failure -R depth_plane_sampling
# merged files restored, rebuilt, rerun; git status --porcelain clean

Results

Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Configure / build / libs (script) ok
Selected tests (script) 2243 ran, no new failures or timeouts. The 7 known failures also fail on main
agc_driver_depth_plane_sampling / _evicting passed (4.7 s / 8.5 s). Both print "no write watch" for the two write-watch cases, as the description says
agc_driver_depth_plane_sampling_unimported (new) passed (5.1 s), and runs the write-watch cases
Validation, depth suite (3 tests) layer loaded, no VUID- lines, no "was not found but was requested"
Validation, agc_driver_image_gather_volume 8 VkSamplerCreateInfo-addressMode* VUID lines with the PR, the same 8 with main's production files, so they come from main. The PR does not touch sampler code
VUID lines, image_gather_volume, merged tree and main production files (identical)
      2 VUID-VkSamplerCreateInfo-addressModeU-01079
      2 VUID-VkSamplerCreateInfo-addressModeU-parameter
      2 VUID-VkSamplerCreateInfo-addressModeV-parameter
      2 VUID-VkSamplerCreateInfo-addressModeW-parameter

Negative control

With main's production files fully restored, the new test cannot build, because it calls NextRecordOrder and KeepNewerDepthUnits. So I disabled each half of the fix separately in the merged tree:

  • A: the StorePendingImages(resource) call in SyncFromMemory (core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:1367) removed. agc_driver_depth_plane_sampling_unimported fails:
    D32 plane drawn after an aliasing image's results were recorded, sampled after those results were stored: texel 0 read 0x3f800000, expected 0x3e800000
  • B: KeepNewerDepthUnits made to always return stamp() (DepthSurface.cpp:3206). agc_driver_depth_plane_sampling_unimported fails:
    D32 plane sampled after a GPU write recorded before its draw completed: texel 0 read 0x3e800000, expected 0x3ec00000

Both match the messages in the description. In both variants the two import-on entries still pass, because they skip these cases. Afterwards I restored the merged files, rebuilt, and reran the three entries (all passed). git status --porcelain was empty.

Findings

Blocking

None.

Non-blocking

  • The keep inside storage-image stores is not exercised end to end. In variant B, the aliased-image check (sample = drawn depth, plane store writes drawn depth) still passes. That check depends only on the pre-sync store. The record-order guard is proven only by the direct KeepNewerDepthUnits calls in the test (core/libs/prx/libSceAgcDriver/tests/execution/DepthPlaneSampling.cpp:410 and :414). Two paths have no test that fails without them: the wrapper in StorageTexture::writeBackLayers (core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:6606-6626) and the two GuestBufferMemory::WriteBack stamps. The description already says the imported-buffer completion is not exercised. Suggestion for a follow-up: a case where an image's results are recorded before a depth draw over the same plane and stored only after it, outside any bind, so that only the writeBackLayers keep protects the drawn units.
  • I checked the locking and found no problem. KeepNewerDepthUnits takes GpuMutex and then surfacesMutex, the same order as the rest of DepthSurface.cpp; both mutexes are recursive. stamp() runs outside both locks. FlushPending gathers its list under pending.mutex after taking GpuMutex, so calling the keep from writeBackLayers adds no inverted lock order that I could find. The post-stamp re-check uses UnchangedSinceCollected, which ignores driver stamps, as StampKeepingNewerResults does.
  • The debt entry added to docs/dev/debt/libSceAgcDriver.md states the remaining gap (BDA completion stamps through markWrittenPages carry no record order). It links a file that exists (Graphics/src/BdaResources.cpp, which defines markWrittenPages) and is in the right debt file. No code comments were added.

Not verified

  • No run on real GPUs here. The only GPU named is AMD RX 9070 XT (RADV); this machine has only lavapipe.
  • I did not check the Astro Bot (PPSA21564) frame-dump results or the performance numbers (about -1.8 % FPS against the earlier base, about 3 ms of draw-thread time per frame); no title was run.
  • I did not check the PPSA05684 regression on the title; only GuestWriteAfterDrawCase passes (in the unimported entry).
  • I did not check the BDA (markWrittenPages) and imported-buffer completion paths end to end.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5760654000 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15621#pullrequestreview-5760654000). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T22:55:35Z. **Review:** APPROVED --- # Reviewed — approved The fix is now ordered by record order: storing a depth plane's pending aliasing images before `SyncFromMemory` takes its generation, and keeping units drawn after a driver store, restores the drawn depth. Each half is covered by a check in `AliasedStoreAfterDrawCase` that fails when that half is disabled. ## What I ran Head `eab4ee3ac6013f9d82b969ddd775ab1ee8fb929d`, `main` `1c8c0efc8c41314402e6966da5bef6ea3d639d10`, merged tree `9dd4f135b3e899321d23e326c68162fadb65808f` (Debian 13 VM, GCC 14.2.0, lavapipe Mesa 26.1.6 / LLVM 19, no GPU). ``` git diff --check 1c8c0efc8c41314402e6966da5bef6ea3d639d10...eab4ee3ac6013f9d82b969ddd775ab1ee8fb929d python3 tools/check_conventions.py --base 1c8c0efc8c41314402e6966da5bef6ea3d639d10 env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \ ctest --test-dir build -V -R "depth_plane_sampling|image_gather_volume" # main's six production files restored: ninja -C build -j32 -l32 agc_driver_image_gather_volume_tests env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \ ctest --test-dir build -V -R "^agc_driver_image_gather_volume$" # variants A and B (see Negative control), each: ninja -C build -j32 -l32 agc_driver_depth_plane_sampling_tests env ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build --output-on-failure -R depth_plane_sampling # merged files restored, rebuilt, rerun; git status --porcelain clean ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | Configure / build / `libs` (script) | ok | | Selected tests (script) | 2243 ran, no new failures or timeouts. The 7 known failures also fail on `main` | | `agc_driver_depth_plane_sampling` / `_evicting` | passed (4.7 s / 8.5 s). Both print "no write watch" for the two write-watch cases, as the description says | | `agc_driver_depth_plane_sampling_unimported` (new) | passed (5.1 s), and runs the write-watch cases | | Validation, depth suite (3 tests) | layer loaded, no `VUID-` lines, no "was not found but was requested" | | Validation, `agc_driver_image_gather_volume` | 8 `VkSamplerCreateInfo-addressMode*` VUID lines with the PR, **the same 8 with `main`'s production files**, so they come from `main`. The PR does not touch sampler code | <details><summary>VUID lines, image_gather_volume, merged tree and main production files (identical)</summary> ``` 2 VUID-VkSamplerCreateInfo-addressModeU-01079 2 VUID-VkSamplerCreateInfo-addressModeU-parameter 2 VUID-VkSamplerCreateInfo-addressModeV-parameter 2 VUID-VkSamplerCreateInfo-addressModeW-parameter ``` </details> ## Negative control With `main`'s production files fully restored, the new test cannot build, because it calls `NextRecordOrder` and `KeepNewerDepthUnits`. So I disabled each half of the fix separately in the merged tree: - **A**: the `StorePendingImages(resource)` call in `SyncFromMemory` (`core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:1367`) removed. `agc_driver_depth_plane_sampling_unimported` fails: `D32 plane drawn after an aliasing image's results were recorded, sampled after those results were stored: texel 0 read 0x3f800000, expected 0x3e800000` - **B**: `KeepNewerDepthUnits` made to always return `stamp()` (`DepthSurface.cpp:3206`). `agc_driver_depth_plane_sampling_unimported` fails: `D32 plane sampled after a GPU write recorded before its draw completed: texel 0 read 0x3e800000, expected 0x3ec00000` Both match the messages in the description. In both variants the two import-on entries still pass, because they skip these cases. Afterwards I restored the merged files, rebuilt, and reran the three entries (all passed). `git status --porcelain` was empty. ## Findings ### Blocking None. ### Non-blocking - **The keep inside storage-image stores is not exercised end to end.** In variant B, the aliased-image check (sample = drawn depth, plane store writes drawn depth) still passes. That check depends only on the pre-sync store. The record-order guard is proven only by the direct `KeepNewerDepthUnits` calls in the test (`core/libs/prx/libSceAgcDriver/tests/execution/DepthPlaneSampling.cpp:410` and `:414`). Two paths have no test that fails without them: the wrapper in `StorageTexture::writeBackLayers` (`core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:6606-6626`) and the two `GuestBufferMemory::WriteBack` stamps. The description already says the imported-buffer completion is not exercised. Suggestion for a follow-up: a case where an image's results are recorded before a depth draw over the same plane and stored only after it, outside any bind, so that only the `writeBackLayers` keep protects the drawn units. - I checked the locking and found no problem. `KeepNewerDepthUnits` takes `GpuMutex` and then `surfacesMutex`, the same order as the rest of `DepthSurface.cpp`; both mutexes are recursive. `stamp()` runs outside both locks. `FlushPending` gathers its list under `pending.mutex` after taking `GpuMutex`, so calling the keep from `writeBackLayers` adds no inverted lock order that I could find. The post-stamp re-check uses `UnchangedSinceCollected`, which ignores driver stamps, as `StampKeepingNewerResults` does. - The debt entry added to `docs/dev/debt/libSceAgcDriver.md` states the remaining gap (BDA completion stamps through `markWrittenPages` carry no record order). It links a file that exists (`Graphics/src/BdaResources.cpp`, which defines `markWrittenPages`) and is in the right debt file. No code comments were added. ## Not verified - No run on real GPUs here. The only GPU named is AMD RX 9070 XT (RADV); this machine has only lavapipe. - I did not check the Astro Bot (PPSA21564) frame-dump results or the performance numbers (about -1.8 % FPS against the earlier base, about 3 ms of draw-thread time per frame); no title was run. - I did not check the PPSA05684 regression on the title; only `GuestWriteAfterDrawCase` passes (in the unimported entry). - I did not check the BDA (`markWrittenPages`) and imported-buffer completion paths end to end. <!-- anyps5-bots job=3662 head=eab4ee3ac6013f9d82b969ddd775ab1ee8fb929d -->
Superseabas commented 2026-11-06 09:24:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-06T09:24:49Z.

Review: APPROVED


Windows run with AMD's own driver, on the integrated Radeon of a Ryzen 7 7700X, and on an RTX 5070 Ti. The earlier AMD results here are RADV on Linux and the Windows ones are Intel and NVIDIA. Everything passes, both halves of the fix are covered on both GPUs, and nothing regresses.

Head db1f5844d8 merged onto main ed41d86d32 (clean merge, local only). Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (x86_64-ucrt-posix-seh, r3), Release. ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, no missing-layer line, ANYPS5_GPU selecting the device, confirmed by Selected GPU:

  • AMD Radeon of a Ryzen 7 7700X (1002:164e, integrated), AMD 26.10.2 (32.0.21045.20006)
  • NVIDIA GeForce RTX 5070 Ti (10de:2c05), 621.01

Depth-plane tests. All 16 agc_driver_depth_plane_* tests on main, and the 17 on this PR (with _sampling_unimported), pass 3 of 3 on both GPUs. No VUID- lines. Write watch works on both devices (host imports of write-watched memory keep the write watch: yes), so the two write-watch cases run in every entry: no "not checked" line, and _sampling_unimported passes instead of skipping.

Red checks, each a local edit of the merged tree, 3 runs per GPU of agc_driver_depth_plane_sampling, _sampling_evicting and _sampling_unimported:

Edit Result on both GPUs
none 3 of 3
StorePendingImages(resource) removed from the sync 0 of 3: D32 plane drawn after an aliasing image's results were recorded, sampled after those results were stored: texel 0 read 0x3f800000, expected 0x3e800000
KeepNewerDepthUnits returning stamp() before it collects the units to keep 0 of 3: D32 plane sampled after a GPU write recorded before its draw completed: texel 0 read 0x3e800000, expected 0x3ec00000

A revert of the six driver files to main doesn't build, because the test calls NextRecordOrder and KeepNewerDepthUnits directly. So these edits keep the functions and switch off one half each.

Whole AGC set. ctest -R '^agc' -j 8 --timeout 300: 1,387 of 1,389 pass on the RTX and 1,386 on the Radeon. Those are the same failures as main on this machine, plus the new entry, which passes. All are tracked: agc_driver_direct_write_completion (#15564), agc_driver_quad_pixel_mask on the RTX (#14341), and on the Radeon agc_driver_scratch_pool (#15566) and agc_driver_sample_order_grid_reference (#9503).

check_conventions.py --base main passes. Astro Bot itself isn't tested here.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5798168331 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15621#pullrequestreview-5798168331). Originally posted by [Superseabas](https://github.com/Superseabas) on 2026-11-06T09:24:49Z. **Review:** APPROVED --- Windows run with AMD's own driver, on the integrated Radeon of a Ryzen 7 7700X, and on an RTX 5070 Ti. The earlier AMD results here are RADV on Linux and the Windows ones are Intel and NVIDIA. Everything passes, both halves of the fix are covered on both GPUs, and nothing regresses. Head `db1f5844d8` merged onto `main` `ed41d86d32` (clean merge, local only). Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (`x86_64-ucrt-posix-seh`, r3), Release. `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, no missing-layer line, `ANYPS5_GPU` selecting the device, confirmed by `Selected GPU`: - AMD Radeon of a Ryzen 7 7700X (`1002:164e`, integrated), AMD 26.10.2 (32.0.21045.20006) - NVIDIA GeForce RTX 5070 Ti (`10de:2c05`), 621.01 **Depth-plane tests.** All 16 `agc_driver_depth_plane_*` tests on `main`, and the 17 on this PR (with `_sampling_unimported`), pass 3 of 3 on both GPUs. No `VUID-` lines. Write watch works on both devices (`host imports of write-watched memory keep the write watch: yes`), so the two write-watch cases run in every entry: no "not checked" line, and `_sampling_unimported` passes instead of skipping. **Red checks**, each a local edit of the merged tree, 3 runs per GPU of `agc_driver_depth_plane_sampling`, `_sampling_evicting` and `_sampling_unimported`: | Edit | Result on both GPUs | |---|---| | none | 3 of 3 | | `StorePendingImages(resource)` removed from the sync | 0 of 3: `D32 plane drawn after an aliasing image's results were recorded, sampled after those results were stored: texel 0 read 0x3f800000, expected 0x3e800000` | | `KeepNewerDepthUnits` returning `stamp()` before it collects the units to keep | 0 of 3: `D32 plane sampled after a GPU write recorded before its draw completed: texel 0 read 0x3e800000, expected 0x3ec00000` | A revert of the six driver files to `main` doesn't build, because the test calls `NextRecordOrder` and `KeepNewerDepthUnits` directly. So these edits keep the functions and switch off one half each. **Whole AGC set.** `ctest -R '^agc' -j 8 --timeout 300`: 1,387 of 1,389 pass on the RTX and 1,386 on the Radeon. Those are the same failures as `main` on this machine, plus the new entry, which passes. All are tracked: `agc_driver_direct_write_completion` (#15564), `agc_driver_quad_pixel_mask` on the RTX (#14341), and on the Radeon `agc_driver_scratch_pool` (#15566) and `agc_driver_sample_order_grid_reference` (#9503). `check_conventions.py --base main` passes. Astro Bot itself isn't tested here. AI-assisted: yes (Claude Code)
MarcZX10 commented 2026-11-21 05:14:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T05:14:52Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the inspected code and reported checks support merging.

What I ran

Reviewed head db1f5844d8f379ce0c0770e82b3870d02d43cffe. No commands or tests were run in this review; the test and hardware results below are author-reported.

Read description.md, commits.md, manifest.json, diff.patch, and the full text of DepthSurface.hpp, GuestBufferMemory.hpp, Texture.hpp, DepthSurface.cpp, GuestBufferMemory.cpp, agc_driver_depth_plane_sampling_tests.cmake, DepthPlaneSampling.cpp, and libSceAgcDriver.md. Read the changed portions of Texture.cpp through repo_read.py; its full text was excluded from the review folder for size.

Results

Check Result Note
Code review passed Inspected changes and relevant callers
Tests not run Results supplied by author
Console behavior not run Hardware evidence supplied by author

Findings

Blocking

None.

Non-blocking

None.

Not verified

The full Texture.cpp file was not read; targeted changed sections and nearby call sites were read through repo_read.py. No tests, builds, or console runs were performed independently. The reported test and Aerial Garden results were not independently verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003028356 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15621#pullrequestreview-6003028356). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T05:14:52Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the inspected code and reported checks support merging. ## What I ran Reviewed head `db1f5844d8f379ce0c0770e82b3870d02d43cffe`. No commands or tests were run in this review; the test and hardware results below are author-reported. Read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, and the full text of `DepthSurface.hpp`, `GuestBufferMemory.hpp`, `Texture.hpp`, `DepthSurface.cpp`, `GuestBufferMemory.cpp`, `agc_driver_depth_plane_sampling_tests.cmake`, `DepthPlaneSampling.cpp`, and `libSceAgcDriver.md`. Read the changed portions of `Texture.cpp` through `repo_read.py`; its full text was excluded from the review folder for size. ## Results | Check | Result | Note | |---|---|---| | Code review | passed | Inspected changes and relevant callers | | Tests | not run | Results supplied by author | | Console behavior | not run | Hardware evidence supplied by author | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The full `Texture.cpp` file was not read; targeted changed sections and nearby call sites were read through `repo_read.py`. No tests, builds, or console runs were performed independently. The reported test and Aerial Garden results were not independently verified. ## To get this to a good state Nothing is required.
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!15621
No description provided.