fix(agc): reuse a host import only while it covers its region #2101

Closed
johnmaia wants to merge 1 commit from upstream-pr/2101 into main
johnmaia commented 2026-10-09 08:37:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-09T08:37:09Z.


What

UploadPrepare merges overlapping regions. At the lease, a registered range takes a host import of exactly its size and records it in direct. When a descriptor range runs past that range's end, and into the next registered range, all three merge into one region. The merged region keeps the first range's import in direct.

UploadPrepare and UploadFinish then reuse that import while the import epoch is unchanged. Descriptor binds the view only up to the import's end and throws guest buffer view exceeds its GPU owner.

Both reuse sites now keep the import only while it covers the whole region. Otherwise the region looks an import up again (findImport already requires coverage) or is copied, as before.

Disney Epic Mickey: Rebrushed (PPSA15657, UE4) stopped at its first presentation on this. A 0x50000-byte import was kept for a merged 0x80000-byte region, under a 0x7f800-byte storage view at its base.

Tested

Linux (Ubuntu 24.04, GCC), RX 7600 (RADV).

  • agc_driver_recorder_tests gets crossingImportTests. It registers two adjacent 64 KiB ranges, imports both, and binds a 512-byte view across their boundary in an address-based build. On main it throws guest buffer view exceeds its GPU owner; with the change it passes.
  • The full ctest passes, 497/497.
  • tools/check_conventions.py and tools/check_test_registration.py pass.
  • PPSA15657, on main with a local stack of open PRs: before, its first presentation fails with this error. With the change, the stale import is dropped once, and the title gets past it to the next stops (#1901 / #1902, #1927 / #1928, then layered color targets).

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
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_0134RWCyiyydJBbfKz8g9Bwe

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4798090720 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2101). Originally posted by [johnmaia](https://github.com/johnmaia) on 2026-10-09T08:37:09Z. --- ### What `UploadPrepare` merges overlapping regions. At the lease, a registered range takes a host import of exactly its size and records it in `direct`. When a descriptor range runs past that range's end, and into the next registered range, all three merge into one region. The merged region keeps the first range's import in `direct`. `UploadPrepare` and `UploadFinish` then reuse that import while the import epoch is unchanged. `Descriptor` binds the view only up to the import's end and throws `guest buffer view exceeds its GPU owner`. Both reuse sites now keep the import only while it covers the whole region. Otherwise the region looks an import up again (`findImport` already requires coverage) or is copied, as before. Disney Epic Mickey: Rebrushed (PPSA15657, UE4) stopped at its first presentation on this. A 0x50000-byte import was kept for a merged 0x80000-byte region, under a 0x7f800-byte storage view at its base. ### Tested Linux (Ubuntu 24.04, GCC), RX 7600 (RADV). - `agc_driver_recorder_tests` gets `crossingImportTests`. It registers two adjacent 64 KiB ranges, imports both, and binds a 512-byte view across their boundary in an address-based build. On `main` it throws `guest buffer view exceeds its GPU owner`; with the change it passes. - The full `ctest` passes, 497/497. - `tools/check_conventions.py` and `tools/check_test_registration.py` pass. - PPSA15657, on `main` with a local stack of open PRs: before, its first presentation fails with this error. With the change, the stale import is dropped once, and the title gets past it to the next stops (#1901 / #1902, #1927 / #1928, then layered color targets). ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed 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] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0134RWCyiyydJBbfKz8g9Bwe
rmz-24 commented 2026-10-09 12:26:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rmz-24 on 2026-10-09T12:26:12Z.


Windows run: Windows 11 Pro 25H2 (10.0.26200.9457), RTX 5060 Ti (NVIDIA 617.42), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON, full build plus libs. b597c7fe cherry-picked onto current main d70b8998 (applies cleanly).

  • agc_driver_recorder_tests (not in ctest, run directly): crossingImportTests runs and passes on this host; the suite then stops at the unrelated refresh-store assertion from #2155, as main does on Windows. With the test change proposed in #2155 applied on top, the whole recorder suite passes.
  • Full ctest: 509/510; the one failure was windows_import_modules, the intermittent Windows Error Reporting timeout fixed by #2227, unrelated to this change.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6080848191 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2101#issuecomment-6080848191). Originally posted by [rmz-24](https://github.com/rmz-24) on 2026-10-09T12:26:12Z. --- Windows run: Windows 11 Pro 25H2 (10.0.26200.9457), RTX 5060 Ti (NVIDIA 617.42), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, `-DANYPS5_ENABLE_SPIRV_TOOLS=ON`, full build plus `libs`. b597c7fe cherry-picked onto current `main` d70b8998 (applies cleanly). - `agc_driver_recorder_tests` (not in ctest, run directly): `crossingImportTests` runs and passes on this host; the suite then stops at the unrelated refresh-store assertion from #2155, as `main` does on Windows. With the test change proposed in #2155 applied on top, the whole recorder suite passes. - Full ctest: 509/510; the one failure was `windows_import_modules`, the intermittent Windows Error Reporting timeout fixed by #2227, unrelated to this change. AI-assisted: yes
oneandonlydean commented 2026-10-09 20:08:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:08:50Z.


Closing: #1489 (merged since) drops the import in UploadPrepare when a merge takes a region past its end, which is this case. Please reopen if PPSA15657 still stops at guest buffer view exceeds its GPU owner on current main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088424705 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2101#issuecomment-6088424705). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T20:08:50Z. --- Closing: #1489 (merged since) drops the import in `UploadPrepare` when a merge takes a region past its end, which is this case. Please reopen if PPSA15657 still stops at `guest buffer view exceeds its GPU owner` on current main.

Pull request closed

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!2101
No description provided.