perf(libSceAgcDriver): keep storage surfaces tracked around unwatching host imports #4448

Open
Mouad-Scriptz-0 wants to merge 11 commits from upstream-pr/4448 into main
Mouad-Scriptz-0 commented 2026-10-12 11:56:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-12T11:56:11Z.


What

On Intel's i915 a VK_EXT_external_memory_host import resolves the guest write watch of its pages (the start-up probe reports "host imports resolve write protection: yes"), so the driver stops trusting the watch for every imported range and a storage surface in such a range compares its whole guest copy with its snapshot at every use. Minecraft (PPSA17221) keeps about 250 such surfaces, atlases of 4 MiB among them, and its render thread ran at 89 % CPU with every stack sample in StorageTexture::Refresh → compareUntracked → memcmp, with the GPU idle. Three causes stacked up:

  • An import spans the whole run of adjacent allocations inside the 8 MiB import window, so importing one 64 KiB vertex buffer unwatched every texture allocated next to it. On a device whose imports unwatch their range the window is now one allocation (shrinkImportWindow, 64 KiB): a buffer's import leaves its neighbours watched. The existing window test keeps the 8 MiB behaviour for other devices; agc_driver_bda_resources gains unwatchedImportWindowTests: after SetImportWatch(Unwatch) an import covers the allocation it serves, a view across two allocations is refused, and the import is reused.
  • A storage surface imported its own range for GPU-direct uploads and write-backs, unwatching itself. StorageImportFor uses an existing import but does not make one for a range the watch still covers on such a device (ExistingHostImport, HostImportsUnwatch); the staged paths serve the upload and clear sites. A refresh with a pending alias, a copy source and a write-back still import: the device path needs the import, and the staged upload's CPU read would flush the alias's results instead of borrowing them.
  • A surface whose range is unwatched compares its guest copy at every use, since nothing else can see a CPU store there; the cost is attacked from the other side: an unwatched import that no lookup used for sixty frames retires at the flip and its range returns to the write watch, its blocks stamped as possibly written like the import window stamps them (RetireIdleImports, GuestMemory::Rewatch); a surface without a guest copy under a range an import unwatches takes one at once (StorageTexture::NoteRangeUnwatched). Minecraft imports a texture's allocation only while its compute uploader writes it through a buffer binding; two frames later the range is tracked again and the comparisons end. A range the GPU writes every frame stays imported and compared. The retirement runs only on devices whose imports unwatch their range. agc_driver_graphics gains idleImportRetireTests.
  • refreshImports re-unwatched every unwatched import at every registry generation change (200,000 Unwatch calls in about a minute of Minecraft); it now checks GuestMemory::Watched first.

Tested

