feat(libSceVrTracker): implement memory queries, init and term, device registration and recalibration checks #9224

Merged
YossiYad merged 8 commits from upstream-pr/9224 into main 2026-10-23 03:14:00 +00:00
YossiYad commented 2026-10-21 15:36:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-21T15:36:06Z.


What

10 libSceVrTracker exports threw. They now follow shadPS4's vr_tracker.cpp, whose parameter shapes the declarations already used:

  • sceVrTrackerQueryMemory checks the size, profile (0 or 100) and calibration modes (no automatic HMD calibration). It reports onion 0x400000, or 0x800000 with automatic Move calibration, garlic 0x3000000 and work 0x1000000, all 0x10000-aligned.
  • sceVrTrackerInit and sceVrTrackerTerm hold the initialized state:
    • ALREADY_INITIALIZED comes before any argument check.
    • Init checks the struct size, the three memory ranges against those sizes and alignments, pipe < 7, queue < 8 and the calibration modes.
    • Term without Init is NOT_INIT.
  • sceVrTrackerRegisterDevice, ...2 and ...Internal keep one handle per device type (HMD, DualShock 4, Move, gun) and return DEVICE_ALREADY_REGISTERED for a second one. A type above 3 or an Internal mode above 4 is ARGUMENT_INVALID.
  • sceVrTrackerUnregisterDevice frees the matching handle. A negative or unknown handle is ARGUMENT_INVALID.
  • sceVrTrackerRecalibrate and sceVrTrackerSetDurationUntilStatusNotTracking check their arguments. Recalibration returns DEVICE_NOT_REGISTERED for the HMD (shadPS4's behaviour with no headset) or for a type with no handle.
  • sceVrTrackerGpuWaitAndCpuProcess returns NOT_EXECUTE_GPU_SUBMIT, since without a camera no GPU submission happens.

Unlike shadPS4:

  • The init memory ranges are not looked up in the memory map.
  • A null init parameter is refused.
  • Only the 128-byte init parameter, in shadPS4's layout, is read. The 144-byte version that #9137 describes still throws, since its fields are not mapped to these checks.
  • Negative device types are refused instead of reaching its unreachable branch.

As in shadPS4, Term keeps the registered handles. Not measured on a PS5; the debt entry says so, and the implemented names leave the pending lists.

sceVrTrackerGetTime, sceVrTrackerGpuSubmit and sceVrTrackerGpuWait are left to #8650, which answers them before initialization. Once Init can succeed here, those need an initialized path too. The test goes in its own GuestVrTrackerDevices.cpp because #8650 adds GuestVrTracker.cpp. sceVrTrackerInit takes the VrTrackerInitParam declaration from #9137.

Tested

Linux (Fedora 44, GCC, Ninja, -DBUILD_TESTING=ON), based on main cecb540a63:

  • guest_vr_tracker_devices (core/libs/tests/GuestVrTrackerDevices.cpp) checks:
    • every call before Init
    • each query result word and each query refusal
    • six init refusals, Init and a second Init
    • registration per type, the bad types and modes, recalibration per type, the duration check and unregistering
    • Term, a second Term, and re-Init keeping a handle
  • It aborts on main. Each of 16 mutations makes it fail:
    • the onion doubling, the HMD calibration bound, the profile value
    • the pipe, queue and work memory checks, the early ALREADY_INITIALIZED
    • the mode bound, the duplicate registration, the HMD recalibration, the unregister reset, the negative handle
    • the GPU wait result, the duration check, the alignment output, the recalibrate struct size
  • Each commit builds on its own.
  • Full ctest: 1794 of 1802 pass. The 8 failures fail the same way on main on this machine and do not link libSceVrTracker: application_heap_scripting, application_heap_lazy, agc_driver_guest_memory_lifetime, agc_driver_image_array_window_past_layer_limit, agc_driver_tessellation and the three net_dontwait_blocking_* cases.
  • tools/progress.py --compare: libraries +0.09%, 10 functions implemented, none lost.
  • tools/check_conventions.py --base upstream/main passes.
  • tools/pr_overlap.py finds core/libs/CMakeLists.txt shared with other PRs.

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:4954201428 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9224). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-21T15:36:06Z. --- ### What 10 libSceVrTracker exports threw. They now follow [shadPS4's vr_tracker.cpp](https://github.com/shadps4-emu/shadPS4/blob/a808e76/src/core/libraries/vr_tracker/vr_tracker.cpp), whose parameter shapes the declarations already used: - `sceVrTrackerQueryMemory` checks the size, profile (0 or 100) and calibration modes (no automatic HMD calibration). It reports onion 0x400000, or 0x800000 with automatic Move calibration, garlic 0x3000000 and work 0x1000000, all 0x10000-aligned. - `sceVrTrackerInit` and `sceVrTrackerTerm` hold the initialized state: - `ALREADY_INITIALIZED` comes before any argument check. - Init checks the struct size, the three memory ranges against those sizes and alignments, pipe < 7, queue < 8 and the calibration modes. - Term without Init is `NOT_INIT`. - `sceVrTrackerRegisterDevice`, `...2` and `...Internal` keep one handle per device type (HMD, DualShock 4, Move, gun) and return `DEVICE_ALREADY_REGISTERED` for a second one. A type above 3 or an `Internal` mode above 4 is `ARGUMENT_INVALID`. - `sceVrTrackerUnregisterDevice` frees the matching handle. A negative or unknown handle is `ARGUMENT_INVALID`. - `sceVrTrackerRecalibrate` and `sceVrTrackerSetDurationUntilStatusNotTracking` check their arguments. Recalibration returns `DEVICE_NOT_REGISTERED` for the HMD (shadPS4's behaviour with no headset) or for a type with no handle. - `sceVrTrackerGpuWaitAndCpuProcess` returns `NOT_EXECUTE_GPU_SUBMIT`, since without a camera no GPU submission happens. Unlike shadPS4: - The init memory ranges are not looked up in the memory map. - A null init parameter is refused. - Only the 128-byte init parameter, in shadPS4's layout, is read. The 144-byte version that #9137 describes still throws, since its fields are not mapped to these checks. - Negative device types are refused instead of reaching its unreachable branch. As in shadPS4, Term keeps the registered handles. Not measured on a PS5; the debt entry says so, and the implemented names leave the pending lists. `sceVrTrackerGetTime`, `sceVrTrackerGpuSubmit` and `sceVrTrackerGpuWait` are left to #8650, which answers them before initialization. Once Init can succeed here, those need an initialized path too. The test goes in its own `GuestVrTrackerDevices.cpp` because #8650 adds `GuestVrTracker.cpp`. `sceVrTrackerInit` takes the `VrTrackerInitParam` declaration from #9137. ### Tested Linux (Fedora 44, GCC, Ninja, `-DBUILD_TESTING=ON`), based on `main` `cecb540a63`: - `guest_vr_tracker_devices` (`core/libs/tests/GuestVrTrackerDevices.cpp`) checks: - every call before Init - each query result word and each query refusal - six init refusals, Init and a second Init - registration per type, the bad types and modes, recalibration per type, the duration check and unregistering - Term, a second Term, and re-Init keeping a handle - It aborts on `main`. Each of 16 mutations makes it fail: - the onion doubling, the HMD calibration bound, the profile value - the pipe, queue and work memory checks, the early `ALREADY_INITIALIZED` - the mode bound, the duplicate registration, the HMD recalibration, the unregister reset, the negative handle - the GPU wait result, the duration check, the alignment output, the recalibrate struct size - Each commit builds on its own. - Full `ctest`: 1794 of 1802 pass. The 8 failures fail the same way on `main` on this machine and do not link libSceVrTracker: `application_heap_scripting`, `application_heap_lazy`, `agc_driver_guest_memory_lifetime`, `agc_driver_image_array_window_past_layer_limit`, `agc_driver_tessellation` and the three `net_dontwait_blocking_*` cases. - `tools/progress.py --compare`: libraries +0.09%, 10 functions implemented, none lost. - `tools/check_conventions.py --base upstream/main` passes. - `tools/pr_overlap.py` finds `core/libs/CMakeLists.txt` shared with other PRs. ### 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-21 15:36:58 +00:00 (Migrated from github.com)

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


