feat(libSceHmd): answer ten buffer and device queries the way the disconnected-headset path implies #8256
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8256"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-20T07:13:48Z.
What
libSceHmd implements the disconnected-headset path (
sceHmdOpenreportsDEVICE_DISCONNECTED, so no handle is ever open). Ten more of its exports were throwing stubs without parameters; they now answer as that path implies:sceHmdDistortionGetWorkMemorySize/Alignreturn0x20000/0x400;sceHmdReprojectionQueryGarlicBuffSize/Alignreturn0x100000/0x100;sceHmdReprojectionQueryOnionBuffSize/Alignreturn0x810/0x100.sceHmdGetFieldOfView(handle, out),sceHmdGet2DEyeOffset(handle, left, right)andsceHmdGetInertialSensorData(handle, data, count)returnHANDLE_INVALID(0x81110003) after initialization andNOT_INITIALIZEDbefore it, assceHmdGetDeviceInformationByHandlealready does;sceHmdGetFieldOfViewreturnsPARAMETER_NULLfor a null output first. No output is written.sceHmdGetAssyError(data)returnsPARAMETER_NULLfor a null output, thenDEVICE_DISCONNECTED(0x81110004) after initialization andNOT_INITIALIZEDbefore it.The constants, signatures and check order follow shadPS4 (PS4, no headset); none is measured on a PS5. Where shadPS4 checks the handle before initialization, these keep the library's existing order (initialization first). The ten "unknown signature" debt entries are replaced by one that says this.
sceHmdDistortionInitializeis left as it is:sceHmdInitializedeliberately refuses a distortion parameter here.Tested
Linux (Fedora 44, GCC, Ninja,
-DBUILD_TESTING=ON), rebased onmain3fd1cc393b:guest_hmdpasses with three new checks: the six sizes; the three handle queries for handles0,-1,1and0x0f000000before and after initialization, with null outputs, and that no output byte changes; andsceHmdGetAssyErrorbefore and after initialization. The handle and assembly-error checks fail when the result ignores initialization.ctest: 1670 of 1675 pass. The 5 failures (application_heap_scripting,application_heap_lazy,agc_driver_bda_device,agc_driver_guest_memory_lifetime,agc_driver_tessellation) fail the same way onmainon this machine.tools/progress.py --compare: libraries +0.16%, 10 functions implemented, none lost.tools/check_conventions.py --base upstream/mainpasses.tools/pr_overlap.pyfinds no overlap; it could not compareGuestHmd.cppwith #6044, which conflicts withmainand moves test registrations.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T07:14:29Z.
Progress report (
3bd7173→fd178d9)📈 System libraries: 54.07% (+0.12%, +10 implemented functions)
✅ 10 implemented
sceHmdDistortionGetWorkMemoryAlignsceHmdDistortionGetWorkMemorySizesceHmdGet2DEyeOffsetsceHmdGetAssyErrorsceHmdGetFieldOfViewsceHmdGetInertialSensorDatasceHmdReprojectionQueryGarlicBuffAlignsceHmdReprojectionQueryGarlicBuffSizesceHmdReprojectionQueryOnionBuffAlignsceHmdReprojectionQueryOnionBuffSize⚪ 6 behaviourally empty (constant return or throw)
sceHmdDistortionGetWorkMemoryAlignsceHmdDistortionGetWorkMemorySizesceHmdReprojectionQueryGarlicBuffAlignsceHmdReprojectionQueryGarlicBuffSizesceHmdReprojectionQueryOnionBuffAlignsceHmdReprojectionQueryOnionBuffSizeImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T07:20:53Z.
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.
core/libs/tests/GuestHmd.cppImported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-20T20:40:56Z.
docs/dev/debt/libSceHmd.md#L9 says the results of
sceHmdGetFieldOfViewfollow shadPS4, but before initialization they don't.With a non-null output, Export.cpp#L381-L384 returns
NOT_INITIALIZED(0x81110002) for every handle. GuestHmd.cpp#L45 asserts this throughCheckHandleQueries(Hmd::NotInitialized)on line 80.The cited shadPS4 hmd.cpp#L149-L175 checks in this order: null output, then
handle != g_internal_handle(0 until a successful open), then the SDK >= 4.50 branch, and initialization last. So in shadPS4,sceHmdGetFieldOfView(1, buf)beforesceHmdInitializereturnsHANDLE_INVALID(0x81110003) for any SDK version. This PR follows the 4.50 branch for the eye offset and sensor queries, and on that branch handle 0 returnsHANDLE_INVALIDtoo.The other three queries match shadPS4 before initialization. shadPS4 checks initialization first in
sceHmdGet2DEyeOffset(L73) andsceHmdGetInertialSensorData(L179), andsceHmdGetAssyErrorhas no handle.The PR description gives the reason (to keep the library's initialization-first order), but the description does not stay in the repository. CONTRIBUTING.md asks a debt entry to state what differs. The libSceHttp and libSceAudio3d entries record their differences from shadPS4 this way; both notes were added during review of #3497 and #1849. I'd suggest one clause in the entry:
Alternatively, follow shadPS4's order with
return fieldOfView ? Hmd::InvalidHandle : Hmd::ParameterNull;, and give field of view its own pre-initialization expectation in the test.Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-21T06:32:38Z.
@nikowolf123 thanks, that difference should be in the repository and not only in the description. I added your clause to the debt entry (
fd178d902): before initializationsceHmdGetFieldOfViewreturnsNOT_INITIALIZEDfor a non-null output, where shadPS4 checks the handle first and returnsHANDLE_INVALID. I kept the initialization-first order so all four queries answer the same way beforesceHmdInitialize. The entry is now 929 characters, andcheck_conventionshas no findings.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T12:05:04Z.
Checked the sizes, alignments, error codes and check order against shadPS4 (
hmd_distortion.cpp,hmd_reprojection.cpp,hmd.cpp); they match, and the one deviation (initialization before handle) is recorded in the debt entry. The newguest_hmdchecks fail without the change because those exports threw before; merged.