feat(libSceHmd2): report the uninitialized library from the device exports #3242

Closed
dantdmdarealguy wants to merge 1 commit from upstream-pr/3242 into main
dantdmdarealguy commented 2026-10-11 03:11:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by dantdmdarealguy on 2026-10-11T03:11:59Z.


What

libSceHmd2 (PS VR2) keeps the model of #1347: sceHmd2Initialize fails because there is no PS VR2 runtime. The library therefore never leaves its uninitialized state, and the five device exports now report that state instead of throwing, with the signatures the console's library is called with:

  • sceHmd2Open(int32_t userId, int32_t type, int32_t index, const OpenParam* param), sceHmd2Close(int32_t handle) and sceHmd2SetVibration(int32_t handle, int32_t strength) return NOT_INITIALIZED (0x8A720002) for any arguments; as in libSceHmd, the initialization check comes before the argument and handle checks.
  • sceHmd2GetDeviceInformation(DeviceInformation* info) and sceHmd2GetFieldOfViewWithoutHandle(FieldOfView* fieldOfView) return PARAMETER_NULL (0x8A720008) for a null output and NOT_INITIALIZED otherwise, leaving the output untouched.
  • The error codes use libSceHmd2's own facility, 0x8A72, which PS5VR observed on a console (0x8A72001A from sceHmd2ReprojectionBeginFrame, 0x8A721003 from the internal camera opens). sceHmd2Initialize moves its placeholder into that facility: 0x8A720016 instead of libSceHmd's 0x81110016 (the low word is still libSceHmd's UNSUPPORTED_FEATURE; the console's code is still unknown). PPSA01317 only tests the result for non-zero.
  • A new Hmd2.hpp (following libSceHmd/Hmd.hpp) holds the error constants, the DeviceInformation (28 bytes), FieldOfView (four tangents) and SizeAlign layouts with static_asserts, and the export declarations.
  • The seven reprojection exports whose signatures PS5VR establishes (ReprojectionInitialize(const void*, const void*), EnableVrMode(uint64_t), DisableVrMode(), BeginFrame(uint64_t), GetPredictedDisplayTime(uint64_t, uint64_t*), and the two Query*BufferSizeAlign() queries returning a size and alignment pair in rax:rdx) are declared with them and still throw: what the console reports for them without a headset is unknown (whether ReprojectionInitialize needs sceHmd2Initialize and what it fails with, whether the other calls fail with NOT_INITIALIZED or REPROJECTION_NOT_INITIALIZED (0x8A72000B) before it, and the sizes the queries return).
  • sceHmd2GazeGetResultForFoveatedRendering, sceHmd2ReprojectionSetAllowPositionalReprojection, sceHmd2ReprojectionSetParamWithBuffer and sceHmd2ReprojectionSetRenderConfig stay declared without parameters and throw; no reference gives their signatures (PS5VR calls SetRenderConfig with three integers, 1, 0, 0, for half-rate rendering, which does not settle the types).
  • TechnicalDebt: the silent-stub entry describes the uninitialized-state model; the sceHmd2Initialize entry records the facility evidence; new entries record the sources of the five implemented exports (signatures, codes, check order, layouts) and of the seven declared reprojection exports and why they throw; the "declared without parameters" entry now names the four remaining exports.

