feat(libSceNpTus): run the try-and-set variable calls offline #8925

Closed
pipe1os wants to merge 3 commits from upstream-pr/8925 into main
pipe1os commented 2026-10-21 06:28:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pipe1os on 2026-10-21T06:28:47Z.


What

The 12 sceNpTusTryAndSetVariable* calls threw not implemented. They now use the offline model the other TUS calls already use: the arguments are checked, and a started request finishes with SCE_NP_ERROR_SIGNED_OUT (0x80550006), or ABORTED after sceNpTusAbortRequest.

  • Async: sceNpTusTryAndSetVariableAsync, ...VUserAsync, ...AAsync, ...AVUserAsync, ...ForCrossSaveAsync and ...ForCrossSaveVUserAsync.
  • Blocking: sceNpTusTryAndSetVariable, ...VUser, ...A, ...AVUser, ...ForCrossSave and ...ForCrossSaveVUser run the async call and return its error, the wait error or the request result.

Signatures and checks follow shadPS4 function by function. A null target or resultVariable is INSUFFICIENT_ARGUMENT, an option or a negative slotId is INVALID_ARGUMENT, and an empty virtual user ID is INVALID_ARGUMENT, checked after opeType. An opeType outside 1 to 6 differs between the calls in shadPS4: INVALID_ARGUMENT in the NpId and VUser calls, INVALID_TYPE (0x80550711) in the account ID, AVUser and cross-save calls. The cross-save calls have the same checks as the account ID ones, so they call them. Like the other TUS calls, resultVariableSize isn't checked and nothing is written, because the variable layouts aren't verified; the test checks that the buffer stays untouched. RPCS3's PS3 module doesn't check opeType or an empty virtual user ID, which the new debt entry records.

The 12 "unknown signature" debt lines are gone, the variable output entry now covers resultVariable, and the new entry says where the checks come from and where the sources disagree.

tools/progress.py --compare against main + #8805: +12 implemented functions, libSceNpTus only. The NID-patched libSceNpTus.prx exports the same 136 NIDs as before.

tools/pr_overlap.py --branch lists only #6977, which already conflicts with main, the same as on #8805.

This builds on #8805: the blocking calls use its sceNpTusWaitAsync path. Until #8805 merges, its commit shows up here too.

