fix(agc): count copied guest buffers and draw snapshots in the batch byte budget #2283

Merged
MathiasDevelopes merged 4 commits from upstream-pr/2283 into main 2026-10-10 22:41:23 +00:00
MathiasDevelopes commented 2026-10-09 14:32:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MathiasDevelopes on 2026-10-09T14:32:22Z.


What

The [recorder](https://github.com/boykopovar/AnyPS5/blob/main/core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp) bounds the bytes a batch keeps alive: BoundKeptBytes submits an open batch at KeptBytesBudget (512 MiB) and waits for the oldest in-flight batches past twice that. Only bytes passed to Recorder::Keep(object, bytes) count, and a recorded dispatch or draw kept its ShaderResources (and a draw its DrawBindings snapshots) with a size of 0. The host-visible copies of guest buffers that these objects own were never counted.

Planet Coaster (PPSA01736) binds a 124 MiB writable guest buffer in nearly every draw after its intro. The process went from 8.7 GB to 20.7 GB private memory within three seconds. 98 buffers of 124 MiB were created and 12 released, until:

[videoout] presentation failed: AGC graphics: vkAllocateMemory buffer: Vulkan result -2

GuestBufferMemory::CopiedBytes() now reports the bytes of its regions that are served by a copy, ShaderResources::CopiedBytes() forwards it, and the dispatch keep, the draw keep and the draw snapshots pass their bytes to Recorder::Keep. The existing bound then applies to them; nothing else about the bound changes.

Related open PRs: #1364 (and #1366, which contains it) counts retained draw upload pages in the same budget; it does not touch these keeps. #1997 passes sizes for its own image merge buffers. The call sites above are untouched by both.

This is a bound, not a fix of the copies themselves: the title still re-copies that buffer for each draw (see the related region fix in a separate PR).

Tested

Windows 11, MinGW-w64 15.2.0, RTX 3060.

  • agc_driver_bda_resources: CopiedBytes() is 0 before an upload and, after it, either 0 (served by an import) or the one copied region's size.
  • Full ctest suite: 507/507 passed. tools/check_conventions.py --base origin/main passes.
  • PPSA01736: with the change, the title runs the 200 s capture without the allocation failure; before, it aborted about 60 s in. It needs other fixes to reach that point on main.

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
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4801838848 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2283). Originally posted by [MathiasDevelopes](https://github.com/MathiasDevelopes) on 2026-10-09T14:32:22Z. --- ### What The [[recorder](https://github.com/boykopovar/AnyPS5/blob/main/core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp)](https://github.com/boykopovar/AnyPS5/blob/main/core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp) bounds the bytes a batch keeps alive: `BoundKeptBytes` submits an open batch at `KeptBytesBudget` (512 MiB) and waits for the oldest in-flight batches past twice that. Only bytes passed to `Recorder::Keep(object, bytes)` count, and a recorded dispatch or draw kept its `ShaderResources` (and a draw its `DrawBindings` snapshots) with a size of 0. The host-visible copies of guest buffers that these objects own were never counted. Planet Coaster (PPSA01736) binds a 124 MiB writable guest buffer in nearly every draw after its intro. The process went from 8.7 GB to 20.7 GB private memory within three seconds. 98 buffers of 124 MiB were created and 12 released, until: ``` [videoout] presentation failed: AGC graphics: vkAllocateMemory buffer: Vulkan result -2 ``` `GuestBufferMemory::CopiedBytes()` now reports the bytes of its regions that are served by a copy, `ShaderResources::CopiedBytes()` forwards it, and the dispatch keep, the draw keep and the draw snapshots pass their bytes to `Recorder::Keep`. The existing bound then applies to them; nothing else about the bound changes. Related open PRs: #1364 (and #1366, which contains it) counts retained draw upload pages in the same budget; it does not touch these keeps. #1997 passes sizes for its own image merge buffers. The call sites above are untouched by both. This is a bound, not a fix of the copies themselves: the title still re-copies that buffer for each draw (see the related region fix in a separate PR). ### Tested Windows 11, MinGW-w64 15.2.0, RTX 3060. - `agc_driver_bda_resources`: `CopiedBytes()` is 0 before an upload and, after it, either 0 (served by an import) or the one copied region's size. - Full ctest suite: 507/507 passed. `tools/check_conventions.py --base origin/main` passes. - PPSA01736: with the change, the title runs the 200 s capture without the allocation failure; before, it aborted about 60 s in. It needs other fixes to reach that point on main. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [[Claude Code](https://claude.com/claude-code)](https://claude.com/claude-code)
copilot-pull-request-reviewer[bot] commented 2026-10-09 14:32:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-09T14:32:30Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5471455351 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2283#pullrequestreview-5471455351). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-09T14:32:30Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
MarcZX10 commented 2026-10-09 14:44:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T14:44:21Z.


I reviewed the complete six-file diff. The byte accounting follows the retained GuestBufferMemory regions and draw snapshots, and the new test checks the no-copy/import path as well as a copied upload. The Windows full-suite report and Linux/Windows/macOS relinker jobs are green; the upstream full Linux and Windows Build jobs were skipped. Could an authorized collaborator run the required full Build workflow on this PR head before merge?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6083210596 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2283#issuecomment-6083210596). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T14:44:21Z. --- I reviewed the complete six-file diff. The byte accounting follows the retained `GuestBufferMemory` regions and draw snapshots, and the new test checks the no-copy/import path as well as a copied upload. The Windows full-suite report and Linux/Windows/macOS relinker jobs are green; the upstream full Linux and Windows Build jobs were skipped. Could an authorized collaborator run the required full Build workflow on this PR head before merge?
adriadam10 commented 2026-10-10 06:01:42 +00:00 (Migrated from github.com)

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

Review: CHANGES_REQUESTED


Thanks, the bound makes sense. Build and the libSceAgcDriver ctest scope are green here (the new assertions fail to compile without the change). Points to address:

  • tests/BdaResources.cpp:431: CopiedBytes() == 0 || CopiedBytes() == sizeof(guest) accepts both outcomes. Pin the expected value for the case the test sets up (copy vs. import), or build one case for each.
  • The test only covers the accessor. Reverting any of the three Keep calls (VulkanDevice.cpp:3318, Draw.cpp:1176, ShaderResources.cpp:3159) leaves it green. Please add a test showing that the kept bytes reach the recorder's budget (see the existing agc_recorder_kept_bytes_tests fixture).
  • Please confirm a ShaderResources retained by several draws/dispatches is not counted once per keep, otherwise the batch is submitted earlier than the budget says.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5477885320 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2283#pullrequestreview-5477885320). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T06:01:42Z. **Review:** CHANGES_REQUESTED --- Thanks, the bound makes sense. Build and the libSceAgcDriver ctest scope are green here (the new assertions fail to compile without the change). Points to address: - `tests/BdaResources.cpp:431`: `CopiedBytes() == 0 || CopiedBytes() == sizeof(guest)` accepts both outcomes. Pin the expected value for the case the test sets up (copy vs. import), or build one case for each. - The test only covers the accessor. Reverting any of the three `Keep` calls (`VulkanDevice.cpp:3318`, `Draw.cpp:1176`, `ShaderResources.cpp:3159`) leaves it green. Please add a test showing that the kept bytes reach the recorder's budget (see the existing `agc_recorder_kept_bytes_tests` fixture). - Please confirm a `ShaderResources` retained by several draws/dispatches is not counted once per keep, otherwise the batch is submitted earlier than the budget says.
MathiasDevelopes commented 2026-10-10 09:59:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MathiasDevelopes on 2026-10-10T09:59:26Z.


@adriadam10

Thanks for the review. Pushed 26d59264 (and 55b09c0f, which drops comments the conventions check rejects):

BdaResources: the check now pins CopiedBytes() == sizeof(guest). guest is stack memory no allocation registers, so no host import serves it and the two views merge into one copied region (the WriteBack publishing the aliased write below already depends on that copy).

New device test agc_driver_recorded_kept_bytes (tests/execution/RecordedKeptBytes.cpp). It reads the open batch's kept bytes (new Recorder::OpenKeptBytes) after a recorded dispatch writing a copied 64 KiB buffer, after a recorded draw reading a copied 64 KiB buffer (into a resident target, so the draw is recorded rather than synchronous), and after two draws reading a registered, write-watched 64 KiB buffer in place, which take a draw snapshot.

I checked it against each revert separately: removing the dispatch keep, the draw keep or the snapshot keep each fails it, and so does counting a reused snapshot twice. It takes about 0.2 s on lavapipe.

The mock fixture gets SharedOwnerCountsOncePerBatch for the counting rule itself.
It was counted once per keep, so you were right. A cached ShaderResources (the dispatch resource cache, the draw SharedResourceCache, recipe templates) is one object shared by every draw or dispatch that hits it. Reusable() accepts device-local staged regions, which have a buffer, so CopiedBytes() can be nonzero for a shared object. Draw snapshots were affected too: ReusableDrawSnapshot hands the next draw the same buffer. Recorder::KeepBytes(owner, bytes) now counts an owner once per batch through a per-batch set, and all three sites use it. An object used by two batches that are both in flight still counts once in each. That errs toward waiting early, never late.

Tested on Linux with lavapipe, with the PR merged into current main: the libSceAgcDriver ctest scope gives 320/320 passing (27 skipped because llvmpipe has subgroup size 8).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6096351820 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2283#issuecomment-6096351820). Originally posted by [MathiasDevelopes](https://github.com/MathiasDevelopes) on 2026-10-10T09:59:26Z. --- @adriadam10 Thanks for the review. Pushed 26d59264 (and 55b09c0f, which drops comments the conventions check rejects): BdaResources: the check now pins CopiedBytes() == sizeof(guest). guest is stack memory no allocation registers, so no host import serves it and the two views merge into one copied region (the WriteBack publishing the aliased write below already depends on that copy). New device test agc_driver_recorded_kept_bytes (tests/execution/RecordedKeptBytes.cpp). It reads the open batch's kept bytes (new Recorder::OpenKeptBytes) after a recorded dispatch writing a copied 64 KiB buffer, after a recorded draw reading a copied 64 KiB buffer (into a resident target, so the draw is recorded rather than synchronous), and after two draws reading a registered, write-watched 64 KiB buffer in place, which take a draw snapshot. I checked it against each revert separately: removing the dispatch keep, the draw keep or the snapshot keep each fails it, and so does counting a reused snapshot twice. It takes about 0.2 s on lavapipe. The mock fixture gets SharedOwnerCountsOncePerBatch for the counting rule itself. It was counted once per keep, so you were right. A cached ShaderResources (the dispatch resource cache, the draw SharedResourceCache, recipe templates) is one object shared by every draw or dispatch that hits it. Reusable() accepts device-local staged regions, which have a buffer, so CopiedBytes() can be nonzero for a shared object. Draw snapshots were affected too: ReusableDrawSnapshot hands the next draw the same buffer. Recorder::KeepBytes(owner, bytes) now counts an owner once per batch through a per-batch set, and all three sites use it. An object used by two batches that are both in flight still counts once in each. That errs toward waiting early, never late. Tested on Linux with lavapipe, with the PR merged into current main: the libSceAgcDriver ctest scope gives 320/320 passing (27 skipped because llvmpipe has subgroup size 8).
Mouhand-Kaddo commented 2026-10-10 10:05:20 +00:00 (Migrated from github.com)

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


Additional platform validation on standalone PR head 6e3e5e48edc11c15f72b57b266876f5832382f75:

Linux: passed — Arch Linux in WSL2 (kernel 6.6.87.2), GCC 16.2.1 20260810; CMake 4.3.1 / Ninja.

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

Tests: agc_driver_graphics.

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

Vulkan: Mesa lavapipe 26.2.4 software Vulkan; no native Linux GPU/retail-title validation.

Internal limitation: write-watched guest-heap mirror subcases returned early because WSL userfaultfd async write protection is unavailable. The other graphics assertions ran; zero CTest skips does not include this internal early return.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6096396001 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2283#issuecomment-6096396001). Originally posted by [Mouhand-Kaddo](https://github.com/Mouhand-Kaddo) on 2026-10-10T10:05:20Z. --- <!-- anyps5-platform-validation:6e3e5e48edc11c15f72b57b266876f5832382f75 --> Additional platform validation on standalone PR head `6e3e5e48edc11c15f72b57b266876f5832382f75`: **Linux: passed** — Arch Linux in WSL2 (kernel 6.6.87.2), GCC 16.2.1 20260810; CMake 4.3.1 / Ninja. Release / `BUILD_TESTING=ON`: built the selected test targets; 1 CTest cases, 0 failures, 0 CTest skips. Tests: `agc_driver_graphics`. Reproduce after building the test targets: `ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_driver_(bda_resources|graphics)$"`. Vulkan: Mesa lavapipe 26.2.4 software Vulkan; no native Linux GPU/retail-title validation. Internal limitation: write-watched guest-heap mirror subcases returned early because WSL userfaultfd async write protection is unavailable. The other graphics assertions ran; zero CTest skips does not include this internal early return.
github-actions[bot] commented 2026-10-10 17:24:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T17:24:55Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#2864 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp L87
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6100219093 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2283#issuecomment-6100219093). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T17:24:55Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #2864 | `core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp` [L87](https://github.com/boykopovar/AnyPS5/blob/d2f43cb87bfca2e391e7955fc312550d872c0016/core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp#L87) | | |
orishamir commented 2026-10-10 19:12:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-10T19:12:17Z.


55b09c0f merges cleanly onto current main (4a747c48) but the new test does not build there: tests/execution/RecordedKeptBytes.cpp:97 calls GuestAllocations::Mutation().Add(block, bytes, true, true), and since c11a9cb5 ("address-based builds map only memory mapped for the GPU") Add takes a fifth gpu argument, so agc_driver_recorded_kept_bytes_tests fails to compile (no matching function for call to ... Add(uint8_t*&, std::size_t&, bool, bool)). #374 and #1619 made the same one-argument adaptation.

With that call changed to Add(block, bytes, true, true, true) locally, the three review points check out on llvmpipe: agc_driver_recorded_kept_bytes, agc_recorder_kept_bytes, agc_driver_bda_device and agc_driver_bda_span_reads pass, and the new test fails under each keep-site revert to main separately: VulkanDevice.cpp ("a dispatch writing a copied 65536 bytes buffer left 0 bytes in its batch's kept bytes"), Draw.cpp ("a draw reading a copied 65536 bytes buffer left 0 bytes ..."), ShaderResources.cpp ("a draw snapshotting a 65536 bytes buffer left 0 bytes ..."). KeepBytes counts an owner once per batch through keptOwners.

AI-assisted: yes (Claude Code Fable 5.1 xhigh)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6101183555 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2283#issuecomment-6101183555). Originally posted by [orishamir](https://github.com/orishamir) on 2026-10-10T19:12:17Z. --- `55b09c0f` merges cleanly onto current `main` (`4a747c48`) but the new test does not build there: `tests/execution/RecordedKeptBytes.cpp:97` calls `GuestAllocations::Mutation().Add(block, bytes, true, true)`, and since `c11a9cb5` ("address-based builds map only memory mapped for the GPU") `Add` takes a fifth `gpu` argument, so `agc_driver_recorded_kept_bytes_tests` fails to compile (`no matching function for call to ... Add(uint8_t*&, std::size_t&, bool, bool)`). #374 and #1619 made the same one-argument adaptation. With that call changed to `Add(block, bytes, true, true, true)` locally, the three review points check out on llvmpipe: `agc_driver_recorded_kept_bytes`, `agc_recorder_kept_bytes`, `agc_driver_bda_device` and `agc_driver_bda_span_reads` pass, and the new test fails under each keep-site revert to `main` separately: `VulkanDevice.cpp` ("a dispatch writing a copied 65536 bytes buffer left 0 bytes in its batch's kept bytes"), `Draw.cpp` ("a draw reading a copied 65536 bytes buffer left 0 bytes ..."), `ShaderResources.cpp` ("a draw snapshotting a 65536 bytes buffer left 0 bytes ..."). `KeepBytes` counts an owner once per batch through `keptOwners`. AI-assisted: yes (Claude Code Fable 5.1 xhigh)
Scramblrrrr commented 2026-10-10 21:56:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-10T21:56:31Z.


Windows cross-test of #2283 head 55b09c0f, applied to the 007 integration stack at 79dd488f. I included the fifth gpu=true argument in GuestAllocations::Mutation().Add, as identified by orishamir. Public integration head f4d4d041: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-2283-cross-test . Original authorship preserved.

Release MinGW GCC 15.2, Windows 11, RTX 5070 Ti, SPIRV-Tools OFF, Vulkan required: 4/4 selected CTest checks pass (agc_driver_recorded_kept_bytes, agc_recorder_kept_bytes, agc_driver_graphics, agc_host_import_unmap). The execution regression exercises copied dispatch and draw keeps. Its reusable draw-snapshot subcase explicitly returns early here because Windows direct imports use comparisons; this is not a claim that all internal snapshot subcases ran. The owner-deduplication mock regression does run.

This is an integration-stack result, not a standalone build of #2283 on main. A fresh 007 run is next; no game-result claim for this head yet. My standalone prototype 01754bf0 on main 262c0316 also built and passed its 3 selected tests, but I am keeping it as a diagnostic comparison, not submitting a competing PR.

AI-assisted (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102597094 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2283#issuecomment-6102597094). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-10T21:56:31Z. --- Windows cross-test of #2283 head **55b09c0f**, applied to the 007 integration stack at `79dd488f`. I included the fifth `gpu=true` argument in `GuestAllocations::Mutation().Add`, as identified by orishamir. Public integration head **f4d4d041**: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-2283-cross-test . Original authorship preserved. Release MinGW GCC 15.2, Windows 11, RTX 5070 Ti, SPIRV-Tools OFF, Vulkan required: **4/4 selected CTest checks pass** (`agc_driver_recorded_kept_bytes`, `agc_recorder_kept_bytes`, `agc_driver_graphics`, `agc_host_import_unmap`). The execution regression exercises copied dispatch and draw keeps. Its reusable draw-snapshot subcase explicitly returns early here because Windows direct imports use comparisons; this is not a claim that all internal snapshot subcases ran. The owner-deduplication mock regression does run. This is an integration-stack result, not a standalone build of #2283 on main. A fresh 007 run is next; no game-result claim for this head yet. My standalone prototype `01754bf0` on main `262c0316` also built and passed its 3 selected tests, but I am keeping it as a diagnostic comparison, not submitting a competing PR. AI-assisted (Codex).
SleglJan commented 2026-10-10 22:00:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-10T22:00:17Z.


Linux cross-test of 55b09c0f. Setup: CachyOS (kernel 7.2.9, GCC 16.2.1), RTX 3080 (NVIDIA 615.71.09), Release.

Merged onto main 262c0316, SPIRV-Tools on
It merges cleanly. I applied orishamir's adaptation of tests/execution/RecordedKeptBytes.cpp:97 (Add(block, bytes, true, true, true)). As orishamir found, the test doesn't compile on main without it. Full suite: of 712 tests, 707 pass, 4 are skipped and 1 fails.

  • Passing: agc_driver_recorded_kept_bytes, agc_recorder_kept_bytes, agc_driver_graphics, agc_driver_bda_device and agc_driver_bda_span_reads.
  • Skipped: four video_out_flip_* tests, under ctest's offscreen SDL driver.
  • Failed: agc_driver_dcc_keys_first_write, a known failure on this machine (#2767). Neither PR touches it.

007 First Light (PPSA11386)
On main, 007 stops earlier (#2523 row 4), so this was tested on the 007 stack from #2523: Scramblrrrr's 79dd488f with local commits, SPIRV-Tools off, default asynchronous draws, one 240 s run each.

An earlier trace on the 75e319f5 stack from #2523, which has the same GuestBufferMemory code and the same 0-byte draw keep, showed the Planet Coaster pattern at a larger size. Draw builds copied one or both of two sparse 512 MiB regions into new host-visible buffers, about 1 GiB per build, and the draws kept those copies with 0 bytes. On 79dd488f without this PR, available memory falls from 33.8 to 6.1 GiB within 7 s, and my watchdog stops the title.

With the three commits cherry-picked:

  • There's no jump. The lowest available memory is 29.4 GiB, peak RssShmem is 7.3 GiB against 35.4 GiB before, and the run lasts its full 240 s. Frames still stop at the unrelated stall from #2523.
  • There are no vkAllocateMemory errors or what(). The cold cache compiles 2,194 shader variants, and none logs could not be prepared.

Combined with #2992 there's no jump either: the lowest available memory is 27.2 GiB. One thing to know about that combination: CopiedBytes() counts region.end - region.begin, but #2992 cuts a sparse region's copy at bufferEnd. With both applied, a cut region is counted at its full size, so the batch is submitted earlier than its real kept bytes require. The full table is in #2523.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102627894 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2283#issuecomment-6102627894). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-10T22:00:17Z. --- Linux cross-test of 55b09c0f. Setup: CachyOS (kernel 7.2.9, GCC 16.2.1), RTX 3080 (NVIDIA 615.71.09), Release. **Merged onto `main` 262c0316, SPIRV-Tools on** It merges cleanly. I applied orishamir's adaptation of `tests/execution/RecordedKeptBytes.cpp:97` (`Add(block, bytes, true, true, true)`). As orishamir found, the test doesn't compile on `main` without it. Full suite: of 712 tests, 707 pass, 4 are skipped and 1 fails. - Passing: `agc_driver_recorded_kept_bytes`, `agc_recorder_kept_bytes`, `agc_driver_graphics`, `agc_driver_bda_device` and `agc_driver_bda_span_reads`. - Skipped: four `video_out_flip_*` tests, under ctest's offscreen SDL driver. - Failed: `agc_driver_dcc_keys_first_write`, a known failure on this machine (#2767). Neither PR touches it. **007 First Light (PPSA11386)** On `main`, 007 stops earlier (#2523 row 4), so this was tested on the 007 stack from #2523: Scramblrrrr's 79dd488f with local commits, SPIRV-Tools off, default asynchronous draws, one 240 s run each. An earlier trace on the 75e319f5 stack from #2523, which has the same `GuestBufferMemory` code and the same 0-byte draw keep, showed the Planet Coaster pattern at a larger size. Draw builds copied one or both of two sparse 512 MiB regions into new host-visible buffers, about 1 GiB per build, and the draws kept those copies with 0 bytes. On 79dd488f without this PR, available memory falls from 33.8 to 6.1 GiB within 7 s, and my watchdog stops the title. With the three commits cherry-picked: - There's no jump. The lowest available memory is 29.4 GiB, peak RssShmem is 7.3 GiB against 35.4 GiB before, and the run lasts its full 240 s. Frames still stop at the unrelated stall from #2523. - There are no `vkAllocateMemory` errors or `what()`. The cold cache compiles 2,194 shader variants, and none logs `could not be prepared`. Combined with #2992 there's no jump either: the lowest available memory is 27.2 GiB. One thing to know about that combination: `CopiedBytes()` counts `region.end - region.begin`, but #2992 cuts a sparse region's copy at `bufferEnd`. With both applied, a cut region is counted at its full size, so the batch is submitted earlier than its real kept bytes require. The full table is in [#2523](https://github.com/boykopovar/AnyPS5/issues/2523#issuecomment-6102597271). AI-assisted: yes (Claude Code)
Scramblrrrr commented 2026-10-10 22:04:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-10T22:04:07Z.


Follow-up to #2283: I reproduced a buffer-only enforcement gap and pushed 0280ac32 on codex/recorder-buffer-only-budget-followup (parent integration f4d4d041): github.com/Scramblrrrr/AnyPS5@0280ac32 . This is a 24-line follow-up, not a competing copied-byte implementation.

The existing bound checks are in sampled/storage texture lookups. A dispatch with no images can keep adding counted buffers without reaching either check. The new Vulkan regression records one buffer-only dispatch, seeds that open batch at the existing byte budget using a kept test holder, then dispatches to a distinct buffer. It requires that the preceding batch has submitted. The helper holds GuestMemory::GpuMutex, matching the driver's calling convention; no giant allocation or title data is needed.

Negative control: with #2283's byte accounting but no entry checks, the regression fails: a buffer-only dispatch did not submit the preceding batch at its kept-byte budget. Positive: budget checks at ordinary/recipe dispatch and draw entry points, before recording new work, make it pass. The four selected Windows tests pass again with Vulkan required. Snapshot subcase remains explicitly untested here as reported above. Conventions and diff checks pass. These are integration-stack checks, not a standalone whole-suite result.

@MathiasDevelopes, happy for you to fold the follow-up into #2283 with authorship preserved if useful. It depends on #2283's recorded-kept-bytes fixture; the integration also has the already reported fifth gpu=true registration argument.

The currently running 007 process still has f4d4d041, not this follow-up, so I am not attributing its behavior to these entry checks. At 369 flips it remains black, paused/resumed under the memory guard during the same large NVIDIA pipeline compilation. No playability claim.

AI-assisted (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102659946 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2283#issuecomment-6102659946). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-10T22:04:07Z. --- Follow-up to #2283: I reproduced a buffer-only enforcement gap and pushed **0280ac32** on `codex/recorder-buffer-only-budget-followup` (parent integration `f4d4d041`): https://github.com/Scramblrrrr/AnyPS5/commit/0280ac32 . This is a 24-line follow-up, not a competing copied-byte implementation. The existing bound checks are in sampled/storage texture lookups. A dispatch with no images can keep adding counted buffers without reaching either check. The new Vulkan regression records one buffer-only dispatch, seeds that open batch at the existing byte budget using a kept test holder, then dispatches to a distinct buffer. It requires that the preceding batch has submitted. The helper holds `GuestMemory::GpuMutex`, matching the driver's calling convention; no giant allocation or title data is needed. **Negative control:** with #2283's byte accounting but no entry checks, the regression fails: `a buffer-only dispatch did not submit the preceding batch at its kept-byte budget`. **Positive:** budget checks at ordinary/recipe dispatch and draw entry points, before recording new work, make it pass. The four selected Windows tests pass again with Vulkan required. Snapshot subcase remains explicitly untested here as reported above. Conventions and diff checks pass. These are integration-stack checks, not a standalone whole-suite result. @MathiasDevelopes, happy for you to fold the follow-up into #2283 with authorship preserved if useful. It depends on #2283's recorded-kept-bytes fixture; the integration also has the already reported fifth `gpu=true` registration argument. The currently running 007 process still has **f4d4d041**, not this follow-up, so I am not attributing its behavior to these entry checks. At 369 flips it remains black, paused/resumed under the memory guard during the same large NVIDIA pipeline compilation. No playability claim. AI-assisted (Codex).
SleglJan commented 2026-10-10 22:25:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-10T22:25:23Z.


Linux check of @Scramblrrrr's follow-up 0280ac32. Setup: CachyOS (kernel 7.2.9, GCC 16.2.1), RTX 3080 (NVIDIA 615.71.09), Release, SPIRV-Tools on. Tested on main a3c43ad2 with #2283 (55b09c0f) merged, then f4d4d041 (the fifth gpu argument) and 0280ac32 cherry-picked.

  • Full suite. Of 722 tests, 717 pass and 4 are skipped: video_out_flip_{lifetime,reopen,controls,overlay}, under the SDL_VIDEODRIVER=offscreen their CMake registration sets. One fails: agc_driver_dcc_keys_first_write, a known failure on this machine (#2767).
  • The four selected tests pass: agc_driver_recorded_kept_bytes, agc_recorder_kept_bytes, agc_driver_graphics and agc_host_import_unmap.
  • The draw-snapshot subcase runs here. agc_driver_recorded_kept_bytes prints recorded kept bytes tests passed without "(draw snapshots not tested)", so the reusable-snapshot case that returned early on your Windows run passes on this setup.
  • Negative control. With 0280ac32's four BoundKeptBytes() entry checks reverted (both source files set back to its parent) and its test kept, agc_driver_recorded_kept_bytes fails with a buffer-only dispatch did not submit the preceding batch at its kept-byte budget.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102831603 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2283#issuecomment-6102831603). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-10T22:25:23Z. --- Linux check of @Scramblrrrr's follow-up 0280ac32. Setup: CachyOS (kernel 7.2.9, GCC 16.2.1), RTX 3080 (NVIDIA 615.71.09), Release, SPIRV-Tools on. Tested on `main` a3c43ad2 with #2283 (55b09c0f) merged, then f4d4d041 (the fifth `gpu` argument) and 0280ac32 cherry-picked. - **Full suite.** Of 722 tests, 717 pass and 4 are skipped: `video_out_flip_{lifetime,reopen,controls,overlay}`, under the `SDL_VIDEODRIVER=offscreen` their CMake registration sets. One fails: `agc_driver_dcc_keys_first_write`, a known failure on this machine (#2767). - **The four selected tests pass:** `agc_driver_recorded_kept_bytes`, `agc_recorder_kept_bytes`, `agc_driver_graphics` and `agc_host_import_unmap`. - **The draw-snapshot subcase runs here.** `agc_driver_recorded_kept_bytes` prints `recorded kept bytes tests passed` without "(draw snapshots not tested)", so the reusable-snapshot case that returned early on your Windows run passes on this setup. - **Negative control.** With 0280ac32's four `BoundKeptBytes()` entry checks reverted (both source files set back to its parent) and its test kept, `agc_driver_recorded_kept_bytes` fails with `a buffer-only dispatch did not submit the preceding batch at its kept-byte budget`. AI-assisted: yes (Claude Code)
adriadam10 commented 2026-10-10 22:37:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T22:37:12Z.

Review: APPROVED


Thanks, the new tests address the earlier review. Checked on current main:

  • The new execution test did not build against main: GuestAllocations::Mutation().Add now takes a fifth gpu argument (tests/execution/RecordedKeptBytes.cpp:97, found by @orishamir). Added as our own commit Add(block, bytes, true, true, true).
  • Build and ctest of bda_resources, recorder_kept_bytes and recorded_kept_bytes pass. Without the change the tests don't compile; removing the KeepBytes call at VulkanDevice.cpp:3489 or Draw.cpp:1436 makes agc_driver_recorded_kept_bytes fail.
  • Cross-tests by @Scramblrrrr (Windows) and @SleglJan (Linux, RTX 3080) agree.

Merging once the full Build workflow is green. The buffer-only follow-up (0280ac32) can go in its own PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5481058036 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2283#pullrequestreview-5481058036). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T22:37:12Z. **Review:** APPROVED --- Thanks, the new tests address the earlier review. Checked on current `main`: - The new execution test did not build against `main`: `GuestAllocations::Mutation().Add` now takes a fifth `gpu` argument (`tests/execution/RecordedKeptBytes.cpp:97`, found by @orishamir). Added as our own commit `Add(block, bytes, true, true, true)`. - Build and ctest of `bda_resources`, `recorder_kept_bytes` and `recorded_kept_bytes` pass. Without the change the tests don't compile; removing the `KeepBytes` call at `VulkanDevice.cpp:3489` or `Draw.cpp:1436` makes `agc_driver_recorded_kept_bytes` fail. - Cross-tests by @Scramblrrrr (Windows) and @SleglJan (Linux, RTX 3080) agree. Merging once the full Build workflow is green. The buffer-only follow-up (0280ac32) can go in its own PR.
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!2283
No description provided.