fix(agc): enforce the kept-byte budget before buffer-only work #3211

Merged
Scramblrrrr merged 1 commit from upstream-pr/3211 into main 2026-10-11 07:20:13 +00:00
Scramblrrrr commented 2026-10-11 01:27:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-11T01:27:33Z.


What

A buffer-only dispatch can keep recording copied buffers beyond the 512 MiB recorder budget after #2283: the accounting increments, but the existing enforcement checks are reached through sampled/storage-image lookup. A dispatch with no images reaches neither check.

Check BoundKeptBytes() at ordinary and recipe dispatch/draw entry, before recording the next work. This submits the preceding batch when its counted bytes reach the existing budget. Byte accounting, owner deduplication and the budget itself stay in #2283. This is the follow-up originally offered there as 0280ac32, rebased onto main d31b57a4 as 4fd6192d (earlier standalone build c11b5292f on 77bd928a3).

The regression dispatches to one buffer, charges a kept test owner at the existing budget, 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. The charge is synthetic; it avoids a huge test allocation while exercising actual buffer-only dispatch and batch submission.

Tested

Windows 11, MinGW GCC 15.2, Release, RTX 5070 Ti, Vulkan required, SPIRV-Tools off:

  • Standalone main-based 4fd6192d (base d31b57a4), and the preceding c11b5292f build: 4/4 selected tests pass: agc_driver_recorded_kept_bytes, agc_recorder_kept_bytes, agc_driver_graphics, agc_host_import_unmap. Relevant targets and dependencies were built; the full suite was not run.
  • Negative control on the earlier #2283 integration: with the new regression and proper GPU mutex but the four entry checks omitted, the recorded-kept-bytes test fails: a buffer-only dispatch did not submit the preceding batch at its kept-byte budget. Adding the checks passes.
  • Independent Linux cross-test of the same 0280ac32 diff by SleglJan, on main a3c43ad2 plus #2283: four selected tests pass; reverting the entry checks fails the same regression. Of 722 full-suite tests, 717 pass, four skip and the known DCC-key first-write failure remains (#2767). Cross-test and negative control.
  • The draw-snapshot subcase returns early on this Windows configuration; it ran and passed in the Linux cross-test. Copied-buffer and budget-entry assertions run on Windows.
  • Conventions and git diff checks pass.

