feat(libSceSaveData): initialize through sceSaveDataInitialize2 #12625

Merged
zaryabzip merged 7 commits from upstream-pr/12625 into main 2026-11-03 08:08:49 +00:00
zaryabzip commented 2026-10-28 23:24:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zaryabzip on 2026-10-28T23:24:02Z.


What

Implements sceSaveDataInitialize2 as sceSaveDataInitialize3 with the same parameter, the way sceSaveDataInitialize already forwards. A title that initializes through the v2 entry point now starts the same save-data session, and sceSaveDataTerminate ends it.

Sources agree that the three initialize entry points are one operation:

  • shadPS4 runs the same initialization for Initialize2 and Initialize3;
  • fpPS4 takes one parameter pointer for all three;
  • SharpEmu also sends Initialize and Initialize2 to one common initializer.

Nothing is measured on a console. The public header gains the parameter, and Initialize2 comes out of the pending-declaration list in the debt file. That list, a single entry of over 6,000 characters, is split into three entries under the length limit, with the same wording and names.

Depends on #10674, which edits the same debt list line. This branch is #10674's head with current main merged in, plus one commit.

The new TestInitialize2 in GuestSaveDataPs4.cpp looks the call up at runtime, because main declares it without parameters. It checks that save-data memory setup is refused before the call, works after it, and is refused again after sceSaveDataTerminate. guest_savedata_ps4_tests now links ${CMAKE_DL_LIBS} for dlsym.

Tested

After the sync with main (8197ab33fd, a debt-text conflict only), Windows 11 and WSL2 reran it: all 7 guest_savedata* tests pass, with guest_savedata_ps4 3 of 3 on --repeat until-fail:3, and no warnings in the changed files. They also pass merged into main ee9a9a66cf. The earlier runs follow.