Fedora 44 (kernel 7.2.8, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, Intel Arc Meteor Lake, Mesa 26.2.3), worktree on main 33ae282e4: agc_driver_bda_resources passes with the new case; tools/check_conventions.py --base origin/main and git diff --check pass. Minecraft (PPSA17221): the render thread no longer spends its time in the untracked comparisons (the 250 surfaces were in the neighbours of imported buffers); the home screen runs at the same frame rate as before the PR once an unrelated in-place vertex input sync is out of the way (separate PR), 60 fps on this device. Not tested on Windows, where imports are compared by design and the window change does not apply unless the probe says so.

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 in TechnicalDebt
  • 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: PPSA17221 (no Game bring-up discussion yet)
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4829028738 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448). Originally posted by [Mouad-Scriptz-0](https://github.com/Mouad-Scriptz-0) on 2026-10-12T11:56:11Z. --- ### What On Intel's i915 a `VK_EXT_external_memory_host` import resolves the guest write watch of its pages (the start-up probe reports "host imports resolve write protection: yes"), so the driver stops trusting the watch for every imported range and a storage surface in such a range compares its whole guest copy with its snapshot at every use. Minecraft (PPSA17221) keeps about 250 such surfaces, atlases of 4 MiB among them, and its render thread ran at 89 % CPU with every stack sample in `StorageTexture::Refresh` → `compareUntracked` → `memcmp`, with the GPU idle. Three causes stacked up: - An import spans the whole run of adjacent allocations inside the 8 MiB import window, so importing one 64 KiB vertex buffer unwatched every texture allocated next to it. On a device whose imports unwatch their range the window is now one allocation (`shrinkImportWindow`, 64 KiB): a buffer's import leaves its neighbours watched. The existing window test keeps the 8 MiB behaviour for other devices; `agc_driver_bda_resources` gains `unwatchedImportWindowTests`: after `SetImportWatch(Unwatch)` an import covers the allocation it serves, a view across two allocations is refused, and the import is reused. - A storage surface imported its own range for GPU-direct uploads and write-backs, unwatching itself. `StorageImportFor` uses an existing import but does not make one for a range the watch still covers on such a device (`ExistingHostImport`, `HostImportsUnwatch`); the staged paths serve the upload and clear sites. A refresh with a pending alias, a copy source and a write-back still import: the device path needs the import, and the staged upload's CPU read would flush the alias's results instead of borrowing them. - A surface whose range is unwatched compares its guest copy at every use, since nothing else can see a CPU store there; the cost is attacked from the other side: an unwatched import that no lookup used for sixty frames retires at the flip and its range returns to the write watch, its blocks stamped as possibly written like the import window stamps them (`RetireIdleImports`, `GuestMemory::Rewatch`); a surface without a guest copy under a range an import unwatches takes one at once (`StorageTexture::NoteRangeUnwatched`). Minecraft imports a texture's allocation only while its compute uploader writes it through a buffer binding; two frames later the range is tracked again and the comparisons end. A range the GPU writes every frame stays imported and compared. The retirement runs only on devices whose imports unwatch their range. `agc_driver_graphics` gains `idleImportRetireTests`. - `refreshImports` re-unwatched every unwatched import at every registry generation change (200,000 `Unwatch` calls in about a minute of Minecraft); it now checks `GuestMemory::Watched` first. ### Tested Fedora 44 (kernel 7.2.8, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, Intel Arc Meteor Lake, Mesa 26.2.3), worktree on `main` 33ae282e4: `agc_driver_bda_resources` passes with the new case; `tools/check_conventions.py --base origin/main` and `git diff --check` pass. Minecraft (PPSA17221): the render thread no longer spends its time in the untracked comparisons (the 250 surfaces were in the neighbours of imported buffers); the home screen runs at the same frame rate as before the PR once an unrelated in-place vertex input sync is out of the way (separate PR), 60 fps on this device. Not tested on Windows, where imports are compared by design and the window change does not apply unless the probe says so. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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: PPSA17221 (no Game bring-up discussion yet) - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Scramblrrrr commented 2026-10-12 12:10:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T12:10:05Z.


Windows/007 cross-test planning: the import-window and storage-import changes look relevant to the comparison hot spot. Before carrying the frame-scoped memo, could you add a regression for an unwatched surface changed by the CPU between two synchronized uses in the same frame (no flip)? A completed first draw/dispatch, CPU store, then a second draw is ordered, so it need not race the console; a frame serial alone cannot validate the old snapshot there. The new stamp also retains only ForgetSerial parity, so a completed forget/remap within that frame deserves an invalidation check. I have not built this head or reproduced a failure yet; these are source-review concerns, not measured Windows results. Preparing a focused comparison fixture while my current heap-corruption repro runs. AI-assisted: yes (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6123990448 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6123990448). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-12T12:10:05Z. --- Windows/007 cross-test planning: the import-window and storage-import changes look relevant to the comparison hot spot. Before carrying the frame-scoped memo, could you add a regression for an unwatched surface changed by the CPU between two synchronized uses in the same frame (no flip)? A completed first draw/dispatch, CPU store, then a second draw is ordered, so it need not race the console; a frame serial alone cannot validate the old snapshot there. The new stamp also retains only ForgetSerial parity, so a completed forget/remap within that frame deserves an invalidation check. I have not built this head or reproduced a failure yet; these are source-review concerns, not measured Windows results. Preparing a focused comparison fixture while my current heap-corruption repro runs. AI-assisted: yes (Codex).
Scramblrrrr commented 2026-10-12 12:13:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T12:13:53Z.


Focused Windows regression now available: github.com/Scramblrrrr/AnyPS5@c4981fb102 (fixture only, older integration base with #3991). After a completed write-back, Refresh + a readback submitted and waited populate/observe the untracked snapshot; a CPU memset follows; another Refresh + waited readback must see 0xabababab. No flip and no concurrent GPU use. Existing policy passes (0.36s); replacing only compareUntracked's stamp/cacheable expressions with your new policy, using constant frame serial1 because this fixture never flips, fails: untracked comparison missed a synchronized CPU store before a flip (CTest exit8,0.37s). Restoring policy passes (0.37s). RTX5070Ti, Windows, GCC15.2, native Vulkan; no skips. This is an isolated policy probe, NOT a build of full4448 and NOT a game FPS result. No failing production mutation left in the branch; no title data in this fixture. Happy to cross-test a refined invalidation policy. AI-assisted: yes (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6124047491 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6124047491). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-12T12:13:53Z. --- Focused Windows regression now available: https://github.com/Scramblrrrr/AnyPS5/commit/c4981fb102e7e58cb6dd2ac2981c30e1c5755c1b (fixture only, older integration base with #3991). After a completed write-back, Refresh + a readback submitted and waited populate/observe the untracked snapshot; a CPU memset follows; another Refresh + waited readback must see 0xabababab. No flip and no concurrent GPU use. Existing policy passes (0.36s); replacing only compareUntracked's stamp/cacheable expressions with your new policy, using constant frame serial1 because this fixture never flips, fails: `untracked comparison missed a synchronized CPU store before a flip` (CTest exit8,0.37s). Restoring policy passes (0.37s). RTX5070Ti, Windows, GCC15.2, native Vulkan; no skips. This is an isolated policy probe, NOT a build of full4448 and NOT a game FPS result. No failing production mutation left in the branch; no title data in this fixture. Happy to cross-test a refined invalidation policy. AI-assisted: yes (Codex).
Scramblrrrr commented 2026-10-12 13:20:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T13:20:30Z.


Reviewed updated headbc616d758e740d0e6b3febee5d0936508a3afff8: the unsafe frame-scoped stamp is removed and the original comparison stamp restored, addressing the isolated policy regression I reported. The idle-unwatching import retirement/capture-on-unwatch approach needs its own lifetime and invalidation cross-test; not claiming the new full head tested or a Windows FPS gain. Currently running the 007 hull-v1 cross-test, so will keep this out until that completes. Thanks for retaining detection of ordered CPU stores. AI-assisted: yes (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6125118055 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6125118055). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-12T13:20:30Z. --- Reviewed updated headbc616d758e740d0e6b3febee5d0936508a3afff8: the unsafe frame-scoped stamp is removed and the original comparison stamp restored, addressing the isolated policy regression I reported. The idle-unwatching import retirement/capture-on-unwatch approach needs its own lifetime and invalidation cross-test; not claiming the new full head tested or a Windows FPS gain. Currently running the 007 hull-v1 cross-test, so will keep this out until that completes. Thanks for retaining detection of ordered CPU stores. AI-assisted: yes (Codex).
Mouad-Scriptz-0 commented 2026-10-12 17:51:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-12T17:51:23Z.


Both points are right, and the fixture shows it well. The frame-scoped memo was a heuristic: for an unwatched range nothing can see a CPU store, so a comparison at every use is the only correct policy, and I had argued a race where an ordered store (completed use, store, second use) is legal. The existing agc_driver_dcc_keys_first_write untracked-reuse case checks the same contract (refresh, CPU edit, refresh must see it, no GPU work between) and would have failed too; I had only run the graphics tests. The forget-serial parity has the same flaw: a completed forget inside the frame kept the parity and the stale snapshot.

Commit 1b6c33d0b drops the memo and restores the original stamp, and attacks the cost from the other side instead: an unwatched import that no lookup used for two frames is retired at the flip and its range goes back under the write watch, with its blocks stamped as possibly CPU-written so a surface there compares once and is tracked from then on (RetireIdleImports, GuestMemory::Rewatch). With the per-allocation import window and StorageImportFor from this PR (now only at the sites that upload from CPU-written memory: a surface with a pending alias, a copy source or a write-back imports as before, since the device path needs the import and the staging path's CPU read would flush the alias), a Minecraft texture is imported only while the title's compute uploader writes it through a buffer binding; two frames later the import retires, the range is watched again, and the per-use comparison ends with it. A range the GPU writes every frame stays imported and compared, correctly. The retirement runs only on a device whose imports unwatch their range (the probe's verdict), so Windows and devices with watched imports keep today's behaviour.

Your fixture passes unchanged under this policy, since the compare path is the original one. One more hole closed on the way: a watched surface created without a guest copy had nothing to compare against once a buffer import of its allocation unwatched it, so the import now reports the range and such surfaces take their copy at once (StorageTexture::NoteRangeUnwatched), which agc_driver_dcc_keys_first_write checks. agc_driver_bda_resources gains idleImportRetireTests: an import used this frame or one frame ago stays, one idle for sixty frames retires, its neighbour stays, the range is watched again when the write watch is available, and it can be imported again. agc_driver_storage_one_slice_alias now states the contract of an unwatching device explicitly: the watched block stays unimported and the alias writes back, where before it imported the block and skipped the check. Measured here on the Minecraft home screen: the retirement at two frames ping-ponged (80 imports and 80 retirements in 30 s, each re-stamping and re-snapshotting the range), so the bound is 60 frames now, and the rewatch stamps the range as possibly written like the import window does, since a definite CPU stamp made every surface with pending results write back. With that the frame rate matched the build before this PR; the gap I had chased (60 to 42 fps) turned out to be unrelated, an in-place vertex input waiting on the CPU for a compute write every frame, which I'm sending separately.

I'd welcome the cross-test on the RTX 5070 Ti; the retirement should be inert there (host imports keep their watch on NVIDIA by the probe), so the interesting check is that nothing else moved.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6129614598 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6129614598). Originally posted by [Mouad-Scriptz-0](https://github.com/Mouad-Scriptz-0) on 2026-10-12T17:51:23Z. --- Both points are right, and the fixture shows it well. The frame-scoped memo was a heuristic: for an unwatched range nothing can see a CPU store, so a comparison at every use is the only correct policy, and I had argued a race where an ordered store (completed use, store, second use) is legal. The existing `agc_driver_dcc_keys_first_write` untracked-reuse case checks the same contract (refresh, CPU edit, refresh must see it, no GPU work between) and would have failed too; I had only run the graphics tests. The forget-serial parity has the same flaw: a completed forget inside the frame kept the parity and the stale snapshot. Commit 1b6c33d0b drops the memo and restores the original stamp, and attacks the cost from the other side instead: an unwatched import that no lookup used for two frames is retired at the flip and its range goes back under the write watch, with its blocks stamped as possibly CPU-written so a surface there compares once and is tracked from then on (`RetireIdleImports`, `GuestMemory::Rewatch`). With the per-allocation import window and `StorageImportFor` from this PR (now only at the sites that upload from CPU-written memory: a surface with a pending alias, a copy source or a write-back imports as before, since the device path needs the import and the staging path's CPU read would flush the alias), a Minecraft texture is imported only while the title's compute uploader writes it through a buffer binding; two frames later the import retires, the range is watched again, and the per-use comparison ends with it. A range the GPU writes every frame stays imported and compared, correctly. The retirement runs only on a device whose imports unwatch their range (the probe's verdict), so Windows and devices with watched imports keep today's behaviour. Your fixture passes unchanged under this policy, since the compare path is the original one. One more hole closed on the way: a watched surface created without a guest copy had nothing to compare against once a buffer import of its allocation unwatched it, so the import now reports the range and such surfaces take their copy at once (`StorageTexture::NoteRangeUnwatched`), which `agc_driver_dcc_keys_first_write` checks. `agc_driver_bda_resources` gains `idleImportRetireTests`: an import used this frame or one frame ago stays, one idle for sixty frames retires, its neighbour stays, the range is watched again when the write watch is available, and it can be imported again. `agc_driver_storage_one_slice_alias` now states the contract of an unwatching device explicitly: the watched block stays unimported and the alias writes back, where before it imported the block and skipped the check. Measured here on the Minecraft home screen: the retirement at two frames ping-ponged (80 imports and 80 retirements in 30 s, each re-stamping and re-snapshotting the range), so the bound is 60 frames now, and the rewatch stamps the range as possibly written like the import window does, since a definite CPU stamp made every surface with pending results write back. With that the frame rate matched the build before this PR; the gap I had chased (60 to 42 fps) turned out to be unrelated, an in-place vertex input waiting on the CPU for a compute write every frame, which I'm sending separately. I'd welcome the cross-test on the RTX 5070 Ti; the retirement should be inert there (host imports keep their watch on NVIDIA by the probe), so the interesting check is that nothing else moved.
oneandonlydean commented 2026-10-13 00:20:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:20:22Z.


On Windows decideImportWatch sets unwatchImports = true for every device, without a probe, and RetireIdleImports and StorageImportFor (through HostImportsUnwatch) key on that flag. So both act there too, on the imports Windows compares, although the description says Windows keeps today's behaviour, and it wasn't run there. Please limit both to devices where the probe found that imports resolve the watch.

Three more things:

  • The branch is still on 33ae282e4, before #2802, which keys the compareUntracked memo on the stores that reach the surface, for the same Intel compare hot spot. Please rebase and say what is still needed on top of it. It conflicts now anyway: docs/dev/TechnicalDebt.md was split, so the entry goes under docs/dev/debt/.
  • The description now says the frame rate is the same with and without the PR. Perf PRs need a before/after for the change itself (#218): render-thread CPU or presents per 10 s, main against main plus this.
  • The debt entry still says imports retire after two frames; IdleImportFrames is 60.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6135176887 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6135176887). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-13T00:20:22Z. --- On Windows `decideImportWatch` sets `unwatchImports = true` for every device, without a probe, and `RetireIdleImports` and `StorageImportFor` (through `HostImportsUnwatch`) key on that flag. So both act there too, on the imports Windows compares, although the description says Windows keeps today's behaviour, and it wasn't run there. Please limit both to devices where the probe found that imports resolve the watch. Three more things: - The branch is still on 33ae282e4, before #2802, which keys the `compareUntracked` memo on the stores that reach the surface, for the same Intel compare hot spot. Please rebase and say what is still needed on top of it. It conflicts now anyway: `docs/dev/TechnicalDebt.md` was split, so the entry goes under `docs/dev/debt/`. - The description now says the frame rate is the same with and without the PR. Perf PRs need a before/after for the change itself (#218): render-thread CPU or presents per 10 s, main against main plus this. - The debt entry still says imports retire after two frames; `IdleImportFrames` is 60.
oneandonlydean commented 2026-10-13 22:37:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T22:37:59Z.


Conflicts with main in PacketExecution.cpp, GuestBufferMemory.cpp/.hpp, tests/BdaResources.cpp and docs/dev/debt/libSceAgcDriver.md after #3874, #4428 and #4515; please rebase. The probe-only limit and the debt entry are right now. The before/after for this change alone is still needed (#218).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6156706351 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6156706351). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-13T22:37:59Z. --- Conflicts with main in `PacketExecution.cpp`, `GuestBufferMemory.cpp/.hpp`, `tests/BdaResources.cpp` and `docs/dev/debt/libSceAgcDriver.md` after #3874, #4428 and #4515; please rebase. The probe-only limit and the debt entry are right now. The before/after for this change alone is still needed (#218).
blawesom commented 2026-10-14 06:09:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-14T06:09:18Z.


Status on the requested rebase — I attempted it and got partway, but I'm not posting a handoff branch because the result isn't correct yet. Details so the next attempt (mine or yours) starts from the real map:

Commit 1 (storage surfaces around unwatching) merges cleanly in spirit: main's newer guards kept, this PR's Watched()-check before unwatch, and the test families both kept. leasedRangeAt maps onto main's leasedRangeOwner (shared_ptr form).

Commit 2 (retire idle imports instead of memoizing) is the hard part: it restructures HostImportFor around frame-serial tracking (lastUseFrame) where main has since landed the LRU useCounter hit path inside the same function, and adds RetireIdleImports with the IdleImportFrames/PendingWriteSettled logic. My assembled merge builds, but three tests fail on it — agc_driver_graphics, agc_driver_host_import_windows (fast assert), and agc_driver_recorded_kept_bytes (timeout — likely a hang in the restructured path) — so the interaction between the two hit-tracking designs needs the author's pass, not my guess at which semantics win.

If it's useful I can push my work-in-progress branch for inspection, or take another run at it with the author's input on the hit-path semantics.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6162099809 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6162099809). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-14T06:09:18Z. --- **Status on the requested rebase** — I attempted it and got partway, but I'm not posting a handoff branch because the result isn't correct yet. Details so the next attempt (mine or yours) starts from the real map: **Commit 1** (storage surfaces around unwatching) merges cleanly in spirit: main's newer guards kept, this PR's `Watched()`-check before unwatch, and the test families both kept. `leasedRangeAt` maps onto main's `leasedRangeOwner` (shared_ptr form). **Commit 2** (retire idle imports instead of memoizing) is the hard part: it restructures `HostImportFor` around frame-serial tracking (`lastUseFrame`) where `main` has since landed the LRU `useCounter` hit path inside the same function, and adds `RetireIdleImports` with the `IdleImportFrames`/`PendingWriteSettled` logic. My assembled merge builds, but three tests fail on it — `agc_driver_graphics`, `agc_driver_host_import_windows` (fast assert), and `agc_driver_recorded_kept_bytes` (timeout — likely a hang in the restructured path) — so the interaction between the two hit-tracking designs needs the author's pass, not my guess at which semantics win. If it's useful I can push my work-in-progress branch for inspection, or take another run at it with the author's input on the hit-path semantics.
oneandonlydean commented 2026-10-14 21:32:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T21:32:59Z.


Still waiting on the two things from 10-13: a rebase onto main (conflicts in PacketExecution.cpp, GuestBufferMemory.cpp/.hpp, tests/BdaResources.cpp and docs/dev/debt/libSceAgcDriver.md after #3874, #4428 and #4515), and a before/after for this change alone (#218). Main's LRU hit path in HostImportFor is where the retire-idle commit needs to fit now.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6178976584 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6178976584). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T21:32:59Z. --- Still waiting on the two things from 10-13: a rebase onto main (conflicts in `PacketExecution.cpp`, `GuestBufferMemory.cpp/.hpp`, `tests/BdaResources.cpp` and `docs/dev/debt/libSceAgcDriver.md` after #3874, #4428 and #4515), and a before/after for this change alone (#218). Main's LRU hit path in `HostImportFor` is where the retire-idle commit needs to fit now.
blawesom commented 2026-10-16 17:04:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-16T17:04:44Z.


Second rebase attempt — two of the three failures root-caused and fixed, one remains, branch pushed for inspection.

Following the hint that the retire-idle commit needs to fit main's LRU hit path: HostImportFor now keeps main's useCounter hit path intact and layers lastUseFrame stamping on both the hit and miss paths, so retirement works alongside the LRU rather than replacing it.

Fixed 1 — agc_driver_host_import_windows: the PR's keep condition in the refreshImports walk gates on a lease range starting at the import's base (leasedRangeAt), which predates main's window-ownership model — mid-range windows get retired and re-created, changing their serial (exactly what WindowsFollowTheirRange checks). Resolution: the walk keys on main's sameRange (owner-identity for partial windows), with this PR's Watched() guard and unwatched-notes layered inside it.

Fixed 2 — agc_driver_recorded_kept_bytes hang: the PR's StorageImportFor watched path routes through ExistingHostImport, which never calls ensurePinWaiter() — so when its refreshImports creates imports (which pin their ranges), a later guest free of those ranges spins forever in RequireUnpinned with no registered waiter. That looks like a genuine bug in the PR, exposed by main's newer test; fix is ensurePinWaiter() at the top of ExistingHostImport.

Remaining — agc_driver_store_over_untracked: "the pending result had saved guest bytes while its memory was write-watched". The test was substantially reworked on main after this PR branched (the PR passes its older version). The creation-path note (if (entry.unwatched) unwatchedNotes.emplace_back(...)) is unchanged from the PR, and gating the walk's note on range-start alignment doesn't clear it — so the question for the author is which note/capture conditions must hold for window imports under main's keep model: the notification fires for a surface whose memory is still write-watched at the test's check.

Current state on the branch: builds, conventions pass, 1284/1287 — store_over_untracked plus the known main regression (agc_driver_tessellation segfault, #4727). Branch is blawesom:rebase/4448 (2ea0a8ad8, your two commits, authorship unchanged) if it's useful as a starting point; the two fixes above are folded into the conflicted commit.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6220629589 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6220629589). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-16T17:04:44Z. --- **Second rebase attempt — two of the three failures root-caused and fixed, one remains, branch pushed for inspection.** Following the hint that the retire-idle commit needs to fit `main`'s LRU hit path: `HostImportFor` now keeps `main`'s `useCounter` hit path intact and layers `lastUseFrame` stamping on both the hit and miss paths, so retirement works alongside the LRU rather than replacing it. **Fixed 1 — `agc_driver_host_import_windows`:** the PR's keep condition in the `refreshImports` walk gates on a lease range *starting at* the import's base (`leasedRangeAt`), which predates `main`'s window-ownership model — mid-range windows get retired and re-created, changing their serial (exactly what `WindowsFollowTheirRange` checks). Resolution: the walk keys on `main`'s `sameRange` (owner-identity for partial windows), with this PR's `Watched()` guard and unwatched-notes layered inside it. **Fixed 2 — `agc_driver_recorded_kept_bytes` hang:** the PR's `StorageImportFor` watched path routes through `ExistingHostImport`, which never calls `ensurePinWaiter()` — so when its `refreshImports` creates imports (which pin their ranges), a later guest free of those ranges spins forever in `RequireUnpinned` with no registered waiter. That looks like a genuine bug in the PR, exposed by `main`'s newer test; fix is `ensurePinWaiter()` at the top of `ExistingHostImport`. **Remaining — `agc_driver_store_over_untracked`:** "the pending result had saved guest bytes while its memory was write-watched". The test was substantially reworked on `main` after this PR branched (the PR passes its older version). The creation-path note (`if (entry.unwatched) unwatchedNotes.emplace_back(...)`) is unchanged from the PR, and gating the walk's note on range-start alignment doesn't clear it — so the question for the author is which note/capture conditions must hold for window imports under `main`'s keep model: the notification fires for a surface whose memory is still write-watched at the test's check. Current state on the branch: builds, conventions pass, **1284/1287** — `store_over_untracked` plus the known `main` regression (`agc_driver_tessellation` segfault, #4727). Branch is `blawesom:rebase/4448` (`2ea0a8ad8`, your two commits, authorship unchanged) if it's useful as a starting point; the two fixes above are folded into the conflicted commit.
oneandonlydean commented 2026-10-17 00:41:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T00:41:46Z.


The second pass fixes agc_driver_host_import_windows and the agc_driver_recorded_kept_bytes hang, and leaves one failure. The hang looks like a real bug in this PR: StorageImportFor goes through ExistingHostImport, which never calls ensurePinWaiter(). @Mouad-Scriptz-0, can you take that branch, fix the remaining failure and post the before/after for this change alone (#218) from the 10-13 ask? If you'd rather not carry it, say so.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6227475205 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6227475205). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T00:41:46Z. --- The second pass fixes `agc_driver_host_import_windows` and the `agc_driver_recorded_kept_bytes` hang, and leaves one failure. The hang looks like a real bug in this PR: `StorageImportFor` goes through `ExistingHostImport`, which never calls `ensurePinWaiter()`. @Mouad-Scriptz-0, can you take that branch, fix the remaining failure and post the before/after for this change alone (#218) from the 10-13 ask? If you'd rather not carry it, say so.
Mouad-Scriptz-0 commented 2026-10-18 12:01:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-18T12:01:12Z.


Taken. The PR head is now @blawesom's rebase/4448 (2ea0a8ad8, both commits with authorship kept) plus one commit, 924aaa4bf:

  • The store_over_untracked failure blawesom left is the staged upload. StorageImportFor keeps a watched surface out of its own import on a device whose imports unwatch, so such a surface takes the staged upload, and that path marked the guest snapshot valid unconditionally (layerOriginal.assign(trackedLayers, true)) where the direct path marks it valid only when the surface is not write-watched. The pending result then carried saved guest bytes while watched, which the test rejects. The commit makes the staged path follow the direct path's rule. Traced with gdb: no captureGuestBytes call touched the failing image; the flag came from upload alone.
  • The rebase had kept the superseded debt entry (the per-frame compare of the first commit) next to the current one; the duplicate is dropped.

One failure remains in the same test, on this machine too (Fedora 44, Intel Arc Meteor Lake, Mesa 26.2, where the probe reports that imports resolve the write watch). The three single-surface leave-the-watch cases print "not run, the surface is not write-watched", since the write-back's HostImportFor still imports and so unwatches the surface. The fourth, "a surface whose first block left the write watch with the page before it", now fails one check later: the result did not reach a block the CPU left alone. With APS5_LOG_SYNC=1 APS5_TRACE_FLUSH=1 and gdb breakpoints:

  1. the fixture's Settle saw AnyPending() true and flushed two images still pending from the previous case (their memory already unregistered), not this surface, whose image the driver thread created afterwards; so the store's result was never settled;
  2. the Read at +0xe000 wrote the image back: keeps 1 CPU-written 64 KiB blocks (first stored byte at +0xf000, 1 ranges stored), through an import HostImportFor created inside writeBackLayers (the SaveBeforeUnwatch hook and NoteRangeUnwatched ran from there);
  3. after FlushAllPending, every block of the surface still holds the untouched fill (0xdeadbeef), so those stored bytes never reached guest memory;
  4. the fill's FillClear ran on the driver thread after that write-back and left the image pending at destruction.

So the path this PR newly takes on such a device, a watched surface uploaded staged and written back through an import created at the write-back, does not land its bytes before the CPU read. I have not yet read the write-back's segment copy and shadow publish to say where they go. @oneandonlydean, before I do: is the leave-the-watch group meant to run on a device whose imports unwatch, when the surface's own write-back imports it anyway? If the answer is that the write-back should use StorageImportFor too, that is the next change; if not, the fixture's "not run" exit belongs before the fill for this case as well.

The branch still sits on blawesom's base (143f13055); I will rebase onto current main with the fix for this failure, and the before/after capture for this change alone follows once the test is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6249664307 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6249664307). Originally posted by [Mouad-Scriptz-0](https://github.com/Mouad-Scriptz-0) on 2026-10-18T12:01:12Z. --- Taken. The PR head is now @blawesom's `rebase/4448` (`2ea0a8ad8`, both commits with authorship kept) plus one commit, `924aaa4bf`: - **The `store_over_untracked` failure blawesom left is the staged upload.** `StorageImportFor` keeps a watched surface out of its own import on a device whose imports unwatch, so such a surface takes the staged upload, and that path marked the guest snapshot valid unconditionally (`layerOriginal.assign(trackedLayers, true)`) where the direct path marks it valid only when the surface is not write-watched. The pending result then carried saved guest bytes while watched, which the test rejects. The commit makes the staged path follow the direct path's rule. Traced with gdb: no `captureGuestBytes` call touched the failing image; the flag came from `upload` alone. - The rebase had kept the superseded debt entry (the per-frame compare of the first commit) next to the current one; the duplicate is dropped. **One failure remains in the same test, on this machine too** (Fedora 44, Intel Arc Meteor Lake, Mesa 26.2, where the probe reports that imports resolve the write watch). The three single-surface leave-the-watch cases print "not run, the surface is not write-watched", since the write-back's `HostImportFor` still imports and so unwatches the surface. The fourth, "a surface whose first block left the write watch with the page before it", now fails one check later: `the result did not reach a block the CPU left alone`. With `APS5_LOG_SYNC=1 APS5_TRACE_FLUSH=1` and gdb breakpoints: 1. the fixture's `Settle` saw `AnyPending()` true and flushed two images still pending from the previous case (their memory already unregistered), not this surface, whose image the driver thread created afterwards; so the store's result was never settled; 2. the `Read` at `+0xe000` wrote the image back: `keeps 1 CPU-written 64 KiB blocks (first stored byte at +0xf000, 1 ranges stored)`, through an import `HostImportFor` created inside `writeBackLayers` (the `SaveBeforeUnwatch` hook and `NoteRangeUnwatched` ran from there); 3. after `FlushAllPending`, every block of the surface still holds the untouched fill (`0xdeadbeef`), so those stored bytes never reached guest memory; 4. the fill's `FillClear` ran on the driver thread after that write-back and left the image pending at destruction. So the path this PR newly takes on such a device, a watched surface uploaded staged and written back through an import created at the write-back, does not land its bytes before the CPU read. I have not yet read the write-back's segment copy and shadow publish to say where they go. @oneandonlydean, before I do: is the leave-the-watch group meant to run on a device whose imports unwatch, when the surface's own write-back imports it anyway? If the answer is that the write-back should use `StorageImportFor` too, that is the next change; if not, the fixture's "not run" exit belongs before the fill for this case as well. The branch still sits on blawesom's base (`143f13055`); I will rebase onto current `main` with the fix for this failure, and the before/after capture for this change alone follows once the test is green.
oneandonlydean commented 2026-10-19 09:52:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T09:52:15Z.


@Mouad-Scriptz-0 Thanks for the trace, it made this quick to answer.

Yes, the leave-the-watch group is meant to run on a device whose imports unwatch, and the write-back should use StorageImportFor too. The point of this PR is that a watched storage surface stays watched on such a device. upload and Refresh now keep it out of a new import, but writeBackLayers (Texture.cpp:4691 on your head) still calls HostImportFor. So the first CPU read that stores the surface's results imports it and takes it out of the watch, and the tracking only lasts until that first write-back. The three "not run, the surface is not write-watched" lines are the test reporting exactly that: the driver's own write-back took the surface out of the watch before the test could. Moving the "not run" exit before the fill would hide the new path (staged upload, then write-back) on the only device class where it runs, so please don't do that. Those exits should stay for what they were written for: a host where the surface isn't watched at all.

When you make that change, please cover all the places that can create an import for a storage surface, not only the one in your trace:

  • writeBackLayers: the whole-surface HostImportFor (Texture.cpp:4691);
  • importSegments, which it falls back to: its per-piece HostImportFor (Texture.cpp:2626) would otherwise import the same surface piece by piece;
  • CopyFrom's "not imported" check (Texture.cpp:4232) also creates an import as a side effect.

With no existing import, a watched surface then takes the readback write-back (vkCmdCopyImageToBuffer, then WriteChangedCommitted), which keeps the watch. Please include that path's cost in the before/after capture, since it is the price of staying tracked.

On the remaining failure: please merge current main and re-run before you read the segment copy. Your step 1 is a fixture race that main has already fixed. On your base, HoldPending returns as soon as StorageTexture::AnyPending() is true, so it accepted the two images left pending by the previous case. Main's #6744 makes it wait for this surface's own image (FindPending(surface) == FindLive(surface)), and adds a --pending-identity mode that checks this. On your base, the same race also lets the post-Fill HoldPending return before the fill is pending. That fits your step 4: the FillClear ran after the write-back and was still pending at destruction, and that alone would explain step 3's untouched blocks. So the failing check may come entirely from the stale fixture. If it still fails on a merged head, the trace is worth repeating there.

The merge is real work. It conflicts in 7 files (both GuestMemory files, VulkanDevice.hpp, PacketExecution.cpp, both GuestBufferMemory files, and the debt doc). Two points to watch:

  • Rewatch. Main now has Rewatch(std::span<const std::pair<std::uint64_t, std::uint64_t>>), which does the work on Windows only (restore plus CPU stamp) and is a no-op on Linux. Your Rewatch(address, bytes) re-registers and stamps on Linux only and is a no-op on Windows. Both would compile side by side as overloads, so neither one would cover both platforms on its own. Please fold yours into main's span form, so that RetireIdleImports returns the range to the watch on both platforms.
  • HostImportFor. Main's hit path now starts with the Windows-only settleUnwatchedImports under the same lock. Keep that call in your restructured function (inside the locked block, before the hit lookup), and keep the drain of unwatchedNotes outside the lock as you have it.

After you push the merged head with the write-back change, we'll review it and run full CI.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6264469322 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6264469322). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-19T09:52:15Z. --- @Mouad-Scriptz-0 Thanks for the trace, it made this quick to answer. **Yes, the leave-the-watch group is meant to run on a device whose imports unwatch, and the write-back should use `StorageImportFor` too.** The point of this PR is that a watched storage surface stays watched on such a device. `upload` and `Refresh` now keep it out of a new import, but `writeBackLayers` (Texture.cpp:4691 on your head) still calls `HostImportFor`. So the first CPU read that stores the surface's results imports it and takes it out of the watch, and the tracking only lasts until that first write-back. The three "not run, the surface is not write-watched" lines are the test reporting exactly that: the driver's own write-back took the surface out of the watch before the test could. Moving the "not run" exit before the fill would hide the new path (staged upload, then write-back) on the only device class where it runs, so please don't do that. Those exits should stay for what they were written for: a host where the surface isn't watched at all. When you make that change, please cover all the places that can create an import for a storage surface, not only the one in your trace: - `writeBackLayers`: the whole-surface `HostImportFor` (Texture.cpp:4691); - `importSegments`, which it falls back to: its per-piece `HostImportFor` (Texture.cpp:2626) would otherwise import the same surface piece by piece; - `CopyFrom`'s "not imported" check (Texture.cpp:4232) also creates an import as a side effect. With no existing import, a watched surface then takes the readback write-back (`vkCmdCopyImageToBuffer`, then `WriteChangedCommitted`), which keeps the watch. Please include that path's cost in the before/after capture, since it is the price of staying tracked. **On the remaining failure: please merge current `main` and re-run before you read the segment copy.** Your step 1 is a fixture race that `main` has already fixed. On your base, `HoldPending` returns as soon as `StorageTexture::AnyPending()` is true, so it accepted the two images left pending by the previous case. Main's #6744 makes it wait for this surface's own image (`FindPending(surface) == FindLive(surface)`), and adds a `--pending-identity` mode that checks this. On your base, the same race also lets the post-`Fill` `HoldPending` return before the fill is pending. That fits your step 4: the `FillClear` ran after the write-back and was still pending at destruction, and that alone would explain step 3's untouched blocks. So the failing check may come entirely from the stale fixture. If it still fails on a merged head, the trace is worth repeating there. The merge is real work. It conflicts in 7 files (both GuestMemory files, VulkanDevice.hpp, PacketExecution.cpp, both GuestBufferMemory files, and the debt doc). Two points to watch: - **`Rewatch`.** Main now has `Rewatch(std::span<const std::pair<std::uint64_t, std::uint64_t>>)`, which does the work on Windows only (restore plus CPU stamp) and is a no-op on Linux. Your `Rewatch(address, bytes)` re-registers and stamps on Linux only and is a no-op on Windows. Both would compile side by side as overloads, so neither one would cover both platforms on its own. Please fold yours into main's span form, so that `RetireIdleImports` returns the range to the watch on both platforms. - **`HostImportFor`.** Main's hit path now starts with the Windows-only `settleUnwatchedImports` under the same lock. Keep that call in your restructured function (inside the locked block, before the hit lookup), and keep the drain of `unwatchedNotes` outside the lock as you have it. After you push the merged head with the write-back change, we'll review it and run full CI.
github-actions[bot] commented 2026-10-19 22:03:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T22:03:08Z.


This pull request is labeled perf, so it needs the summary line of a capture on main and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both aps5-summary.jsonl lines, attach the two traces and add the output of tools/trace_digest.py.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6278374108 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6278374108). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T22:03:08Z. --- <!-- pr-labels-perf --> This pull request is labeled `perf`, so it needs the summary line of a capture on `main` and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both `aps5-summary.jsonl` lines, attach the two traces and add the output of `tools/trace_digest.py`.
Mouad-Scriptz-0 commented 2026-10-19 22:03:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-19T22:03:18Z.


Merged current main (903cbbd5b) as ea55323d5; the head is mergeable again.

  • agc_driver_store_over_untracked passes on the merged head, all ten cases run (no "not run" exits), including "a surface whose first block left the write watch with the page before it" — so the remaining failure was the fixture race #6744 fixed, as you expected. agc_write_tracking, agc_driver_graphics (+ maps_fallback), agc_host_import_unmap and the recorder tests pass on this i915 device.
  • Rewatch is now one function in main's span form: Windows keeps the coverage restore + CPU stamp, Linux re-registers the kernel write watch per range and stamps the blocks as an import window; RetireIdleImports passes its retired ranges as one span, so retirement rewatches on both platforms.
  • settleUnwatchedImports stays at the start of HostImportFor's locked block before the hit lookup; the unwatchedNotes drain stays outside the lock.
  • Dropped ExistingHostImport for main's ExistingHostImportFor. One difference to know about: main's returns null while the registry is stale instead of refreshing it, so a watched surface takes the staged path until the next ordinary lookup refreshes — I kept main's semantics.
  • writeBackLayers, importSegments and CopyFrom's "not imported" check now go through StorageImportFor (it gained a requester parameter so importSegments keeps passing Segment). A watched surface therefore takes the readback write-back.

Next is the before/after capture for this change alone on Minecraft, with the readback write-back cost (vkCmdCopyImageToBuffer + WriteChangedCommitted) included; I'll post it here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6278376389 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6278376389). Originally posted by [Mouad-Scriptz-0](https://github.com/Mouad-Scriptz-0) on 2026-10-19T22:03:18Z. --- Merged current `main` (903cbbd5b) as ea55323d5; the head is mergeable again. - `agc_driver_store_over_untracked` passes on the merged head, all ten cases run (no "not run" exits), including "a surface whose first block left the write watch with the page before it" — so the remaining failure was the fixture race #6744 fixed, as you expected. `agc_write_tracking`, `agc_driver_graphics` (+ `maps_fallback`), `agc_host_import_unmap` and the recorder tests pass on this i915 device. - `Rewatch` is now one function in `main`'s span form: Windows keeps the coverage restore + CPU stamp, Linux re-registers the kernel write watch per range and stamps the blocks as an import window; `RetireIdleImports` passes its retired ranges as one span, so retirement rewatches on both platforms. - `settleUnwatchedImports` stays at the start of `HostImportFor`'s locked block before the hit lookup; the `unwatchedNotes` drain stays outside the lock. - Dropped `ExistingHostImport` for `main`'s `ExistingHostImportFor`. One difference to know about: `main`'s returns null while the registry is stale instead of refreshing it, so a watched surface takes the staged path until the next ordinary lookup refreshes — I kept `main`'s semantics. - `writeBackLayers`, `importSegments` and `CopyFrom`'s "not imported" check now go through `StorageImportFor` (it gained a requester parameter so `importSegments` keeps passing `Segment`). A watched surface therefore takes the readback write-back. Next is the before/after capture for this change alone on Minecraft, with the readback write-back cost (`vkCmdCopyImageToBuffer` + `WriteChangedCommitted`) included; I'll post it here.
Mouad-Scriptz-0 commented 2026-10-19 22:23:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-19T22:23:42Z.


The before/after is blocked on this machine: Minecraft (PPSA17221) no longer starts on current main.

  • Plain main 903cbbd5b (Fedora 44, Meteor Lake, Mesa 26.2.3, Release libs): one minute, zero presents, one dispatch; the log stops right after the title opens /temp0/user268435456/games/com.mojang/behavior_packs. That is the start-up hang I hit last week on the rebased depth branch (a Bedrock background worker parked in sceKernelWaitEqueue, drivers idle), and the depth remap is in main since #4650. The merged head of this PR hangs the same way, as expected.
  • The last set that presented here is main 5d50886ee + the depth remap as it was then + the save-data fix, in-world at about 42 fps.

Two options; I'd rather not guess which you prefer:

  1. I capture this change alone on that older base (5d50886ee + depth + save-data, with this PR's current diff applied on top), and say so in the PR. The numbers would miss a week of main, but the change under test is the same.
  2. Someone whose Minecraft runs on current main captures APS5_TRACE_SECONDS=60:20 on the home screen for main and for this head; I'll digest the traces and add the write-back cost from the [storage] and [texture] lines.

Either way I'll open a separate issue for the start-up hang once I have a thread dump of it, so it does not stay buried here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6278686134 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6278686134). Originally posted by [Mouad-Scriptz-0](https://github.com/Mouad-Scriptz-0) on 2026-10-19T22:23:42Z. --- The before/after is blocked on this machine: Minecraft (PPSA17221) no longer starts on current `main`. - Plain `main` 903cbbd5b (Fedora 44, Meteor Lake, Mesa 26.2.3, Release libs): one minute, zero presents, one dispatch; the log stops right after the title opens `/temp0/user268435456/games/com.mojang/behavior_packs`. That is the start-up hang I hit last week on the rebased depth branch (a Bedrock background worker parked in `sceKernelWaitEqueue`, drivers idle), and the depth remap is in `main` since #4650. The merged head of this PR hangs the same way, as expected. - The last set that presented here is `main` 5d50886ee + the depth remap as it was then + the save-data fix, in-world at about 42 fps. Two options; I'd rather not guess which you prefer: 1. I capture this change alone on that older base (5d50886ee + depth + save-data, with this PR's current diff applied on top), and say so in the PR. The numbers would miss a week of `main`, but the change under test is the same. 2. Someone whose Minecraft runs on current `main` captures `APS5_TRACE_SECONDS=60:20` on the home screen for `main` and for this head; I'll digest the traces and add the write-back cost from the `[storage]` and `[texture]` lines. Either way I'll open a separate issue for the start-up hang once I have a thread dump of it, so it does not stay buried here.
oneandonlydean commented 2026-10-20 01:22:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T01:22:11Z.


@Mouad-Scriptz-0 Option 1. Capture on 5d50886ee + depth + save-data, with and without this PR's diff on top, both arms on that same base, and say the base in the PR. That is a valid A/B for this change alone. Option 2 isn't possible on our side: we don't have PPSA17221, and our GPU has VK_EXT_depth_range_unrestricted, so it never takes the remap path your Intel does.

Before the hang gets its own issue, one cheap check may settle it. On plain main 903cbbd5b, grep stderr (not only the log file) for [gpu] driver failure and [gpu] viewport depth clamp bounds. Reading the code, a device without VK_EXT_depth_range_unrestricted runs ApplyDepthRemap (#4650) for every draw whose viewport depth is outside [0, 1], and it has Requires that throw at draw time. Driver::ReportFailure prints that line once to stderr, then clears the pending work, so the end-of-pipe event the title waits on never arrives. That would look exactly like your worker parked in sceKernelWaitEqueue with the drivers idle.

  • If the line is there, paste it; it names the throw.
  • If there is no such line, run 903cbbd5b with #4650 reverted (git revert -m 1 3ddbc4accc; it doesn't revert cleanly, e.g. conflicts in VulkanDevice.hpp, so say if you want the tree from us), once with and once without your save-data fix, so the two causes separate.
  • Either way, the thread dump you planned (gdb -p <pid> -batch -ex 'thread apply all bt'), naming which kqueue/filter the worker waits on.

If it is that, your report found a regression on main for devices without that extension, and it belongs in its own issue with the line pasted.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6281100383 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6281100383). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T01:22:11Z. --- @Mouad-Scriptz-0 Option 1. Capture on `5d50886ee` + depth + save-data, with and without this PR's diff on top, both arms on that same base, and say the base in the PR. That is a valid A/B for this change alone. Option 2 isn't possible on our side: we don't have PPSA17221, and our GPU has `VK_EXT_depth_range_unrestricted`, so it never takes the remap path your Intel does. Before the hang gets its own issue, one cheap check may settle it. On plain `main` 903cbbd5b, grep **stderr** (not only the log file) for `[gpu] driver failure` and `[gpu] viewport depth clamp bounds`. Reading the code, a device without `VK_EXT_depth_range_unrestricted` runs `ApplyDepthRemap` (#4650) for every draw whose viewport depth is outside [0, 1], and it has `Require`s that throw at draw time. `Driver::ReportFailure` prints that line once to stderr, then clears the pending work, so the end-of-pipe event the title waits on never arrives. That would look exactly like your worker parked in `sceKernelWaitEqueue` with the drivers idle. - If the line is there, paste it; it names the throw. - If there is no such line, run 903cbbd5b with #4650 reverted (`git revert -m 1 3ddbc4accc`; it doesn't revert cleanly, e.g. conflicts in `VulkanDevice.hpp`, so say if you want the tree from us), once with and once without your save-data fix, so the two causes separate. - Either way, the thread dump you planned (`gdb -p <pid> -batch -ex 'thread apply all bt'`), naming which kqueue/filter the worker waits on. If it is that, your report found a regression on main for devices without that extension, and it belongs in its own issue with the line pasted.
Mouad-Scriptz-0 commented 2026-10-20 19:58:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-20T19:58:07Z.


Base correction first: the set that presents here is 5d50886ee + the save-data fix (e8d947d31, now #4649) without the depth remap; mc-base with d17e97e15 on top is the tree that hung last week. The home screen never takes the remap path, so I'll run both arms on 5d50886ee + e8d947d31, with and without this PR's net change (903cbbd5b..ea55323d5 ported onto it), and name that base in the PR.

Cheap check: yesterday's stderr of plain main 903cbbd5b (redirected to a file, 41 lines until the kill) has [gpu] viewport depth clamp bounds [-1, 1] on a float depth target are clipped to [0, 1]: the device has no VK_EXT_depth_range_unrestricted and no [gpu] driver failure line, so as far as that line goes it is not a draw-time throw. Thread dump next, then the reverted tree: yes please to yours, it saves the conflicts.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6300174412 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6300174412). Originally posted by [Mouad-Scriptz-0](https://github.com/Mouad-Scriptz-0) on 2026-10-20T19:58:07Z. --- Base correction first: the set that presents here is `5d50886ee` + the save-data fix (`e8d947d31`, now #4649) **without** the depth remap; `mc-base` with `d17e97e15` on top is the tree that hung last week. The home screen never takes the remap path, so I'll run both arms on `5d50886ee` + `e8d947d31`, with and without this PR's net change (`903cbbd5b..ea55323d5` ported onto it), and name that base in the PR. Cheap check: yesterday's stderr of plain `main` 903cbbd5b (redirected to a file, 41 lines until the kill) has `[gpu] viewport depth clamp bounds [-1, 1] on a float depth target are clipped to [0, 1]: the device has no VK_EXT_depth_range_unrestricted` and no `[gpu] driver failure` line, so as far as that line goes it is not a draw-time throw. Thread dump next, then the reverted tree: yes please to yours, it saves the conflicts.
Mouad-Scriptz-0 commented 2026-10-21 00:00:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-21T00:00:33Z.


A/B done, both arms on one base, home screen only (the panorama scene, nobody touching the title). Not the base I promised: 5d50886ee + e8d947d31 aborts at the first present here (viewport depth outside [0, 1] requires VK_EXT_depth_range_unrestricted, the clamp clip is not in that tree). The only tree that presents on this Intel is my 2026-10-12 integration tree, so that is the base, named in full:

Base main 33ae282e4 (2026-10-13) + fix/agc-flip-eop-event + perf/guest-memory-registry-lookups + feat/videoout-mouse-capture + feat/signin-dialog-npauth-signed-out + perf/recompiler-select-load-guards + fix/dmabuf-import-coherence (#4449) + the old feat/agc-depth-range-remap + the clamp-bounds clip and NpAuth export from that tree, plus main's four trace commits (5668e0d0e, 5c7da226d, 016b2dbe8, eb8a7255d) cherry-picked so both arms write aps5-summary.jsonl. Arm commits: base a139a481f, change 91d63f116.
Change = base + this PR as merged in that tree on 10-12 (49578e426) + the later review deltas (unwatchProbed gating of shrink/retire/import, NoteRangeUnwatched, the refresh guard, originalValid = !Watched). It is not today's head ea55323d5, which only differs by main's own movement since.

Fedora 44, Meteor Lake iGPU, Mesa 26.2.4, 1920x1080, Release libs. Per arm: one warm run with APS5_PROFILE_DRAW=1, then two runs with APS5_TRACE_SECONDS=60:20, each 130 s. The window was focused throughout the trace windows (unfocused, GNOME holds the title at 1 present/s, which I had to learn the hard way).

arm run presents / 20 s p50 ms p90 ms p99 ms max ms GPU busy ms/present worker busy
base 1 1051 16.80 23.71 51.96 57.92 12.31 80 %
base 2 1105 16.69 21.81 43.16 54.91 11.19 84 %
change 1 919 19.64 25.49 49.23 87.16 12.25 94 %
change 2 1005 17.81 22.71 41.55 47.89 12.33 94 %

The change is slower on this scene, and it draws wrong.

Per-frame slices (tools/trace_digest.py, run 2 of each arm, ms per frame, inclusive): Driver.Draw 12.6 → 15.8, Graphics.Draw 9.0 → 12.9, Driver.Packet 14.8 → 18.2; the presenter waits less (VideoOut.Flip 13.3 → 9.2) because the worker is now the bottleneck. The extra time is in the untracked compare, which this PR was meant to shrink. From the [guestmem] 10-s lines of the warm runs (focused intervals only):

arm compare calls / 10 s MiB per call MiB per frame compare ms per frame
base 8.8k–9.5k 5.1 79–88 11.3–12.2
change 5.4k–6.6k 8.44 (every call) 93–152 11.9–19.6

Every compare in the change arm is a whole 0x870000-byte image (the three 1920-wide storage images at 0x258160000, 0x242460000, 0x242cd0000); the base compares partial units averaging 5.1 MiB. Write-backs are the same in both arms ([storage] 111–147 idle write-backs / 10 s, all GPU-direct, ~1 GiB / 10 s), so the import rule does not change what is written back here, only what is compared.

Rendering regression. On the change arm the rotating panorama has a solid black region covering roughly the right half of the frame with a sharp vertical edge, every run, stable while the camera turns (screenshot attached, taken during the second trace run). The base arm renders it whole. The [textures] counter points at the mechanism:

  • base: sampled created: 27 from storage images, 0 snapshots
  • change: sampled created: 1 from storage images, 26 snapshots

In the change arm the sampled-texture lookup (ShaderResources.cpp, the source == nullptr branch) no longer finds the storage image that holds the panorama faces, so the texture is built from a guest-memory snapshot via ReadTextureSurface, and it is then kept as long as GuestMemory::UnchangedSince holds. A write-back through an unwatched import does not bump the generation that UnchangedSince checks, so a face whose write-back landed after the snapshot stays black. The change arm also logs 80 retire import / 80 import for / 60 refresh ... direct=1 per run on those same three images (the [diag] prints in that tree), so the storage images are being retired and re-imported about once a second rather than staying resident.

Attached: the four aps5-trace-*.json.gz, aps5-summary.jsonl with the four lines, the screenshot. Capture dir and the [storage]/[guestmem]/[textures] lines of every run are kept here if you want more of them.

aps5-summary.jsonl
{"commit":"a139a481f4ab","dirty":true,"env":{"APS5_TRACE_SECONDS":"60:20"},"gpu":"Intel(R) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.11-200.fc44.x86_64","resolution":"1920x1080","window":{"spec":"seconds 60:20","first_present":3276,"ms":20008.033},"presents":1051,"frame_ms":{"p50":16.797,"p90":23.714,"p99":51.961,"max":57.925},"gpu_busy_ms_per_present":12.306,"worker_busy_pct":{"queue worker 0x0":80.080},"top_phases_ms_per_frame":{"Driver.Packet":15.101,"VideoOut.Flip":14.087,"Driver.Present":12.876,"VideoOut.Flip.present":12.871,"Driver.Packet.draw":12.445,"Driver.Draw":12.432,"Driver.Draw.draw_and_resource_release":11.503,"Driver.Present.render_fence_wait":10.376},"trace_dropped":false,"trace":"aps5-trace-a139a481f4ab-179456.json.gz"}
{"commit":"a139a481f4ab","dirty":true,"env":{"APS5_TRACE_SECONDS":"60:20"},"gpu":"Intel(R) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.11-200.fc44.x86_64","resolution":"1920x1080","window":{"spec":"seconds 60:20","first_present":3326,"ms":20005.457},"presents":1105,"frame_ms":{"p50":16.694,"p90":21.811,"p99":43.159,"max":54.914},"gpu_busy_ms_per_present":11.193,"worker_busy_pct":{"queue worker 0x0":84.282},"top_phases_ms_per_frame":{"Driver.Packet":15.133,"VideoOut.Flip":13.339,"Driver.Packet.draw":12.700,"Driver.Draw":12.688,"Driver.Present":11.589,"VideoOut.Flip.present":11.577,"Driver.Draw.draw_and_resource_release":11.513,"Graphics.Draw":9.282},"trace_dropped":false,"trace":"aps5-trace-a139a481f4ab-180802.json.gz"}
{"commit":"91d63f116177","dirty":false,"env":{"APS5_TRACE_SECONDS":"60:20"},"gpu":"Intel(R) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.11-200.fc44.x86_64","resolution":"1920x1080","window":{"spec":"seconds 60:20","first_present":2686,"ms":20000.802},"presents":919,"frame_ms":{"p50":19.638,"p90":25.488,"p99":49.231,"max":87.159},"gpu_busy_ms_per_present":12.247,"worker_busy_pct":{"queue worker 0x0":94.404},"top_phases_ms_per_frame":{"Driver.Packet":20.286,"Driver.Packet.draw":17.264,"Driver.Draw":17.243,"Driver.Draw.draw_and_resource_release":16.476,"Graphics.Draw":14.410,"Graphics.Draw.draw_and_resource_release":14.144,"VideoOut.Flip":9.835,"Driver.Present":9.765},"trace_dropped":false,"trace":"aps5-trace-91d63f116177-183469.json.gz"}
{"commit":"91d63f116177","dirty":false,"env":{"APS5_TRACE_SECONDS":"60:20"},"gpu":"Intel(R) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.11-200.fc44.x86_64","resolution":"1920x1080","window":{"spec":"seconds 60:20","first_present":2507,"ms":20004.046},"presents":1005,"frame_ms":{"p50":17.811,"p90":22.707,"p99":41.553,"max":47.890},"gpu_busy_ms_per_present":12.325,"worker_busy_pct":{"queue worker 0x0":94.136},"top_phases_ms_per_frame":{"Driver.Packet":18.501,"Driver.Packet.draw":15.791,"Driver.Draw":15.773,"Driver.Draw.draw_and_resource_release":15.081,"Graphics.Draw":12.940,"Graphics.Draw.draw_and_resource_release":12.682,"VideoOut.Flip":9.150,"Driver.Present":9.073},"trace_dropped":false,"trace":"aps5-trace-91d63f116177-184618.json.gz"}

ab5-base-aps5-trace-a139a481f4ab-179456.json.gz
ab5-base-aps5-trace-a139a481f4ab-180802.json.gz
ab5-change-aps5-trace-91d63f116177-183469.json.gz
ab5-change-aps5-trace-91d63f116177-184618.json.gz
ab5-change-cap2-panorama

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6304545510 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6304545510). Originally posted by [Mouad-Scriptz-0](https://github.com/Mouad-Scriptz-0) on 2026-10-21T00:00:33Z. --- A/B done, both arms on one base, home screen only (the panorama scene, nobody touching the title). Not the base I promised: `5d50886ee` + `e8d947d31` aborts at the first present here (`viewport depth outside [0, 1] requires VK_EXT_depth_range_unrestricted`, the clamp clip is not in that tree). The only tree that presents on this Intel is my 2026-10-12 integration tree, so that is the base, named in full: **Base** `main` 33ae282e4 (2026-10-13) + `fix/agc-flip-eop-event` + `perf/guest-memory-registry-lookups` + `feat/videoout-mouse-capture` + `feat/signin-dialog-npauth-signed-out` + `perf/recompiler-select-load-guards` + `fix/dmabuf-import-coherence` (#4449) + the old `feat/agc-depth-range-remap` + the clamp-bounds clip and NpAuth export from that tree, plus `main`'s four trace commits (5668e0d0e, 5c7da226d, 016b2dbe8, eb8a7255d) cherry-picked so both arms write `aps5-summary.jsonl`. Arm commits: base a139a481f, change 91d63f116. **Change** = base + this PR as merged in that tree on 10-12 (`49578e426`) + the later review deltas (`unwatchProbed` gating of shrink/retire/import, `NoteRangeUnwatched`, the refresh guard, `originalValid = !Watched`). It is not today's head `ea55323d5`, which only differs by `main`'s own movement since. Fedora 44, Meteor Lake iGPU, Mesa 26.2.4, 1920x1080, Release libs. Per arm: one warm run with `APS5_PROFILE_DRAW=1`, then two runs with `APS5_TRACE_SECONDS=60:20`, each 130 s. The window was focused throughout the trace windows (unfocused, GNOME holds the title at 1 present/s, which I had to learn the hard way). | arm | run | presents / 20 s | p50 ms | p90 ms | p99 ms | max ms | GPU busy ms/present | worker busy | |---|---|---|---|---|---|---|---|---| | base | 1 | 1051 | 16.80 | 23.71 | 51.96 | 57.92 | 12.31 | 80 % | | base | 2 | 1105 | 16.69 | 21.81 | 43.16 | 54.91 | 11.19 | 84 % | | change | 1 | 919 | 19.64 | 25.49 | 49.23 | 87.16 | 12.25 | 94 % | | change | 2 | 1005 | 17.81 | 22.71 | 41.55 | 47.89 | 12.33 | 94 % | **The change is slower on this scene, and it draws wrong.** Per-frame slices (`tools/trace_digest.py`, run 2 of each arm, ms per frame, inclusive): `Driver.Draw` 12.6 → 15.8, `Graphics.Draw` 9.0 → 12.9, `Driver.Packet` 14.8 → 18.2; the presenter waits less (`VideoOut.Flip` 13.3 → 9.2) because the worker is now the bottleneck. The extra time is in the untracked compare, which this PR was meant to shrink. From the `[guestmem]` 10-s lines of the warm runs (focused intervals only): | arm | compare calls / 10 s | MiB per call | MiB per frame | compare ms per frame | |---|---|---|---|---| | base | 8.8k–9.5k | 5.1 | 79–88 | 11.3–12.2 | | change | 5.4k–6.6k | 8.44 (every call) | 93–152 | 11.9–19.6 | Every compare in the change arm is a whole 0x870000-byte image (the three 1920-wide storage images at 0x258160000, 0x242460000, 0x242cd0000); the base compares partial units averaging 5.1 MiB. Write-backs are the same in both arms (`[storage]` 111–147 idle write-backs / 10 s, all GPU-direct, ~1 GiB / 10 s), so the import rule does not change what is written back here, only what is compared. **Rendering regression.** On the change arm the rotating panorama has a solid black region covering roughly the right half of the frame with a sharp vertical edge, every run, stable while the camera turns (screenshot attached, taken during the second trace run). The base arm renders it whole. The `[textures]` counter points at the mechanism: - base: `sampled created: 27 from storage images, 0 snapshots` - change: `sampled created: 1 from storage images, 26 snapshots` In the change arm the sampled-texture lookup (`ShaderResources.cpp`, the `source == nullptr` branch) no longer finds the storage image that holds the panorama faces, so the texture is built from a guest-memory snapshot via `ReadTextureSurface`, and it is then kept as long as `GuestMemory::UnchangedSince` holds. A write-back through an unwatched import does not bump the generation that `UnchangedSince` checks, so a face whose write-back landed after the snapshot stays black. The change arm also logs 80 `retire import` / 80 `import for` / 60 `refresh ... direct=1` per run on those same three images (the `[diag]` prints in that tree), so the storage images are being retired and re-imported about once a second rather than staying resident. Attached: the four `aps5-trace-*.json.gz`, `aps5-summary.jsonl` with the four lines, the screenshot. Capture dir and the `[storage]`/`[guestmem]`/`[textures]` lines of every run are kept here if you want more of them. <details><summary>aps5-summary.jsonl</summary> ``` {"commit":"a139a481f4ab","dirty":true,"env":{"APS5_TRACE_SECONDS":"60:20"},"gpu":"Intel(R) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.11-200.fc44.x86_64","resolution":"1920x1080","window":{"spec":"seconds 60:20","first_present":3276,"ms":20008.033},"presents":1051,"frame_ms":{"p50":16.797,"p90":23.714,"p99":51.961,"max":57.925},"gpu_busy_ms_per_present":12.306,"worker_busy_pct":{"queue worker 0x0":80.080},"top_phases_ms_per_frame":{"Driver.Packet":15.101,"VideoOut.Flip":14.087,"Driver.Present":12.876,"VideoOut.Flip.present":12.871,"Driver.Packet.draw":12.445,"Driver.Draw":12.432,"Driver.Draw.draw_and_resource_release":11.503,"Driver.Present.render_fence_wait":10.376},"trace_dropped":false,"trace":"aps5-trace-a139a481f4ab-179456.json.gz"} {"commit":"a139a481f4ab","dirty":true,"env":{"APS5_TRACE_SECONDS":"60:20"},"gpu":"Intel(R) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.11-200.fc44.x86_64","resolution":"1920x1080","window":{"spec":"seconds 60:20","first_present":3326,"ms":20005.457},"presents":1105,"frame_ms":{"p50":16.694,"p90":21.811,"p99":43.159,"max":54.914},"gpu_busy_ms_per_present":11.193,"worker_busy_pct":{"queue worker 0x0":84.282},"top_phases_ms_per_frame":{"Driver.Packet":15.133,"VideoOut.Flip":13.339,"Driver.Packet.draw":12.700,"Driver.Draw":12.688,"Driver.Present":11.589,"VideoOut.Flip.present":11.577,"Driver.Draw.draw_and_resource_release":11.513,"Graphics.Draw":9.282},"trace_dropped":false,"trace":"aps5-trace-a139a481f4ab-180802.json.gz"} {"commit":"91d63f116177","dirty":false,"env":{"APS5_TRACE_SECONDS":"60:20"},"gpu":"Intel(R) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.11-200.fc44.x86_64","resolution":"1920x1080","window":{"spec":"seconds 60:20","first_present":2686,"ms":20000.802},"presents":919,"frame_ms":{"p50":19.638,"p90":25.488,"p99":49.231,"max":87.159},"gpu_busy_ms_per_present":12.247,"worker_busy_pct":{"queue worker 0x0":94.404},"top_phases_ms_per_frame":{"Driver.Packet":20.286,"Driver.Packet.draw":17.264,"Driver.Draw":17.243,"Driver.Draw.draw_and_resource_release":16.476,"Graphics.Draw":14.410,"Graphics.Draw.draw_and_resource_release":14.144,"VideoOut.Flip":9.835,"Driver.Present":9.765},"trace_dropped":false,"trace":"aps5-trace-91d63f116177-183469.json.gz"} {"commit":"91d63f116177","dirty":false,"env":{"APS5_TRACE_SECONDS":"60:20"},"gpu":"Intel(R) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.4","os":"Linux 7.2.11-200.fc44.x86_64","resolution":"1920x1080","window":{"spec":"seconds 60:20","first_present":2507,"ms":20004.046},"presents":1005,"frame_ms":{"p50":17.811,"p90":22.707,"p99":41.553,"max":47.890},"gpu_busy_ms_per_present":12.325,"worker_busy_pct":{"queue worker 0x0":94.136},"top_phases_ms_per_frame":{"Driver.Packet":18.501,"Driver.Packet.draw":15.791,"Driver.Draw":15.773,"Driver.Draw.draw_and_resource_release":15.081,"Graphics.Draw":12.940,"Graphics.Draw.draw_and_resource_release":12.682,"VideoOut.Flip":9.150,"Driver.Present":9.073},"trace_dropped":false,"trace":"aps5-trace-91d63f116177-184618.json.gz"} ``` </details> [ab5-base-aps5-trace-a139a481f4ab-179456.json.gz](https://github.com/user-attachments/files/33744162/ab5-base-aps5-trace-a139a481f4ab-179456.json.gz) [ab5-base-aps5-trace-a139a481f4ab-180802.json.gz](https://github.com/user-attachments/files/33744165/ab5-base-aps5-trace-a139a481f4ab-180802.json.gz) [ab5-change-aps5-trace-91d63f116177-183469.json.gz](https://github.com/user-attachments/files/33744174/ab5-change-aps5-trace-91d63f116177-183469.json.gz) [ab5-change-aps5-trace-91d63f116177-184618.json.gz](https://github.com/user-attachments/files/33744177/ab5-change-aps5-trace-91d63f116177-184618.json.gz) <img width="1944" height="1212" alt="ab5-change-cap2-panorama" src="https://github.com/user-attachments/assets/691db675-8b20-4769-87f4-2894fc1ea77c" />
oneandonlydean commented 2026-10-21 00:32:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T00:32:50Z.


@Mouad-Scriptz-0 Thanks for the A/B and for naming the base in full. One question before we can use it for this PR: did the change arm include the 19 Oct StorageImportFor write-back routing? That routing targets exactly the black region you saw. If it didn't, could you port the head's net diff (main..ea55323d5 on this PR's files) onto the same base and rerun? We'd like to know whether the black region is gone and whether the compares are still whole-image. A same-base A/B is fine as evidence while plain main hangs at start-up on your machine. If you can, add one arm without #4449 in the base, or say why it has to stay.

On the abort: plain main already clips the viewport depth to [0, 1] when the device has no VK_EXT_depth_range_unrestricted (your own main log shows that line), so that one is fixed. The start-up hang on plain main is worth its own issue once you have the thread dump.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6304983364 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6304983364). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T00:32:50Z. --- @Mouad-Scriptz-0 Thanks for the A/B and for naming the base in full. One question before we can use it for this PR: did the change arm include the 19 Oct `StorageImportFor` write-back routing? That routing targets exactly the black region you saw. If it didn't, could you port the head's net diff (`main..ea55323d5` on this PR's files) onto the same base and rerun? We'd like to know whether the black region is gone and whether the compares are still whole-image. A same-base A/B is fine as evidence while plain `main` hangs at start-up on your machine. If you can, add one arm without #4449 in the base, or say why it has to stay. On the abort: plain `main` already clips the viewport depth to [0, 1] when the device has no `VK_EXT_depth_range_unrestricted` (your own `main` log shows that line), so that one is fixed. The start-up hang on plain `main` is worth its own issue once you have the thread dump.
Mouad-Scriptz-0 commented 2026-10-21 19:45:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-21T19:45:55Z.


Yes, the change arm had the routing. I checked it against today's head rather than trust my notes: for every one of the nine files in main..ea55323d5, the head's added and removed lines against the change arm's added and removed lines over its base.

Call sites in Texture.cpp (function: lookup), change arm vs head:

function change arm 91d63f116 head ea55323d5
Refresh direct path alias != nullptr ? HostImportFor : StorageImportFor same line
upload (both sites) StorageImportFor StorageImportFor
writeBackLayers StorageImportFor StorageImportFor
CopyFrom StorageImportFor StorageImportFor
importSegments function does not exist in that base StorageImportFor(..., ImportRequester::Segment)

StorageImportFor itself is the same two lines in both (HostImportsUnwatch && Watched ? ExistingHostImport : HostImportFor). The arm also has HostImportFor's importsStale guard and lastUseFrame, RetireIdleImports with IdleImportFrames = 60 and the rewatch of retired ranges, the Linux Rewatch body (kernel re-register plus StampKind::ImportWindow stamps), NoteRangeUnwatched, and 924aaa4bf's staged-upload rule as originalValid = !GuestMemory::Watched(...) (that base has no layerOriginal). What the arm lacks is only what the 10-13 base does not have: ImportRequester and its per-requester counts, importSegments, layerOriginal/cancelStoredSaves, the Windows settles. None of those changes which import a storage surface takes on Linux. So the black region and the whole-image compares are the PR's current behaviour on this scene, not a stale arm.

The arm without #4449 is next: both arms with the fix/dmabuf-import-coherence merge reverted (d807ffc63 base, b4a701ff7 change), same base otherwise, same protocol. #4449 was in the base only because the 10-12 tree carried it; nothing else there depends on it, so I will post those numbers rather than argue for keeping it.

Thread dump of the plain main start-up hang and its own issue after that.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6325008967 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#issuecomment-6325008967). Originally posted by [Mouad-Scriptz-0](https://github.com/Mouad-Scriptz-0) on 2026-10-21T19:45:55Z. --- Yes, the change arm had the routing. I checked it against today's head rather than trust my notes: for every one of the nine files in `main..ea55323d5`, the head's added and removed lines against the change arm's added and removed lines over its base. Call sites in `Texture.cpp` (function: lookup), change arm vs head: | function | change arm 91d63f116 | head ea55323d5 | |---|---|---| | `Refresh` direct path | `alias != nullptr ? HostImportFor : StorageImportFor` | same line | | `upload` (both sites) | `StorageImportFor` | `StorageImportFor` | | `writeBackLayers` | `StorageImportFor` | `StorageImportFor` | | `CopyFrom` | `StorageImportFor` | `StorageImportFor` | | `importSegments` | function does not exist in that base | `StorageImportFor(..., ImportRequester::Segment)` | `StorageImportFor` itself is the same two lines in both (`HostImportsUnwatch && Watched ? ExistingHostImport : HostImportFor`). The arm also has `HostImportFor`'s `importsStale` guard and `lastUseFrame`, `RetireIdleImports` with `IdleImportFrames = 60` and the rewatch of retired ranges, the Linux `Rewatch` body (kernel re-register plus `StampKind::ImportWindow` stamps), `NoteRangeUnwatched`, and 924aaa4bf's staged-upload rule as `originalValid = !GuestMemory::Watched(...)` (that base has no `layerOriginal`). What the arm lacks is only what the 10-13 base does not have: `ImportRequester` and its per-requester counts, `importSegments`, `layerOriginal`/`cancelStoredSaves`, the Windows settles. None of those changes which import a storage surface takes on Linux. So the black region and the whole-image compares are the PR's current behaviour on this scene, not a stale arm. The arm without #4449 is next: both arms with the `fix/dmabuf-import-coherence` merge reverted (`d807ffc63` base, `b4a701ff7` change), same base otherwise, same protocol. #4449 was in the base only because the 10-12 tree carried it; nothing else there depends on it, so I will post those numbers rather than argue for keeping it. Thread dump of the plain `main` start-up hang and its own issue after that.
CnRJay commented 2026-11-01 19:52:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:52:29Z.

Review: COMMENTED


The retirement after IdleImportFrames = 60 is where I'd look first. A retired range comes back stamped as possibly written, so its next use pays a full compare, and if the title imports it again it is unwatched again. A surface the compute uploader touches every 61 frames or so would go round that loop forever: import, unwatch, retire, compare. Is there a counter for imports retired and re-imported per 10 s, and what does it show on the Minecraft home screen?

This is titled perf, so it needs the main and change summary lines from the same machine and scene, with traces. The Tested section says the home screen runs at the same 60 fps as before, so the summary lines are also what would show the render thread time going down.

The four changes in the description (one-allocation window, storage surfaces not importing their own range, idle retirement, the Watched check in refreshImports) could each land on its own. The refreshImports check alone looks like an easy split.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729932146 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#pullrequestreview-5729932146). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:52:29Z. **Review:** COMMENTED --- The retirement after `IdleImportFrames = 60` is where I'd look first. A retired range comes back stamped as possibly written, so its next use pays a full compare, and if the title imports it again it is unwatched again. A surface the compute uploader touches every 61 frames or so would go round that loop forever: import, unwatch, retire, compare. Is there a counter for imports retired and re-imported per 10 s, and what does it show on the Minecraft home screen? This is titled `perf`, so it needs the `main` and change summary lines from the same machine and scene, with traces. The Tested section says the home screen runs at the same 60 fps as before, so the summary lines are also what would show the render thread time going down. The four changes in the description (one-allocation window, storage surfaces not importing their own range, idle retirement, the `Watched` check in `refreshImports`) could each land on its own. The `refreshImports` check alone looks like an easy split.
XairRrR commented 2026-11-03 09:08:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T09:08:10Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The merge is clean and builds, but on lavapipe five existing tests now fail. They pass with main's production files and with APS5_WRITE_WATCH_IMPORTS=unwatch, so the cause is the PR's probe-gated paths. Lavapipe's start-up probe reports that host imports resolve the write watch, so those paths also run on the Linux CI device.

What I ran

Head 7771062935fcfb3206a0f002e77781f461a2f641, main 4f41f4c375f5abb487dbd184fbc150f31994d762, merged with --no-ff (merged tree a3aed2e7681a04cf99ffd245a4841fca0ebaf536). Debian 13 VM, 32 vCPU Xeon Gold 6136, GCC 14.2.0, Release, Ninja, Vulkan on lavapipe (Mesa 26.1.6, LLVM 19). Probe line in every failing test: [write-watch] host imports resolve write protection: yes (0 of 4 scratch pages written after a GPU read, 4 after a GPU write, ...).

git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...7771062935fcfb3206a0f002e77781f461a2f641
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
ctest --test-dir build -j5 --test-load 32 -R "^(agc_driver_copy_surface_bytes|agc_driver_host_import_proofs|agc_driver_storage_one_slice_alias|agc_map_gate_retry|agc_windowed_import_refresh|agc_driver_graphics)$"
# production files (PacketExecution.cpp, GuestMemory.cpp, GuestBufferMemory.hpp/.cpp, Texture.hpp/.cpp) and BdaResources.cpp restored from main
git show 4f41f4c375f5abb487dbd184fbc150f31994d762:<path> > <path>
ninja -C build -j32 -l32 tests/agc_driver_copy_surface_bytes_tests tests/agc_driver_host_import_proofs_tests tests/agc_driver_storage_one_slice_alias_tests tests/agc_driver_recorder_tests
ctest --test-dir build -j5 --test-load 32 -R "^(agc_driver_copy_surface_bytes|agc_driver_host_import_proofs|agc_driver_storage_one_slice_alias|agc_map_gate_retry|agc_windowed_import_refresh)$"
# merged files restored, rebuilt
git show a3aed2e7681a04cf99ffd245a4841fca0ebaf536:<path> > <path>
ninja -C build -j32 -l32 <same targets> tests/agc_driver_graphics_tests
ctest ... (same five)
APS5_WRITE_WATCH_IMPORTS=unwatch ctest ... (same five)
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_native_depth_uniform_planes$"   # with and without APS5_WRITE_WATCH_IMPORTS=unwatch
git status --porcelain

Results

Check Result
git diff --check clean
check_conventions.py 0 errors, 1 warning: docs/dev/debt/libSceAgcDriver.md:351 debt entry is 1507 characters (over 1000)
Configure / build / libs (script) ok
Selected tests (script) 2171 ran, 2044 passed, 115 expected skips, 7 known main failures, 5 new failures
The 5 new failures on the merged tree (rerun) all fail again
The same 5 with main's production files all pass
The same 5 on the merged tree with APS5_WRITE_WATCH_IMPORTS=unwatch all pass
agc_driver_graphics (has the new idleImportRetireTests / unwatchedImportWindowTests) passes, 35.6 s
Validation layer (script) layer loaded in 769 of 770; one test with new VUID-vkCmdDispatch-groupCountX-00386: agc_driver_native_depth_uniform_planes, which was not run on the baseline. I get the same 8 VUID lines with and without APS5_WRITE_WATCH_IMPORTS=unwatch, so they do not come from this PR's probe-gated paths. I did not count it as a finding.
Worktree after the control git status --porcelain empty
First failing check of each new failure (merged tree)
agc_driver_copy_surface_bytes: AGC graphics: surface byte copy: image alias did not preserve the raw byte copy
  (preceded by "[copy] image copy ... (0x20000 bytes) refused: not imported")
agc_driver_host_import_proofs: AGC graphics: host import proofs: a registration completed the import window of 0x7f0524000000, but the proof over its import held
agc_driver_storage_one_slice_alias: AGC graphics: the array image's refresh wrote the 2D image's results back instead of taking them on the device
agc_map_gate_retry: AGC graphics: (r) the grown run did not take the stripes again
agc_windowed_import_refresh: AGC graphics: an import whose window gained a continuing range was kept

Negative control

The new cases (idleImportRetireTests, unwatchedImportWindowTests in tests/BdaResources.cpp) call API this PR adds (RetireIdleImports, HostImportsUnwatch, the three-argument SetImportWatch). With main's production files they cannot compile, so a "fails without the change" run is not possible beyond that compile failure. I used the reverse control for the regressions instead: with main's production files (and main's BdaResources.cpp), the five failing tests pass. With the merged files restored, they fail again. The worktree matches the merged tree afterwards.

Findings

Blocking

  1. Five existing tests fail on any device whose probe says imports unwatch, including lavapipe. These are agc_driver_copy_surface_bytes, agc_driver_host_import_proofs, agc_driver_storage_one_slice_alias, agc_map_gate_retry and agc_windowed_import_refresh. All pass with main's production files, and all pass on the merged tree with APS5_WRITE_WATCH_IMPORTS=unwatch (which skips the probe, so unwatchProbed stays false). Upstream Linux CI runs on lavapipe, so it should hit these failures. The NVIDIA run in the discussion passed because that probe answers "no".
    Part of the cause is in the import window (merged tree):

    • core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp:1410 (shrinkImportWindow) stores 64 KiB into the process-wide importWindow atomic (line 1408). A probed device triggers it at GuestBufferMemory.cpp:1477, and nothing ever restores it. SetImportWatch(..., Watch) does not, and neither does a later device whose probe says "no". Only an explicit SetHostImportWindow does.
    • With the window at 64 KiB, every window/run test that relies on the default unbounded run sees single-allocation imports. The host_import_proofs, map_gate_retry and windowed_import_refresh messages are exactly that.

    The rest is in the storage paths:

    • StorageImportFor (GuestBufferMemory.cpp:4544) now backs CopyRefusal (Texture.cpp:6004). A watched copy source on such a device is refused as "not imported", which breaks the raw byte copy that agc_driver_copy_surface_bytes checks.
    • The one-slice alias refresh now writes back instead of taking the results on the device. In the discussion the author said agc_driver_storage_one_slice_alias had been updated for the new contract, but this diff has no change to that test. So either the behaviour change is unintended, or the test change was lost in the merges.

    Suggested fix: keep the window per device state, or restore it when the decision changes, rather than as a one-way global store. Make CopyRefusal and the one-slice alias refresh keep main's import behaviour, or update those tests with a stated reason. Run the affected tests on lavapipe or another "probe: yes" device before pushing.

  2. The perf evidence the rules require is still missing from the description. The perf numbers missing label is still on the PR. CONTRIBUTING requires two aps5-summary.jsonl lines (from main and from the change, same machine and scene) plus traces. Those lines are only in comments, and the latest same-base A/B (2026-10-31, on d6b8a6227a) shows both arms vsync-locked. That run also explains how the black panorama arises: a GPU-only-written surface that StorageImportFor keeps watched is sampled from a guest snapshot that lacks unstored layers. It ends with a proposed fix ("a copy destination ... takes the import"). The commits since then are merges only, so that fix is not in this head, and the snapshot-path problem the maintainer asked to fix is still open as far as this diff shows.

  3. The checklist is missing the Fixes: and GPUs tested: lines (required for AGC changes). I confirm the earlier reports in the discussion that these lines are missing; the description is unchanged.

Non-blocking

  1. New code comments that are not technical debt. These are core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:2440-2441 ("Only the direct path uploads the selected layers alone..."), core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp:1990-1991, and the new comments above SetImportWatch, HostImportsUnwatch and StorageImportFor in GuestBufferMemory.hpp. CONVENTIONS allows comments only for technical debt. The checker accepts them only because the PR also edits the debt file. Please drop them or turn them into debt text.
  2. The debt entry is 1507 characters (docs/dev/debt/libSceAgcDriver.md:351, checker warning), against the 1000-character guidance. It also describes implemented behaviour at length. Please state the gap first (the unmeasured 60-frame bound, unwatched ranges compared at every use) and cut the rest.
  3. On Linux, Rewatch re-registers ranges with the kernel write watch before checking tracker.covers (GuestMemory.cpp, the #else branch of Rewatch). A range outside the tracker is registered but never stamped. Consider checking coverage first.
  4. agc_driver_graphics took 35.6 s here, over the 30 s limit (the NVIDIA run in the discussion reports 37.3 s on this head). I did not measure main for comparison, so I cannot say how much the two new cases add.

Not verified

  • Behaviour on real Intel i915 hardware, any title, and the Minecraft numbers or panorama rendering. I did not launch titles.
  • Windows (MinGW) builds and tests.
  • Whether agc_driver_graphics's run time over 30 s comes from this PR or from main.
  • I did not root-cause each of the five failures line by line. The window/run failures follow from the sticky 64 KiB window. For the copy and one-slice-alias failures I traced only the refusal message and the call sites that changed.

To get this to a good state

  1. Make the five failing tests pass on a device whose probe says imports unwatch (lavapipe is enough): stop the 64 KiB window from leaking process-wide, and restore or justify the copy-source and one-slice-alias import behaviour.
  2. Land the panorama/snapshot fix the 2026-10-31 comment proposes, or explain why it is not needed.
  3. Put the two summary lines, the traces and the tools/trace_digest.py output for main and this head in the description, and add the Fixes: and GPUs tested: checklist lines.
  4. Remove the non-debt comments and shorten the debt entry.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5749504175 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#pullrequestreview-5749504175). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T09:08:10Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The merge is clean and builds, but on lavapipe five existing tests now fail. They pass with `main`'s production files and with `APS5_WRITE_WATCH_IMPORTS=unwatch`, so the cause is the PR's probe-gated paths. Lavapipe's start-up probe reports that host imports resolve the write watch, so those paths also run on the Linux CI device. ## What I ran Head `7771062935fcfb3206a0f002e77781f461a2f641`, `main` `4f41f4c375f5abb487dbd184fbc150f31994d762`, merged with `--no-ff` (merged tree `a3aed2e7681a04cf99ffd245a4841fca0ebaf536`). Debian 13 VM, 32 vCPU Xeon Gold 6136, GCC 14.2.0, Release, Ninja, Vulkan on lavapipe (Mesa 26.1.6, LLVM 19). Probe line in every failing test: `[write-watch] host imports resolve write protection: yes (0 of 4 scratch pages written after a GPU read, 4 after a GPU write, ...)`. ``` git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...7771062935fcfb3206a0f002e77781f461a2f641 python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 ctest --test-dir build -j5 --test-load 32 -R "^(agc_driver_copy_surface_bytes|agc_driver_host_import_proofs|agc_driver_storage_one_slice_alias|agc_map_gate_retry|agc_windowed_import_refresh|agc_driver_graphics)$" # production files (PacketExecution.cpp, GuestMemory.cpp, GuestBufferMemory.hpp/.cpp, Texture.hpp/.cpp) and BdaResources.cpp restored from main git show 4f41f4c375f5abb487dbd184fbc150f31994d762:<path> > <path> ninja -C build -j32 -l32 tests/agc_driver_copy_surface_bytes_tests tests/agc_driver_host_import_proofs_tests tests/agc_driver_storage_one_slice_alias_tests tests/agc_driver_recorder_tests ctest --test-dir build -j5 --test-load 32 -R "^(agc_driver_copy_surface_bytes|agc_driver_host_import_proofs|agc_driver_storage_one_slice_alias|agc_map_gate_retry|agc_windowed_import_refresh)$" # merged files restored, rebuilt git show a3aed2e7681a04cf99ffd245a4841fca0ebaf536:<path> > <path> ninja -C build -j32 -l32 <same targets> tests/agc_driver_graphics_tests ctest ... (same five) APS5_WRITE_WATCH_IMPORTS=unwatch ctest ... (same five) 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_native_depth_uniform_planes$" # with and without APS5_WRITE_WATCH_IMPORTS=unwatch git status --porcelain ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | 0 errors, 1 warning: `docs/dev/debt/libSceAgcDriver.md:351` debt entry is 1507 characters (over 1000) | | Configure / build / libs (script) | ok | | Selected tests (script) | 2171 ran, 2044 passed, 115 expected skips, 7 known `main` failures, **5 new failures** | | The 5 new failures on the merged tree (rerun) | all fail again | | The same 5 with `main`'s production files | **all pass** | | The same 5 on the merged tree with `APS5_WRITE_WATCH_IMPORTS=unwatch` | **all pass** | | `agc_driver_graphics` (has the new `idleImportRetireTests` / `unwatchedImportWindowTests`) | passes, 35.6 s | | Validation layer (script) | layer loaded in 769 of 770; one test with new `VUID-vkCmdDispatch-groupCountX-00386`: `agc_driver_native_depth_uniform_planes`, which was not run on the baseline. I get the same 8 VUID lines with and without `APS5_WRITE_WATCH_IMPORTS=unwatch`, so they do not come from this PR's probe-gated paths. I did not count it as a finding. | | Worktree after the control | `git status --porcelain` empty | <details><summary>First failing check of each new failure (merged tree)</summary> ``` agc_driver_copy_surface_bytes: AGC graphics: surface byte copy: image alias did not preserve the raw byte copy (preceded by "[copy] image copy ... (0x20000 bytes) refused: not imported") agc_driver_host_import_proofs: AGC graphics: host import proofs: a registration completed the import window of 0x7f0524000000, but the proof over its import held agc_driver_storage_one_slice_alias: AGC graphics: the array image's refresh wrote the 2D image's results back instead of taking them on the device agc_map_gate_retry: AGC graphics: (r) the grown run did not take the stripes again agc_windowed_import_refresh: AGC graphics: an import whose window gained a continuing range was kept ``` </details> ## Negative control The new cases (`idleImportRetireTests`, `unwatchedImportWindowTests` in `tests/BdaResources.cpp`) call API this PR adds (`RetireIdleImports`, `HostImportsUnwatch`, the three-argument `SetImportWatch`). With `main`'s production files they cannot compile, so a "fails without the change" run is not possible beyond that compile failure. I used the reverse control for the regressions instead: with `main`'s production files (and `main`'s `BdaResources.cpp`), the five failing tests pass. With the merged files restored, they fail again. The worktree matches the merged tree afterwards. ## Findings ### Blocking 1. **Five existing tests fail on any device whose probe says imports unwatch, including lavapipe.** These are `agc_driver_copy_surface_bytes`, `agc_driver_host_import_proofs`, `agc_driver_storage_one_slice_alias`, `agc_map_gate_retry` and `agc_windowed_import_refresh`. All pass with `main`'s production files, and all pass on the merged tree with `APS5_WRITE_WATCH_IMPORTS=unwatch` (which skips the probe, so `unwatchProbed` stays false). Upstream Linux CI runs on lavapipe, so it should hit these failures. The NVIDIA run in the discussion passed because that probe answers "no". Part of the cause is in the import window (merged tree): - `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp:1410` (`shrinkImportWindow`) stores 64 KiB into the process-wide `importWindow` atomic (line 1408). A probed device triggers it at `GuestBufferMemory.cpp:1477`, and nothing ever restores it. `SetImportWatch(..., Watch)` does not, and neither does a later device whose probe says "no". Only an explicit `SetHostImportWindow` does. - With the window at 64 KiB, every window/run test that relies on the default unbounded run sees single-allocation imports. The `host_import_proofs`, `map_gate_retry` and `windowed_import_refresh` messages are exactly that. The rest is in the storage paths: - `StorageImportFor` (`GuestBufferMemory.cpp:4544`) now backs `CopyRefusal` (`Texture.cpp:6004`). A watched copy source on such a device is refused as "not imported", which breaks the raw byte copy that `agc_driver_copy_surface_bytes` checks. - The one-slice alias refresh now writes back instead of taking the results on the device. In the discussion the author said `agc_driver_storage_one_slice_alias` had been updated for the new contract, but this diff has no change to that test. So either the behaviour change is unintended, or the test change was lost in the merges. Suggested fix: keep the window per device state, or restore it when the decision changes, rather than as a one-way global store. Make `CopyRefusal` and the one-slice alias refresh keep `main`'s import behaviour, or update those tests with a stated reason. Run the affected tests on lavapipe or another "probe: yes" device before pushing. 2. **The `perf` evidence the rules require is still missing from the description.** The `perf numbers missing` label is still on the PR. CONTRIBUTING requires two `aps5-summary.jsonl` lines (from `main` and from the change, same machine and scene) plus traces. Those lines are only in comments, and the latest same-base A/B (2026-10-31, on `d6b8a6227a`) shows both arms vsync-locked. That run also explains how the black panorama arises: a GPU-only-written surface that `StorageImportFor` keeps watched is sampled from a guest snapshot that lacks unstored layers. It ends with a proposed fix ("a copy destination ... takes the import"). The commits since then are merges only, so that fix is not in this head, and the snapshot-path problem the maintainer asked to fix is still open as far as this diff shows. 3. **The checklist is missing the `Fixes:` and `GPUs tested:` lines** (required for AGC changes). I confirm the earlier reports in the discussion that these lines are missing; the description is unchanged. ### Non-blocking 1. **New code comments that are not technical debt.** These are `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:2440-2441` ("Only the direct path uploads the selected layers alone..."), `core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp:1990-1991`, and the new comments above `SetImportWatch`, `HostImportsUnwatch` and `StorageImportFor` in `GuestBufferMemory.hpp`. CONVENTIONS allows comments only for technical debt. The checker accepts them only because the PR also edits the debt file. Please drop them or turn them into debt text. 2. **The debt entry is 1507 characters** (`docs/dev/debt/libSceAgcDriver.md:351`, checker warning), against the 1000-character guidance. It also describes implemented behaviour at length. Please state the gap first (the unmeasured 60-frame bound, unwatched ranges compared at every use) and cut the rest. 3. **On Linux, `Rewatch` re-registers ranges with the kernel write watch before checking `tracker.covers`** (`GuestMemory.cpp`, the `#else` branch of `Rewatch`). A range outside the tracker is registered but never stamped. Consider checking coverage first. 4. **`agc_driver_graphics` took 35.6 s here**, over the 30 s limit (the NVIDIA run in the discussion reports 37.3 s on this head). I did not measure `main` for comparison, so I cannot say how much the two new cases add. ## Not verified - Behaviour on real Intel i915 hardware, any title, and the Minecraft numbers or panorama rendering. I did not launch titles. - Windows (MinGW) builds and tests. - Whether `agc_driver_graphics`'s run time over 30 s comes from this PR or from `main`. - I did not root-cause each of the five failures line by line. The window/run failures follow from the sticky 64 KiB window. For the copy and one-slice-alias failures I traced only the refusal message and the call sites that changed. ## To get this to a good state 1. Make the five failing tests pass on a device whose probe says imports unwatch (lavapipe is enough): stop the 64 KiB window from leaking process-wide, and restore or justify the copy-source and one-slice-alias import behaviour. 2. Land the panorama/snapshot fix the 2026-10-31 comment proposes, or explain why it is not needed. 3. Put the two summary lines, the traces and the `tools/trace_digest.py` output for `main` and this head in the description, and add the `Fixes:` and `GPUs tested:` checklist lines. 4. Remove the non-debt comments and shorten the debt entry. <!-- anyps5-bots job=2371 head=7771062935fcfb3206a0f002e77781f461a2f641 -->
MarcZX10 commented 2026-11-23 03:10:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T03:10:58Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the reported Linux test and performance results are author-supplied, and I found no verified blocking defect in the code reviewed.

What I ran

Reviewed head 820f6a468a98cec4d66ee6626d692bf28dbd69bd. No commands or tests were run; repository context was read through repo_read.py.

Results

Check Result Note
Source review passed Reviewed all changed-file additions
Tests not run Results in the PR description are author-reported
Build and runtime not run No local execution was available

Findings

Blocking

None.

Non-blocking

None.

Not verified

No tests, builds, Windows behavior, or physical-console behavior were verified. The PR description reports the Fedora test and Minecraft measurements; those results were not independently run. Read all changed files listed in review/README.md and the targeted repository context for import retirement, rewatching, and snapshot capture. The only changed-file lines not read were pre-existing context lines; all additions in manifest.json were read. files.json was not supplied; review/README.md identifies the changed files excluded from files/ as VulkanDevice.cpp, GuestBufferMemory.cpp, Texture.cpp, and Recorder.cpp, and those were read through the repository reader.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6016147275 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4448#pullrequestreview-6016147275). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T03:10:58Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the reported Linux test and performance results are author-supplied, and I found no verified blocking defect in the code reviewed. ## What I ran Reviewed head `820f6a468a98cec4d66ee6626d692bf28dbd69bd`. No commands or tests were run; repository context was read through `repo_read.py`. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Reviewed all changed-file additions | | Tests | not run | Results in the PR description are author-reported | | Build and runtime | not run | No local execution was available | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No tests, builds, Windows behavior, or physical-console behavior were verified. The PR description reports the Fedora test and Minecraft measurements; those results were not independently run. Read all changed files listed in `review/README.md` and the targeted repository context for import retirement, rewatching, and snapshot capture. The only changed-file lines not read were pre-existing context lines; all additions in `manifest.json` were read. `files.json` was not supplied; `review/README.md` identifies the changed files excluded from `files/` as `VulkanDevice.cpp`, `GuestBufferMemory.cpp`, `Texture.cpp`, and `Recorder.cpp`, and those were read through the repository reader. ## To get this to a good state Nothing is required.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/4448:upstream-pr/4448'
git switch 'upstream-pr/4448'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/4448'
git switch 'upstream-pr/4448'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/4448'
git switch 'upstream-pr/4448'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/4448'
git switch 'main'
git merge --squash 'upstream-pr/4448'
git switch 'main'
git merge --ff-only 'upstream-pr/4448'
git switch 'main'
git merge 'upstream-pr/4448'
git push origin 'main'
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!4448
No description provided.