Progress report (3ca07d0 → 24447ef)

📈 System libraries: 43.31% (+0.08%, +9 implemented functions)

✅ 9 implemented
Library Name
libSceVrTracker sceVrTrackerGpuWaitAndCpuProcess
libSceVrTracker sceVrTrackerQueryMemory
libSceVrTracker sceVrTrackerRecalibrate
libSceVrTracker sceVrTrackerRegisterDevice
libSceVrTracker sceVrTrackerRegisterDevice2
libSceVrTracker sceVrTrackerRegisterDeviceInternal
libSceVrTracker sceVrTrackerSetDurationUntilStatusNotTracking
libSceVrTracker sceVrTrackerTerm
libSceVrTracker sceVrTrackerUnregisterDevice
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6319911322 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9224#issuecomment-6319911322). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-21T15:36:58Z. --- <!-- progress-report --> ### Progress report (3ca07d0 → 24447ef) 📈 **System libraries**: 43.31% (+0.08%, +9 implemented functions) <details> <summary>✅ 9 implemented</summary> | Library | Name | | - | - | | libSceVrTracker | `sceVrTrackerGpuWaitAndCpuProcess` | | libSceVrTracker | `sceVrTrackerQueryMemory` | | libSceVrTracker | `sceVrTrackerRecalibrate` | | libSceVrTracker | `sceVrTrackerRegisterDevice` | | libSceVrTracker | `sceVrTrackerRegisterDevice2` | | libSceVrTracker | `sceVrTrackerRegisterDeviceInternal` | | libSceVrTracker | `sceVrTrackerSetDurationUntilStatusNotTracking` | | libSceVrTracker | `sceVrTrackerTerm` | | libSceVrTracker | `sceVrTrackerUnregisterDevice` | </details>
YossiYad commented 2026-10-22 05:33:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-22T05:33:53Z.


