fix(ajm): keep batch handles within their creating context #7789

Merged
JJenkx merged 1 commit from upstream-pr/7789 into main 2026-10-20 01:45:03 +00:00
JJenkx commented 2026-10-19 07:37:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-19T07:37:20Z.


What

Keep each completed AJM batch associated with the context that started it. Previously another initialized context could cancel the batch or wait on it and consume its handle. Wrong-context operations now return INVALID_BATCH without consuming the owner's batch. Start and wait also reject context IDs that initialization has not allocated, matching the existing cancel check.

Add a two-context regression covering cross-context access, invalid contexts, owner access after rejected operations and repeated waits. Document the remaining finalization and synchronous-execution limitations. Context ownership follows the shadPS4 implementation cited in the debt entry; this has not been verified on PS5 hardware. No title unblock or performance improvement is claimed.

Tested

Linux x86-64 Release, AMD Ryzen 9 7950X, rebased on main d8d0222d02:

  • The new two-context regression aborts on unmodified main fb0dc118f3; it passes with this change.
  • Full libs build passed.
  • guest_ajm, guest_ajm_teardown, atrac9_gradient and atrac9_config_data: 4/4 passed, zero skipped (0.05 seconds).
  • python3 tools/check_conventions.py --base origin/main and git diff --check passed.
  • tools/pr_overlap.py required manual comparison with #3205 and #6044. #3205 adds an unrelated error-string test; #6044 only relocates this test file unchanged to tests/media/GuestAjm.cpp (R100). Neither implements batch ownership; no functional dependency. Other comparisons reported no overlap.
  • After rebasing onto d8d0222d02, the full libs build and 15 allocator/AJM/ATRAC9 tests passed with zero skips (0.07 seconds).
  • No native title test or GPU change.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4917531136 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7789). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-19T07:37:20Z. --- ### What Keep each completed AJM batch associated with the context that started it. Previously another initialized context could cancel the batch or wait on it and consume its handle. Wrong-context operations now return INVALID_BATCH without consuming the owner's batch. Start and wait also reject context IDs that initialization has not allocated, matching the existing cancel check. Add a two-context regression covering cross-context access, invalid contexts, owner access after rejected operations and repeated waits. Document the remaining finalization and synchronous-execution limitations. Context ownership follows the shadPS4 implementation cited in the debt entry; this has not been verified on PS5 hardware. No title unblock or performance improvement is claimed. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Linux x86-64 Release, AMD Ryzen 9 7950X, rebased on main d8d0222d0289d10bbd110c72bbd8c0b1f1984c8b: - The new two-context regression aborts on unmodified main fb0dc118f338; it passes with this change. - Full `libs` build passed. - `guest_ajm`, `guest_ajm_teardown`, `atrac9_gradient` and `atrac9_config_data`: 4/4 passed, zero skipped (0.05 seconds). - `python3 tools/check_conventions.py --base origin/main` and `git diff --check` passed. - `tools/pr_overlap.py` required manual comparison with #3205 and #6044. #3205 adds an unrelated error-string test; #6044 only relocates this test file unchanged to `tests/media/GuestAjm.cpp` (R100). Neither implements batch ownership; no functional dependency. Other comparisons reported no overlap. - After rebasing onto d8d0222d0289, the full `libs` build and 15 allocator/AJM/ATRAC9 tests passed with zero skips (0.07 seconds). - No native title test or GPU change. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
github-actions[bot] commented 2026-10-19 07:44:19 +00:00 (Migrated from github.com)

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


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 3205 core/libs/tests/GuestAjm.cpp
PR 6044 core/libs/tests/GuestAjm.cpp
PR 8106 docs/dev/debt/libSceAjm.native.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6262266772 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7789#issuecomment-6262266772). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T07:44:19Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 3205](https://www.github.com/boykopovar/AnyPS5/pull/3205) | `core/libs/tests/GuestAjm.cpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestAjm.cpp` | | [PR 8106](https://www.github.com/boykopovar/AnyPS5/pull/8106) | `docs/dev/debt/libSceAjm.native.md` |
adriadam10 commented 2026-10-20 01:50:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T01:50:44Z.


Checked the batch map against shadPS4 (per-context batches, INVALID_CONTEXT for unknown contexts), the cross-context, invalid-context and repeated-wait cases in the new test, and the debt entry; merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6281450557 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7789#issuecomment-6281450557). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-20T01:50:44Z. --- Checked the batch map against shadPS4 (per-context batches, INVALID_CONTEXT for unknown contexts), the cross-context, invalid-context and repeated-wait cases in the new test, and the debt entry; merged.
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!7789
No description provided.