Sources: PS5VR (app/src/app_vr.c, vr_system.c, vr_exports_1360.h: a homebrew that loads the console's libSceHmd2 and plays video in a PS VR2 with these calls), KytyPS5 (src/libs/libHmd2.cpp, hmd2.h, and PR #607), shadPS4's PS4 libSceHmd for the Hmd family's check order and documented error numbering, and ALVR-PS4 for the measured PS4 FieldOfView and DeviceInformation layouts.

Tested

Windows 11, WinLibs MinGW-w64 GCC 15.2.0, Ninja, Release, -DBUILD_TESTING=ON, this branch on current main (961b25fe2):

  • cmake --build --parallel 6 (full) and --target libs pass with no warnings in the touched files; nid_patcher reports OK for libSceHmd2.prx, whose 17 exports keep their NIDs.
  • ctest -R "guest_hmd2|patched_libraries": 2/2 pass. guest_hmd2 checks initialization with and without a param, PARAMETER_NULL for null outputs and untouched outputs on NOT_INITIALIZED, sceHmd2Open with valid and invalid arguments, sceHmd2Close and sceHmd2SetVibration for several handles and an invalid strength, that failed calls create no state, and that sceHmd2ReprojectionInitialize and sceHmd2ReprojectionBeginFrame still throw.
  • python tools/check_test_registration.py and python tools/check_conventions.py --base origin/main pass; tools/progress.py --compare reports +5 implemented (system libraries 84.7%, +0.15%), the 11 throwing exports stay stubs.
  • No title run: PPSA01317 never reaches these exports, as it skips its VR set-up when sceHmd2Initialize fails.

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, some AI assistance was used
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4816213467 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3242). Originally posted by [dantdmdarealguy](https://github.com/dantdmdarealguy) on 2026-10-11T03:11:59Z. --- ### What libSceHmd2 (PS VR2) keeps the model of #1347: `sceHmd2Initialize` fails because there is no PS VR2 runtime. The library therefore never leaves its uninitialized state, and the five device exports now report that state instead of throwing, with the signatures the console's library is called with: - `sceHmd2Open(int32_t userId, int32_t type, int32_t index, const OpenParam* param)`, `sceHmd2Close(int32_t handle)` and `sceHmd2SetVibration(int32_t handle, int32_t strength)` return `NOT_INITIALIZED` (0x8A720002) for any arguments; as in libSceHmd, the initialization check comes before the argument and handle checks. - `sceHmd2GetDeviceInformation(DeviceInformation* info)` and `sceHmd2GetFieldOfViewWithoutHandle(FieldOfView* fieldOfView)` return `PARAMETER_NULL` (0x8A720008) for a null output and `NOT_INITIALIZED` otherwise, leaving the output untouched. - The error codes use libSceHmd2's own facility, 0x8A72, which PS5VR observed on a console (0x8A72001A from `sceHmd2ReprojectionBeginFrame`, 0x8A721003 from the internal camera opens). `sceHmd2Initialize` moves its placeholder into that facility: 0x8A720016 instead of libSceHmd's 0x81110016 (the low word is still libSceHmd's `UNSUPPORTED_FEATURE`; the console's code is still unknown). PPSA01317 only tests the result for non-zero. - A new `Hmd2.hpp` (following `libSceHmd/Hmd.hpp`) holds the error constants, the `DeviceInformation` (28 bytes), `FieldOfView` (four tangents) and `SizeAlign` layouts with static_asserts, and the export declarations. - The seven reprojection exports whose signatures PS5VR establishes (`ReprojectionInitialize(const void*, const void*)`, `EnableVrMode(uint64_t)`, `DisableVrMode()`, `BeginFrame(uint64_t)`, `GetPredictedDisplayTime(uint64_t, uint64_t*)`, and the two `Query*BufferSizeAlign()` queries returning a size and alignment pair in rax:rdx) are declared with them and still throw: what the console reports for them without a headset is unknown (whether `ReprojectionInitialize` needs `sceHmd2Initialize` and what it fails with, whether the other calls fail with `NOT_INITIALIZED` or `REPROJECTION_NOT_INITIALIZED` (0x8A72000B) before it, and the sizes the queries return). - `sceHmd2GazeGetResultForFoveatedRendering`, `sceHmd2ReprojectionSetAllowPositionalReprojection`, `sceHmd2ReprojectionSetParamWithBuffer` and `sceHmd2ReprojectionSetRenderConfig` stay declared without parameters and throw; no reference gives their signatures (PS5VR calls `SetRenderConfig` with three integers, 1, 0, 0, for half-rate rendering, which does not settle the types). - TechnicalDebt: the silent-stub entry describes the uninitialized-state model; the `sceHmd2Initialize` entry records the facility evidence; new entries record the sources of the five implemented exports (signatures, codes, check order, layouts) and of the seven declared reprojection exports and why they throw; the "declared without parameters" entry now names the four remaining exports. Sources: [PS5VR](https://github.com/theghostonline/PS5VR/blob/main/app/src/app_vr.c) (`app/src/app_vr.c`, `vr_system.c`, `vr_exports_1360.h`: a homebrew that loads the console's libSceHmd2 and plays video in a PS VR2 with these calls), [KytyPS5](https://github.com/KytyPS5/KytyPS5/blob/main/src/libs/libHmd2.cpp) (`src/libs/libHmd2.cpp`, `hmd2.h`, and PR #607), shadPS4's PS4 `libSceHmd` for the Hmd family's check order and documented error numbering, and [ALVR-PS4](https://github.com/nicolas-riera/ALVR-PS4/blob/main/docs/psvr-technical-reference.md) for the measured PS4 `FieldOfView` and `DeviceInformation` layouts. ### Tested Windows 11, WinLibs MinGW-w64 GCC 15.2.0, Ninja, Release, `-DBUILD_TESTING=ON`, this branch on current `main` (961b25fe2): - `cmake --build --parallel 6` (full) and `--target libs` pass with no warnings in the touched files; `nid_patcher` reports `OK` for `libSceHmd2.prx`, whose 17 exports keep their NIDs. - `ctest -R "guest_hmd2|patched_libraries"`: 2/2 pass. `guest_hmd2` checks initialization with and without a param, `PARAMETER_NULL` for null outputs and untouched outputs on `NOT_INITIALIZED`, `sceHmd2Open` with valid and invalid arguments, `sceHmd2Close` and `sceHmd2SetVibration` for several handles and an invalid strength, that failed calls create no state, and that `sceHmd2ReprojectionInitialize` and `sceHmd2ReprojectionBeginFrame` still throw. - `python tools/check_test_registration.py` and `python tools/check_conventions.py --base origin/main` pass; `tools/progress.py --compare` reports +5 implemented (system libraries 84.7%, +0.15%), the 11 throwing exports stay stubs. - No title run: PPSA01317 never reaches these exports, as it skips its VR set-up when `sceHmd2Initialize` fails. ### 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 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, some AI assistance was used
github-actions[bot] commented 2026-10-11 03:12:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T03:12:09Z.


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:6104913385 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3242#issuecomment-6104913385). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T03:12:09Z. --- 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.

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