Rebased onto main da54c652e after #9137 (head 8f0a0d2ef). #9137 gave sceVrTrackerInit a VrTrackerInitParam from the module: a 144-byte layout, with the 128-byte one still unresolved. This PR reads shadPS4's 128-byte layout, so a 144-byte parameter now throws, as on main, instead of failing these checks with ARGUMENT_INVALID. The test checks that throw, and the debt entry and description say so. guest_vr_tracker_devices passes 3 of 3.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6333560051 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9224#issuecomment-6333560051). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-22T05:33:53Z. --- Rebased onto `main` `da54c652e` after #9137 (head `8f0a0d2ef`). #9137 gave `sceVrTrackerInit` a `VrTrackerInitParam` from the module: a 144-byte layout, with the 128-byte one still unresolved. This PR reads shadPS4's 128-byte layout, so a 144-byte parameter now throws, as on `main`, instead of failing these checks with `ARGUMENT_INVALID`. The test checks that throw, and the debt entry and description say so. `guest_vr_tracker_devices` passes 3 of 3.
YossiYad commented 2026-10-22 12:58:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-22T12:58:48Z.


Rebased onto main 8b3a6ba88 (head 24447ef99). The only conflict was #9201's test registration next to this one in core/libs/CMakeLists.txt, and I kept both. guest_vr_tracker_devices passes 3 of 3.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6341341575 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9224#issuecomment-6341341575). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-22T12:58:48Z. --- Rebased onto `main` `8b3a6ba88` (head `24447ef99`). The only conflict was #9201's test registration next to this one in `core/libs/CMakeLists.txt`, and I kept both. `guest_vr_tracker_devices` passes 3 of 3.
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!9224
No description provided.