Tested

  • Windows 11 Pro 26300, WinLibs GCC 15.2.0, Ninja, Release, BUILD_TESTING=ON, main a07e985c8f + #8805 a7d5b6a89: ctest --test-dir build -R '^guest_np_tus$' passes.
  • With Export.cpp put back to #8805 and the new test kept, it fails with sceNpTusTryAndSetVariableAsync not implemented (0xc0000409).
  • The changed files compile with -Wall -Wextra without warnings.
  • Linux: not built.
  • No title was run. I don't know of a title that stops on these calls.
  • tools/check_conventions.py --base origin/main passes, and tools/check_test_registration.py reports nothing new.

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: #8805
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4947388935 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8925). Originally posted by [pipe1os](https://github.com/pipe1os) on 2026-10-21T06:28:47Z. --- ### What The 12 `sceNpTusTryAndSetVariable*` calls threw `not implemented`. They now use the offline model the other TUS calls already use: the arguments are checked, and a started request finishes with `SCE_NP_ERROR_SIGNED_OUT` (`0x80550006`), or `ABORTED` after `sceNpTusAbortRequest`. - Async: `sceNpTusTryAndSetVariableAsync`, `...VUserAsync`, `...AAsync`, `...AVUserAsync`, `...ForCrossSaveAsync` and `...ForCrossSaveVUserAsync`. - Blocking: `sceNpTusTryAndSetVariable`, `...VUser`, `...A`, `...AVUser`, `...ForCrossSave` and `...ForCrossSaveVUser` run the async call and return its error, the wait error or the request result. Signatures and checks follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/c1b26558352b863f80142256e4df38585aa7d727/src/core/libraries/np/np_tus/np_tus.cpp) function by function. A null target or `resultVariable` is `INSUFFICIENT_ARGUMENT`, an `option` or a negative `slotId` is `INVALID_ARGUMENT`, and an empty virtual user ID is `INVALID_ARGUMENT`, checked after `opeType`. An `opeType` outside 1 to 6 differs between the calls in shadPS4: `INVALID_ARGUMENT` in the NpId and `VUser` calls, `INVALID_TYPE` (`0x80550711`) in the account ID, `AVUser` and cross-save calls. The cross-save calls have the same checks as the account ID ones, so they call them. Like the other TUS calls, `resultVariableSize` isn't checked and nothing is written, because the variable layouts aren't verified; the test checks that the buffer stays untouched. RPCS3's [PS3 module](https://github.com/RPCS3/rpcs3/blob/1a9dca3a3a84a18df866e3021918322bd295160a/rpcs3/Emu/Cell/Modules/sceNpTus.cpp) doesn't check `opeType` or an empty virtual user ID, which the new debt entry records. The 12 "unknown signature" debt lines are gone, the variable output entry now covers `resultVariable`, and the new entry says where the checks come from and where the sources disagree. `tools/progress.py --compare` against `main` + #8805: +12 implemented functions, libSceNpTus only. The NID-patched `libSceNpTus.prx` exports the same 136 NIDs as before. `tools/pr_overlap.py --branch` lists only #6977, which already conflicts with `main`, the same as on #8805. This builds on #8805: the blocking calls use its `sceNpTusWaitAsync` path. Until #8805 merges, its commit shows up here too. ### 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. --> - Windows 11 Pro 26300, WinLibs GCC 15.2.0, Ninja, Release, `BUILD_TESTING=ON`, `main` a07e985c8f + #8805 a7d5b6a89: `ctest --test-dir build -R '^guest_np_tus$'` passes. - With `Export.cpp` put back to #8805 and the new test kept, it fails with `sceNpTusTryAndSetVariableAsync not implemented` (`0xc0000409`). - The changed files compile with `-Wall -Wextra` without warnings. - Linux: not built. - No title was run. I don't know of a title that stops on these calls. - `tools/check_conventions.py --base origin/main` passes, and `tools/check_test_registration.py` reports nothing new. ### 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: #8805 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-21 06:29:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T06:29:36Z.


Progress report (2c4b116 → d79adb5)

📈 System libraries: 42.21% (+0.11%, +12 implemented functions)

✅ 12 implemented
Library Name
libSceNpTus sceNpTusTryAndSetVariable
libSceNpTus sceNpTusTryAndSetVariableA
libSceNpTus sceNpTusTryAndSetVariableAAsync
libSceNpTus sceNpTusTryAndSetVariableAVUser
libSceNpTus sceNpTusTryAndSetVariableAVUserAsync
libSceNpTus sceNpTusTryAndSetVariableAsync
libSceNpTus sceNpTusTryAndSetVariableForCrossSave
libSceNpTus sceNpTusTryAndSetVariableForCrossSaveAsync
libSceNpTus sceNpTusTryAndSetVariableForCrossSaveVUser
libSceNpTus sceNpTusTryAndSetVariableForCrossSaveVUserAsync
libSceNpTus sceNpTusTryAndSetVariableVUser
libSceNpTus sceNpTusTryAndSetVariableVUserAsync
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309631189 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8925#issuecomment-6309631189). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-21T06:29:36Z. --- <!-- progress-report --> ### Progress report (2c4b116 → d79adb5) 📈 **System libraries**: 42.21% (+0.11%, +12 implemented functions) <details> <summary>✅ 12 implemented</summary> | Library | Name | | - | - | | libSceNpTus | `sceNpTusTryAndSetVariable` | | libSceNpTus | `sceNpTusTryAndSetVariableA` | | libSceNpTus | `sceNpTusTryAndSetVariableAAsync` | | libSceNpTus | `sceNpTusTryAndSetVariableAVUser` | | libSceNpTus | `sceNpTusTryAndSetVariableAVUserAsync` | | libSceNpTus | `sceNpTusTryAndSetVariableAsync` | | libSceNpTus | `sceNpTusTryAndSetVariableForCrossSave` | | libSceNpTus | `sceNpTusTryAndSetVariableForCrossSaveAsync` | | libSceNpTus | `sceNpTusTryAndSetVariableForCrossSaveVUser` | | libSceNpTus | `sceNpTusTryAndSetVariableForCrossSaveVUserAsync` | | libSceNpTus | `sceNpTusTryAndSetVariableVUser` | | libSceNpTus | `sceNpTusTryAndSetVariableVUserAsync` | </details>
github-actions[bot] commented 2026-10-21 06:39:55 +00:00 (Migrated from github.com)

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


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 9531 core/libs/prx/libSceNpTus/Export.cpp
core/libs/tests/GuestNpTus.cpp
docs/dev/debt/libSceNpTus.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309782422 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8925#issuecomment-6309782422). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-21T06:39:55Z. --- <!-- 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 9531](https://www.github.com/boykopovar/AnyPS5/pull/9531) | `core/libs/prx/libSceNpTus/Export.cpp`<br>`core/libs/tests/GuestNpTus.cpp`<br>`docs/dev/debt/libSceNpTus.md` |
pipe1os commented 2026-10-22 05:59:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pipe1os on 2026-10-22T05:59:09Z.


Closing this: #9009 is merged and covers the same 12 sceNpTusTryAndSetVariable* calls with the same checks, so there's nothing left here to add.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6333898504 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8925#issuecomment-6333898504). Originally posted by [pipe1os](https://github.com/pipe1os) on 2026-10-22T05:59:09Z. --- Closing this: #9009 is merged and covers the same 12 `sceNpTusTryAndSetVariable*` calls with the same checks, so there's nothing left here to add.

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