007 integration testing is tracked in #2523. It remains visually black; this PR does not claim playability or solve the separate wait/compiler delays.

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; 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
  • Generic behaviour, not specific to one title
  • Depends on: none (#2283 is merged)
  • AI-assisted: yes (Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4815763909 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3211). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-11T01:27:33Z. --- ### What A buffer-only dispatch can keep recording copied buffers beyond the 512 MiB recorder budget after #2283: the accounting increments, but the existing enforcement checks are reached through sampled/storage-image lookup. A dispatch with no images reaches neither check. Check `BoundKeptBytes()` at ordinary and recipe dispatch/draw entry, before recording the next work. This submits the preceding batch when its counted bytes reach the existing budget. Byte accounting, owner deduplication and the budget itself stay in #2283. This is the follow-up originally offered there as 0280ac32, rebased onto main d31b57a4 as 4fd6192d (earlier standalone build c11b5292f on 77bd928a3). The regression dispatches to one buffer, charges a kept test owner at the existing budget, 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. The charge is synthetic; it avoids a huge test allocation while exercising actual buffer-only dispatch and batch submission. ### Tested Windows 11, MinGW GCC 15.2, Release, RTX 5070 Ti, Vulkan required, SPIRV-Tools off: - Standalone main-based 4fd6192d (base d31b57a4), and the preceding c11b5292f build: 4/4 selected tests pass: agc_driver_recorded_kept_bytes, agc_recorder_kept_bytes, agc_driver_graphics, agc_host_import_unmap. Relevant targets and dependencies were built; the full suite was not run. - Negative control on the earlier #2283 integration: with the new regression and proper GPU mutex but the four entry checks omitted, the recorded-kept-bytes test fails: `a buffer-only dispatch did not submit the preceding batch at its kept-byte budget`. Adding the checks passes. - Independent Linux cross-test of the same 0280ac32 diff by SleglJan, on main a3c43ad2 plus #2283: four selected tests pass; reverting the entry checks fails the same regression. Of 722 full-suite tests, 717 pass, four skip and the known DCC-key first-write failure remains (#2767). [Cross-test and negative control](https://github.com/boykopovar/AnyPS5/pull/2283#issuecomment-6102831603). - The draw-snapshot subcase returns early on this Windows configuration; it ran and passed in the Linux cross-test. Copied-buffer and budget-entry assertions run on Windows. - Conventions and git diff checks pass. 007 integration testing is tracked in #2523. It remains visually black; this PR does not claim playability or solve the separate wait/compiler delays. ### 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; 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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none (#2283 is merged) - [x] AI-assisted: yes (Codex)
github-actions[bot] commented 2026-10-11 01:27:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T01:27:43Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104191303 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3211#issuecomment-6104191303). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T01:27:43Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
SleglJan commented 2026-10-11 01:36:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-11T01:36:51Z.


@Scramblrrrr #3211 was closed by the intake bot (fewer than 10 merged PRs), not on its merits. If you'd like, I can open it from my account with your commit and authorship unchanged, as #2976 carried @queeeef's #2909. I already ran the same change (0280ac32) on Linux: comment on #2283. The four selected tests pass, the draw-snapshot subcase runs, and with the four entry checks reverted the new test fails with your message. Reply here if you want that; I won't open it otherwise.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104256305 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3211#issuecomment-6104256305). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-11T01:36:51Z. --- @Scramblrrrr #3211 was closed by the intake bot (fewer than 10 merged PRs), not on its merits. If you'd like, I can open it from my account with your commit and authorship unchanged, as #2976 carried @queeeef's #2909. I already ran the same change (0280ac32) on Linux: [comment on #2283](https://github.com/boykopovar/AnyPS5/pull/2283#issuecomment-6102831603). The four selected tests pass, the draw-snapshot subcase runs, and with the four entry checks reverted the new test fails with your message. Reply here if you want that; I won't open it otherwise. AI-assisted: yes (Claude Code)
adriadam10 commented 2026-10-11 07:20:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:20:09Z.


Checked the four entry checks (dispatch, DispatchRecipe, Draw, DrawWithRecipe) and the new buffer-only regression. Built libSceAgcDriver and ran its 354 tests (all pass, incl. agc_driver_recorded_kept_bytes); with the checks reverted the new test fails. Also matches @SleglJan's Linux/NVIDIA cross-test. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106616947 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3211#issuecomment-6106616947). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T07:20:09Z. --- Checked the four entry checks (`dispatch`, `DispatchRecipe`, `Draw`, `DrawWithRecipe`) and the new buffer-only regression. Built libSceAgcDriver and ran its 354 tests (all pass, incl. `agc_driver_recorded_kept_bytes`); with the checks reverted the new test fails. Also matches @SleglJan's Linux/NVIDIA cross-test. Merging once CI is green.
Scramblrrrr commented 2026-10-11 13:25:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-11T13:25:04Z.


Thanks @adriadam10 for the build, all-354-test run and negative-control verification, and @SleglJan for the independent Linux/NVIDIA cross-test. Confirmed #3211 merged at df23cab62b. We are continuing the 007 integration tests and keeping separate storage-image pins / descriptor-heap copies distinct from this kept-byte entry check. AI-assisted (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109495817 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3211#issuecomment-6109495817). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-11T13:25:04Z. --- Thanks @adriadam10 for the build, all-354-test run and negative-control verification, and @SleglJan for the independent Linux/NVIDIA cross-test. Confirmed #3211 merged at df23cab62b49503c1f442496a8cb98edf982d2e7. We are continuing the 007 integration tests and keeping separate storage-image pins / descriptor-heap copies distinct from this kept-byte entry check. AI-assisted (Codex).
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!3211
No description provided.