Windows 11 Home 25H2 (i7-11800H, WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2, Release, BUILD_TESTING=ON) and Ubuntu 24.04.5 on WSL2 (GCC 13.3.0, CMake 3.28.3), both at bc6a5e4ea1 merged into main 3a2b919816 (clean merge):

  • No warnings in the changed files on either host.
  • ctest -R "^guest_savedata|^savedata_": 100% tests passed, 0 tests failed out of 13 on both hosts. savedata_memory_growth_read_failure is skipped on Linux, as always.
  • guest_savedata_ps4 with --repeat until-fail:3: 3 of 3 on both hosts.
  • Baseline: on main with only this test file and the ${CMAKE_DL_LIBS} line, guest_savedata_ps4 builds and then aborts with sceSaveDataInitialize2 not implemented on both hosts (Windows exit 0xc0000409).
  • Every target that includes libSceSaveData/include/Api.hpp builds on both hosts.
  • tools/check_conventions.py passes. Rechecked on reopening against main b9bf246ea2: git merge-tree merges this cleanly with main. It overlaps #12748 and #13551 in the libSceSaveData.native debt line #10674 also edits. It also overlaps #14150 on one neighbouring include/Api.hpp declaration. #14150 implements sceSaveDataGetMountedSaveDataCount, not this export. Whichever merges second needs a one-line rebase.

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: #10674
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5059296168 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12625). Originally posted by [zaryabzip](https://github.com/zaryabzip) on 2026-10-28T23:24:02Z. --- ### What Implements `sceSaveDataInitialize2` as `sceSaveDataInitialize3` with the same parameter, the way `sceSaveDataInitialize` already forwards. A title that initializes through the v2 entry point now starts the same save-data session, and `sceSaveDataTerminate` ends it. Sources agree that the three initialize entry points are one operation: - [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/0614ce324be092791b758d79f93d9f1ca5b10a81/src/core/libraries/save_data/savedata.cpp#L1228-L1238) runs the same initialization for `Initialize2` and `Initialize3`; - [fpPS4](https://github.com/red-prig/fpPS4/blob/04cefd43e6fddd1ab033e7980cd356d14c964905/src/ps4_libscesavedata.pas#L291-L304) takes one parameter pointer for all three; - SharpEmu also sends `Initialize` and `Initialize2` to one common initializer. Nothing is measured on a console. The public header gains the parameter, and `Initialize2` comes out of the pending-declaration list in the debt file. That list, a single entry of over 6,000 characters, is split into three entries under the length limit, with the same wording and names. Depends on #10674, which edits the same debt list line. This branch is #10674's head with current `main` merged in, plus one commit. The new `TestInitialize2` in `GuestSaveDataPs4.cpp` looks the call up at runtime, because `main` declares it without parameters. It checks that save-data memory setup is refused before the call, works after it, and is refused again after `sceSaveDataTerminate`. `guest_savedata_ps4_tests` now links `${CMAKE_DL_LIBS}` for `dlsym`. ### 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. --> After the sync with `main` (8197ab33fd, a debt-text conflict only), Windows 11 and WSL2 reran it: all 7 `guest_savedata*` tests pass, with `guest_savedata_ps4` 3 of 3 on `--repeat until-fail:3`, and no warnings in the changed files. They also pass merged into `main` ee9a9a66cf. The earlier runs follow. Windows 11 Home 25H2 (i7-11800H, WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2, Release, `BUILD_TESTING=ON`) and Ubuntu 24.04.5 on WSL2 (GCC 13.3.0, CMake 3.28.3), both at bc6a5e4ea1 merged into `main` 3a2b919816 (clean merge): - No warnings in the changed files on either host. - `ctest -R "^guest_savedata|^savedata_"`: `100% tests passed, 0 tests failed out of 13` on both hosts. `savedata_memory_growth_read_failure` is skipped on Linux, as always. - `guest_savedata_ps4` with `--repeat until-fail:3`: 3 of 3 on both hosts. - Baseline: on `main` with only this test file and the `${CMAKE_DL_LIBS}` line, `guest_savedata_ps4` builds and then aborts with `sceSaveDataInitialize2 not implemented` on both hosts (Windows exit 0xc0000409). - Every target that includes `libSceSaveData/include/Api.hpp` builds on both hosts. - `tools/check_conventions.py` passes. Rechecked on reopening against `main` b9bf246ea2: `git merge-tree` merges this cleanly with `main`. It overlaps #12748 and #13551 in the `libSceSaveData.native` debt line #10674 also edits. It also overlaps #14150 on one neighbouring `include/Api.hpp` declaration. #14150 implements `sceSaveDataGetMountedSaveDataCount`, not this export. Whichever merges second needs a one-line rebase. ### 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: <!-- #PR, or none --> #10674 - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes (Claude Code)
BunnyFl commented 2026-11-02 01:55:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T01:55:49Z.

Review: APPROVED


Windows 11, WinLibs GCC 15.2.0 r7, Release. Head 8197ab33fd merged into upstream/main 93dbd0f82a:

  • ctest -R '^guest_savedata': 8/8 pass, including guest_savedata_ps4 with the new TestInitialize2 and guest_savedata_dialog.
  • Negative control: with main's libSceSaveData.native/Export.cpp and libSceSaveData/include/Api.hpp, guest_savedata_ps4 aborts with sceSaveDataInitialize2 not implemented. So the test reaches the export through the runtime lookup, as intended.
  • tools/check_conventions.py --base upstream/main --head 8197ab33fd: passes. The split debt entries clear #10674's debt-length warning.

Forwarding to sceSaveDataInitialize3, as sceSaveDataInitialize already does, matches the three references you list. I approved #10674, which this builds on, separately.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5731356247 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12625#pullrequestreview-5731356247). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-02T01:55:49Z. **Review:** APPROVED --- Windows 11, WinLibs GCC 15.2.0 r7, Release. Head 8197ab33fd merged into upstream/main 93dbd0f82a: - `ctest -R '^guest_savedata'`: 8/8 pass, including `guest_savedata_ps4` with the new `TestInitialize2` and `guest_savedata_dialog`. - Negative control: with main's `libSceSaveData.native/Export.cpp` and `libSceSaveData/include/Api.hpp`, `guest_savedata_ps4` aborts with `sceSaveDataInitialize2 not implemented`. So the test reaches the export through the runtime lookup, as intended. - `tools/check_conventions.py --base upstream/main --head 8197ab33fd`: passes. The split debt entries clear #10674's `debt-length` warning. Forwarding to `sceSaveDataInitialize3`, as `sceSaveDataInitialize` already does, matches the three references you list. I approved #10674, which this builds on, separately.
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!12625
No description provided.